|
22 | 22 |
|
23 | 23 | #include <stdint.h>
|
24 | 24 | #include <stdbool.h>
|
| 25 | +#if __STDC_NO_THREADS__ |
| 26 | +# define thread_local _Thread_local |
| 27 | +#else |
| 28 | +# include <threads.h> |
| 29 | +#endif |
25 | 30 |
|
26 | 31 | #ifdef TSRM_WIN32
|
27 | 32 | # ifdef TSRM_EXPORTS
|
@@ -142,12 +147,6 @@ TSRM_API bool tsrm_is_shutdown(void);
|
142 | 147 | TSRM_API const char *tsrm_api_name(void);
|
143 | 148 | TSRM_API bool tsrm_is_managed_thread(void);
|
144 | 149 |
|
145 |
| -#ifdef TSRM_WIN32 |
146 |
| -# define TSRM_TLS __declspec(thread) |
147 |
| -#else |
148 |
| -# define TSRM_TLS __thread |
149 |
| -#endif |
150 |
| - |
151 | 150 | #ifndef __has_attribute
|
152 | 151 | # define __has_attribute(x) 0
|
153 | 152 | #endif
|
@@ -175,10 +174,10 @@ TSRM_API bool tsrm_is_managed_thread(void);
|
175 | 174 | #define TSRMG_BULK_STATIC(id, type) ((type) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(id)])
|
176 | 175 | #define TSRMG_FAST_STATIC(offset, type, element) (TSRMG_FAST_BULK_STATIC(offset, type)->element)
|
177 | 176 | #define TSRMG_FAST_BULK_STATIC(offset, type) ((type) (((char*) TSRMLS_CACHE)+(offset)))
|
178 |
| -#define TSRMLS_MAIN_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; |
179 |
| -#define TSRMLS_MAIN_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL; |
180 |
| -#define TSRMLS_CACHE_EXTERN() extern TSRM_TLS void *TSRMLS_CACHE; |
181 |
| -#define TSRMLS_CACHE_DEFINE() TSRM_TLS void *TSRMLS_CACHE = NULL; |
| 177 | +#define TSRMLS_MAIN_CACHE_EXTERN() extern thread_local void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR; |
| 178 | +#define TSRMLS_MAIN_CACHE_DEFINE() thread_local void *TSRMLS_CACHE TSRM_TLS_MODEL_ATTR = NULL; |
| 179 | +#define TSRMLS_CACHE_EXTERN() extern thread_local void *TSRMLS_CACHE; |
| 180 | +#define TSRMLS_CACHE_DEFINE() thread_local void *TSRMLS_CACHE = NULL; |
182 | 181 | #define TSRMLS_CACHE_UPDATE() TSRMLS_CACHE = tsrm_get_ls_cache()
|
183 | 182 | #define TSRMLS_CACHE _tsrm_ls_cache
|
184 | 183 |
|
|
0 commit comments