Add pipe support
authorbdemsky <bdemsky@uci.edu>
Fri, 15 Nov 2019 08:22:51 +0000 (00:22 -0800)
committerbdemsky <bdemsky@uci.edu>
Fri, 15 Nov 2019 08:22:51 +0000 (00:22 -0800)
Makefile
pipe.cc [new file with mode: 0644]

index 4329fc46d50542fd0106c184f7c2a3ab705ea878..d74c3a3d1408a62e373f81df9b390f9624eddc7b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ OBJECTS := libthreads.o schedule.o model.o threads.o librace.o action.o \
           snapshot.o malloc.o mymemory.o common.o mutex.o conditionvariable.o \
           context.o execution.o libannotate.o plugins.o pthread.o futex.o fuzzer.o \
           sleeps.o history.o funcnode.o funcinst.o predicate.o printf.o newfuzzer.o \
-          concretepredicate.o waitobj.o hashfunction.o
+          concretepredicate.o waitobj.o hashfunction.o pipe.o
 
 CPPFLAGS += -Iinclude -I.
 LDFLAGS := -ldl -lrt -rdynamic -lpthread
diff --git a/pipe.cc b/pipe.cc
new file mode 100644 (file)
index 0000000..37bb0dc
--- /dev/null
+++ b/pipe.cc
@@ -0,0 +1,22 @@
+#include "common.h"
+#include <unistd.h>
+#include "model.h"
+#include <dlfcn.h>
+
+static int (*pipe_init_p)(int filep[2]) = NULL;
+
+int pipe(int fildes[2]) {
+  if (!model) {
+    snapshot_system_init(10000, 1024, 1024, 40000);
+    model = new ModelChecker();
+    model->startChecker();
+  }
+  if (!pipe_init_p) {
+    pipe_init_p = (int (*)(int file[2])) dlsym(RTLD_NEXT, "pipe");
+    if ((error = dlerror()) != NULL) {
+      fputs(error, stderr);
+      exit(EXIT_FAILURE);
+    }
+  }
+  pipe_init_p(filedes);
+}