4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
8 /** EFI headers also define NULL */
12 #define NULL ( ( void * ) 0 )
15 * Get offset of a field within a structure
17 * @v type Structure type
18 * @v field Field within structure
19 * @ret offset Offset within structure
21 #if defined ( __GNUC__ ) && ( __GNUC__ > 3 )
22 #define offsetof( type, field ) __builtin_offsetof ( type, field )
24 #define offsetof( type, field ) ( ( size_t ) &( ( ( type * ) NULL )->field ) )
28 * Get containing structure
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
35 #define container_of( ptr, type, field ) ( { \
37 const typeof ( __container->field ) *__field = (ptr); \
38 __container = ( ( ( void * ) __field ) - \
39 offsetof ( type, field ) ); \
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
47 #define __WINT_TYPE__ int
49 typedef __WCHAR_TYPE__ wchar_t;
50 typedef __WINT_TYPE__ wint_t;