From 8cb98357dec364739926b52f20fdd1e3b91c61c8 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Tue, 26 May 2020 00:03:46 +0300 Subject: [PATCH 1/2] stbi: fix thread local selector * GCC < 5 supports __thread and GCC >= 5 supports C11 with _Thread_local * Skip _Thread_local for MSVC because it may not be supported --- stb_image.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stb_image.h b/stb_image.h index 2857f05..ce3353a 100644 --- a/stb_image.h +++ b/stb_image.h @@ -574,13 +574,13 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch #ifndef STBI_NO_THREAD_LOCALS #if defined(__cplusplus) && __cplusplus >= 201103L #define STBI_THREAD_LOCAL thread_local - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define STBI_THREAD_LOCAL _Thread_local - #elif defined(__GNUC__) + #elif defined(__GNUC__) && __GNUC__ < 5 #define STBI_THREAD_LOCAL __thread #elif defined(_MSC_VER) #define STBI_THREAD_LOCAL __declspec(thread) -#endif + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) + #define STBI_THREAD_LOCAL _Thread_local + #endif #endif #ifdef _MSC_VER From ec898982b0f1815cc660ece28d655677d2286626 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Tue, 26 May 2020 00:22:12 +0300 Subject: [PATCH 2/2] stbi: use __thread if GCC can't use _Thread_local --- stb_image.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stb_image.h b/stb_image.h index ce3353a..f66e5f4 100644 --- a/stb_image.h +++ b/stb_image.h @@ -581,6 +581,12 @@ STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const ch #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) #define STBI_THREAD_LOCAL _Thread_local #endif + + #ifndef STBI_THREAD_LOCAL + #if defined(__GNUC__) + #define STBI_THREAD_LOCAL __thread + #endif + #endif #endif #ifdef _MSC_VER