[Tsan] Fix test.h to work on FreeBSD
authorViktor Kutuzov <vkutuzov@accesssoftek.com>
Fri, 13 Mar 2015 14:08:55 +0000 (14:08 +0000)
committerViktor Kutuzov <vkutuzov@accesssoftek.com>
Fri, 13 Mar 2015 14:08:55 +0000 (14:08 +0000)
Differential Revision: http://reviews.llvm.org/D8303

llvm-svn: 232167

compiler-rt/test/tsan/test.h

index bb861b0..4e877f6 100644 (file)
 __typeof(pthread_barrier_wait) *barrier_wait;
 
 void barrier_init(pthread_barrier_t *barrier, unsigned count) {
+#if defined(__FreeBSD__)
+  static const char libpthread_name[] = "libpthread.so";
+#else
+  static const char libpthread_name[] = "libpthread.so.0";
+#endif
+
   if (barrier_wait == 0) {
-    void *h = dlopen("libpthread.so.0", RTLD_LAZY);
+    void *h = dlopen(libpthread_name, RTLD_LAZY);
     if (h == 0) {
-      fprintf(stderr, "failed to dlopen libpthread.so.0, exiting\n");
+      fprintf(stderr, "failed to dlopen %s, exiting\n", libpthread_name);
       exit(1);
     }
     barrier_wait = (__typeof(barrier_wait))dlsym(h, "pthread_barrier_wait");