From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=74.6.128.47; helo=sonic304-24.consmr.mail.bf2.yahoo.com; envelope-from=zenith432@users.sourceforge.net; receiver=edk2-devel@lists.01.org Received: from sonic304-24.consmr.mail.bf2.yahoo.com (sonic304-24.consmr.mail.bf2.yahoo.com [74.6.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DF40821A1099A for ; Tue, 12 Dec 2017 02:19:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1513074270; bh=4/A8T+KwRsz+PAjtXFwhzC0pfmy2y9Skt/S5MMS3U3I=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=QfMQ9L5aw71B3PUxXMUCEvHwvzyPkGl2aYS3IwyQ7JhgLzu4JFzHMKT9LuhAhgQRFhVkqhOAn3xmnt8tfGwfXS+RWq2DXXAtInQaWZNMD/hRzAoPeeuPQHsq6nwSrRB8J9+AxyLtzHYAQLn6Hr5CHotb/V8oSuJbfpAMtPONgLsatLHe56tLymN1mc+q/XBInOy2K7ky09vBDgis/kJRZJ5ry/VObjLwNSEKSUdf3EsqOCJbVWb9iC86ZQA3x1K9cHVPJRTurWi30ZFkkAHZZ7X9oWkazhzVh7tsBCDELhvKqSH1nMhMMj27lrTDW2AFlhEx+39M+EN6UsuGUZtgBw== X-YMail-OSG: KOWXfp8VM1lYPvn.xDrjlEA.4tybD5nQOxZbzHHkpkIu6s0cQXkeHk8SuuTb4Cy 65m6_Y7c4jCNreGCEYOMzbQri26czUHlOHdzXKid1YYiI6iqROVHF5kVQv4h3Zh2m.1hzmPZN485 JMmfo3MTzmw8shQYLg0S_oTKHl9SRzSWMfu0w_6kayqytXPpI1emhHlNPEP.K3B3SQKL0EkfGvg3 qNF4u75bxX4et4ldHI2Lp7tjriYViu6ayxYrvEAZQ0K9lFvb.Q.TCZr6DZHwz5XDayuedWQy.Nld 5_y_c97phXKR8Szvd6hA4PZ1kgnnYEUjsi0FIfcEqViEsaIBBLbUPcIU2WVA9s._fCCC8ia.uG7l UTSjdy4jzHcC3nyvJbX6wQlqMJN8QsJykGBOzkkAxlE6LArdUWu0cwDhvle0bnyOa9z98b7RQylY fC04hrn4QnfxGxjEr2qcb34pOh3qLMhEUGFji3Lasck.MPdroGgWuAA8JKby3.8XPLfbsIkojKHU f2GUUEO_VLomgwgDmLE4QYds- Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.bf2.yahoo.com with HTTP; Tue, 12 Dec 2017 10:24:30 +0000 Received: from smtp103.rhel.mail.bf1.yahoo.com (EHLO robicon.homeip.net) ([98.139.230.213]) by smtp401.mail.bf1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID -506164517; Tue, 12 Dec 2017 10:24:27 +0000 (UTC) To: edk2-devel@lists.01.org Cc: Laszlo Ersek , michael.d.kinney@intel.com, liming.gao@intel.com References: <1667068483.2112668.1512898346914.ref@mail.yahoo.com> <1667068483.2112668.1512898346914@mail.yahoo.com> From: Zenith432 Message-ID: <90e6e057-3fa3-eed9-46a2-44bb8a78e652@users.sourceforge.net> Date: Tue, 12 Dec 2017 12:24:24 +0200 User-Agent: Thunderbird/52.5 MIME-Version: 1.0 In-Reply-To: Subject: Re: [PATCH] MdePkg: correct and clarify documentation of VA_LIST in Base.h X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2017 10:19:53 -0000 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Below is an amended patch. I changed the wording in the notes a little to exclude a non-variadic function using VA_START, and to remind that VA_COPY should also be paired with VA_END. Also, if GCC gets its VA_COPY repaired, documentation may change to allow to using VA_COPY inside non-EFIAPI as well. --- This is to resolve bug 457. https://bugzilla.tianocore.org/show_bug.cgi?id=457 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Zenith432 --- MdePkg/Include/Base.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index 02140a5a..4fd5161f 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -552,21 +552,24 @@ struct _LIST_ENTRY { #define BASE_8EB 0x8000000000000000ULL // -// Support for variable length argument lists using the ANSI standard. +// Support for variable argument lists in freestanding edk2 modules. // -// Since we are using the ANSI standard we used the standard naming and -// did not follow the coding convention +// For modules that use the ISO C library interfaces for variable +// argument lists, refer to "StdLib/Include/stdarg.h". // // VA_LIST - typedef for argument list. // VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use. // VA_END (VA_LIST Marker) - Clear Marker -// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argument from -// the ... list. You must know the size and pass it in this macro. +// VA_ARG (VA_LIST Marker, var arg type) - Use Marker to get an argument from +// the ... list. You must know the type and pass it in this macro. Type +// must be compatible with the type of the actual next argument (as promoted +// according to the default argument promotions.) // VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a copy of Start. // -// example: +// Example: // // UINTN +// EFIAPI // ExampleVarArg ( // IN UINTN NumberOfArgs, // ... @@ -582,15 +585,21 @@ struct _LIST_ENTRY { // VA_START (Marker, NumberOfArgs); // for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) { // // -// // The ... list is a series of UINTN values, so average them up. +// // The ... list is a series of UINTN values, so sum them up. // // // Result += VA_ARG (Marker, UINTN); // } // // VA_END (Marker); -// return Result +// return Result; // } // +// Notes: +// - Functions that call VA_START() / VA_END() must have a variable +// argument list and must be declared EFIAPI. +// - Functions that call VA_COPY() / VA_END() must be declared EFIAPI. +// - Functions that only use VA_LIST and VA_ARG() need not be EFIAPI. +// /** Return the size of argument that has been aligned to sizeof (UINTN). -- 2.14.3