c11: Implement thread_local in c11/threads.h

Use thread_local when possible

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15087>
This commit is contained in:
Yonggang Luo
2022-04-09 22:33:44 +08:00
committed by Marge Bot
parent 09cd5c9bdb
commit 6e33ef2bb9
4 changed files with 33 additions and 7 deletions
+3 -5
View File
@@ -79,13 +79,11 @@
* expensive pthread_getspecific() or its equivalent).
*/
#ifdef USE_ELF_TLS
#ifdef _MSC_VER
#define __THREAD_INITIAL_EXEC __declspec(thread)
#elif defined(__GLIBC__)
#define __THREAD_INITIAL_EXEC __thread __attribute__((tls_model("initial-exec")))
#if defined(__GLIBC__)
#define __THREAD_INITIAL_EXEC thread_local __attribute__((tls_model("initial-exec")))
#define REALLY_INITIAL_EXEC
#else
#define __THREAD_INITIAL_EXEC __thread
#define __THREAD_INITIAL_EXEC thread_local
#endif
#endif