1#include <fcntl.h>
2#include <sanitizer/linux_syscall_hooks.h>
3#include <signal.h>
4#include <sys/syscall.h>
5#include <sys/types.h>
6#include <unistd.h>
7
8int myfork() {
9 __sanitizer_syscall_pre_fork();
10#ifdef SYS_fork
11 int res = syscall(SYS_fork);
12#else
13 int res = syscall(SYS_clone, SIGCHLD, 0);
14#endif
15 __sanitizer_syscall_post_fork(res);
16 return res;
17}
18
19int mypipe(int pipefd[2]) {
20 __sanitizer_syscall_pre_pipe(pipefd);
21 int res = syscall(SYS_pipe2, pipefd, 0);
22 __sanitizer_syscall_post_pipe(res, pipefd);
23 return res;
24}
25
26int myclose(int fd) {
27 __sanitizer_syscall_pre_close(fd);
28 int res = syscall(SYS_close, fd);
29 __sanitizer_syscall_post_close(res, fd);
30 return res;
31}
32
33ssize_t myread(int fd, void *buf, size_t count) {
34 __sanitizer_syscall_pre_read(fd, buf, count);
35 ssize_t res = syscall(SYS_read, fd, buf, count);
36 __sanitizer_syscall_post_read(res, fd, buf, count);
37 return res;
38}
39
40ssize_t mywrite(int fd, const void *buf, size_t count) {
41 __sanitizer_syscall_pre_write(fd, buf, count);
42 ssize_t res = syscall(SYS_write, fd, buf, count);
43 __sanitizer_syscall_post_write(res, fd, buf, count);
44 return res;
45}
46

source code of compiler-rt/test/tsan/Linux/syscall.h