Skip to content

Commit 4ac77b7

Browse files
authored
Merge pull request #358 from adierking/tsd
Use _Thread_local for thread-local storage
2 parents e723a8e + b0663b9 commit 4ac77b7

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ option(USE_GOLD_LINKER "use the gold linker" ${USE_GOLD_LINKER_DEFAULT})
102102

103103
option(USE_LLD_LINKER "use the lld linker" OFF)
104104

105-
option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via __thread" ON)
105+
option(ENABLE_THREAD_LOCAL_STORAGE "enable usage of thread local storage via _Thread_local" ON)
106106
set(DISPATCH_USE_THREAD_LOCAL_STORAGE ${ENABLE_THREAD_LOCAL_STORAGE})
107107

108108
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR

cmake/config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* Define if building pthread work queues from source */
33
#cmakedefine01 DISPATCH_USE_INTERNAL_WORKQUEUE
44

5-
/* Enable usage of thread local storage via __thread */
5+
/* Enable usage of thread local storage via _Thread_local */
66
#cmakedefine01 DISPATCH_USE_THREAD_LOCAL_STORAGE
77

88
/* Define to 1 if you have the declaration of `CLOCK_MONOTONIC', and to 0 if

src/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void (*_dispatch_end_NSAutoReleasePool)(void *);
112112
#endif
113113

114114
#if DISPATCH_USE_THREAD_LOCAL_STORAGE
115-
__thread struct dispatch_tsd __dispatch_tsd;
115+
_Thread_local struct dispatch_tsd __dispatch_tsd;
116116
#if defined(_WIN32)
117117
DWORD __dispatch_tsd_key;
118118
#else

src/shims/tsd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ _dispatch_thread_key_create(DWORD *k, void (DISPATCH_TSD_DTOR_CC *d)(void *))
115115
dispatch_assert_zero((*k = FlsAlloc(d)));
116116
}
117117

118-
extern __declspec(thread) struct dispatch_tsd __dispatch_tsd;
119118
extern DWORD __dispatch_tsd_key;
120119

121120
#else
@@ -127,7 +126,6 @@ _dispatch_thread_key_create(pthread_key_t *k, void (DISPATCH_TSD_DTOR_CC *d)(voi
127126
dispatch_assert_zero(pthread_key_create(k, d));
128127
}
129128

130-
extern __thread struct dispatch_tsd __dispatch_tsd;
131129
extern pthread_key_t __dispatch_tsd_key;
132130

133131
#endif
@@ -156,6 +154,8 @@ struct dispatch_tsd {
156154
void *dispatch_deferred_items_key;
157155
};
158156

157+
extern _Thread_local struct dispatch_tsd __dispatch_tsd;
158+
159159
extern void libdispatch_tsd_init(void);
160160
extern void _libdispatch_tsd_cleanup(void *ctx);
161161

0 commit comments

Comments
 (0)