arch: kernel: lib: toolchain: Standardize TLS keyword

Up until now, the `__thread` keyword has been used for declaring
variables as Thread local storage. However, `__thread` is a GNU
specific keyword which thus limits compatibility with other
toolchains (for instance IAR).

This PR intoduces a new macro `Z_THREAD_LOCAL` which expands to the
corresponding C11, C23 or C++11 standard keyword based on the standard
that is specified during compilation, else it uses the old `__thread`
keyword.

Signed-off-by: Daniel Flodin <daniel.flodin@iar.com>
This commit is contained in:
Daniel Flodin 2024-09-18 14:07:42 +02:00 committed by Carles Cufí
commit 746c59c82a
11 changed files with 37 additions and 19 deletions

View file

@ -47,7 +47,7 @@ void _StackCheckHandler(void)
* The canary value gets initialized in z_cstart().
*/
#ifdef CONFIG_STACK_CANARIES_TLS
__thread volatile uintptr_t __stack_chk_guard;
Z_THREAD_LOCAL volatile uintptr_t __stack_chk_guard;
#elif CONFIG_USERSPACE
K_APP_DMEM(z_libc_partition) volatile uintptr_t __stack_chk_guard;
#else