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