[cfe-dev] va_list definition in library variadic functions for X64
Shi, Steven via cfe-dev
cfe-dev at lists.llvm.org
Mon Jan 4 08:45:41 PST 2016
Hello,
I'm trying to enable Uefi firmware clang build which is to switch gcc to clang as the firmware default CC compiler, and I have some troubles to handle the X64 library variable arguments parsing with __attribute__((ms_abi)) calling convention. I hope to implement my own va_list macros, e.g. va_start, va_arg, va_end, va_copy, and I see the Stdarg.h define the va_list as __builtin_va_list, but I don't know how clang define the __builtin_va_list for X64 architecture. Where can I find it?
* I thought the __builtin_va_list might be the char * and I defined the va_list macros as below, but they does not work.
typedef CHAR8 *VA_LIST;
#define VA_START(Marker, Parameter) (Marker = (VA_LIST) ((UINTN) & (Parameter) + _INT_SIZE_OF (Parameter)))
#define VA_ARG(Marker, TYPE) (*(TYPE *) ((Marker += _INT_SIZE_OF (TYPE)) - _INT_SIZE_OF (TYPE)))
#define VA_END(Marker) (Marker = (VA_LIST) 0)
#define VA_COPY(Dest, Start) ((void)((Dest) = (Start)))
* I also tried directly use the _builtin functions as below, the result is better, but still cannot completely work if the library function have very long variable arguments.
typedef __builtin_va_list VA_LIST;
#define VA_START(Marker, Parameter) __builtin_va_start (Marker, Parameter)
#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))
#define VA_END(Marker) __builtin_va_end (Marker)
#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)
Any suggestion is appreciated!
Steven Shi
SSG\STO\UEFI Firmware
Tel: +86 021-61166522
iNet: 821-6522
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160104/252fb7d5/attachment.html>
More information about the cfe-dev
mailing list