1 // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdint.h>
4 #include <stdio.h>
5 
6 typedef int32_t OSSpinLock;
7 extern "C" void OSSpinLockLock(OSSpinLock *);
8 extern "C" void OSSpinLockUnlock(OSSpinLock *);
9 
10 int Global;
11 OSSpinLock lock;
12 
Thread(void * x)13 void *Thread(void *x) {
14   OSSpinLockLock(&lock);
15   Global++;
16   OSSpinLockUnlock(&lock);
17   return NULL;
18 }
19 
main()20 int main() {
21   fprintf(stderr, "Hello world.\n");
22 
23   pthread_t t[2];
24   pthread_create(&t[0], NULL, Thread, NULL);
25   pthread_create(&t[1], NULL, Thread, NULL);
26   pthread_join(t[0], NULL);
27   pthread_join(t[1], NULL);
28 
29   fprintf(stderr, "Done.\n");
30 }
31 
32 // CHECK: Hello world.
33 // CHECK: Done.
34 // CHECK-NOT: WARNING: ThreadSanitizer
35