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:
parent
62c0fc3e14
commit
746c59c82a
11 changed files with 37 additions and 19 deletions
|
@ -143,7 +143,7 @@ ZTEST(stackprot, test_create_alt_thread)
|
|||
}
|
||||
|
||||
#ifdef CONFIG_STACK_CANARIES_TLS
|
||||
extern __thread volatile uintptr_t __stack_chk_guard;
|
||||
extern Z_THREAD_LOCAL volatile uintptr_t __stack_chk_guard;
|
||||
#else
|
||||
extern volatile uintptr_t __stack_chk_guard;
|
||||
#endif
|
||||
|
|
|
@ -51,14 +51,14 @@ K_APP_BMEM(part_common) static k_tid_t tls_tid[NUM_THREADS];
|
|||
K_APP_BMEM(part_common) static enum test_result tls_result[NUM_THREADS];
|
||||
|
||||
/* Thread data with initialized values */
|
||||
static uint8_t __thread thread_data8 = STATIC_DATA8;
|
||||
static uint32_t __thread thread_data32 = STATIC_DATA32;
|
||||
static uint64_t __thread thread_data64 = STATIC_DATA64;
|
||||
static uint8_t Z_THREAD_LOCAL thread_data8 = STATIC_DATA8;
|
||||
static uint32_t Z_THREAD_LOCAL thread_data32 = STATIC_DATA32;
|
||||
static uint64_t Z_THREAD_LOCAL thread_data64 = STATIC_DATA64;
|
||||
|
||||
/* Zeroed thread data */
|
||||
static uint8_t __thread thread_bss8;
|
||||
static uint32_t __thread thread_bss32;
|
||||
static uint64_t __thread thread_bss64;
|
||||
static uint8_t Z_THREAD_LOCAL thread_bss8;
|
||||
static uint32_t Z_THREAD_LOCAL thread_bss32;
|
||||
static uint64_t Z_THREAD_LOCAL thread_bss64;
|
||||
|
||||
static void tls_thread_entry(void *p1, void *p2, void *p3)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue