Warning: That file was not part of the compilation database. It may have many parsing errors.

1#include <pthread.h>
2#include <string.h>
3#include <stdlib.h>
4#include <stdio.h>
5#include <unistd.h>
6
7void *volatile mem;
8volatile int len;
9
10void *Thread(void *p) {
11 while ((p = __atomic_load_n(&mem, __ATOMIC_ACQUIRE)) == 0)
12 usleep(100);
13 memset(p, 0, len);
14 return 0;
15}
16
17extern "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");
25}
26

Warning: That file was not part of the compilation database. It may have many parsing errors.