• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * stddef.h
3  */
4 
5 #ifndef _STDDEF_H
6 #define _STDDEF_H
7 
8 #ifndef __KLIBC__
9 # define __KLIBC__ 1
10 #endif
11 
12 #include <bitsize/stddef.h>
13 
14 #undef NULL
15 #ifdef __cplusplus
16 # define NULL 0
17 #else
18 # define NULL ((void *)0)
19 #endif
20 
21 #undef offsetof
22 #define offsetof(t,m) ((size_t)&((t *)0)->m)
23 
24 #undef container_of
25 /*
26  * The container_of construct: if p is a pointer to member m of
27  * container class c, then return a pointer to the container of which
28  * *p is a member.
29  */
30 #define container_of(p, c, m) ((c *)((char *)(p) - offsetof(c,m)))
31 
32 #endif /* _STDDEF_H */
33