diff options
Diffstat (limited to 'lib/birdlib.h')
-rw-r--r-- | lib/birdlib.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h index d55b1a44..d743ecdf 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -14,8 +14,9 @@ /* Ugly structure offset handling macros */ +#define SAME_TYPE(a, b) ({ int _ = ((a) != (b)); !_; }) #define OFFSETOF(s, i) ((size_t) &((s *)0)->i) -#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); ASSERT_DIE(&_ptr->i == p); _ptr; }) +#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); SAME_TYPE(&_ptr->i, p); _ptr; }) #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1)) #define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64))) #define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN) |