Index: compiler-rt/trunk/test/tsan/thread_name.cc =================================================================== --- compiler-rt/trunk/test/tsan/thread_name.cc +++ compiler-rt/trunk/test/tsan/thread_name.cc @@ -3,6 +3,16 @@ #include #include +#if defined(__linux__) +#define USE_PTHREAD_SETNAME_NP __GLIBC_PREREQ(2, 12) +#elif defined(__FreeBSD__) +#include +#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 *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 @@ // CHECK: WARNING: ThreadSanitizer: data race // CHECK: Thread T1 'Thread1' // CHECK: Thread T2 'Thread2' - Index: compiler-rt/trunk/test/tsan/thread_name2.cc =================================================================== --- compiler-rt/trunk/test/tsan/thread_name2.cc +++ compiler-rt/trunk/test/tsan/thread_name2.cc @@ -3,6 +3,11 @@ #include #include +#if defined(__FreeBSD__) +#include +#define pthread_setname_np pthread_set_name_np +#endif + int Global; void *Thread1(void *x) { @@ -29,4 +34,3 @@ // CHECK: WARNING: ThreadSanitizer: data race // CHECK: Thread T1 'foobar1' // CHECK: Thread T2 'foobar2' -