summaryrefslogtreecommitdiff
path: root/src/syscall.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/syscall.h')
-rw-r--r--src/syscall.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/syscall.h b/src/syscall.h
index a2da030..6a0a76c 100644
--- a/src/syscall.h
+++ b/src/syscall.h
@@ -1,5 +1,6 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include <errno.h>
#define _SYMSTR(str) #str
#define SYMSTR(str) _SYMSTR(str)
@@ -29,6 +30,37 @@
#elif defined(__aarch64__)
#include "syscall-arm64.h"
#else
-#warning "using generic syscall method"
-#include "syscall-generic.h"
+#warning "using system call numbers from sys/syscall.h"
#endif
+
+#define _body_io_syscall(sname, args...) \
+{ \
+ int ret, saved_errno; \
+ saved_errno = errno; \
+ ret= syscall(__NR_##sname, ## args); \
+ if (ret < 0) { \
+ ret = -errno; \
+ errno = saved_errno; \
+ } \
+ return ret; \
+}
+
+#define io_syscall1(type,fname,sname,type1,arg1) \
+type fname(type1 arg1) \
+_body_io_syscall(sname, (long)arg1)
+
+#define io_syscall2(type,fname,sname,type1,arg1,type2,arg2) \
+type fname(type1 arg1,type2 arg2) \
+_body_io_syscall(sname, (long)arg1, (long)arg2)
+
+#define io_syscall3(type,fname,sname,type1,arg1,type2,arg2,type3,arg3) \
+type fname(type1 arg1,type2 arg2,type3 arg3) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3)
+
+#define io_syscall4(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type fname (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3, (long)arg4)
+
+#define io_syscall5(type,fname,sname,type1,arg1,type2,arg2,type3,arg3,type4,arg4, type5,arg5) \
+type fname (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+_body_io_syscall(sname, (long)arg1, (long)arg2, (long)arg3, (long)arg4, (long)arg5)