[compiler-rt] r220552 - [Tsan] Fix the thread_name tests to build on FreeBSD

Viktor Kutuzov vkutuzov at accesssoftek.com
Fri Oct 24 02:27:34 PDT 2014


Author: vkutuzov
Date: Fri Oct 24 04:27:34 2014
New Revision: 220552

URL: http://llvm.org/viewvc/llvm-project?rev=220552&view=rev
Log:
[Tsan] Fix the thread_name tests to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5855

Modified:
    compiler-rt/trunk/test/tsan/thread_name.cc
    compiler-rt/trunk/test/tsan/thread_name2.cc

Modified: compiler-rt/trunk/test/tsan/thread_name.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/thread_name.cc?rev=220552&r1=220551&r2=220552&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/thread_name.cc (original)
+++ compiler-rt/trunk/test/tsan/thread_name.cc Fri Oct 24 04:27:34 2014
@@ -3,6 +3,16 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#if defined(__linux__)
+#define USE_PTHREAD_SETNAME_NP __GLIBC_PREREQ(2, 12)
+#elif defined(__FreeBSD__)
+#include <pthread_np.h>
+#define USE_PTHREAD_SETNAME_NP 1
+#define pthread_setname_np pthread_set_name_np
+#else
+#define USE_PTHREAD_SETNAME_NP 0
+#endif
+
 extern "C" void AnnotateThreadName(const char *f, int l, const char *name);
 
 int Global;
@@ -15,7 +25,7 @@ void *Thread1(void *x) {
 }
 
 void *Thread2(void *x) {
-#if SANITIZER_LINUX && __GLIBC_PREREQ(2, 12)
+#if USE_PTHREAD_SETNAME_NP
   pthread_setname_np(pthread_self(), "Thread2");
 #else
   AnnotateThreadName(__FILE__, __LINE__, "Thread2");
@@ -35,4 +45,3 @@ int main() {
 // CHECK: WARNING: ThreadSanitizer: data race
 // CHECK:   Thread T1 'Thread1'
 // CHECK:   Thread T2 'Thread2'
-

Modified: compiler-rt/trunk/test/tsan/thread_name2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/thread_name2.cc?rev=220552&r1=220551&r2=220552&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/thread_name2.cc (original)
+++ compiler-rt/trunk/test/tsan/thread_name2.cc Fri Oct 24 04:27:34 2014
@@ -3,6 +3,11 @@
 #include <stdio.h>
 #include <unistd.h>
 
+#if defined(__FreeBSD__)
+#include <pthread_np.h>
+#define pthread_setname_np pthread_set_name_np
+#endif
+
 int Global;
 
 void *Thread1(void *x) {
@@ -29,4 +34,3 @@ int main() {
 // CHECK: WARNING: ThreadSanitizer: data race
 // CHECK:   Thread T1 'foobar1'
 // CHECK:   Thread T2 'foobar2'
-





More information about the llvm-commits mailing list