From 8c0ea495fe51792dc24f0d1e5da9ab659bc628ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20D=C3=B6ring?= Date: Fri, 22 Nov 2019 14:10:58 +0100 Subject: [PATCH] use align pragma --- lib/nimalloc.h | 7 ------- lib/system/alloc.nim | 5 ++--- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 lib/nimalloc.h diff --git a/lib/nimalloc.h b/lib/nimalloc.h deleted file mode 100644 index a4a147fe11b42..0000000000000 --- a/lib/nimalloc.h +++ /dev/null @@ -1,7 +0,0 @@ -#include - -// this type is used in alloc.nim. It is intended to ensure 16 byte -// alignments for all allocations. -typedef struct { - alignas(16) char unused; -} NimAlign16Type; diff --git a/lib/system/alloc.nim b/lib/system/alloc.nim index 5a8ebffe552b0..62535acd1bf03 100644 --- a/lib/system/alloc.nim +++ b/lib/system/alloc.nim @@ -45,7 +45,6 @@ type data: TrunkBuckets type - AlignType {.importc: "NimAlign16Type", header: "nimalloc.h".} = object FreeCell {.final, pure.} = object next: ptr FreeCell # next free cell in chunk (overlaid with refcount) zeroField: int # 0 means cell is not used (overlaid with typ field) @@ -65,11 +64,11 @@ type freeList: ptr FreeCell free: int # how many bytes remain acc: int # accumulator for small object allocation - data: UncheckedArray[AlignType] # start of usable memory + data {.align: MemAlign.}: UncheckedArray[byte] # start of usable memory BigChunk = object of BaseChunk # not necessarily > PageSize! next, prev: PBigChunk # chunks of the same (or bigger) size - data: UncheckedArray[AlignType] # start of usable memory + data {.align: MemAlign.}: UncheckedArray[byte] # start of usable memory template smallChunkOverhead(): untyped = sizeof(SmallChunk) template bigChunkOverhead(): untyped = sizeof(BigChunk)