Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-03-09 19:54:25 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-03-09 19:54:25 +0300
commit1b28081102899654df629bafa876e19e629e8d7c (patch)
tree9921f395035efac722c7301c47a5c5cee5a82094 /source/blender/blenlib/intern
parent69a486e038da6c430188cc46c48836f6949c0aca (diff)
Mac + OpenMP + pthreads workaround: recent commit broke compile, just
moved it into threads.c now instead of having it duplicated in various places.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/threads.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 371fae3dda2..5f5a0720940 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -56,6 +56,12 @@
#include <sys/time.h>
#endif
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
+extern pthread_key_t gomp_tls_key;
+static void *thread_tls_data;
+#endif
+
/* ********** basic thread control API ************
Many thread cases have an X amount of jobs, and only an Y amount of
@@ -148,9 +154,17 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
tslot->avail= 1;
}
- if(thread_levels == 0)
+ if(thread_levels == 0) {
MEM_set_lock_callback(BLI_lock_malloc_thread, BLI_unlock_malloc_thread);
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ /* workaround for Apple gcc 4.2.1 omp vs background thread bug,
+ we copy gomp thread local storage pointer to setting it again
+ inside the thread that we start */
+ thread_tls_data = pthread_getspecific(gomp_tls_key);
+#endif
+ }
+
thread_levels++;
}
}
@@ -181,6 +195,18 @@ int BLI_available_thread_index(ListBase *threadbase)
return 0;
}
+static void *tslot_thread_start(void *tslot_p)
+{
+ ThreadSlot *tslot= (ThreadSlot*)tslot_p;
+
+#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
+ /* workaround for Apple gcc 4.2.1 omp vs background thread bug,
+ set gomp thread local storage pointer which was copied beforehand */
+ pthread_setspecific (gomp_tls_key, thread_tls_data);
+#endif
+
+ return tslot->do_thread(tslot->callerdata);
+}
void BLI_insert_thread(ListBase *threadbase, void *callerdata)
{
@@ -190,7 +216,7 @@ void BLI_insert_thread(ListBase *threadbase, void *callerdata)
if(tslot->avail) {
tslot->avail= 0;
tslot->callerdata= callerdata;
- pthread_create(&tslot->pthread, NULL, tslot->do_thread, tslot->callerdata);
+ pthread_create(&tslot->pthread, NULL, tslot_thread_start, tslot);
return;
}
}