From 15515269a19da36e0026ee946d39ea84876967e7 Mon Sep 17 00:00:00 2001 From: churl Date: Mon, 9 May 2022 18:24:51 +0200 Subject: [PATCH] add macro for word alignment setting --- c_os/kernel/allocator/LinkedListAllocator.cc | 2 +- c_os/kernel/allocator/LinkedListAllocator.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/c_os/kernel/allocator/LinkedListAllocator.cc b/c_os/kernel/allocator/LinkedListAllocator.cc index de3c005..cc1d875 100755 --- a/c_os/kernel/allocator/LinkedListAllocator.cc +++ b/c_os/kernel/allocator/LinkedListAllocator.cc @@ -89,7 +89,7 @@ void* LinkedListAllocator::alloc(unsigned int req_size) { } // Round to word borders - unsigned int req_size_diff = (4 - req_size % 4) % 4; + unsigned int req_size_diff = (BASIC_ALIGN - req_size % BASIC_ALIGN) % BASIC_ALIGN; unsigned int rreq_size = req_size + req_size_diff; if (req_size_diff > 0) { kout << " - Rounded to word border (+" << dec << req_size_diff << " bytes)" << endl; diff --git a/c_os/kernel/allocator/LinkedListAllocator.h b/c_os/kernel/allocator/LinkedListAllocator.h index 3d3c4e7..71cd080 100755 --- a/c_os/kernel/allocator/LinkedListAllocator.h +++ b/c_os/kernel/allocator/LinkedListAllocator.h @@ -14,6 +14,9 @@ #include "kernel/Allocator.h" +// TODO: Is it 8 or 4? +#define BASIC_ALIGN 8 + // Format eines freien Blocks, 4 + 4 + 4 Byte typedef struct free_block { bool allocated; // NOTE: I added this to allow easier merging of free blocks: