diff --git a/src/lib/thread.c b/src/lib/thread.c index 3be2e92f5c..262cfa53bd 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -11,6 +11,10 @@ #include #include +/* Can't use the IS_POWER_OF_2 in _Static_assert */ +_Static_assert((CONFIG_STACK_SIZE & (CONFIG_STACK_SIZE - 1)) == 0, + "`cpu_info()` requires the stack size to be a power of 2"); + static bool initialized; static void idle_thread_init(void); @@ -257,6 +261,9 @@ void threads_initialize(void) thread_stacks = arch_get_thread_stackbase(); + /* `cpu_info()` requires the stacks to be STACK_SIZE aligned */ + assert(IS_ALIGNED((uintptr_t)thread_stacks, CONFIG_STACK_SIZE)); + /* Initialize the BSP thread first. The cpu_info structure is assumed * to be just under the top of the stack. */ t = &all_threads[0];