improve container_of macro
This commit is contained in:
parent
dc5a888633
commit
48cdf650d9
|
@ -42,9 +42,9 @@ http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
|
|||
#else
|
||||
// non ISO variant from linux kernel; checks ptr type, but triggers 'ISO C forbids braced-groups within expressions [-Wpedantic]'
|
||||
// __extension__ is here to disable this warning
|
||||
#define container_of(ptr, type, member) __extension__ ({ \
|
||||
#define container_of(ptr, type, member) ( __extension__ ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );}))
|
||||
|
||||
static inline int16_t cmp16(uint16_t a, uint16_t b) { return a-b; }
|
||||
static inline int32_t cmp32(uint32_t a, uint32_t b) { return a-b; }
|
||||
|
|
Loading…
Reference in New Issue