Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _INC_VADEFS
      7 #define _INC_VADEFS
      8 
      9 #include <_mingw.h>
     10 
     11 #ifndef __WIDL__
     12 #pragma pack(push,_CRT_PACKING)
     13 #endif
     14 
     15 #ifdef __cplusplus
     16 extern "C" {
     17 #endif
     18 
     19 #if defined (__GNUC__)
     20 #ifndef __GNUC_VA_LIST
     21 #define __GNUC_VA_LIST
     22   typedef __builtin_va_list __gnuc_va_list;
     23 #endif
     24 #endif /* __GNUC__ */
     25 
     26 #ifndef _VA_LIST_DEFINED	/* if stdargs.h didn't define it */
     27 #define _VA_LIST_DEFINED
     28 #if defined(__GNUC__)
     29   typedef __gnuc_va_list va_list;
     30 #elif defined(_MSC_VER)
     31   typedef char *  va_list;
     32 #elif !defined(__WIDL__)
     33 #error VARARGS not implemented for this compiler
     34 #endif
     35 #endif /* _VA_LIST_DEFINED */
     36 
     37 #ifdef __cplusplus
     38 #define _ADDRESSOF(v) (&reinterpret_cast<const char &>(v))
     39 #else
     40 #define _ADDRESSOF(v) (&(v))
     41 #endif
     42 
     43 #if defined (__GNUC__)
     44 /* Use GCC builtins */
     45 
     46 #define _crt_va_start(v,l)	__builtin_va_start(v,l)
     47 #define _crt_va_arg(v,l)	__builtin_va_arg(v,l)
     48 #define _crt_va_end(v)		__builtin_va_end(v)
     49 #define _crt_va_copy(d,s)	__builtin_va_copy(d,s)
     50 
     51 #elif defined(_MSC_VER)
     52 /* MSVC specific */
     53 
     54 #if defined(_M_IA64)
     55 #define _VA_ALIGN 8
     56 #define _SLOTSIZEOF(t) ((sizeof(t) + _VA_ALIGN - 1) & ~(_VA_ALIGN - 1))
     57 #define _VA_STRUCT_ALIGN 16
     58 #define _ALIGNOF(ap) ((((ap)+_VA_STRUCT_ALIGN - 1) & ~(_VA_STRUCT_ALIGN -1)) - (ap))
     59 #define _APALIGN(t,ap) (__alignof(t) > 8 ? _ALIGNOF((uintptr_t) ap) : 0)
     60 #else
     61 #define _SLOTSIZEOF(t) (sizeof(t))
     62 #define _APALIGN(t,ap) (__alignof(t))
     63 #endif
     64 
     65 #if defined(_M_IX86)
     66 
     67 #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
     68 #define _crt_va_start(v,l)	((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l))
     69 #define _crt_va_arg(v,l)	(*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l)))
     70 #define _crt_va_end(v)		((v) = (va_list)0)
     71 #define _crt_va_copy(d,s)	((d) = (s))
     72 
     73 #elif defined(_M_AMD64)
     74 
     75 #define _PTRSIZEOF(n) ((sizeof(n) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
     76 #define _ISSTRUCT(t)  ((sizeof(t) > sizeof(void*)) || (sizeof(t) & (sizeof(t) - 1)) != 0)
     77 #define _crt_va_start(v,l)	((v) = (va_list)_ADDRESSOF(l) + _PTRSIZEOF(l))
     78 #define _crt_va_arg(v,t)	_ISSTRUCT(t) ?						\
     79 				 (**(t**)(((v) += sizeof(void*)) - sizeof(void*))) :	\
     80 				 ( *(t *)(((v) += sizeof(void*)) - sizeof(void*)))
     81 #define _crt_va_end(v)		((v) = (va_list)0)
     82 #define _crt_va_copy(d,s)	((d) = (s))
     83 
     84 #elif defined(_M_IA64)
     85 
     86 #error VARARGS not implemented for IA64
     87 
     88 #else
     89 
     90 #error VARARGS not implemented for this TARGET
     91 
     92 #endif /* cpu ifdefs */
     93 
     94 #endif /* compiler ifdefs */
     95 
     96 #ifdef __cplusplus
     97 }
     98 #endif
     99 
    100 #ifndef __WIDL__
    101 #pragma pack(pop)
    102 #endif
    103 
    104 #endif /* _INC_VADEFS */
    105 
    106