From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (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 603B921A1099A for ; Tue, 12 Dec 2017 02:34:27 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31FC6642; Tue, 12 Dec 2017 10:39:05 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-105.rdu2.redhat.com [10.10.120.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE06D69303; Tue, 12 Dec 2017 10:39:03 +0000 (UTC) To: Zenith432 , edk2-devel@lists.01.org Cc: michael.d.kinney@intel.com, liming.gao@intel.com References: <1667068483.2112668.1512898346914.ref@mail.yahoo.com> <1667068483.2112668.1512898346914@mail.yahoo.com> <90e6e057-3fa3-eed9-46a2-44bb8a78e652@users.sourceforge.net> From: Laszlo Ersek Message-ID: <147f3c39-cfc4-a0ad-44c8-a58487624c7f@redhat.com> Date: Tue, 12 Dec 2017 11:39:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <90e6e057-3fa3-eed9-46a2-44bb8a78e652@users.sourceforge.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 12 Dec 2017 10:39:05 +0000 (UTC) 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:34:28 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 12/12/17 11:24, Zenith432 wrote: > 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). Reviewed-by: Laszlo Ersek (Liming, I can help with applying this patch, if you want that.) Thanks! Laszlo