improve container_of macro

This commit is contained in:
Petr Ledvina 2015-10-09 11:20:36 +02:00 committed by Dominic Clifton
parent dc5a888633
commit 48cdf650d9
1 changed files with 2 additions and 2 deletions

View File

@ -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; }