huangcm
2025-02-24 69ed55dec4b2116a19e4cca4393cbc014fce5fb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// RUN: echo "race_top:TopFunction" > %t.supp
// RUN: %clangxx_tsan -O1 %s -o %t
// RUN: %env_tsan_opts=suppressions='%t.supp' %run %t 2>&1 | FileCheck %s
// RUN: rm %t.supp
#include "test.h"
 
int Global;
 
void TopFunction(int *p) {
  *p = 1;
}
 
void *Thread(void *x) {
  barrier_wait(&barrier);
  TopFunction(&Global);
  return 0;
}
 
int main() {
  barrier_init(&barrier, 2);
  pthread_t t;
  pthread_create(&t, 0, Thread, 0);
  Global--;
  barrier_wait(&barrier);
  pthread_join(t, 0);
  fprintf(stderr, "DONE\n");
}
 
// CHECK-NOT: WARNING: ThreadSanitizer: data race