Skip to content

Commit f8299b6

Browse files
danielfl-iardleach02
authored andcommitted
include: types.h: toolchain.h: Move TLS macro definition
Move the `Z_THREAD_LOCAL` macro from `include/zephyr/toolchain/common.h` to `include/zephyr/types.h`. This is needed since some `syscall.h` files are using TLS but aren't including `zephyr/toolchain.h` (but they are including `zephyr/types.h`). Signed-off-by: Daniel Flodin <[email protected]>
1 parent 5b607ed commit f8299b6

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

include/zephyr/toolchain/common.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,6 @@
3939
#endif
4040
#endif
4141

42-
/*
43-
* Thread local variables are declared with different keywords depending on
44-
* which C/C++ standard that is used. C++11 and C23 uses "thread_local" whilst
45-
* C11 uses "_Thread_local". Previously the GNU "__thread" keyword was used
46-
* which is the same in both gcc and g++.
47-
*/
48-
#ifndef Z_THREAD_LOCAL
49-
#if defined(__cplusplus) && (__cplusplus) >= 201103L /* C++11 */
50-
#define Z_THREAD_LOCAL thread_local
51-
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__) >= 202311L /* C23 */
52-
#define Z_THREAD_LOCAL thread_local
53-
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__) >= 201112L /* C11 */
54-
#define Z_THREAD_LOCAL _Thread_local
55-
#else /* Default back to old behavior which used the GNU keyword. */
56-
#define Z_THREAD_LOCAL __thread
57-
#endif
58-
#endif /* Z_THREAD_LOCAL */
59-
6042
/*
6143
* Generate a reference to an external symbol.
6244
* The reference indicates to the linker that the symbol is required

include/zephyr/types.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ typedef union {
2929
void (*thepfunc)(void);
3030
} z_max_align_t;
3131

32+
/*
33+
* Thread local variables are declared with different keywords depending on
34+
* which C/C++ standard that is used. C++11 and C23 uses "thread_local" whilst
35+
* C11 uses "_Thread_local". Previously the GNU "__thread" keyword was used
36+
* which is the same in both gcc and g++.
37+
*/
38+
#ifndef Z_THREAD_LOCAL
39+
#if defined(__cplusplus) && (__cplusplus) >= 201103L /* C++11 */
40+
#define Z_THREAD_LOCAL thread_local
41+
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__) >= 202311L /* C23 */
42+
#define Z_THREAD_LOCAL thread_local
43+
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__) >= 201112L /* C11 */
44+
#define Z_THREAD_LOCAL _Thread_local
45+
#else /* Default back to old behavior which used the GNU keyword. */
46+
#define Z_THREAD_LOCAL __thread
47+
#endif
48+
#endif /* Z_THREAD_LOCAL */
49+
3250
#ifdef __cplusplus
3351
/* Zephyr requires an int main(void) signature with C linkage for the application main if present */
3452
extern int main(void);

0 commit comments

Comments
 (0)