1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
15 static void handler(int sig
) {
21 static void* busy(void *p
) {
22 while (__atomic_load_n(&stop
, __ATOMIC_RELAXED
) == 0) {
27 static void* reset(void *p
) {
28 struct sigaction act
= {};
29 for (int i
= 0; i
< 1000000; i
++) {
30 act
.sa_handler
= &handler
;
31 if (sigaction(SIGPROF
, &act
, 0)) {
35 act
.sa_handler
= SIG_IGN
;
36 if (sigaction(SIGPROF
, &act
, 0)) {
45 struct sigaction act
= {};
46 act
.sa_handler
= SIG_IGN
;
47 if (sigaction(SIGPROF
, &act
, 0)) {
53 t
.it_value
.tv_sec
= 0;
54 t
.it_value
.tv_usec
= 10;
55 t
.it_interval
= t
.it_value
;
56 if (setitimer(ITIMER_PROF
, &t
, 0)) {
62 pthread_create(&th
[0], 0, busy
, 0);
63 pthread_create(&th
[1], 0, reset
, 0);
65 pthread_join(th
[1], 0);
66 __atomic_store_n(&stop
, 1, __ATOMIC_RELAXED
);
67 pthread_join(th
[0], 0);
69 fprintf(stderr
, "DONE\n");
73 // CHECK-NOT: WARNING: ThreadSanitizer:
75 // CHECK-NOT: WARNING: ThreadSanitizer: