forked from OSchip/llvm-project
[Tsan] Fix the thread_name tests to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D5855 llvm-svn: 220552
This commit is contained in:
parent
6a9dec2aa2
commit
f266601ce9
|
@ -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'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue