summaryrefslogtreecommitdiff
path: root/rts/Task.c
diff options
context:
space:
mode:
authorDavid M Peixotto <dmp@rice.edu>2011-06-28 15:31:42 -0500
committerDavid M Peixotto <dmp@rice.edu>2011-10-07 16:48:34 -0500
commitdba7254566b121408e7167200d0223a531b66e8b (patch)
tree0a3bfcb739b35123822cb644db93081b46c54fca /rts/Task.c
parent29a97fded4010bd01aa0a17945c84258e285d421 (diff)
downloadhaskell-dba7254566b121408e7167200d0223a531b66e8b.tar.gz
Enable pthread_getspecific() tls for LLVM compiler
LLVM does not support the __thread attribute for thread local storage and may generate incorrect code for global register variables. We want to allow building the runtime with LLVM-based compilers such as llvm-gcc and clang, particularly for MacOS. This patch changes the gct variable used by the garbage collector to use pthread_getspecific() for thread local storage when an llvm based compiler is used to build the runtime.
Diffstat (limited to 'rts/Task.c')
-rw-r--r--rts/Task.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/rts/Task.c b/rts/Task.c
index cf406b2abe..9e8214899c 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -49,6 +49,9 @@ __thread Task *my_task;
# else
ThreadLocalKey currentTaskKey;
# endif
+#ifdef llvm_CC_FLAVOR
+ThreadLocalKey gctKey;
+#endif
#else
Task *my_task;
#endif
@@ -67,6 +70,9 @@ initTaskManager (void)
#if !defined(MYTASK_USE_TLV)
newThreadLocalKey(&currentTaskKey);
#endif
+#if defined(llvm_CC_FLAVOR)
+ newThreadLocalKey(&gctKey);
+#endif
initMutex(&all_tasks_mutex);
#endif
}
@@ -96,10 +102,15 @@ freeTaskManager (void)
RELEASE_LOCK(&all_tasks_mutex);
-#if defined(THREADED_RTS) && !defined(MYTASK_USE_TLV)
+#if defined(THREADED_RTS)
closeMutex(&all_tasks_mutex);
+#if !defined(MYTASK_USE_TLV)
freeThreadLocalKey(&currentTaskKey);
#endif
+#if defined(llvm_CC_FLAVOR)
+ freeThreadLocalKey(&gctKey);
+#endif
+#endif
tasksInitialized = 0;