msvcrt: Use WINAPIV calling convention for variadic functions.
[wine.git] / include / msvcrt / crtdefs.h
blob9ec20828f563c78e39d70ea9a6a3610e4431e974
1 /*
2 * CRT definitions
4 * Copyright 2000 Francois Gouget.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_CRTDEFS_H
22 #define __WINE_CRTDEFS_H
24 #ifndef __WINE_USE_MSVCRT
25 #define __WINE_USE_MSVCRT
26 #endif
28 #ifdef __WINE_WINE_PORT_H
29 # error You cannot use both wine/port.h and msvcrt headers
30 #endif
32 #if (defined(__x86_64__) || defined(__powerpc64__) || defined(__aarch64__)) && !defined(_WIN64)
33 #define _WIN64
34 #endif
36 #if !defined(_MSC_VER) && !defined(__int64)
37 # if defined(_WIN64) && !defined(__MINGW64__)
38 # define __int64 long
39 # else
40 # define __int64 long long
41 # endif
42 #endif
44 #ifndef __stdcall
45 # ifdef __i386__
46 # ifdef __GNUC__
47 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
48 # define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
49 # else
50 # define __stdcall __attribute__((__stdcall__))
51 # endif
52 # elif defined(_MSC_VER)
53 /* Nothing needs to be done. __stdcall already exists */
54 # else
55 # error You need to define __stdcall for your compiler
56 # endif
57 # elif defined(__x86_64__) && defined (__GNUC__)
58 # if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
59 # define __stdcall __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
60 # else
61 # define __stdcall __attribute__((ms_abi))
62 # endif
63 # else /* __i386__ */
64 # define __stdcall
65 # endif /* __i386__ */
66 #endif /* __stdcall */
68 #ifndef __cdecl
69 # if defined(__i386__) && defined(__GNUC__)
70 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
71 # define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
72 # else
73 # define __cdecl __attribute__((__cdecl__))
74 # endif
75 # elif defined(__x86_64__) && defined (__GNUC__)
76 # if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
77 # define __cdecl __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
78 # else
79 # define __cdecl __attribute__((ms_abi))
80 # endif
81 # elif !defined(_MSC_VER)
82 # define __cdecl
83 # endif
84 #endif /* __cdecl */
86 #ifndef __ms_va_list
87 # if defined(__x86_64__) && defined (__GNUC__)
88 # define __ms_va_list __builtin_ms_va_list
89 # define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
90 # define __ms_va_end(list) __builtin_ms_va_end(list)
91 # define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
92 # else
93 # define __ms_va_list va_list
94 # define __ms_va_start(list,arg) va_start(list,arg)
95 # define __ms_va_end(list) va_end(list)
96 # ifdef va_copy
97 # define __ms_va_copy(dest,src) va_copy(dest,src)
98 # else
99 # define __ms_va_copy(dest,src) ((dest) = (src))
100 # endif
101 # endif
102 #endif
104 #ifndef WINAPIV
105 # define WINAPIV __cdecl
106 #endif
108 #ifndef DECLSPEC_ALIGN
109 # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
110 # define DECLSPEC_ALIGN(x) __declspec(align(x))
111 # elif defined(__GNUC__)
112 # define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
113 # else
114 # define DECLSPEC_ALIGN(x)
115 # endif
116 #endif
118 #define _ARGMAX 100
120 #ifndef _MSVCRT_LONG_DEFINED
121 #define _MSVCRT_LONG_DEFINED
122 /* we need 32-bit longs even on 64-bit */
123 typedef int __msvcrt_long;
124 typedef unsigned int __msvcrt_ulong;
125 #endif
127 #ifndef _INTPTR_T_DEFINED
128 #ifdef _WIN64
129 typedef __int64 intptr_t;
130 #else
131 typedef int intptr_t;
132 #endif
133 #define _INTPTR_T_DEFINED
134 #endif
136 #ifndef _UINTPTR_T_DEFINED
137 #ifdef _WIN64
138 typedef unsigned __int64 uintptr_t;
139 #else
140 typedef unsigned int uintptr_t;
141 #endif
142 #define _UINTPTR_T_DEFINED
143 #endif
145 #ifndef _PTRDIFF_T_DEFINED
146 #ifdef _WIN64
147 typedef __int64 ptrdiff_t;
148 #else
149 typedef int ptrdiff_t;
150 #endif
151 #define _PTRDIFF_T_DEFINED
152 #endif
154 #ifndef _SIZE_T_DEFINED
155 #ifdef _WIN64
156 typedef unsigned __int64 size_t;
157 #else
158 typedef unsigned int size_t;
159 #endif
160 #define _SIZE_T_DEFINED
161 #endif
163 #ifndef _TIME32_T_DEFINED
164 typedef __msvcrt_long __time32_t;
165 #define _TIME32_T_DEFINED
166 #endif
168 #ifndef _TIME64_T_DEFINED
169 typedef __int64 DECLSPEC_ALIGN(8) __time64_t;
170 #define _TIME64_T_DEFINED
171 #endif
173 #ifdef _USE_32BIT_TIME_T
174 # ifdef _WIN64
175 # error You cannot use 32-bit time_t in Win64
176 # endif
177 #elif !defined(_WIN64)
178 # define _USE_32BIT_TIME_T
179 #endif
181 #ifndef _TIME_T_DEFINED
182 #ifdef _USE_32BIT_TIME_T
183 typedef __time32_t time_t;
184 #else
185 typedef __time64_t time_t;
186 #endif
187 #define _TIME_T_DEFINED
188 #endif
190 #ifndef _WCHAR_T_DEFINED
191 #ifndef __cplusplus
192 typedef unsigned short wchar_t;
193 #endif
194 #define _WCHAR_T_DEFINED
195 #endif
197 #ifndef _WCTYPE_T_DEFINED
198 typedef unsigned short wint_t;
199 typedef unsigned short wctype_t;
200 #define _WCTYPE_T_DEFINED
201 #endif
203 #ifndef _ERRNO_T_DEFINED
204 typedef int errno_t;
205 #define _ERRNO_T_DEFINED
206 #endif
208 struct threadlocaleinfostruct;
209 struct threadmbcinfostruct;
210 typedef struct threadlocaleinfostruct *pthreadlocinfo;
211 typedef struct threadmbcinfostruct *pthreadmbcinfo;
213 typedef struct localeinfo_struct
215 pthreadlocinfo locinfo;
216 pthreadmbcinfo mbcinfo;
217 } _locale_tstruct, *_locale_t;
219 #ifndef _TAGLC_ID_DEFINED
220 typedef struct tagLC_ID {
221 unsigned short wLanguage;
222 unsigned short wCountry;
223 unsigned short wCodePage;
224 } LC_ID, *LPLC_ID;
225 #define _TAGLC_ID_DEFINED
226 #endif
228 #ifndef _THREADLOCALEINFO
229 typedef struct threadlocaleinfostruct {
230 int refcount;
231 unsigned int lc_codepage;
232 unsigned int lc_collate_cp;
233 __msvcrt_ulong lc_handle[6];
234 LC_ID lc_id[6];
235 struct {
236 char *locale;
237 wchar_t *wlocale;
238 int *refcount;
239 int *wrefcount;
240 } lc_category[6];
241 int lc_clike;
242 int mb_cur_max;
243 int *lconv_intl_refcount;
244 int *lconv_num_refcount;
245 int *lconv_mon_refcount;
246 struct lconv *lconv;
247 int *ctype1_refcount;
248 unsigned short *ctype1;
249 const unsigned short *pctype;
250 const unsigned char *pclmap;
251 const unsigned char *pcumap;
252 struct __lc_time_data *lc_time_curr;
253 } threadlocinfo;
254 #define _THREADLOCALEINFO
255 #endif
257 #endif /* __WINE_CRTDEFS_H */