Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / tsan / Darwin / os_unfair_lock.c
blob320e7f5e56d1d4688d83862df53959c599ef0b00
1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include <os/lock.h>
5 #include <pthread.h>
6 #include <stdio.h>
8 long global_variable;
9 os_unfair_lock lock = OS_UNFAIR_LOCK_INIT;
11 void *Thread(void *a) {
12 os_unfair_lock_lock(&lock);
13 global_variable++;
14 os_unfair_lock_unlock(&lock);
15 return NULL;
18 int main() {
19 pthread_t t1, t2;
20 global_variable = 0;
21 pthread_create(&t1, NULL, Thread, NULL);
22 pthread_create(&t2, NULL, Thread, NULL);
23 pthread_join(t1, NULL);
24 pthread_join(t2, NULL);
25 fprintf(stderr, "global_variable = %ld\n", global_variable);
28 // CHECK: global_variable = 2