Add datarace support for atomics and calloc
[c11tester.git] / pipe.cc
1 #include "common.h"
2 #include <unistd.h>
3 #include "model.h"
4 #include "snapshot-interface.h"
5 #include <dlfcn.h>
6 #include <errno.h>
7
8 static int (*pipe_init_p)(int filep[2]) = NULL;
9
10 int pipe(int fildes[2]) {
11   if (!model) {
12     snapshot_system_init(10000, 1024, 1024, 40000);
13     model = new ModelChecker();
14     model->startChecker();
15   }
16   if (!pipe_init_p) {
17     pipe_init_p = (int (*)(int fildes[2])) dlsym(RTLD_NEXT, "pipe");
18     char *error = dlerror();
19     if (error != NULL) {
20       fputs(error, stderr);
21       exit(EXIT_FAILURE);
22     }
23   }
24   return pipe_init_p(fildes);
25 }