|
@@ -2,12 +2,17 @@
|
2
|
2
|
#define STDDEF_H
|
3
|
3
|
|
4
|
4
|
/* for size_t */
|
5
|
|
-#include "stdint.h"
|
|
5
|
+#include <stdint.h>
|
6
|
6
|
|
7
|
7
|
#undef NULL
|
8
|
|
-#define NULL ((void *)0)
|
|
8
|
+#define NULL ((void *)0)
|
9
|
9
|
|
10
|
10
|
#undef offsetof
|
11
|
11
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
12
|
12
|
|
|
13
|
+#undef container_of
|
|
14
|
+#define container_of(ptr, type, member) ({ \
|
|
15
|
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
16
|
+ (type *)( (char *)__mptr - offsetof(type,member) );})
|
|
17
|
+
|
13
|
18
|
#endif /* STDDEF_H */
|