1// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
3
4void *Thread(void *x) {
5 pthread_mutex_lock((pthread_mutex_t*)x);
6 pthread_mutex_unlock((pthread_mutex_t*)x);
7 barrier_wait(&barrier);
8 return 0;
9}
10
11int main() {
12 barrier_init(&barrier, 2);
13 pthread_mutex_t Mtx;
14 pthread_mutex_init(&Mtx, 0);
15 pthread_t t;
16 pthread_create(&t, 0, Thread, &Mtx);
17 barrier_wait(&barrier);
18 pthread_mutex_destroy(&Mtx);
19 pthread_join(t, 0);
20 return 0;
21}
22
23// CHECK: WARNING: ThreadSanitizer: data race
24