0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-27 11:20:03 +00:00

Merge commit 'abecb5bb408f253cd24345ba94940ea0f7b59f4f' into HEAD

This commit is contained in:
Maria Matejka 2025-01-09 18:55:26 +01:00
commit 000ba7e960
4 changed files with 5 additions and 18 deletions

View File

@ -41,7 +41,7 @@
size_t _alignment = _Alignof(typeof(*ptr)); \ size_t _alignment = _Alignof(typeof(*ptr)); \
ptr = (typeof(ptr)) BIRD_ALIGN((uintptr_t)(val), _alignment); \ ptr = (typeof(ptr)) BIRD_ALIGN((uintptr_t)(val), _alignment); \
} while (0) } while (0)
#define CPU_STRUCT_ALIGN (MAX_(_Alignof(void*), _Alignof(u64))) #define CPU_STRUCT_ALIGN (alignof(max_align_t))
#define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN) #define BIRD_CPU_ALIGN(s) BIRD_ALIGN((s), CPU_STRUCT_ALIGN)
/* Structure item alignment macros */ /* Structure item alignment macros */

View File

@ -28,8 +28,7 @@
struct lp_chunk { struct lp_chunk {
struct lp_chunk *next; struct lp_chunk *next;
struct linpool *lp; struct linpool *lp;
uintptr_t data_align[0]; max_align_t data_align[0];
_Atomic u64 data_align_atomic[0];
byte data[0]; byte data[0];
}; };

View File

@ -384,10 +384,7 @@ tmp_flush(void)
struct mblock { struct mblock {
resource r; resource r;
unsigned size; unsigned size;
union { max_align_t data_align[0];
uintptr_t bigint;
_Atomic u64 atom;
} _align[0];
byte data[0]; byte data[0];
}; };

View File

@ -68,7 +68,7 @@ static struct resclass sl_class = {
struct sl_obj { struct sl_obj {
node n; node n;
uintptr_t data_align[0]; max_align_t data_align[0];
byte data[0]; byte data[0];
}; };
@ -168,13 +168,6 @@ struct sl_head {
u32 used_bits[0]; u32 used_bits[0];
}; };
struct sl_alignment { /* Magic structure for testing of alignment */
byte data;
int x[0];
_Atomic u64 y[0];
void *z[0];
};
#define TLIST_PREFIX sl_head #define TLIST_PREFIX sl_head
#define TLIST_TYPE struct sl_head #define TLIST_TYPE struct sl_head
#define TLIST_ITEM n #define TLIST_ITEM n
@ -221,9 +214,7 @@ slab *
sl_new(pool *p, uint size) sl_new(pool *p, uint size)
{ {
slab *s = ralloc(p, &sl_class); slab *s = ralloc(p, &sl_class);
uint align = sizeof(struct sl_alignment); uint align = CPU_STRUCT_ALIGN;
if (align < sizeof(void *))
align = sizeof(void *);
s->data_size = size; s->data_size = size;
size = (size + align - 1) / align * align; size = (size + align - 1) / align * align;
s->obj_size = size; s->obj_size = size;