mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-03 07:31:54 +00:00
Macro SKIP_BACK now evaluates its argument only once.
This commit is contained in:
parent
48abd6a963
commit
194ed4e6e6
@ -26,7 +26,11 @@
|
|||||||
#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
|
#define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SKIP_BACK(s, i, p) ({ s *_ptr = ((s *)((char *)p - OFFSETOF(s, i))); SAME_TYPE(&_ptr->i, p); _ptr; })
|
#define SKIP_BACK(s, i, p) ({ \
|
||||||
|
typeof(p) _orig = p; \
|
||||||
|
s *_ptr = ((s *)((char *)_orig - OFFSETOF(s, i))); \
|
||||||
|
SAME_TYPE(&_ptr->i, _orig); \
|
||||||
|
_ptr; })
|
||||||
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
|
#define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
|
||||||
#define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64)))
|
#define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64)))
|
||||||
#define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN)
|
#define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN)
|
||||||
|
Loading…
Reference in New Issue
Block a user