[zbin] Fix check for existence of most recent output byte
[ipxe.git] / src / include / stddef.h
1 #ifndef STDDEF_H
2 #define STDDEF_H
3
4 FILE_LICENCE ( GPL2_ONLY );
5
6 /* for size_t */
7 #include <stdint.h>
8
9 #undef NULL
10 #define NULL ((void *)0)
11
12 #undef offsetof
13 #if ( defined ( __GNUC__ ) && ( __GNUC__ > 3 ) )
14 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
15 #else
16 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
17 #endif
18
19 #undef container_of
20 #define container_of(ptr, type, member) ({ \
21 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
22 (type *)( (char *)__mptr - offsetof(type,member) );})
23
24 /* __WCHAR_TYPE__ is defined by gcc and will change if -fshort-wchar is used */
25 #ifndef __WCHAR_TYPE__
26 #define __WCHAR_TYPE__ uint16_t
27 #endif
28 #ifndef __WINT_TYPE__
29 #define __WINT_TYPE__ int
30 #endif
31 typedef __WCHAR_TYPE__ wchar_t;
32 typedef __WINT_TYPE__ wint_t;
33
34 #endif /* STDDEF_H */