]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix alignment requirements to include atomic u64.
authorMaria Matejka <mq@ucw.cz>
Wed, 11 Dec 2024 16:51:46 +0000 (17:51 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 11 Dec 2024 16:51:46 +0000 (17:51 +0100)
Not having this led to bus errors on unaligned atomic u64 access
on architectures with 4B pointers.

lib/mempool.c
lib/resource.c
lib/slab.c

index 5940e57128638254adfa81195cf51b179e3c8966..6de44b6bd6114c9399b44a2d9828ff1bd96d60d2 100644 (file)
@@ -29,6 +29,7 @@ struct lp_chunk {
   struct lp_chunk *next;
   struct linpool *lp;
   uintptr_t data_align[0];
+  _Atomic u64 data_align_atomic[0];
   byte data[0];
 };
 
index b89f772c1dfdc682b63fcf92de624ead9a854666..17af79d75a68f982efeb3368d299fa5f66a550bc 100644 (file)
@@ -373,7 +373,10 @@ tmp_flush(void)
 struct mblock {
   resource r;
   unsigned size;
-  uintptr_t data_align[0];
+  union {
+    uintptr_t bigint;
+    _Atomic u64 atom;
+  } _align[0];
   byte data[0];
 };
 
index ab913f0cd406479f445b3d6b0e4dadd8c1ed856c..276ea8d09941de058d01080200cf61695ea3c670 100644 (file)
@@ -171,6 +171,8 @@ struct sl_head {
 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