From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 641A221A1098A for ; Mon, 11 Dec 2017 17:28:08 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Dec 2017 17:32:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,393,1508828400"; d="scan'208";a="1791728" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 11 Dec 2017 17:32:46 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 11 Dec 2017 17:32:45 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 12 Dec 2017 09:32:44 +0800 From: "Gao, Liming" To: Zenith432 , "edk2-devel@lists.01.org" , "Laszlo Ersek (lersek@redhat.com)" CC: "Kinney, Michael D" Thread-Topic: [edk2] [PATCH] MdePkg: correct and clarify documentation of VA_LIST in Base.h Thread-Index: AQHTcc2oEbJQTIdKPkW5zHb7ASLP2qM+NmtQ//+An4CAATaNAA== Date: Tue, 12 Dec 2017 01:32:44 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E190191@SHSMSX104.ccr.corp.intel.com> References: <1667068483.2112668.1512898346914.ref@mail.yahoo.com> <1667068483.2112668.1512898346914@mail.yahoo.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E18E2A8@SHSMSX104.ccr.corp.intel.com> <2dfbe819-78d5-e328-dd10-9c614e901d05@users.sourceforge.net> <4A89E2EF3DFEDB4C8BFDE51014F606A14E18FDF5@SHSMSX104.ccr.corp.intel.com> <101f64da-99b1-a542-bae0-794e4fd1d25b@users.sourceforge.net> In-Reply-To: <101f64da-99b1-a542-bae0-794e4fd1d25b@users.sourceforge.net> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 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 01:28:08 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Laszlo: Have you any comments for this patch? Seemly, you discussed this topic in= bugzillar.=20 Thanks Liming > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ze= nith432 > Sent: Monday, December 11, 2017 10:58 PM > To: Gao, Liming ; edk2-devel@lists.01.org > Cc: Kinney, Michael D > Subject: Re: [edk2] [PATCH] MdePkg: correct and clarify documentation of = VA_LIST in Base.h >=20 > Yes, that's right, in mixed ABI on GCC 7.2 (which is what GCC5 toolchain = in tools_def.sample creates...), VA_COPY when > used inside native (non-EFIAPI) function causes incorrect code generation= that leads to crash (it mistreats the > __builtin_ms_va_list as a __builtin_sysv_va_list). >=20 > The same source code works in current versions of LLVM and Apple clang - = so it's a compiler-specific bug. >=20 > The text I wrote > >> +// -- VA_END, VA_ARG, VA_COPY, va_end, va_arg, and va_copy may be u= sed > >> +// in functions of either calling conventions. >=20 > is the hypothetical desired condition, but it depends on compilers genera= ting proper code in mixed ABI. It obviously > does not hold for current GCC. >=20 > However, the part of the documentation to add EFIAPI to ExampleVarArg sho= uld definitely be fixed. Using > __builtin_ms_va_list (=3DVA_LIST) in a sysv_abi (native) function probabl= y yields a compile-time diagnostic, and if not - > generates code that crashes for sure. >=20 > On 11/12/2017 04:35 PM, Gao, Liming wrote: > > Hi, > > I see you and Laszlo are still in discussion on GCC behavior. Becaus= e there is one bug in GCC compiler, the following functions in > edk2 must be EFIAPI. Right? > > > > - functions that have a variable argument list and call VA_START / VA_E= ND > > - functions that call VA_COPY > > > > Thanks > > Liming > >> -----Original Message----- > >> From: Zenith432 [mailto:zenith432@users.sourceforge.net] > >> Sent: Sunday, December 10, 2017 11:43 PM > >> To: Gao, Liming ; edk2-devel@lists.01.org > >> Cc: Kinney, Michael D > >> Subject: Re: [PATCH] MdePkg: correct and clarify documentation of VA_L= IST in Base.h > >> > >> On 10/12/2017 03:53 PM, Gao, Liming wrote: > >>> Could you add bug 457 link in the commit message? > >> --- > >> Subject: [PATCH] MdePkg: correct and clarify documentation of VA_LIST = in Base.h > >> > >> This is to resolve bug 457. > >> https://bugzilla.tianocore.org/show_bug.cgi?id=3D457 > >> > >> Contributed-under: TianoCore Contribution Agreement 1.1 > >> Signed-off-by: Zenith432 > >> --- > >> MdePkg/Include/Base.h | 24 ++++++++++++++++++++---- > >> 1 file changed, 20 insertions(+), 4 deletions(-) > >> > >> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h > >> index 02140a5a..19f36872 100644 > >> --- a/MdePkg/Include/Base.h > >> +++ b/MdePkg/Include/Base.h > >> @@ -560,13 +560,14 @@ struct _LIST_ENTRY { > >> // VA_LIST - typedef for argument list. > >> // VA_START (VA_LIST Marker, argument before the ...) - Init Mark= er for use. > >> // VA_END (VA_LIST Marker) - Clear Marker > >> -// VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argu= ment 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 argu= ment from > >> +// the ... list. You must know the type and pass it in this macro. > >> // VA_COPY (VA_LIST Dest, VA_LIST Start) - Initialize Dest as a c= opy of Start. > >> // > >> -// example: > >> +// Example: > >> // > >> // UINTN > >> +// EFIAPI > >> // ExampleVarArg ( > >> // IN UINTN NumberOfArgs, > >> // ... > >> @@ -582,7 +583,7 @@ struct _LIST_ENTRY { > >> // VA_START (Marker, NumberOfArgs); > >> // for (Index =3D 0, Result =3D 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 +=3D VA_ARG (Marker, UINTN); > >> // } > >> @@ -591,6 +592,21 @@ struct _LIST_ENTRY { > >> // return Result > >> // } > >> // > >> +// Notes: > >> +// > >> +// This set of macros is intended to support variadic functions that > >> +// use the EFIAPI calling convention. Variadic functions that use a > >> +// native calling convention should use stdarg.h. > >> +// In particular: > >> +// -- VA_START may only be used in a variadic EFIAPI function. > >> +// -- va_start may only be used in a variadic native function. > >> +// -- VA_START, VA_END, VA_ARG and VA_COPY may only be used on a VA_= LIST. > >> +// -- va_start, va_end, va_arg and va_copy may only be used on a va_= list. > >> +// -- Both VA_LIST or va_list may be passed as arguments to function= s > >> +// of either EFIAPI or native calling conventions. > >> +// -- VA_END, VA_ARG, VA_COPY, va_end, va_arg, and va_copy may be us= ed > >> +// in functions of either calling conventions. > >> +// > >> > >> /** > >> Return the size of argument that has been aligned to sizeof (UIN= TN). > >> -- > >> 2.14.3 > > >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel