[PATCH] Hopefully fix breakage on OS X w/ LLVM
Simon Marlow
marlowsd at gmail.com
Thu Jan 17 17:42:38 CET 2013
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.
---
rts/Task.c | 9 ---------
rts/Task.h | 6 ------
rts/sm/GCTDecl.h | 2 +-
rts/sm/GCThread.h | 4 ++++
rts/sm/Storage.c | 7 +++++++
5 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/rts/Task.c b/rts/Task.c
index 78725dd..e6781a1 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(¤tTaskKey);
#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(¤tTaskKey);
#endif
-#if defined(llvm_CC_FLAVOR)
- freeThreadLocalKey(&gctKey);
-#endif
#endif
tasksInitialized = 0;
diff --git a/rts/Task.h b/rts/Task.h
index e5b7295..f18f154 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 f9c8fcb..6eb6cc2 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 7d163cb..59327bc 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 ff4f172..518ae0d 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();
}
--
1.7.9.5
--------------050405050103070602040206--
More information about the ghc-devs
mailing list