From 9535447e6faaa01c2c4e43d92d2e1ea169cab6cb Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 25 Nov 2021 09:20:22 +0100 Subject: [PATCH] core/kernel_defines.h: drop ALIGN_OF() Since we moved to C11 now for all platforms, using `alignof()` provided by `` has become the better option. --- core/include/kernel_defines.h | 8 -------- core/thread.c | 7 ++++--- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/core/include/kernel_defines.h b/core/include/kernel_defines.h index abd3afdb40..4ade63792e 100644 --- a/core/include/kernel_defines.h +++ b/core/include/kernel_defines.h @@ -132,14 +132,6 @@ extern "C" { #define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) #endif -/** - * @def ALIGN_OF(T) - * @brief Calculate the minimal alignment for type T. - * @param[in] T Type to examine - * @returns The minimal alignment of T. - */ -#define ALIGN_OF(T) (offsetof(struct { char c; T t; }, t)) - /** * @def BUILD_BUG_ON(condition) * @brief Forces a compilation error if condition is true. diff --git a/core/thread.c b/core/thread.c index fa2e49130b..ff3dcc7687 100644 --- a/core/thread.c +++ b/core/thread.c @@ -19,6 +19,7 @@ */ #include +#include #include #ifdef PICOLIBC_TLS #include @@ -205,9 +206,9 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority, #endif /* align the stack on a 16/32bit boundary */ - uintptr_t misalignment = (uintptr_t)stack % ALIGN_OF(void *); + uintptr_t misalignment = (uintptr_t)stack % alignof(void *); if (misalignment) { - misalignment = ALIGN_OF(void *) - misalignment; + misalignment = alignof(void *) - misalignment; stack += misalignment; stacksize -= misalignment; } @@ -216,7 +217,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, uint8_t priority, stacksize -= sizeof(thread_t); /* round down the stacksize to a multiple of thread_t alignments (usually 16/32bit) */ - stacksize -= stacksize % ALIGN_OF(thread_t); + stacksize -= stacksize % alignof(thread_t); if (stacksize < 0) { DEBUG("thread_create: stacksize is too small!\n");