Add .gitattributes and .gitignore files and normalize line endings in the repository...
[reactos.git] / sdk / include / crt / stddef.h
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER within this package.
5 */
6
7 #include <crtdefs.h>
8
9 #ifndef _INC_STDDEF
10 #define _INC_STDDEF
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #include <errno.h>
17
18 _CRTIMP extern unsigned long __cdecl __threadid(void);
19 #define _threadid (__threadid())
20 _CRTIMP extern uintptr_t __cdecl __threadhandle(void);
21
22 #ifdef __cplusplus
23 }
24 #endif
25
26 #endif
27
28 /*
29 * ISO C Standard: 7.17 Common definitions <stddef.h>
30 */
31 #if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \
32 && !defined(__STDDEF_H__)) \
33 || defined(__need_wchar_t) || defined(__need_size_t) \
34 || defined(__need_ptrdiff_t) || defined(__need_NULL) \
35 || defined(__need_wint_t)
36
37 /* Any one of these symbols __need_* means that GNU libc
38 wants us just to define one data type. So don't define
39 the symbols that indicate this file's entire job has been done. */
40 #if (!defined(__need_wchar_t) && !defined(__need_size_t) \
41 && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \
42 && !defined(__need_wint_t))
43 #define _STDDEF_H
44 #define _STDDEF_H_
45 /* snaroff@next.com says the NeXT needs this. */
46 #define _ANSI_STDDEF_H
47 /* Irix 5.1 needs this. */
48 #define __STDDEF_H__
49 #endif
50
51 #ifndef __sys_stdtypes_h
52 /* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are
53 defined if the corresponding type is *not* defined.
54 FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */
55 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
56 #if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_)
57 #define _SIZE_T
58 #endif
59 #if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_)
60 #define _PTRDIFF_T
61 #endif
62 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
63 instead of _WCHAR_T_. */
64 #if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_)
65 #ifndef _BSD_WCHAR_T_
66 #define _WCHAR_T
67 #endif
68 #endif
69 /* Undef _FOO_T_ if we are supposed to define foo_t. */
70 #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
71 #undef _PTRDIFF_T_
72 #undef _BSD_PTRDIFF_T_
73 #endif
74 #if defined (__need_size_t) || defined (_STDDEF_H_)
75 #undef _SIZE_T_
76 #undef _BSD_SIZE_T_
77 #endif
78 #if defined (__need_wchar_t) || defined (_STDDEF_H_)
79 #undef _WCHAR_T_
80 #undef _BSD_WCHAR_T_
81 #endif
82 #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
83
84 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
85 Just ignore it. */
86 #if defined (__sequent__) && defined (_PTRDIFF_T_)
87 #undef _PTRDIFF_T_
88 #endif
89
90 /* On VxWorks, <type/vxTypesBase.h> may have defined macros like
91 _TYPE_size_t which will typedef size_t. fixincludes patched the
92 vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is
93 not defined, and so that defining this macro defines _GCC_SIZE_T.
94 If we find that the macros are still defined at this point, we must
95 invoke them so that the type is defined as expected. */
96 #if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_))
97 _TYPE_ptrdiff_t;
98 #undef _TYPE_ptrdiff_t
99 #endif
100 #if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_))
101 _TYPE_size_t;
102 #undef _TYPE_size_t
103 #endif
104 #if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_))
105 _TYPE_wchar_t;
106 #undef _TYPE_wchar_t
107 #endif
108
109 /* In case nobody has defined these types, but we aren't running under
110 GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE_TYPE__, and
111 __WCHAR_TYPE__ have reasonable values. This can happen if the
112 parts of GCC is compiled by an older compiler, that actually
113 include gstddef.h, such as collect2. */
114
115 /* Signed type of difference of two pointers. */
116
117 /* Define this type if we are doing the whole job,
118 or if we want this type in particular. */
119 #if defined (_STDDEF_H) || defined (__need_ptrdiff_t)
120 #ifndef _PTRDIFF_T /* in case <sys/types.h> has defined it. */
121 #ifndef _T_PTRDIFF_
122 #ifndef _T_PTRDIFF
123 #ifndef __PTRDIFF_T
124 #ifndef _PTRDIFF_T_
125 #ifndef _BSD_PTRDIFF_T_
126 #ifndef ___int_ptrdiff_t_h
127 #ifndef _GCC_PTRDIFF_T
128 #define _PTRDIFF_T
129 #define _T_PTRDIFF_
130 #define _T_PTRDIFF
131 #define __PTRDIFF_T
132 #define _PTRDIFF_T_
133 #define _BSD_PTRDIFF_T_
134 #define ___int_ptrdiff_t_h
135 #define _GCC_PTRDIFF_T
136 #ifndef __PTRDIFF_TYPE__
137 #ifdef _WIN64
138 #define __PTRDIFF_TYPE__ long long int
139 #else
140 #define __PTRDIFF_TYPE__ long int
141 #endif
142 #endif
143 #ifndef _PTRDIFF_T_DEFINED
144 #define _PTRDIFF_T_DEFINED
145 __MINGW_EXTENSION typedef __PTRDIFF_TYPE__ ptrdiff_t;
146 #endif
147 #endif /* _GCC_PTRDIFF_T */
148 #endif /* ___int_ptrdiff_t_h */
149 #endif /* _BSD_PTRDIFF_T_ */
150 #endif /* _PTRDIFF_T_ */
151 #endif /* __PTRDIFF_T */
152 #endif /* _T_PTRDIFF */
153 #endif /* _T_PTRDIFF_ */
154 #endif /* _PTRDIFF_T */
155
156 /* If this symbol has done its job, get rid of it. */
157 #undef __need_ptrdiff_t
158
159 #endif /* _STDDEF_H or __need_ptrdiff_t. */
160
161 /* Unsigned type of `sizeof' something. */
162
163 /* Define this type if we are doing the whole job,
164 or if we want this type in particular. */
165 #if defined (_STDDEF_H) || defined (__need_size_t)
166 #ifndef __size_t__ /* BeOS */
167 #ifndef __SIZE_T__ /* Cray Unicos/Mk */
168 #ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
169 #ifndef _SYS_SIZE_T_H
170 #ifndef _T_SIZE_
171 #ifndef _T_SIZE
172 #ifndef __SIZE_T
173 #ifndef _SIZE_T_
174 #ifndef _BSD_SIZE_T_
175 #ifndef _SIZE_T_DEFINED_
176 #ifndef _SIZE_T_DEFINED
177 #ifndef _BSD_SIZE_T_DEFINED_ /* Darwin */
178 #ifndef _SIZE_T_DECLARED /* FreeBSD 5 */
179 #ifndef ___int_size_t_h
180 #ifndef _GCC_SIZE_T
181 #ifndef _SIZET_
182 #ifndef __size_t
183 #define __size_t__ /* BeOS */
184 #define __SIZE_T__ /* Cray Unicos/Mk */
185 #define _SIZE_T
186 #define _SYS_SIZE_T_H
187 #define _T_SIZE_
188 #define _T_SIZE
189 #define __SIZE_T
190 #define _SIZE_T_
191 #define _BSD_SIZE_T_
192 #define _SIZE_T_DEFINED_
193 #define _SIZE_T_DEFINED
194 #define _BSD_SIZE_T_DEFINED_ /* Darwin */
195 #define _SIZE_T_DECLARED /* FreeBSD 5 */
196 #define ___int_size_t_h
197 #define _GCC_SIZE_T
198 #define _SIZET_
199 #if defined (__FreeBSD__) && (__FreeBSD__ >= 5)
200 /* __size_t is a typedef on FreeBSD 5!, must not trash it. */
201 #else
202 #define __size_t
203 #endif
204 #ifndef __SIZE_TYPE__
205 #ifdef _WIN64
206 #define __SIZE_TYPE__ long long unsigned int
207 #else
208 #define __SIZE_TYPE__ long unsigned int
209 #endif
210 #endif
211 #if !(defined (__GNUG__) && defined (size_t))
212 __MINGW_EXTENSION typedef __SIZE_TYPE__ size_t;
213 #ifdef __BEOS__
214 typedef long ssize_t;
215 #endif /* __BEOS__ */
216 #endif /* !(defined (__GNUG__) && defined (size_t)) */
217 #endif /* __size_t */
218 #endif /* _SIZET_ */
219 #endif /* _GCC_SIZE_T */
220 #endif /* ___int_size_t_h */
221 #endif /* _SIZE_T_DECLARED */
222 #endif /* _BSD_SIZE_T_DEFINED_ */
223 #endif /* _SIZE_T_DEFINED */
224 #endif /* _SIZE_T_DEFINED_ */
225 #endif /* _BSD_SIZE_T_ */
226 #endif /* _SIZE_T_ */
227 #endif /* __SIZE_T */
228 #endif /* _T_SIZE */
229 #endif /* _T_SIZE_ */
230 #endif /* _SYS_SIZE_T_H */
231 #endif /* _SIZE_T */
232 #endif /* __SIZE_T__ */
233 #endif /* __size_t__ */
234 #undef __need_size_t
235 #endif /* _STDDEF_H or __need_size_t. */
236
237
238 /* Wide character type.
239 Locale-writers should change this as necessary to
240 be big enough to hold unique values not between 0 and 127,
241 and not (wchar_t) -1, for each defined multibyte character. */
242
243 /* Define this type if we are doing the whole job,
244 or if we want this type in particular. */
245 #if defined (_STDDEF_H) || defined (__need_wchar_t)
246 #ifndef __wchar_t__ /* BeOS */
247 #ifndef __WCHAR_T__ /* Cray Unicos/Mk */
248 #ifndef _WCHAR_T
249 #ifndef _T_WCHAR_
250 #ifndef _T_WCHAR
251 #ifndef __WCHAR_T
252 #ifndef _WCHAR_T_
253 #ifndef _BSD_WCHAR_T_
254 #ifndef _BSD_WCHAR_T_DEFINED_ /* Darwin */
255 #ifndef _BSD_RUNE_T_DEFINED_ /* Darwin */
256 #ifndef _WCHAR_T_DECLARED /* FreeBSD 5 */
257 #ifndef _WCHAR_T_DEFINED_
258 #ifndef _WCHAR_T_DEFINED
259 #ifndef _WCHAR_T_H
260 #ifndef ___int_wchar_t_h
261 #ifndef __INT_WCHAR_T_H
262 #ifndef _GCC_WCHAR_T
263 #define __wchar_t__ /* BeOS */
264 #define __WCHAR_T__ /* Cray Unicos/Mk */
265 #define _WCHAR_T
266 #define _T_WCHAR_
267 #define _T_WCHAR
268 #define __WCHAR_T
269 #define _WCHAR_T_
270 #define _BSD_WCHAR_T_
271 #define _WCHAR_T_DEFINED_
272 #define _WCHAR_T_DEFINED
273 #define _WCHAR_T_H
274 #define ___int_wchar_t_h
275 #define __INT_WCHAR_T_H
276 #define _GCC_WCHAR_T
277 #define _WCHAR_T_DECLARED
278
279 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
280 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
281 symbols in the _FOO_T_ family, stays defined even after its
282 corresponding type is defined). If we define wchar_t, then we
283 must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if
284 we undef _WCHAR_T_, then we must also define rune_t, since
285 headers like runetype.h assume that if machine/ansi.h is included,
286 and _BSD_WCHAR_T_ is not defined, then rune_t is available.
287 machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of
288 the same type." */
289 #ifdef _BSD_WCHAR_T_
290 #undef _BSD_WCHAR_T_
291 #ifdef _BSD_RUNE_T_
292 #if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
293 typedef _BSD_RUNE_T_ rune_t;
294 #define _BSD_WCHAR_T_DEFINED_
295 #define _BSD_RUNE_T_DEFINED_ /* Darwin */
296 #if defined (__FreeBSD__) && (__FreeBSD__ < 5)
297 /* Why is this file so hard to maintain properly? In contrast to
298 the comment above regarding BSD/386 1.1, on FreeBSD for as long
299 as the symbol has existed, _BSD_RUNE_T_ must not stay defined or
300 redundant typedefs will occur when stdlib.h is included after this file. */
301 #undef _BSD_RUNE_T_
302 #endif
303 #endif
304 #endif
305 #endif
306
307 #ifndef __WCHAR_TYPE__
308 #define __WCHAR_TYPE__ unsigned short
309 #endif
310 #ifndef __cplusplus
311 typedef __WCHAR_TYPE__ wchar_t;
312 #endif
313 #endif
314 #endif
315 #endif
316 #endif
317 #endif
318 #endif
319 #endif /* _WCHAR_T_DECLARED */
320 #endif /* _BSD_RUNE_T_DEFINED_ */
321 #endif
322 #endif
323 #endif
324 #endif
325 #endif
326 #endif
327 #endif
328 #endif /* __WCHAR_T__ */
329 #endif /* __wchar_t__ */
330 #undef __need_wchar_t
331 #endif /* _STDDEF_H or __need_wchar_t. */
332
333 /* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
334 are already defined. */
335 /* BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. */
336 #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_)
337 /* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_
338 are probably typos and should be removed before 2.8 is released. */
339 #ifdef _GCC_PTRDIFF_T_
340 #undef _PTRDIFF_T_
341 #undef _BSD_PTRDIFF_T_
342 #endif
343 #ifdef _GCC_SIZE_T_
344 #undef _SIZE_T_
345 #undef _BSD_SIZE_T_
346 #endif
347 #ifdef _GCC_WCHAR_T_
348 #undef _WCHAR_T_
349 #undef _BSD_WCHAR_T_
350 #endif
351 /* The following ones are the real ones. */
352 #ifdef _GCC_PTRDIFF_T
353 #undef _PTRDIFF_T_
354 #undef _BSD_PTRDIFF_T_
355 #endif
356 #ifdef _GCC_SIZE_T
357 #undef _SIZE_T_
358 #undef _BSD_SIZE_T_
359 #endif
360 #ifdef _GCC_WCHAR_T
361 #undef _WCHAR_T_
362 #undef _BSD_WCHAR_T_
363 #endif
364 #endif /* _ANSI_H_ || _MACHINE_ANSI_H_ */
365
366 #endif /* __sys_stdtypes_h */
367
368 /* A null pointer constant. */
369 #ifndef NULL
370 #ifdef __cplusplus
371 #define NULL 0
372 #else
373 #define NULL ((void*)0)
374 #endif
375 #endif
376
377 #ifndef offsetof
378
379 /* Offset of member MEMBER in a struct of type TYPE. */
380 #if defined(__GNUC__)
381 #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
382 #else
383 #define offsetof(TYPE, MEMBER) ((size_t)&(((TYPE *)0)->MEMBER))
384 #endif
385
386 #endif /* !offsetof */
387
388 #endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__
389 || __need_XXX was not defined before */