Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / tsan / ignore_lib_lib.h
blob2bfe84dfc0ecb4dbea1440f2a7c3b58dd5ab277c
1 #include <pthread.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <unistd.h>
7 void *volatile mem;
8 volatile int len;
10 void *Thread(void *p) {
11 while ((p = __atomic_load_n(&mem, __ATOMIC_ACQUIRE)) == 0)
12 usleep(100);
13 memset(p, 0, len);
14 return 0;
17 extern "C" void libfunc() {
18 pthread_t t;
19 pthread_create(&t, 0, Thread, 0);
20 len = 10;
21 __atomic_store_n(&mem, malloc(len), __ATOMIC_RELEASE);
22 pthread_join(t, 0);
23 free(mem);
24 fprintf(stderr, "OK\n");