mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-16 16:21:32 +00:00
508dcdb303
the definition of it uses offsetof(), and the two concepts are related.
19 lines
414 B
C
19 lines
414 B
C
#ifndef STDDEF_H
|
|
#define STDDEF_H
|
|
|
|
/* for size_t */
|
|
#include <stdint.h>
|
|
|
|
#undef NULL
|
|
#define NULL ((void *)0)
|
|
|
|
#undef offsetof
|
|
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
|
|
|
#undef container_of
|
|
#define container_of(ptr, type, member) ({ \
|
|
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
|
(type *)( (char *)__mptr - offsetof(type,member) );})
|
|
|
|
#endif /* STDDEF_H */
|