summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2013-01-17 16:42:38 +0000
committerSimon Marlow <marlowsd@gmail.com>2013-01-17 20:30:01 +0000
commit0dcccf0ca650a3f6fd69e4af428e827b718f0b4b (patch)
tree619f13bbb52acb78a403ffff155d15e56abf1674
parent81f4cd3e08996d35b3a70dfee4d70a829f2f2622 (diff)
downloadhaskell-0dcccf0ca650a3f6fd69e4af428e827b718f0b4b.tar.gz
Hopefully fix breakage on OS X w/ LLVM
Reordering of includes in GC.c broke on OS X because gctKey is declared in Task.h and is needed in the storage manager. This is really the wrong place for it anyway, so I've moved the gctKey pieces to where they should be.
-rw-r--r--rts/Task.c9
-rw-r--r--rts/Task.h6
-rw-r--r--rts/sm/GCTDecl.h2
-rw-r--r--rts/sm/GCThread.h4
-rw-r--r--rts/sm/Storage.c7
5 files changed, 12 insertions, 16 deletions
diff --git a/rts/Task.c b/rts/Task.c
index 78725dd41c..e6781a17ff 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -54,9 +54,6 @@ __thread Task *my_task;
# else
ThreadLocalKey currentTaskKey;
# endif
-#ifdef llvm_CC_FLAVOR
-ThreadLocalKey gctKey;
-#endif
#else
Task *my_task;
#endif
@@ -78,9 +75,6 @@ initTaskManager (void)
#if !defined(MYTASK_USE_TLV)
newThreadLocalKey(&currentTaskKey);
#endif
-#if defined(llvm_CC_FLAVOR)
- newThreadLocalKey(&gctKey);
-#endif
initMutex(&all_tasks_mutex);
#endif
}
@@ -115,9 +109,6 @@ freeTaskManager (void)
#if !defined(MYTASK_USE_TLV)
freeThreadLocalKey(&currentTaskKey);
#endif
-#if defined(llvm_CC_FLAVOR)
- freeThreadLocalKey(&gctKey);
-#endif
#endif
tasksInitialized = 0;
diff --git a/rts/Task.h b/rts/Task.h
index e5b729527d..f18f154117 100644
--- a/rts/Task.h
+++ b/rts/Task.h
@@ -238,12 +238,6 @@ extern __thread Task *my_task;
#else
extern ThreadLocalKey currentTaskKey;
#endif
-// LLVM-based compilers do not upport the __thread attribute, so we need
-// to store the gct variable as a pthread local storage. We declare the
-// key here to keep thread local storage initialization in the same place.
-#if defined(llvm_CC_FLAVOR)
-extern ThreadLocalKey gctKey;
-#endif
#else
extern Task *my_task;
#endif
diff --git a/rts/sm/GCTDecl.h b/rts/sm/GCTDecl.h
index f9c8fcb137..6eb6cc2e8b 100644
--- a/rts/sm/GCTDecl.h
+++ b/rts/sm/GCTDecl.h
@@ -52,7 +52,7 @@ extern __thread gc_thread* gct;
// with a C compiler that uses an LLVM back end (clang or llvm-gcc) then we
// use pthread_getspecific() to handle the thread local storage for gct.
#define gct ((gc_thread *)(pthread_getspecific(gctKey)))
-#define DECLARE_GCT /* nothing */
+#define DECLARE_GCT ThreadLocalKey gctKey;
#elif defined(sparc_HOST_ARCH)
// On SPARC we can't pin gct to a register. Names like %l1 are just offsets
diff --git a/rts/sm/GCThread.h b/rts/sm/GCThread.h
index 7d163cb48a..59327bc20b 100644
--- a/rts/sm/GCThread.h
+++ b/rts/sm/GCThread.h
@@ -204,6 +204,10 @@ extern nat n_gc_threads;
extern gc_thread **gc_threads;
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+extern ThreadLocalKey gctKey;
+#endif
+
#include "EndPrivate.h"
#endif // SM_GCTHREAD_H
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index ff4f172ac5..518ae0d0c8 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -229,6 +229,10 @@ void storageAddCapabilities (nat from, nat to)
}
}
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+ newThreadLocalKey(&gctKey);
+#endif
+
initGcThreads(from, to);
}
@@ -249,6 +253,9 @@ freeStorage (rtsBool free_heap)
closeMutex(&sm_mutex);
#endif
stgFree(nurseries);
+#if defined(THREADED_RTS) && defined(llvm_CC_FLAVOR)
+ freeThreadLocalKey(&gctKey);
+#endif
freeGcThreads();
}