Skip to content
Snippets Groups Projects
Commit 36629369 authored by Cheng Shao's avatar Cheng Shao
Browse files

rts: replace ad-hoc MYTASK_USE_TLV with proper CC_SUPPORTS_TLS

This patch replaces the ad-hoc `MYTASK_USE_TLV` with the
`CC_SUPPORTS_TLS` macro. If TLS support is detected by autoconf, then
we should use that for managing `myTask` in the threaded RTS.

(cherry picked from commit f3017dd3)
parent 241f401d
No related branches found
No related tags found
No related merge requests found
...@@ -52,7 +52,7 @@ Mutex all_tasks_mutex; ...@@ -52,7 +52,7 @@ Mutex all_tasks_mutex;
// A thread-local-storage key that we can use to get access to the // A thread-local-storage key that we can use to get access to the
// current thread's Task structure. // current thread's Task structure.
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
# if defined(MYTASK_USE_TLV) # if CC_SUPPORTS_TLS
__thread Task *my_task; __thread Task *my_task;
# else # else
ThreadLocalKey currentTaskKey; ThreadLocalKey currentTaskKey;
...@@ -75,7 +75,7 @@ initTaskManager (void) ...@@ -75,7 +75,7 @@ initTaskManager (void)
peakWorkerCount = 0; peakWorkerCount = 0;
tasksInitialized = 1; tasksInitialized = 1;
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
#if !defined(MYTASK_USE_TLV) #if !CC_SUPPORTS_TLS
newThreadLocalKey(&currentTaskKey); newThreadLocalKey(&currentTaskKey);
#endif #endif
initMutex(&all_tasks_mutex); initMutex(&all_tasks_mutex);
...@@ -109,7 +109,7 @@ freeTaskManager (void) ...@@ -109,7 +109,7 @@ freeTaskManager (void)
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
closeMutex(&all_tasks_mutex); closeMutex(&all_tasks_mutex);
#if !defined(MYTASK_USE_TLV) #if !CC_SUPPORTS_TLS
freeThreadLocalKey(&currentTaskKey); freeThreadLocalKey(&currentTaskKey);
#endif #endif
#endif #endif
......
...@@ -265,11 +265,7 @@ extern uint32_t peakWorkerCount; ...@@ -265,11 +265,7 @@ extern uint32_t peakWorkerCount;
// A thread-local-storage key that we can use to get access to the // A thread-local-storage key that we can use to get access to the
// current thread's Task structure. // current thread's Task structure.
#if defined(THREADED_RTS) #if defined(THREADED_RTS)
#if ((defined(linux_HOST_OS) && \ #if CC_SUPPORTS_TLS
(defined(i386_HOST_ARCH) || defined(x86_64_HOST_ARCH))) || \
(defined(mingw32_HOST_OS) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4)) && \
(!defined(CC_LLVM_BACKEND))
#define MYTASK_USE_TLV
extern __thread Task *my_task; extern __thread Task *my_task;
#else #else
extern ThreadLocalKey currentTaskKey; extern ThreadLocalKey currentTaskKey;
...@@ -287,7 +283,7 @@ extern Task *my_task; ...@@ -287,7 +283,7 @@ extern Task *my_task;
INLINE_HEADER Task * INLINE_HEADER Task *
myTask (void) myTask (void)
{ {
#if defined(THREADED_RTS) && !defined(MYTASK_USE_TLV) #if defined(THREADED_RTS) && !CC_SUPPORTS_TLS
return (Task*) getThreadLocalVar(&currentTaskKey); return (Task*) getThreadLocalVar(&currentTaskKey);
#else #else
return my_task; return my_task;
...@@ -297,7 +293,7 @@ myTask (void) ...@@ -297,7 +293,7 @@ myTask (void)
INLINE_HEADER void INLINE_HEADER void
setMyTask (Task *task) setMyTask (Task *task)
{ {
#if defined(THREADED_RTS) && !defined(MYTASK_USE_TLV) #if defined(THREADED_RTS) && !CC_SUPPORTS_TLS
setThreadLocalVar(&currentTaskKey,task); setThreadLocalVar(&currentTaskKey,task);
#else #else
my_task = task; my_task = task;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment