iPXE
stddef.h
Go to the documentation of this file.
1 #ifndef STDDEF_H
2 #define STDDEF_H
3 
4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5 
6 #include <stdint.h>
7 
8 /** EFI headers also define NULL */
9 #undef NULL
10 
11 /** Null pointer */
12 #define NULL ( ( void * ) 0 )
13 
14 /**
15  * Get offset of a field within a structure
16  *
17  * @v type Structure type
18  * @v field Field within structure
19  * @ret offset Offset within structure
20  */
21 #if defined ( __GNUC__ ) && ( __GNUC__ > 3 )
22 #define offsetof( type, field ) __builtin_offsetof ( type, field )
23 #else
24 #define offsetof( type, field ) ( ( size_t ) &( ( ( type * ) NULL )->field ) )
25 #endif
26 
27 /**
28  * Get containing structure
29  *
30  * @v ptr Pointer to contained field
31  * @v type Containing structure type
32  * @v field Field within containing structure
33  * @ret container Pointer to containing structure
34  */
35 #define container_of( ptr, type, field ) ( { \
36  type *__container; \
37  const volatile typeof ( __container->field ) *__field = (ptr); \
38  __container = ( ( ( void * ) __field ) - \
39  offsetof ( type, field ) ); \
40  __container; } )
41 
42 /* __WCHAR_TYPE__ is defined by gcc and will change if -fshort-wchar is used */
43 #ifndef __WCHAR_TYPE__
44 #define __WCHAR_TYPE__ uint16_t
45 #endif
46 #ifndef __WINT_TYPE__
47 #define __WINT_TYPE__ int
48 #endif
51 
52 #endif /* STDDEF_H */
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define __WCHAR_TYPE__
Definition: stddef.h:44
__WCHAR_TYPE__ wchar_t
Definition: stddef.h:49
#define __WINT_TYPE__
Definition: stddef.h:47
__WINT_TYPE__ wint_t
Definition: stddef.h:50