ReactOS 0.4.16-dev-297-gc569aee
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#undef _CRT_PACKING
14#define _CRT_PACKING 8
15#pragma pack(push,_CRT_PACKING)
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#ifdef __GNUC__
22#ifndef __GNUC_VA_LIST
23#define __GNUC_VA_LIST
24 typedef __builtin_va_list __gnuc_va_list;
25#endif
26#endif
27
28#ifndef _VA_LIST_DEFINED
29#define _VA_LIST_DEFINED
30#if defined(__GNUC__)
31 typedef __gnuc_va_list va_list;
32#elif defined(_MSC_VER)
33 typedef _Writable_bytes_(_Inexpressible_("length varies")) char * va_list;
34#endif
35#endif
36
37#ifndef _UINTPTR_T_DEFINED
38#define _UINTPTR_T_DEFINED
39#ifndef __uintptr_t_defined
40#define __uintptr_t_defined
41#undef uintptr_t
42#ifdef _WIN64
43#if defined(__GNUC__) && defined(__STRICT_ANSI__)
44 typedef unsigned int uintptr_t __attribute__ ((mode (DI)));
45#else
46 typedef unsigned __int64 uintptr_t;
47#endif
48#else
49 typedef unsigned int uintptr_t;
50#endif
51#endif
52#endif
53
54#ifdef __cplusplus
55#define _ADDRESSOF(v) (&reinterpret_cast<const char &>(v))
56#else
57#define _ADDRESSOF(v) (&(v))
58#endif
59
60#if defined(__ia64__)
61#define _VA_ALIGN 8
62#define _SLOTSIZEOF(t) ((sizeof(t) + _VA_ALIGN - 1) & ~(_VA_ALIGN - 1))
63#define _VA_STRUCT_ALIGN 16
64#define _ALIGNOF(ap) ((((ap)+_VA_STRUCT_ALIGN - 1) & ~(_VA_STRUCT_ALIGN -1)) - (ap))
65#define _APALIGN(t,ap) (__alignof(t) > 8 ? _ALIGNOF((uintptr_t) ap) : 0)
66#else
67#define _SLOTSIZEOF(t) (sizeof(t))
68#define _APALIGN(t,ap) (__alignof(t))
69#endif
70
71#define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
72
73#if defined(__GNUC__) || defined(__clang__)
74#define __crt_va_start(v,l) __builtin_va_start(v,l)
75#define __crt_va_arg(v,l) __builtin_va_arg(v,l)
76#define __crt_va_end(v) __builtin_va_end(v)
77#define __va_copy(d,s) __builtin_va_copy(d,s)
78#elif defined(_MSC_VER)
79
80#if defined(_M_IX86)
81#define __crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l)))
82#define __crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l)))
83#define __crt_va_end(v) ((void)((v) = (va_list)0))
84#define __va_copy(d,s) ((void)((d) = (s)))
85#elif defined(_M_AMD64)
86#define _PTRSIZEOF(n) ((sizeof(n) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
87#define _ISSTRUCT(t) ((sizeof(t) > sizeof(void*)) || (sizeof(t) & (sizeof(t)-1)) != 0)
88#define __crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _PTRSIZEOF(l)))
89#define __crt_va_arg(v,t) (_ISSTRUCT(t) ? \
90 (**(t**)(((v) += sizeof(void*)) - sizeof(void*))) : \
91 (*(t*)(((v) += sizeof(void*)) - sizeof(void*))))
92#define __crt_va_end(v) ((void)((v) = (va_list)0))
93#define __va_copy(d,s) ((void)((d) = (s)))
94#elif defined(_M_ARM)
95#ifdef __cplusplus
96 extern void __cdecl __va_start(va_list*, ...);
97 #define __crt_va_start(ap,v) __va_start(&ap, _ADDRESSOF(v), _SLOTSIZEOF(v), _ADDRESSOF(v))
98#else
99 #define __crt_va_start(ap,v) (ap = (va_list)_ADDRESSOF(v) + _SLOTSIZEOF(v))
100#endif
101#define __crt_va_arg(ap,t) (*(t*)((ap += _SLOTSIZEOF(t) + _APALIGN(t,ap)) - _SLOTSIZEOF(t)))
102#define __crt_va_end(ap) ( ap = (va_list)0 )
103#define __va_copy(d,s) ((void)((d) = (s)))
104#elif defined(_M_ARM64)
105extern void __cdecl __va_start(va_list*, ...);
106#define __crt_va_start(ap,v) ((void)(__va_start(&ap, _ADDRESSOF(v), _SLOTSIZEOF(v), __alignof(v), _ADDRESSOF(v))))
107#define __crt_va_arg(ap, t) \
108 ((sizeof(t) > (2 * sizeof(__int64))) \
109 ? **(t**)((ap += sizeof(__int64)) - sizeof(__int64)) \
110 : *(t*)((ap += _SLOTSIZEOF(t) + _APALIGN(t,ap)) - _SLOTSIZEOF(t)))
111#define __crt_va_end(ap) ((void)(ap = (va_list)0))
112#define __va_copy(d,s) ((void)((d) = (s)))
113#else //if defined(_M_IA64) || defined(_M_CEE)
114#error Please implement me
115#endif
116
117#endif
118
119#if !defined(va_copy) && (!defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L)
120#define va_copy(d,s) __va_copy((d),(s))
121#endif
122
123#ifdef __cplusplus
124}
125#endif
126
127#pragma pack(pop)
128#endif
#define __cdecl
Definition: accygwin.h:79
char * va_list
Definition: acmsvcex.h:78
#define __int64
Definition: basetyps.h:16
#define __attribute__(x)
Definition: wpp_private.h:207
unsigned char
Definition: typeof.h:29
GLenum mode
Definition: glext.h:6217
unsigned int uintptr_t
Definition: intrin.h:47
#define _Writable_bytes_(s)
Definition: no_sal2.h:70
unsigned int uintptr_t
Definition: vadefs.h:49