llvm-project
27 строк · 536.0 Байт
1// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2#include "test.h"3
4int Global;5int WTFGlobal;6
7void *Thread(void *x) {8Global = 42;9WTFGlobal = 142;10barrier_wait(&barrier);11return 0;12}
13
14int main() {15barrier_init(&barrier, 2);16ANNOTATE_BENIGN_RACE(Global);17WTF_ANNOTATE_BENIGN_RACE(WTFGlobal);18pthread_t t;19pthread_create(&t, 0, Thread, 0);20barrier_wait(&barrier);21Global = 43;22WTFGlobal = 143;23pthread_join(t, 0);24fprintf(stderr, "OK\n");25}
26
27// CHECK-NOT: WARNING: ThreadSanitizer: data race
28