1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

Merge pull request #17267 from maribu/core/alignof

core/kernel_defines.h: drop ALIGN_OF()
This commit is contained in:
Alexandre Abadie 2022-01-05 14:10:00 +01:00 committed by GitHub
commit b84c3e47bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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");