1 // RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s
2 // RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s
3 // This test is for GNU specific version of strerror_r()
4 // UNSUPPORTED: darwin, netbsd, freebsd
5
6 #include "test.h"
7
8 #include <errno.h>
9 #include <pthread.h>
10 #include <string.h>
11
12 char buffer[1000];
13
Thread(void * p)14 void *Thread(void *p) {
15 barrier_wait(&barrier);
16 return strerror_r(TEST_ERROR, buffer, sizeof(buffer));
17 }
18
main()19 int main() {
20 barrier_init(&barrier, 2);
21 pthread_t th;
22 pthread_create(&th, 0, Thread, 0);
23 strerror_r(TEST_ERROR, buffer, sizeof(buffer));
24 barrier_wait(&barrier);
25 pthread_join(th, 0);
26 fprintf(stderr, "DONE\n");
27 }
28
29 // CHECK-USER: WARNING: ThreadSanitizer: data race
30 // CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race
31
32 // CHECK: DONE
33