ReactOS  0.4.15-dev-1152-g6c94e4f
vadefs.h
Go to the documentation of this file.
1 
6 #ifndef _INC_VADEFS
7 #define _INC_VADEFS
8 
9 #ifndef _WIN32
10 #error Only Win32 target is supported!
11 #endif
12 
13 #include <crtdefs.h>
14 
15 #undef _CRT_PACKING
16 #define _CRT_PACKING 8
17 #pragma pack(push,_CRT_PACKING)
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #ifdef __cplusplus
24 #define _ADDRESSOF(v) (&reinterpret_cast<const char &>(v))
25 #else
26 #define _ADDRESSOF(v) (&(v))
27 #endif
28 
29 #if defined(__ia64__)
30 #define _VA_ALIGN 8
31 #define _SLOTSIZEOF(t) ((sizeof(t) + _VA_ALIGN - 1) & ~(_VA_ALIGN - 1))
32 #define _VA_STRUCT_ALIGN 16
33 #define _ALIGNOF(ap) ((((ap)+_VA_STRUCT_ALIGN - 1) & ~(_VA_STRUCT_ALIGN -1)) - (ap))
34 #define _APALIGN(t,ap) (__alignof(t) > 8 ? _ALIGNOF((uintptr_t) ap) : 0)
35 #else
36 #define _SLOTSIZEOF(t) (sizeof(t))
37 #define _APALIGN(t,ap) (__alignof(t))
38 #endif
39 
40 #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
41 
42 #if defined(__GNUC__) || defined(__clang__)
43 #define _crt_va_start(v,l) __builtin_va_start(v,l)
44 #define _crt_va_arg(v,l) __builtin_va_arg(v,l)
45 #define _crt_va_end(v) __builtin_va_end(v)
46 #define __va_copy(d,s) __builtin_va_copy(d,s)
47 #elif defined(_MSC_VER)
48 
49 #if defined(_M_IX86)
50 #define _crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l)))
51 #define _crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l)))
52 #define _crt_va_end(v) ((void)((v) = (va_list)0))
53 #define __va_copy(d,s) ((void)((d) = (s)))
54 #elif defined(_M_AMD64)
55 #define _PTRSIZEOF(n) ((sizeof(n) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
56 #define _ISSTRUCT(t) ((sizeof(t) > sizeof(void*)) || (sizeof(t) & (sizeof(t)-1)) != 0)
57 #define _crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _PTRSIZEOF(l)))
58 #define _crt_va_arg(v,t) (_ISSTRUCT(t) ? \
59  (**(t**)(((v) += sizeof(void*)) - sizeof(void*))) : \
60  (*(t*)(((v) += sizeof(void*)) - sizeof(void*))))
61 #define _crt_va_end(v) ((void)((v) = (va_list)0))
62 #define __va_copy(d,s) ((void)((d) = (s)))
63 #elif defined(_M_ARM)
64 #ifdef __cplusplus
65  extern void __cdecl __va_start(va_list*, ...);
66  #define _crt_va_start(ap,v) __va_start(&ap, _ADDRESSOF(v), _SLOTSIZEOF(v), _ADDRESSOF(v))
67 #else
68  #define _crt_va_start(ap,v) (ap = (va_list)_ADDRESSOF(v) + _SLOTSIZEOF(v))
69 #endif
70 #define _crt_va_arg(ap,t) (*(t*)((ap += _SLOTSIZEOF(t) + _APALIGN(t,ap)) - _SLOTSIZEOF(t)))
71 #define _crt_va_end(ap) ( ap = (va_list)0 )
72 #define __va_copy(d,s) ((void)((d) = (s)))
73 #else //if defined(_M_IA64) || defined(_M_CEE)
74 #error Please implement me
75 #endif
76 
77 #endif
78 
79 #if !defined(va_copy) && (!defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L)
80 #define va_copy(d,s) __va_copy((d),(s))
81 #endif
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #pragma pack(pop)
88 #endif
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78