[Sanitizer] Add rudimentary support for wide-character strings to scanf/printf interc...
[blocksruntime.git] / test / tsan / benign_race.cc
bloba4d4d23c362af334caf0908c5025e85e36505ff5
1 // RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <unistd.h>
6 int Global;
7 int WTFGlobal;
9 extern "C" {
10 void AnnotateBenignRaceSized(const char *f, int l,
11 void *mem, unsigned int size, const char *desc);
12 void WTFAnnotateBenignRaceSized(const char *f, int l,
13 void *mem, unsigned int size,
14 const char *desc);
18 void *Thread(void *x) {
19 Global = 42;
20 WTFGlobal = 142;
21 return 0;
24 int main() {
25 AnnotateBenignRaceSized(__FILE__, __LINE__,
26 &Global, sizeof(Global), "Race on Global");
27 WTFAnnotateBenignRaceSized(__FILE__, __LINE__,
28 &WTFGlobal, sizeof(WTFGlobal),
29 "Race on WTFGlobal");
30 pthread_t t;
31 pthread_create(&t, 0, Thread, 0);
32 sleep(1);
33 Global = 43;
34 WTFGlobal = 143;
35 pthread_join(t, 0);
36 printf("OK\n");
39 // CHECK-NOT: WARNING: ThreadSanitizer: data race