File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 3
3
#include < stdio.h>
4
4
#include < unistd.h>
5
5
6
+ #if defined(__linux__)
7
+ #define USE_PTHREAD_SETNAME_NP __GLIBC_PREREQ (2 , 12 )
8
+ #elif defined(__FreeBSD__)
9
+ #include < pthread_np.h>
10
+ #define USE_PTHREAD_SETNAME_NP 1
11
+ #define pthread_setname_np pthread_set_name_np
12
+ #else
13
+ #define USE_PTHREAD_SETNAME_NP 0
14
+ #endif
15
+
6
16
extern " C" void AnnotateThreadName (const char *f, int l, const char *name);
7
17
8
18
int Global;
@@ -15,7 +25,7 @@ void *Thread1(void *x) {
15
25
}
16
26
17
27
void *Thread2 (void *x) {
18
- #if SANITIZER_LINUX && __GLIBC_PREREQ(2, 12)
28
+ #if USE_PTHREAD_SETNAME_NP
19
29
pthread_setname_np (pthread_self (), " Thread2" );
20
30
#else
21
31
AnnotateThreadName (__FILE__, __LINE__, " Thread2" );
@@ -35,4 +45,3 @@ int main() {
35
45
// CHECK: WARNING: ThreadSanitizer: data race
36
46
// CHECK: Thread T1 'Thread1'
37
47
// CHECK: Thread T2 'Thread2'
38
-
Original file line number Diff line number Diff line change 3
3
#include < stdio.h>
4
4
#include < unistd.h>
5
5
6
+ #if defined(__FreeBSD__)
7
+ #include < pthread_np.h>
8
+ #define pthread_setname_np pthread_set_name_np
9
+ #endif
10
+
6
11
int Global;
7
12
8
13
void *Thread1 (void *x) {
@@ -29,4 +34,3 @@ int main() {
29
34
// CHECK: WARNING: ThreadSanitizer: data race
30
35
// CHECK: Thread T1 'foobar1'
31
36
// CHECK: Thread T2 'foobar2'
32
-
You can’t perform that action at this time.
0 commit comments