]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Merge commit 'abecb5bb408f253cd24345ba94940ea0f7b59f4f' into HEAD
authorMaria Matejka <mq@ucw.cz>
Thu, 9 Jan 2025 17:55:26 +0000 (18:55 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 9 Jan 2025 17:55:26 +0000 (18:55 +0100)
1  2 
lib/birdlib.h
lib/mempool.c
lib/resource.c
lib/slab.c

diff --cc lib/birdlib.h
index 442bf60040cf970f494acc46e8e40e6d39cbaf58,8209a108d5193dd7323199ccd2b72cf29ed1773b..bc7c334cb36bfc68c8ff5f433fa0a934dd625cb1
  
  /* Ugly structure offset handling macros */
  
 +#define SAME_TYPE(a, b)       ({ int _ = ((a) != (b)); !_; })
 +#define TYPE_CAST(from, to, what) ( SAME_TYPE(((from) NULL), (what)), ((to) (what)))
 +
 +#ifdef offsetof
 +#define OFFSETOF offsetof
 +#else
  #define OFFSETOF(s, i) ((size_t) &((s *)0)->i)
 -#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i)))
 +#endif
 +
 +#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 SKIP_BACK_DECLARE(s, n, i, p) s *n = SKIP_BACK(s, i, p)
  #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1))
- #define CPU_STRUCT_ALIGN  (MAX_(_Alignof(void*), _Alignof(u64)))
 +#define BIRD_SET_ALIGNED_POINTER(ptr, val)  do { \
 +  size_t _alignment = _Alignof(typeof(*ptr)); \
 +  ptr = (typeof(ptr)) BIRD_ALIGN((uintptr_t)(val), _alignment); \
 +} while (0)
+ #define CPU_STRUCT_ALIGN (alignof(max_align_t))
 +#define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN)
 +
 +/* Structure item alignment macros */
 +
 +#define PADDING_NAME(id)      _padding_##id
 +#define PADDING_(id, sz)      u8 PADDING_NAME(id)[sz]
 +
 +#if CPU_POINTER_ALIGNMENT == 4
 +#define PADDING(id, n32, n64) PADDING_(id, n32)
 +#elif CPU_POINTER_ALIGNMENT == 8
 +#define PADDING(id, n32, n64) PADDING_(id, n64)
 +#else
 +#error "Strange CPU pointer alignment: " CPU_POINTER_ALIGNMENT
 +#endif
  
  /* Utility macros */
  
diff --cc lib/mempool.c
index 1ca6d03b66b6ec1ec7cc2598af4acbb2c40e9c82,525eee8fc7e21784549bebc78232aef9edae5686..b88bc122781580cc33da1b375b05ba5cf4dd6aef
@@@ -27,9 -27,7 +27,8 @@@
  
  struct lp_chunk {
    struct lp_chunk *next;
-   uintptr_t data_align[0];
-   _Atomic u64 data_align_atomic[0];
 +  struct linpool *lp;
+   max_align_t data_align[0];
    byte data[0];
  };
  
diff --cc lib/resource.c
Simple merge
diff --cc lib/slab.c
Simple merge