mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2025-01-27 03:10:03 +00:00
Merge commit 'abecb5bb408f253cd24345ba94940ea0f7b59f4f' into HEAD
This commit is contained in:
commit
000ba7e960
@ -41,7 +41,7 @@
|
||||
size_t _alignment = _Alignof(typeof(*ptr)); \
|
||||
ptr = (typeof(ptr)) BIRD_ALIGN((uintptr_t)(val), _alignment); \
|
||||
} 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)
|
||||
|
||||
/* Structure item alignment macros */
|
||||
|
@ -28,8 +28,7 @@
|
||||
struct lp_chunk {
|
||||
struct lp_chunk *next;
|
||||
struct linpool *lp;
|
||||
uintptr_t data_align[0];
|
||||
_Atomic u64 data_align_atomic[0];
|
||||
max_align_t data_align[0];
|
||||
byte data[0];
|
||||
};
|
||||
|
||||
|
@ -384,10 +384,7 @@ tmp_flush(void)
|
||||
struct mblock {
|
||||
resource r;
|
||||
unsigned size;
|
||||
union {
|
||||
uintptr_t bigint;
|
||||
_Atomic u64 atom;
|
||||
} _align[0];
|
||||
max_align_t data_align[0];
|
||||
byte data[0];
|
||||
};
|
||||
|
||||
|
13
lib/slab.c
13
lib/slab.c
@ -68,7 +68,7 @@ static struct resclass sl_class = {
|
||||
|
||||
struct sl_obj {
|
||||
node n;
|
||||
uintptr_t data_align[0];
|
||||
max_align_t data_align[0];
|
||||
byte data[0];
|
||||
};
|
||||
|
||||
@ -168,13 +168,6 @@ struct sl_head {
|
||||
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_TYPE struct sl_head
|
||||
#define TLIST_ITEM n
|
||||
@ -221,9 +214,7 @@ slab *
|
||||
sl_new(pool *p, uint size)
|
||||
{
|
||||
slab *s = ralloc(p, &sl_class);
|
||||
uint align = sizeof(struct sl_alignment);
|
||||
if (align < sizeof(void *))
|
||||
align = sizeof(void *);
|
||||
uint align = CPU_STRUCT_ALIGN;
|
||||
s->data_size = size;
|
||||
size = (size + align - 1) / align * align;
|
||||
s->obj_size = size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user