about summary refs log tree commit diff
path: root/src/internal
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-03-19 21:36:10 -0400
committerRich Felker <dalias@aerifal.cx>2011-03-19 21:36:10 -0400
commit685e40bb09f5f24a2af54ea09c97328808f76990 (patch)
tree73bbf60045bb3a9c8af4f2639e8adb2ad1ea6994 /src/internal
parent462dbfc20788a6c9dd1ea4bb1cef086aa189615a (diff)
downloadmusl-685e40bb09f5f24a2af54ea09c97328808f76990.tar.gz
musl-685e40bb09f5f24a2af54ea09c97328808f76990.tar.xz
musl-685e40bb09f5f24a2af54ea09c97328808f76990.zip
syscall overhaul part two - unify public and internal syscall interface
with this patch, the syscallN() functions are no longer needed; a
variadic syscall() macro allows syscalls with anywhere from 0 to 6
arguments to be made with a single macro name. also, manually casting
each non-integer argument with (long) is no longer necessary; the
casts are hidden in the macros.

some source files which depended on being able to define the old macro
SYSCALL_RETURNS_ERRNO have been modified to directly use __syscall()
instead of syscall(). references to SYSCALL_SIGSET_SIZE and SYSCALL_LL
have also been changed.

x86_64 has not been tested, and may need a follow-up commit to fix any
minor bugs/oversights.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/syscall.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
new file mode 100644
index 00000000..819aafe6
--- /dev/null
+++ b/src/internal/syscall.h
@@ -0,0 +1,32 @@
+#ifndef _SYSCALL_H
+#define _SYSCALL_H
+
+/* This header is mostly useless leftover wrapper cruft */
+
+#include <sys/syscall.h>
+
+#define syscall0 syscall
+#define syscall1 syscall
+#define syscall2 syscall
+#define syscall3 syscall
+#define syscall4 syscall
+#define syscall5 syscall
+#define syscall6 syscall
+
+#define socketcall __socketcall
+
+/* the following are needed for iso c functions to use */
+#define __syscall_open(filename, flags, mode) syscall(__NR_open, (filename), (flags)|0100000, (mode))
+#define __syscall_read(fd, buf, len)          syscall(__NR_read, (fd), (buf), (len))
+#define __syscall_write(fd, buf, len)         syscall(__NR_write, (fd), (buf), (len))
+#define __syscall_close(fd)                   syscall(__NR_close, (fd))
+#define __syscall_fcntl(fd, cmd, arg)         syscall(__NR_fcntl, (fd), (cmd), (arg))
+#define __syscall_dup2(old, new)              syscall(__NR_dup2, (old), (new))
+#define __syscall_unlink(path)                syscall(__NR_unlink, (path))
+#define __syscall_getpid()                    syscall(__NR_getpid)
+#define __syscall_kill(pid,sig)               syscall(__NR_kill, (pid), (sig))
+#define __syscall_sigaction(sig,new,old)      syscall(__NR_rt_sigaction, (sig), (new), (old), 8)
+#define __syscall_ioctl(fd,ioc,arg)           syscall(__NR_ioctl, (fd), (ioc), (arg))
+#define __syscall_exit(code)                  syscall(__NR_exit, code)
+
+#endif