mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
improve container_of macro
This commit is contained in:
parent
dc5a888633
commit
48cdf650d9
1 changed files with 2 additions and 2 deletions
|
@ -42,9 +42,9 @@ http://resnet.uoregon.edu/~gurney_j/jmpc/bitwise.html
|
||||||
#else
|
#else
|
||||||
// non ISO variant from linux kernel; checks ptr type, but triggers 'ISO C forbids braced-groups within expressions [-Wpedantic]'
|
// 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
|
// __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); \
|
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 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; }
|
static inline int32_t cmp32(uint32_t a, uint32_t b) { return a-b; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue