1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 15:31:17 +01:00

core/kernel_defines.h: drop ALIGN_OF()

Since we moved to C11 now for all platforms, using `alignof()` provided
by `<stdalign.h>` has become the better option.
This commit is contained in:
Marian Buschsieweke 2021-11-25 09:20:22 +01:00
parent 0de8bfaadc
commit 9535447e6f
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94
2 changed files with 4 additions and 11 deletions

View File

@ -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.

View File

@ -19,6 +19,7 @@
*/
#include <errno.h>
#include <stdalign.h>
#include <stdio.h>
#ifdef PICOLIBC_TLS
#include <picotls.h>
@ -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");