about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dirent/__getdents.c2
-rw-r--r--src/fcntl/fcntl.c2
-rw-r--r--src/fcntl/open.c2
-rw-r--r--src/fcntl/openat.c2
-rw-r--r--src/internal/syscall.h22
-rw-r--r--src/ipc/semctl.c4
-rw-r--r--src/ipc/semget.c4
-rw-r--r--src/ipc/semop.c4
-rw-r--r--src/ipc/shmat.c4
-rw-r--r--src/ipc/shmctl.c4
-rw-r--r--src/ipc/shmdt.c4
-rw-r--r--src/ipc/shmget.c4
-rw-r--r--src/linux/brk.c2
-rw-r--r--src/linux/chroot.c2
-rw-r--r--src/linux/epoll_create.c2
-rw-r--r--src/linux/epoll_create1.c2
-rw-r--r--src/linux/epoll_ctl.c2
-rw-r--r--src/linux/epoll_pwait.c2
-rw-r--r--src/linux/epoll_wait.c2
-rw-r--r--src/linux/inotify_add_watch.c2
-rw-r--r--src/linux/inotify_init.c2
-rw-r--r--src/linux/inotify_init1.c2
-rw-r--r--src/linux/inotify_rm_watch.c2
-rw-r--r--src/linux/klogctl.c2
-rw-r--r--src/linux/mount.c2
-rw-r--r--src/linux/prctl.c2
-rw-r--r--src/linux/sbrk.c2
-rw-r--r--src/linux/sendfile.c2
-rw-r--r--src/linux/setgroups.c2
-rw-r--r--src/linux/sethostname.c2
-rw-r--r--src/linux/settimeofday.c2
-rw-r--r--src/linux/signalfd.c2
-rw-r--r--src/linux/swapoff.c2
-rw-r--r--src/linux/swapon.c2
-rw-r--r--src/linux/sysinfo.c2
-rw-r--r--src/linux/umount.c2
-rw-r--r--src/linux/umount2.c2
-rw-r--r--src/linux/utimes.c7
-rw-r--r--src/linux/wait4.c2
-rw-r--r--src/malloc/__brk.c2
-rw-r--r--src/misc/getpriority.c2
-rw-r--r--src/misc/getrlimit.c2
-rw-r--r--src/misc/getrusage.c14
-rw-r--r--src/misc/ioctl.c2
-rw-r--r--src/misc/sched_yield.c2
-rw-r--r--src/misc/setpriority.c2
-rw-r--r--src/misc/setrlimit.c2
-rw-r--r--src/misc/uname.c2
-rw-r--r--src/mman/madvise.c2
-rw-r--r--src/mman/mlock.c2
-rw-r--r--src/mman/mlockall.c2
-rw-r--r--src/mman/mmap.c4
-rw-r--r--src/mman/mprotect.c2
-rw-r--r--src/mman/mremap.c2
-rw-r--r--src/mman/msync.c2
-rw-r--r--src/mman/munlock.c2
-rw-r--r--src/mman/munlockall.c2
-rw-r--r--src/mman/munmap.c2
-rw-r--r--src/process/execve.c2
-rw-r--r--src/process/fork.c6
-rw-r--r--src/process/vfork.c2
-rw-r--r--src/process/waitid.c2
-rw-r--r--src/process/waitpid.c2
-rw-r--r--src/select/poll.c2
-rw-r--r--src/select/pselect.c2
-rw-r--r--src/select/select.c2
-rw-r--r--src/signal/getitimer.c7
-rw-r--r--src/signal/kill.c2
-rw-r--r--src/signal/raise.c6
-rw-r--r--src/signal/setitimer.c10
-rw-r--r--src/signal/sigaction.c2
-rw-r--r--src/signal/sigaltstack.c2
-rw-r--r--src/signal/sigprocmask.c2
-rw-r--r--src/signal/sigqueue.c2
-rw-r--r--src/stat/chmod.c2
-rw-r--r--src/stat/fchmod.c2
-rw-r--r--src/stat/fchmodat.c2
-rw-r--r--src/stat/fstat.c2
-rw-r--r--src/stat/fstatat.c2
-rw-r--r--src/stat/fstatvfs.c2
-rw-r--r--src/stat/lstat.c2
-rw-r--r--src/stat/mkdir.c2
-rw-r--r--src/stat/mkdirat.c2
-rw-r--r--src/stat/mknod.c2
-rw-r--r--src/stat/mknodat.c2
-rw-r--r--src/stat/stat.c2
-rw-r--r--src/stat/statvfs.c2
-rw-r--r--src/stat/umask.c2
-rw-r--r--src/stat/utimensat.c2
-rw-r--r--src/stdio/__fdopen.c6
-rw-r--r--src/stdio/__fopen_rb_ca.c2
-rw-r--r--src/stdio/__lockfile.c2
-rw-r--r--src/stdio/__stdio_close.c2
-rw-r--r--src/stdio/__stdio_read.c2
-rw-r--r--src/stdio/__stdio_seek.c6
-rw-r--r--src/stdio/__stdio_write.c2
-rw-r--r--src/stdio/fopen.c4
-rw-r--r--src/stdio/freopen.c6
-rw-r--r--src/stdio/remove.c2
-rw-r--r--src/stdio/rename.c2
-rw-r--r--src/stdio/tmpfile.c2
-rw-r--r--src/thread/__futex.c3
-rw-r--r--src/thread/pthread_create.c2
-rw-r--r--src/thread/pthread_mutex_trylock.c4
-rw-r--r--src/thread/pthread_self.c2
-rw-r--r--src/time/clock_getres.c2
-rw-r--r--src/time/clock_gettime.c2
-rw-r--r--src/time/clock_settime.c2
-rw-r--r--src/time/nanosleep.c2
-rw-r--r--src/time/times.c2
-rw-r--r--src/time/utime.c7
-rw-r--r--src/unistd/access.c2
-rw-r--r--src/unistd/alarm.c2
-rw-r--r--src/unistd/chdir.c2
-rw-r--r--src/unistd/chown.c2
-rw-r--r--src/unistd/close.c2
-rw-r--r--src/unistd/dup.c2
-rw-r--r--src/unistd/dup2.c2
-rw-r--r--src/unistd/faccessat.c2
-rw-r--r--src/unistd/fchdir.c2
-rw-r--r--src/unistd/fchown.c2
-rw-r--r--src/unistd/fchownat.c2
-rw-r--r--src/unistd/fsync.c2
-rw-r--r--src/unistd/getcwd.c2
-rw-r--r--src/unistd/getegid.c2
-rw-r--r--src/unistd/geteuid.c2
-rw-r--r--src/unistd/getgid.c2
-rw-r--r--src/unistd/getgroups.c2
-rw-r--r--src/unistd/getpgid.c2
-rw-r--r--src/unistd/getpgrp.c2
-rw-r--r--src/unistd/getpid.c2
-rw-r--r--src/unistd/getppid.c2
-rw-r--r--src/unistd/getsid.c2
-rw-r--r--src/unistd/getuid.c2
-rw-r--r--src/unistd/lchown.c2
-rw-r--r--src/unistd/link.c2
-rw-r--r--src/unistd/linkat.c2
-rw-r--r--src/unistd/lseek.c4
-rw-r--r--src/unistd/nice.c2
-rw-r--r--src/unistd/pause.c2
-rw-r--r--src/unistd/pipe.c2
-rw-r--r--src/unistd/read.c2
-rw-r--r--src/unistd/readlink.c2
-rw-r--r--src/unistd/readlinkat.c2
-rw-r--r--src/unistd/readv.c2
-rw-r--r--src/unistd/renameat.c2
-rw-r--r--src/unistd/rmdir.c2
-rw-r--r--src/unistd/setgid.c2
-rw-r--r--src/unistd/setpgid.c2
-rw-r--r--src/unistd/setregid.c2
-rw-r--r--src/unistd/setreuid.c2
-rw-r--r--src/unistd/setsid.c2
-rw-r--r--src/unistd/setuid.c2
-rw-r--r--src/unistd/symlink.c2
-rw-r--r--src/unistd/symlinkat.c2
-rw-r--r--src/unistd/sync.c2
-rw-r--r--src/unistd/unlink.c2
-rw-r--r--src/unistd/unlinkat.c2
-rw-r--r--src/unistd/write.c2
-rw-r--r--src/unistd/writev.c2
160 files changed, 180 insertions, 238 deletions
diff --git a/src/dirent/__getdents.c b/src/dirent/__getdents.c
index dc373440..1acd5a69 100644
--- a/src/dirent/__getdents.c
+++ b/src/dirent/__getdents.c
@@ -4,7 +4,7 @@
 
 int __getdents(int fd, struct dirent *buf, size_t len)
 {
-	return syscall3(__NR_getdents, fd, (long)buf, len);
+	return syscall(SYS_getdents, fd, buf, len);
 }
 
 weak_alias(__getdents, getdents);
diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c
index 464dbf00..ab0ebecf 100644
--- a/src/fcntl/fcntl.c
+++ b/src/fcntl/fcntl.c
@@ -14,7 +14,7 @@ int fcntl(int fd, int cmd, ...)
 	va_end(ap);
 	if (cmd == F_SETFL) arg |= O_LARGEFILE;
 	if (cmd == F_SETLKW) CANCELPT_BEGIN;
-	r = __syscall_fcntl(fd, cmd, arg);
+	r = syscall(SYS_fcntl, fd, cmd, arg);
 	if (cmd == F_SETLKW) CANCELPT_END;
 	return r;
 }
diff --git a/src/fcntl/open.c b/src/fcntl/open.c
index 4c1a591d..064d298c 100644
--- a/src/fcntl/open.c
+++ b/src/fcntl/open.c
@@ -13,7 +13,7 @@ int open(const char *filename, int flags, ...)
 	mode = va_arg(ap, mode_t);
 	va_end(ap);
 	CANCELPT_BEGIN;
-	r = __syscall_open(filename, flags, mode);
+	r = syscall(SYS_open, filename, flags|O_LARGEFILE, mode);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/fcntl/openat.c b/src/fcntl/openat.c
index eefa0901..1a2d9535 100644
--- a/src/fcntl/openat.c
+++ b/src/fcntl/openat.c
@@ -13,7 +13,7 @@ int openat(int fd, const char *filename, int flags, ...)
 	mode = va_arg(ap, mode_t);
 	va_end(ap);
 	CANCELPT_BEGIN;
-	r = syscall4(__NR_openat, fd, (long)filename, flags|O_LARGEFILE, mode);
+	r = syscall(SYS_openat, fd, filename, flags|O_LARGEFILE, mode);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index 819aafe6..39efc42d 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -5,28 +5,6 @@
 
 #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
diff --git a/src/ipc/semctl.c b/src/ipc/semctl.c
index 7ada116b..392a4aac 100644
--- a/src/ipc/semctl.c
+++ b/src/ipc/semctl.c
@@ -11,8 +11,8 @@ int semctl(int id, int num, int cmd, ...)
 	arg = va_arg(ap, long);
 	va_end(ap);
 #ifdef __NR_semctl
-	return syscall4(__NR_semctl, id, num, cmd, arg);
+	return syscall(SYS_semctl, id, num, cmd, arg);
 #else
-	return syscall5(__NR_ipc, IPCOP_semctl, id, num, cmd | 0x100, (long)&arg);
+	return syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | 0x100, &arg);
 #endif
 }
diff --git a/src/ipc/semget.c b/src/ipc/semget.c
index 2dcf6eac..530c75ff 100644
--- a/src/ipc/semget.c
+++ b/src/ipc/semget.c
@@ -5,8 +5,8 @@
 int semget(key_t key, int n, int fl)
 {
 #ifdef __NR_semget
-	return syscall3(__NR_semget, key, n, fl);
+	return syscall(SYS_semget, key, n, fl);
 #else
-	return syscall4(__NR_ipc, IPCOP_semget, key, n, fl);
+	return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
 #endif
 }
diff --git a/src/ipc/semop.c b/src/ipc/semop.c
index 48d8a654..15453406 100644
--- a/src/ipc/semop.c
+++ b/src/ipc/semop.c
@@ -5,8 +5,8 @@
 int semop(int id, struct sembuf *buf, size_t n)
 {
 #ifdef __NR_semop
-	return syscall3(__NR_semop, id, (long)buf, n);
+	return syscall(SYS_semop, id, buf, n);
 #else
-	return syscall5(__NR_ipc, IPCOP_semop, id, n, 0, (long)buf);
+	return syscall(SYS_ipc, IPCOP_semop, id, n, 0, buf);
 #endif
 }
diff --git a/src/ipc/shmat.c b/src/ipc/shmat.c
index 98a2cd42..c6ee4007 100644
--- a/src/ipc/shmat.c
+++ b/src/ipc/shmat.c
@@ -5,13 +5,13 @@
 #ifdef __NR_shmat
 void *shmat(int id, const void *addr, int flag)
 {
-	return (void *)syscall3(__NR_shmat, id, (long)addr, flag);
+	return (void *)syscall(SYS_shmat, id, addr, flag);
 }
 #else
 void *shmat(int id, const void *addr, int flag)
 {
 	unsigned long ret;
-	ret = syscall5(__NR_ipc, IPCOP_shmat, id, flag, (long)&addr, (long)addr);
+	ret = syscall(SYS_ipc, IPCOP_shmat, id, flag, &addr, addr);
 	return (ret > -(unsigned long)SHMLBA) ? (void *)ret : (void *)addr;
 }
 #endif
diff --git a/src/ipc/shmctl.c b/src/ipc/shmctl.c
index da357fa8..3645fe2d 100644
--- a/src/ipc/shmctl.c
+++ b/src/ipc/shmctl.c
@@ -5,8 +5,8 @@
 int shmctl(int id, int cmd, struct shmid_ds *buf)
 {
 #ifdef __NR_shmctl
-	return syscall3(__NR_shmctl, id, cmd, (long)buf);
+	return syscall(SYS_shmctl, id, cmd, buf);
 #else
-	return syscall4(__NR_ipc, IPCOP_shmctl, id, cmd | IPC_MODERN, (long)buf);
+	return syscall(SYS_ipc, IPCOP_shmctl, id, cmd | IPC_MODERN, buf);
 #endif
 }
diff --git a/src/ipc/shmdt.c b/src/ipc/shmdt.c
index e04188f9..b4c9e69f 100644
--- a/src/ipc/shmdt.c
+++ b/src/ipc/shmdt.c
@@ -5,8 +5,8 @@
 int shmdt(const void *addr)
 {
 #ifdef __NR_shmdt
-	return syscall1(__NR_shmdt, (long)addr);
+	return syscall(SYS_shmdt, addr);
 #else
-	return syscall2(__NR_ipc, IPCOP_shmdt, (long)addr);
+	return syscall(SYS_ipc, IPCOP_shmdt, addr);
 #endif
 }
diff --git a/src/ipc/shmget.c b/src/ipc/shmget.c
index 86e254af..9b14f8d3 100644
--- a/src/ipc/shmget.c
+++ b/src/ipc/shmget.c
@@ -5,8 +5,8 @@
 int shmget(key_t key, size_t size, int flag)
 {
 #ifdef __NR_shmget
-	return syscall3(__NR_shmget, key, size, flag);
+	return syscall(SYS_shmget, key, size, flag);
 #else
-	return syscall4(__NR_ipc, IPCOP_shmget, key, size, flag);
+	return syscall(SYS_ipc, IPCOP_shmget, key, size, flag);
 #endif
 }
diff --git a/src/linux/brk.c b/src/linux/brk.c
index 3c2982c6..9f63c5a8 100644
--- a/src/linux/brk.c
+++ b/src/linux/brk.c
@@ -2,5 +2,5 @@
 
 int brk(void *end)
 {
-	return -(syscall1(__NR_brk, (long)end) == -1);
+	return -(syscall(SYS_brk, end) == -1);
 }
diff --git a/src/linux/chroot.c b/src/linux/chroot.c
index 81363a6b..82b4fe75 100644
--- a/src/linux/chroot.c
+++ b/src/linux/chroot.c
@@ -3,5 +3,5 @@
 
 int chroot(const char *path)
 {
-	return syscall1(__NR_chroot, (long)path);
+	return syscall(SYS_chroot, path);
 }
diff --git a/src/linux/epoll_create.c b/src/linux/epoll_create.c
index c9dea8ce..29d82999 100644
--- a/src/linux/epoll_create.c
+++ b/src/linux/epoll_create.c
@@ -3,5 +3,5 @@
 
 int epoll_create(int size)
 {
-	return syscall1(__NR_epoll_create, size);
+	return syscall(SYS_epoll_create, size);
 }
diff --git a/src/linux/epoll_create1.c b/src/linux/epoll_create1.c
index 2e82e995..380b5dad 100644
--- a/src/linux/epoll_create1.c
+++ b/src/linux/epoll_create1.c
@@ -3,5 +3,5 @@
 
 int epoll_create1(int flags)
 {
-	return syscall1(__NR_epoll_create1, flags);
+	return syscall(SYS_epoll_create1, flags);
 }
diff --git a/src/linux/epoll_ctl.c b/src/linux/epoll_ctl.c
index 4214f407..da3e999b 100644
--- a/src/linux/epoll_ctl.c
+++ b/src/linux/epoll_ctl.c
@@ -3,5 +3,5 @@
 
 int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
 {
-	return syscall4(__NR_epoll_ctl, fd, op, fd2, (long)ev);
+	return syscall(SYS_epoll_ctl, fd, op, fd2, ev);
 }
diff --git a/src/linux/epoll_pwait.c b/src/linux/epoll_pwait.c
index 5aaacba6..39ad5b77 100644
--- a/src/linux/epoll_pwait.c
+++ b/src/linux/epoll_pwait.c
@@ -3,5 +3,5 @@
 
 int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
 {
-	return syscall6(__NR_epoll_pwait, fd, (long)ev, cnt, to, (long)sigs, 8);
+	return syscall(SYS_epoll_pwait, fd, ev, cnt, to, sigs, 8);
 }
diff --git a/src/linux/epoll_wait.c b/src/linux/epoll_wait.c
index 8a68ebdd..9d3924e0 100644
--- a/src/linux/epoll_wait.c
+++ b/src/linux/epoll_wait.c
@@ -3,5 +3,5 @@
 
 int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to)
 {
-	return syscall4(__NR_epoll_wait, fd, (long)ev, cnt, to);
+	return syscall(SYS_epoll_wait, fd, ev, cnt, to);
 }
diff --git a/src/linux/inotify_add_watch.c b/src/linux/inotify_add_watch.c
index 9973f161..75f207d7 100644
--- a/src/linux/inotify_add_watch.c
+++ b/src/linux/inotify_add_watch.c
@@ -3,5 +3,5 @@
 
 int inotify_add_watch(int fd, const char *pathname, uint32_t mask)
 {
-	return syscall3(__NR_inotify_add_watch, fd, (long)pathname, mask);
+	return syscall(SYS_inotify_add_watch, fd, pathname, mask);
 }
diff --git a/src/linux/inotify_init.c b/src/linux/inotify_init.c
index d378460d..05070846 100644
--- a/src/linux/inotify_init.c
+++ b/src/linux/inotify_init.c
@@ -3,5 +3,5 @@
 
 int inotify_init()
 {
-	return syscall0(__NR_inotify_init);
+	return syscall(SYS_inotify_init);
 }
diff --git a/src/linux/inotify_init1.c b/src/linux/inotify_init1.c
index 5fad0946..6472a7b2 100644
--- a/src/linux/inotify_init1.c
+++ b/src/linux/inotify_init1.c
@@ -3,5 +3,5 @@
 
 int inotify_init1(int flags)
 {
-	return syscall1(__NR_inotify_init1, flags);
+	return syscall(SYS_inotify_init1, flags);
 }
diff --git a/src/linux/inotify_rm_watch.c b/src/linux/inotify_rm_watch.c
index 0772d719..cba597eb 100644
--- a/src/linux/inotify_rm_watch.c
+++ b/src/linux/inotify_rm_watch.c
@@ -3,5 +3,5 @@
 
 int inotify_rm_watch(int fd, uint32_t wd)
 {
-	return syscall2(__NR_inotify_rm_watch, fd, wd);
+	return syscall(SYS_inotify_rm_watch, fd, wd);
 }
diff --git a/src/linux/klogctl.c b/src/linux/klogctl.c
index 976f29e3..209ae742 100644
--- a/src/linux/klogctl.c
+++ b/src/linux/klogctl.c
@@ -2,5 +2,5 @@
 
 int klogctl (int type, char *buf, int len)
 {
-	return syscall3(__NR_syslog, type, (long)buf, len);
+	return syscall(SYS_syslog, type, buf, len);
 }
diff --git a/src/linux/mount.c b/src/linux/mount.c
index 8e3cc122..83a8db44 100644
--- a/src/linux/mount.c
+++ b/src/linux/mount.c
@@ -3,5 +3,5 @@
 
 int mount(const char *special, const char *dir, const char *fstype, unsigned long flags, const void *data)
 {
-	return syscall5(__NR_mount, (long)special, (long)dir, (long)fstype, flags, (long)data);
+	return syscall(SYS_mount, special, dir, fstype, flags, data);
 }
diff --git a/src/linux/prctl.c b/src/linux/prctl.c
index d5516830..1f8589e1 100644
--- a/src/linux/prctl.c
+++ b/src/linux/prctl.c
@@ -9,5 +9,5 @@ int prctl(int op, ...)
 	va_list ap;
 	va_start(ap, op);
 	for (i=0; i<4; i++) x[i] = va_arg(ap, unsigned long);
-	return syscall5(__NR_prctl, op, x[0], x[1], x[2], x[3]);
+	return syscall(SYS_prctl, op, x[0], x[1], x[2], x[3]);
 }
diff --git a/src/linux/sbrk.c b/src/linux/sbrk.c
index 56f60d1b..b2943a92 100644
--- a/src/linux/sbrk.c
+++ b/src/linux/sbrk.c
@@ -3,5 +3,5 @@
 
 void *sbrk(ptrdiff_t inc)
 {
-	return (void *)syscall1(__NR_brk, syscall1(__NR_brk, 0)+inc);
+	return (void *)syscall(SYS_brk, syscall(SYS_brk, 0)+inc);
 }
diff --git a/src/linux/sendfile.c b/src/linux/sendfile.c
index bfbc40ae..818b19d3 100644
--- a/src/linux/sendfile.c
+++ b/src/linux/sendfile.c
@@ -4,7 +4,7 @@
 
 ssize_t sendfile(int out_fd, int in_fd, off_t *ofs, size_t count)
 {
-	return syscall4(__NR_sendfile, out_fd, in_fd, (long)ofs, count);
+	return syscall(SYS_sendfile, out_fd, in_fd, ofs, count);
 }
 
 LFS64(sendfile);
diff --git a/src/linux/setgroups.c b/src/linux/setgroups.c
index 4d578013..bdee58d5 100644
--- a/src/linux/setgroups.c
+++ b/src/linux/setgroups.c
@@ -3,5 +3,5 @@
 
 int setgroups(int count, const gid_t list[])
 {
-	return syscall2(__NR_setgroups, count, (long)list);
+	return syscall(SYS_setgroups, count, list);
 }
diff --git a/src/linux/sethostname.c b/src/linux/sethostname.c
index c94325e6..79a87078 100644
--- a/src/linux/sethostname.c
+++ b/src/linux/sethostname.c
@@ -3,5 +3,5 @@
 
 int sethostname(const char *name, size_t len)
 {
-	return syscall2(__NR_sethostname, (long)name, len);
+	return syscall(SYS_sethostname, name, len);
 }
diff --git a/src/linux/settimeofday.c b/src/linux/settimeofday.c
index bd7e4104..d741f66b 100644
--- a/src/linux/settimeofday.c
+++ b/src/linux/settimeofday.c
@@ -3,5 +3,5 @@
 
 int settimeofday(const struct timeval *tv, void *tz)
 {
-	return syscall2(__NR_settimeofday, (long)tv, 0);
+	return syscall(SYS_settimeofday, tv, 0);
 }
diff --git a/src/linux/signalfd.c b/src/linux/signalfd.c
index ecda263e..99c35143 100644
--- a/src/linux/signalfd.c
+++ b/src/linux/signalfd.c
@@ -3,5 +3,5 @@
 
 int signalfd(int fd, const sigset_t *sigs, int flags)
 {
-	return syscall3(__NR_signalfd, fd, (long)sigs, 8);
+	return syscall(SYS_signalfd, fd, sigs, 8);
 }
diff --git a/src/linux/swapoff.c b/src/linux/swapoff.c
index 4f19823f..9f95e82d 100644
--- a/src/linux/swapoff.c
+++ b/src/linux/swapoff.c
@@ -3,5 +3,5 @@
 
 int swapoff(const char *path)
 {
-	return syscall1(__NR_swapoff, (long)path);
+	return syscall(SYS_swapoff, path);
 }
diff --git a/src/linux/swapon.c b/src/linux/swapon.c
index 5c75247f..2b40a30b 100644
--- a/src/linux/swapon.c
+++ b/src/linux/swapon.c
@@ -3,5 +3,5 @@
 
 int swapon(const char *path, int flags)
 {
-	return syscall2(__NR_swapon, (long)path, flags);
+	return syscall(SYS_swapon, path, flags);
 }
diff --git a/src/linux/sysinfo.c b/src/linux/sysinfo.c
index c61b7aa8..2dbd0ad9 100644
--- a/src/linux/sysinfo.c
+++ b/src/linux/sysinfo.c
@@ -4,5 +4,5 @@ struct sysinfo;
 
 int sysinfo(struct sysinfo *info)
 {
-	return syscall1(__NR_sysinfo, (long)info);
+	return syscall(SYS_sysinfo, info);
 }
diff --git a/src/linux/umount.c b/src/linux/umount.c
index f709b33a..fb9b5e73 100644
--- a/src/linux/umount.c
+++ b/src/linux/umount.c
@@ -3,5 +3,5 @@
 
 int umount(const char *special)
 {
-	return syscall2(__NR_umount2, (long)special, 0);
+	return syscall(SYS_umount2, special, 0);
 }
diff --git a/src/linux/umount2.c b/src/linux/umount2.c
index ff0803c1..25ad057c 100644
--- a/src/linux/umount2.c
+++ b/src/linux/umount2.c
@@ -3,5 +3,5 @@
 
 int umount2(const char *special, int flags)
 {
-	return syscall2(__NR_umount2, (long)special, flags);
+	return syscall(SYS_umount2, special, flags);
 }
diff --git a/src/linux/utimes.c b/src/linux/utimes.c
index 59ee1a81..d998b401 100644
--- a/src/linux/utimes.c
+++ b/src/linux/utimes.c
@@ -3,10 +3,5 @@
 
 int utimes(const char *path, const struct timeval times[2])
 {
-	long ktimes[2];
-	if (times) {
-		ktimes[0] = times[0].tv_sec;
-		ktimes[1] = times[1].tv_sec;
-	}
-	return syscall2(__NR_utime, (long)path, times ? (long)ktimes : 0);
+	return syscall(SYS_utime, path, times);
 }
diff --git a/src/linux/wait4.c b/src/linux/wait4.c
index 252beb0c..b3ae75e3 100644
--- a/src/linux/wait4.c
+++ b/src/linux/wait4.c
@@ -6,5 +6,5 @@
 
 pid_t wait4(pid_t pid, int *status, int options, struct rusage *usage)
 {
-	return syscall4(__NR_wait4, pid, (long)status, options, (long)usage);
+	return syscall(SYS_wait4, pid, status, options, usage);
 }
diff --git a/src/malloc/__brk.c b/src/malloc/__brk.c
index e3b3af31..0b561ea0 100644
--- a/src/malloc/__brk.c
+++ b/src/malloc/__brk.c
@@ -3,5 +3,5 @@
 
 uintptr_t __brk(uintptr_t newbrk)
 {
-	return syscall1(__NR_brk, newbrk);
+	return syscall(SYS_brk, newbrk);
 }
diff --git a/src/misc/getpriority.c b/src/misc/getpriority.c
index 2fb26b2b..5c0b1682 100644
--- a/src/misc/getpriority.c
+++ b/src/misc/getpriority.c
@@ -3,7 +3,7 @@
 
 int getpriority(int which, id_t who)
 {
-	int ret = syscall2(__NR_getpriority, which, who);
+	int ret = syscall(SYS_getpriority, which, who);
 	if (ret < 0) return ret;
 	return 20-ret;
 }
diff --git a/src/misc/getrlimit.c b/src/misc/getrlimit.c
index 84a659d4..13835257 100644
--- a/src/misc/getrlimit.c
+++ b/src/misc/getrlimit.c
@@ -5,7 +5,7 @@
 int getrlimit(int resource, struct rlimit *rlim)
 {
 	long k_rlim[2];
-	if (syscall2(__NR_getrlimit, resource, (long)k_rlim) < 0)
+	if (syscall(SYS_getrlimit, resource, k_rlim) < 0)
 		return -1;
 	rlim->rlim_cur = k_rlim[0] == -1 ? -1 : (unsigned long)k_rlim[0];
 	rlim->rlim_max = k_rlim[1] == -1 ? -1 : (unsigned long)k_rlim[1];
diff --git a/src/misc/getrusage.c b/src/misc/getrusage.c
index 1b8850f9..a5cbd757 100644
--- a/src/misc/getrusage.c
+++ b/src/misc/getrusage.c
@@ -2,19 +2,7 @@
 #include <string.h>
 #include "syscall.h"
 
-/* this is a huge hack to make up for the kernel's stupid 32bit time_t
- * without having to recopy the whole rusage structure ourselves.. */
-
 int getrusage(int who, struct rusage *ru)
 {
-	struct { long tv_sec, tv_usec; } ktv[2];
-	char *fakeaddr = ((char *)ru + sizeof(struct timeval [2]) - sizeof ktv);
-	if (syscall2(__NR_getrusage, who, (long)fakeaddr) < 0)
-		return -1;
-	memcpy(ktv, fakeaddr, sizeof ktv);
-	ru->ru_utime.tv_sec  = ktv[0].tv_sec;
-	ru->ru_utime.tv_usec = ktv[0].tv_usec;
-	ru->ru_stime.tv_sec  = ktv[1].tv_sec;
-	ru->ru_stime.tv_usec = ktv[1].tv_usec;
-	return 0;
+	return syscall(SYS_getrusage, who, ru);
 }
diff --git a/src/misc/ioctl.c b/src/misc/ioctl.c
index 808b7c9c..5a41f0e8 100644
--- a/src/misc/ioctl.c
+++ b/src/misc/ioctl.c
@@ -9,5 +9,5 @@ int ioctl(int fd, int req, ...)
 	va_start(ap, req);
 	arg = va_arg(ap, void *);
 	va_end(ap);
-	return syscall3(__NR_ioctl, fd, req, (long)arg);
+	return syscall(SYS_ioctl, fd, req, arg);
 }
diff --git a/src/misc/sched_yield.c b/src/misc/sched_yield.c
index 8a68519e..6c0742b4 100644
--- a/src/misc/sched_yield.c
+++ b/src/misc/sched_yield.c
@@ -4,7 +4,7 @@
 
 int __yield()
 {
-	return syscall0(__NR_sched_yield);
+	return syscall(SYS_sched_yield);
 }
 
 weak_alias(__yield, sched_yield);
diff --git a/src/misc/setpriority.c b/src/misc/setpriority.c
index 26da4b83..866b3b6e 100644
--- a/src/misc/setpriority.c
+++ b/src/misc/setpriority.c
@@ -3,5 +3,5 @@
 
 int setpriority(int which, id_t who, int prio)
 {
-	return syscall3(__NR_getpriority, which, who, prio);
+	return syscall(SYS_getpriority, which, who, prio);
 }
diff --git a/src/misc/setrlimit.c b/src/misc/setrlimit.c
index 7fdfc4e5..68bd9d74 100644
--- a/src/misc/setrlimit.c
+++ b/src/misc/setrlimit.c
@@ -5,7 +5,7 @@
 int setrlimit(int resource, const struct rlimit *rlim)
 {
 	long k_rlim[2] = { rlim->rlim_cur, rlim->rlim_max };
-	return syscall2(__NR_setrlimit, resource, (long)k_rlim);
+	return syscall(SYS_setrlimit, resource, k_rlim);
 }
 
 LFS64(setrlimit);
diff --git a/src/misc/uname.c b/src/misc/uname.c
index fbe86643..46db90d3 100644
--- a/src/misc/uname.c
+++ b/src/misc/uname.c
@@ -4,5 +4,5 @@
 
 int uname(struct utsname *uts)
 {
-	return syscall1(__NR_uname, (long)uts);
+	return syscall(SYS_uname, uts);
 }
diff --git a/src/mman/madvise.c b/src/mman/madvise.c
index f03647ca..f80926be 100644
--- a/src/mman/madvise.c
+++ b/src/mman/madvise.c
@@ -4,7 +4,7 @@
 
 int __madvise(void *addr, size_t len, int advice)
 {
-	return syscall3(__NR_madvise, (long)addr, len, advice);
+	return syscall(SYS_madvise, addr, len, advice);
 }
 
 weak_alias(__madvise, madvise);
diff --git a/src/mman/mlock.c b/src/mman/mlock.c
index 3c7c653c..e683a44a 100644
--- a/src/mman/mlock.c
+++ b/src/mman/mlock.c
@@ -3,5 +3,5 @@
 
 int mlock(const void *addr, size_t len)
 {
-	return syscall2(__NR_mlock, (long)addr, len);
+	return syscall(SYS_mlock, addr, len);
 }
diff --git a/src/mman/mlockall.c b/src/mman/mlockall.c
index 782fc9db..0ba4e662 100644
--- a/src/mman/mlockall.c
+++ b/src/mman/mlockall.c
@@ -3,5 +3,5 @@
 
 int mlockall(int flags)
 {
-	return syscall1(__NR_mlockall, flags);
+	return syscall(SYS_mlockall, flags);
 }
diff --git a/src/mman/mmap.c b/src/mman/mmap.c
index 5be6e12d..0b092ae2 100644
--- a/src/mman/mmap.c
+++ b/src/mman/mmap.c
@@ -11,9 +11,9 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
 		if (((long)off & 0xfff) | ((long)((unsigned long long)off>>(12 + 8*(sizeof(off_t)-sizeof(long))))))
 			start = (void *)-1;
 #ifdef __NR_mmap2
-	return (void *)syscall6(__NR_mmap2, (long)start, len, prot, flags, fd, off>>12);
+	return (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off>>12);
 #else
-	return (void *)syscall6(__NR_mmap, (long)start, len, prot, flags, fd, off);
+	return (void *)syscall(SYS_mmap, start, len, prot, flags, fd, off);
 #endif
 }
 
diff --git a/src/mman/mprotect.c b/src/mman/mprotect.c
index 11d5e231..1db2aea2 100644
--- a/src/mman/mprotect.c
+++ b/src/mman/mprotect.c
@@ -3,5 +3,5 @@
 
 int mprotect(void *addr, size_t len, int prot)
 {
-	return syscall3(__NR_mprotect, (long)addr, len, prot);
+	return syscall(SYS_mprotect, addr, len, prot);
 }
diff --git a/src/mman/mremap.c b/src/mman/mremap.c
index 78491ef4..596c45fb 100644
--- a/src/mman/mremap.c
+++ b/src/mman/mremap.c
@@ -13,7 +13,7 @@ void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
 	new_addr = va_arg(ap, void *);
 	va_end(ap);
 
-	return (void *)syscall5(__NR_mremap, (long)old_addr, old_len, new_len, flags, (long)new_addr);
+	return (void *)syscall(SYS_mremap, old_addr, old_len, new_len, flags, new_addr);
 }
 
 weak_alias(__mremap, mremap);
diff --git a/src/mman/msync.c b/src/mman/msync.c
index e0926470..eaf35d3b 100644
--- a/src/mman/msync.c
+++ b/src/mman/msync.c
@@ -4,5 +4,5 @@
 
 int msync(void *start, size_t len, int flags)
 {
-	return syscall3(__NR_msync, (long)start, len, flags);
+	return syscall(SYS_msync, start, len, flags);
 }
diff --git a/src/mman/munlock.c b/src/mman/munlock.c
index 0db59815..2cccef0c 100644
--- a/src/mman/munlock.c
+++ b/src/mman/munlock.c
@@ -3,5 +3,5 @@
 
 int munlock(const void *addr, size_t len)
 {
-	return syscall2(__NR_munlock, (long)addr, len);
+	return syscall(SYS_munlock, addr, len);
 }
diff --git a/src/mman/munlockall.c b/src/mman/munlockall.c
index ce3e86cc..6e9d39d6 100644
--- a/src/mman/munlockall.c
+++ b/src/mman/munlockall.c
@@ -3,5 +3,5 @@
 
 int munlockall(void)
 {
-	return syscall0(__NR_munlockall);
+	return syscall(SYS_munlockall);
 }
diff --git a/src/mman/munmap.c b/src/mman/munmap.c
index c9661cda..ab7da9e2 100644
--- a/src/mman/munmap.c
+++ b/src/mman/munmap.c
@@ -5,7 +5,7 @@
 
 int __munmap(void *start, size_t len)
 {
-	return syscall2(__NR_munmap, (long)start, len);
+	return syscall(SYS_munmap, start, len);
 }
 
 weak_alias(__munmap, munmap);
diff --git a/src/process/execve.c b/src/process/execve.c
index 2a0b62d6..70286a17 100644
--- a/src/process/execve.c
+++ b/src/process/execve.c
@@ -4,5 +4,5 @@
 int execve(const char *path, char *const argv[], char *const envp[])
 {
 	/* do we need to use environ if envp is null? */
-	return syscall3(__NR_execve, (long)path, (long)argv, (long)envp);
+	return syscall(SYS_execve, path, argv, envp);
 }
diff --git a/src/process/fork.c b/src/process/fork.c
index 87e7dc96..012b7ca5 100644
--- a/src/process/fork.c
+++ b/src/process/fork.c
@@ -7,11 +7,11 @@ pid_t fork(void)
 {
 	pid_t ret;
 	if (libc.fork_handler) libc.fork_handler(-1);
-	ret = syscall0(__NR_fork);
+	ret = syscall(SYS_fork);
 	if (libc.lock && !ret) {
 		pthread_t self = __pthread_self();
-		self->pid = syscall0(__NR_getpid);
-		self->tid = syscall0(__NR_gettid);
+		self->pid = syscall(SYS_getpid);
+		self->tid = syscall(SYS_gettid);
 		libc.threads_minus_1 = 0;
 	}
 	if (libc.fork_handler) libc.fork_handler(!ret);
diff --git a/src/process/vfork.c b/src/process/vfork.c
index 32a7a6ed..a7dd86c8 100644
--- a/src/process/vfork.c
+++ b/src/process/vfork.c
@@ -4,5 +4,5 @@
 pid_t vfork(void)
 {
 	/* vfork syscall cannot be made from C code */
-	return syscall0(__NR_fork);
+	return syscall(SYS_fork);
 }
diff --git a/src/process/waitid.c b/src/process/waitid.c
index 0ec0d55c..b1e5e9b1 100644
--- a/src/process/waitid.c
+++ b/src/process/waitid.c
@@ -3,5 +3,5 @@
 
 int waitid(idtype_t type, id_t id, siginfo_t *info, int options)
 {
-	return syscall5(__NR_waitid, type, id, (long)info, options, 0);
+	return syscall(SYS_waitid, type, id, info, options, 0);
 }
diff --git a/src/process/waitpid.c b/src/process/waitpid.c
index 0ddcd15a..ec2757b3 100644
--- a/src/process/waitpid.c
+++ b/src/process/waitpid.c
@@ -3,5 +3,5 @@
 
 pid_t waitpid(pid_t pid, int *status, int options)
 {
-	return syscall4(__NR_wait4, pid, (long)status, options, 0);
+	return syscall(SYS_wait4, pid, status, options, 0);
 }
diff --git a/src/select/poll.c b/src/select/poll.c
index e92943e1..caceebaf 100644
--- a/src/select/poll.c
+++ b/src/select/poll.c
@@ -6,7 +6,7 @@ int poll(struct pollfd *fds, nfds_t n, int timeout)
 {
 	int r;
 	CANCELPT_BEGIN;
-	r = syscall3(__NR_poll, (long)fds, n, timeout);
+	r = syscall(SYS_poll, fds, n, timeout);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/select/pselect.c b/src/select/pselect.c
index 795c5b0d..63ea0695 100644
--- a/src/select/pselect.c
+++ b/src/select/pselect.c
@@ -9,7 +9,7 @@ int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timesp
 	struct timespec ts_tmp;
 	if (ts) ts_tmp = *ts;
 	CANCELPT_BEGIN;
-	r = syscall6(__NR_pselect6, n, (long)rfds, (long)wfds, (long)efds, ts ? (long)&ts_tmp : 0, (long)data);
+	r = syscall(SYS_pselect6, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/select/select.c b/src/select/select.c
index b3946635..12322718 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -6,7 +6,7 @@ int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
 {
 	int r;
 	CANCELPT_BEGIN;
-	r = syscall5(__NR_select, n, (long)rfds, (long)wfds, (long)efds, (long)tv);
+	r = syscall(SYS_select, n, rfds, wfds, efds, tv);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/signal/getitimer.c b/src/signal/getitimer.c
index 222d113e..8a8046a7 100644
--- a/src/signal/getitimer.c
+++ b/src/signal/getitimer.c
@@ -3,10 +3,5 @@
 
 int getitimer(int which, struct itimerval *old)
 {
-	int ret;
-	long kold[4];
-
-	if (!(ret = syscall2(__NR_getitimer, which, (long)&kold)))
-		*old = (struct itimerval){ { kold[0], kold[1] }, { kold[2], kold[3] } };
-	return ret;
+	return syscall(SYS_getitimer, which, old);
 }
diff --git a/src/signal/kill.c b/src/signal/kill.c
index cc4b51e1..05805733 100644
--- a/src/signal/kill.c
+++ b/src/signal/kill.c
@@ -3,5 +3,5 @@
 
 int kill(pid_t pid, int sig)
 {
-	return syscall2(__NR_kill, pid, sig);
+	return syscall(SYS_kill, pid, sig);
 }
diff --git a/src/signal/raise.c b/src/signal/raise.c
index cc2b19b7..9948f418 100644
--- a/src/signal/raise.c
+++ b/src/signal/raise.c
@@ -10,9 +10,9 @@ int raise(int sig)
 	sigset_t set;
 	sigfillset(&set);
 	__sigprocmask(SIG_BLOCK, &set, &set);
-	tid = syscall0(__NR_gettid);
-	pid = syscall0(__NR_getpid);
-	ret = syscall3(__NR_tgkill, pid, tid, sig);
+	tid = syscall(SYS_gettid);
+	pid = syscall(SYS_getpid);
+	ret = syscall(SYS_tgkill, pid, tid, sig);
 	__sigprocmask(SIG_SETMASK, &set, 0);
 	return ret;
 }
diff --git a/src/signal/setitimer.c b/src/signal/setitimer.c
index cacab036..3b237580 100644
--- a/src/signal/setitimer.c
+++ b/src/signal/setitimer.c
@@ -3,13 +3,5 @@
 
 int setitimer(int which, const struct itimerval *new, struct itimerval *old)
 {
-	int ret;
-	long knew[4] = {
-		new->it_interval.tv_sec, new->it_interval.tv_usec,
-		new->it_value.tv_sec, new->it_value.tv_usec
-	}, kold[4];
-
-	if (!(ret = syscall3(__NR_setitimer, which, (long)&knew, old ? (long)&kold : 0)) && old)
-		*old = (struct itimerval){ { kold[0], kold[1] }, { kold[2], kold[3] } };
-	return ret;
+	return syscall(SYS_setitimer, which, new, old);
 }
diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
index b1603b9f..3d374e1f 100644
--- a/src/signal/sigaction.c
+++ b/src/signal/sigaction.c
@@ -23,7 +23,7 @@ int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
 		pksa = (long)&ksa;
 	}
 	if (old) pkold = (long)&kold;
-	if (syscall4(__NR_rt_sigaction, sig, pksa, pkold, 8))
+	if (syscall(SYS_rt_sigaction, sig, pksa, pkold, 8))
 		return -1;
 	if (old) {
 		old->sa_handler = kold.handler;
diff --git a/src/signal/sigaltstack.c b/src/signal/sigaltstack.c
index 6e46d098..550f2f9d 100644
--- a/src/signal/sigaltstack.c
+++ b/src/signal/sigaltstack.c
@@ -14,5 +14,5 @@ int sigaltstack(const stack_t *ss, stack_t *old)
 			return -1;
 		}
 	}
-	return syscall2(__NR_sigaltstack, (long)ss, (long)old);
+	return syscall(SYS_sigaltstack, ss, old);
 }
diff --git a/src/signal/sigprocmask.c b/src/signal/sigprocmask.c
index 96d08478..66b17a42 100644
--- a/src/signal/sigprocmask.c
+++ b/src/signal/sigprocmask.c
@@ -6,7 +6,7 @@
 
 int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old)
 {
-	return syscall4(__NR_rt_sigprocmask, how, (long)set, (long)old, 8);
+	return syscall(SYS_rt_sigprocmask, how, set, old, 8);
 }
 
 int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
diff --git a/src/signal/sigqueue.c b/src/signal/sigqueue.c
index b8135d56..aeac4875 100644
--- a/src/signal/sigqueue.c
+++ b/src/signal/sigqueue.c
@@ -12,5 +12,5 @@ int sigqueue(pid_t pid, int sig, const union sigval value)
 	si.si_value = value;
 	si.si_pid = getpid();
 	si.si_uid = getuid();
-	return syscall3(__NR_rt_sigqueueinfo, pid, sig, (long)&si);
+	return syscall(SYS_rt_sigqueueinfo, pid, sig, &si);
 }
diff --git a/src/stat/chmod.c b/src/stat/chmod.c
index cb310fec..beb66e59 100644
--- a/src/stat/chmod.c
+++ b/src/stat/chmod.c
@@ -3,5 +3,5 @@
 
 int chmod(const char *path, mode_t mode)
 {
-	return syscall2(__NR_chmod, (long)path, mode);
+	return syscall(SYS_chmod, path, mode);
 }
diff --git a/src/stat/fchmod.c b/src/stat/fchmod.c
index 91897383..f9b99366 100644
--- a/src/stat/fchmod.c
+++ b/src/stat/fchmod.c
@@ -3,5 +3,5 @@
 
 int fchmod(int fd, mode_t mode)
 {
-	return syscall2(__NR_fchmod, fd, mode);
+	return syscall(SYS_fchmod, fd, mode);
 }
diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
index f4f22b2c..61d32065 100644
--- a/src/stat/fchmodat.c
+++ b/src/stat/fchmodat.c
@@ -3,5 +3,5 @@
 
 int fchmodat(int fd, const char *path, mode_t mode, int flag)
 {
-	return syscall4(__NR_fchmodat, fd, (long)path, mode, flag);
+	return syscall(SYS_fchmodat, fd, path, mode, flag);
 }
diff --git a/src/stat/fstat.c b/src/stat/fstat.c
index 88ac6f3c..10228f75 100644
--- a/src/stat/fstat.c
+++ b/src/stat/fstat.c
@@ -4,7 +4,7 @@
 
 int fstat(int fd, struct stat *buf)
 {
-	return syscall2(__NR_fstat, fd, (long)buf);
+	return syscall(SYS_fstat, fd, buf);
 }
 
 LFS64(fstat);
diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
index e39f833b..d6b9390c 100644
--- a/src/stat/fstatat.c
+++ b/src/stat/fstatat.c
@@ -4,7 +4,7 @@
 
 int fstatat(int fd, const char *path, struct stat *buf, int flag)
 {
-	return syscall4(__NR_fstatat, fd, (long)path, (long)buf, flag);
+	return syscall(SYS_fstatat, fd, path, buf, flag);
 }
 
 LFS64(fstatat);
diff --git a/src/stat/fstatvfs.c b/src/stat/fstatvfs.c
index 4a8bfe2e..8a2e4235 100644
--- a/src/stat/fstatvfs.c
+++ b/src/stat/fstatvfs.c
@@ -4,7 +4,7 @@
 
 int fstatvfs(int fd, struct statvfs *buf)
 {
-	return syscall2(__NR_fstatfs, fd, (long)buf);
+	return syscall(SYS_fstatfs, fd, buf);
 }
 
 weak_alias(fstatvfs, fstatfs);
diff --git a/src/stat/lstat.c b/src/stat/lstat.c
index 3b22e620..9053d998 100644
--- a/src/stat/lstat.c
+++ b/src/stat/lstat.c
@@ -4,7 +4,7 @@
 
 int lstat(const char *path, struct stat *buf)
 {
-	return syscall2(__NR_lstat, (long)path, (long)buf);
+	return syscall(SYS_lstat, path, buf);
 }
 
 LFS64(lstat);
diff --git a/src/stat/mkdir.c b/src/stat/mkdir.c
index 8295cad5..770e1ccc 100644
--- a/src/stat/mkdir.c
+++ b/src/stat/mkdir.c
@@ -3,5 +3,5 @@
 
 int mkdir(const char *path, mode_t mode)
 {
-	return syscall2(__NR_mkdir, (long)path, mode);
+	return syscall(SYS_mkdir, path, mode);
 }
diff --git a/src/stat/mkdirat.c b/src/stat/mkdirat.c
index 1fb38250..b8bc2527 100644
--- a/src/stat/mkdirat.c
+++ b/src/stat/mkdirat.c
@@ -3,5 +3,5 @@
 
 int mkdirat(int fd, const char *path, mode_t mode)
 {
-	return syscall3(__NR_mkdirat, fd, (long)path, mode);
+	return syscall(SYS_mkdirat, fd, path, mode);
 }
diff --git a/src/stat/mknod.c b/src/stat/mknod.c
index 0123eeef..90c6a1ca 100644
--- a/src/stat/mknod.c
+++ b/src/stat/mknod.c
@@ -6,5 +6,5 @@ int mknod(const char *path, mode_t mode, dev_t dev)
 	/* since dev_t is system-specific anyway we defer to the idiotic
 	 * legacy-compatible bitfield mapping of the type.. at least we've
 	 * made it large enough to leave space for future expansion.. */
-	return syscall3(__NR_mknod, (long)path, mode, dev & 0xffff);
+	return syscall(SYS_mknod, path, mode, dev & 0xffff);
 }
diff --git a/src/stat/mknodat.c b/src/stat/mknodat.c
index b5687e47..63cacd58 100644
--- a/src/stat/mknodat.c
+++ b/src/stat/mknodat.c
@@ -3,5 +3,5 @@
 
 int mknodat(int fd, const char *path, mode_t mode, dev_t dev)
 {
-	return syscall4(__NR_mknodat, fd, (long)path, mode, dev & 0xffff);
+	return syscall(SYS_mknodat, fd, path, mode, dev & 0xffff);
 }
diff --git a/src/stat/stat.c b/src/stat/stat.c
index 9847552a..c5491eb0 100644
--- a/src/stat/stat.c
+++ b/src/stat/stat.c
@@ -4,7 +4,7 @@
 
 int stat(const char *path, struct stat *buf)
 {
-	return syscall2(__NR_stat, (long)path, (long)buf);
+	return syscall(SYS_stat, path, buf);
 }
 
 LFS64(stat);
diff --git a/src/stat/statvfs.c b/src/stat/statvfs.c
index ebf14b43..17252997 100644
--- a/src/stat/statvfs.c
+++ b/src/stat/statvfs.c
@@ -4,7 +4,7 @@
 
 int statvfs(const char *path, struct statvfs *buf)
 {
-	return syscall2(__NR_statfs, (long)path, (long)buf);
+	return syscall(SYS_statfs, path, buf);
 }
 
 weak_alias(statvfs, statfs);
diff --git a/src/stat/umask.c b/src/stat/umask.c
index 49cb48a6..5ee913e2 100644
--- a/src/stat/umask.c
+++ b/src/stat/umask.c
@@ -3,5 +3,5 @@
 
 mode_t umask(mode_t mode)
 {
-	return syscall1(__NR_umask, mode);
+	return syscall(SYS_umask, mode);
 }
diff --git a/src/stat/utimensat.c b/src/stat/utimensat.c
index b9b02adf..929698bc 100644
--- a/src/stat/utimensat.c
+++ b/src/stat/utimensat.c
@@ -3,5 +3,5 @@
 
 int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
 {
-	return syscall4(__NR_utimensat, fd, (long)path, (long)times, flags);
+	return syscall(SYS_utimensat, fd, path, times, flags);
 }
diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c
index 6ad7c57d..235d348f 100644
--- a/src/stdio/__fdopen.c
+++ b/src/stdio/__fdopen.c
@@ -20,8 +20,8 @@ FILE *__fdopen(int fd, const char *mode)
 
 	/* Set append mode on fd if opened for append */
 	if (*mode == 'a') {
-		int flags = __syscall_fcntl(fd, F_GETFL, 0);
-		__syscall_fcntl(fd, F_SETFL, flags | O_APPEND);
+		int flags = syscall(SYS_fcntl, fd, F_GETFL, 0);
+		syscall(SYS_fcntl, fd, F_SETFL, flags | O_APPEND);
 	}
 
 	f->fd = fd;
@@ -30,7 +30,7 @@ FILE *__fdopen(int fd, const char *mode)
 
 	/* Activate line buffered mode for terminals */
 	f->lbf = EOF;
-	if (!(f->flags & F_NOWR) && !__syscall_ioctl(fd, TCGETS, &tio))
+	if (!(f->flags & F_NOWR) && !syscall(SYS_ioctl, fd, TCGETS, &tio))
 		f->lbf = '\n';
 
 	/* Initialize op ptrs. No problem if some are unneeded. */
diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c
index 57d9b73c..4ba50d61 100644
--- a/src/stdio/__fopen_rb_ca.c
+++ b/src/stdio/__fopen_rb_ca.c
@@ -4,7 +4,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le
 {
 	memset(f, 0, sizeof *f);
 
-	f->fd = __syscall_open(filename, O_RDONLY, 0);
+	f->fd = syscall(SYS_open, filename, O_RDONLY|O_LARGEFILE, 0);
 	if (f->fd < 0) return 0;
 
 	f->flags = F_NOWR | F_PERM;
diff --git a/src/stdio/__lockfile.c b/src/stdio/__lockfile.c
index 82f50b42..e4320f05 100644
--- a/src/stdio/__lockfile.c
+++ b/src/stdio/__lockfile.c
@@ -13,7 +13,7 @@ void __lockfile(FILE *f)
 	spins = 100000;
 	while (a_swap(&f->lock, 1))
 		if (spins) spins--, a_spin();
-		else syscall0(__NR_sched_yield);
+		else syscall(SYS_sched_yield);
 	f->owner = __pthread_self()->tid;
 	f->lockcount = 1;
 }
diff --git a/src/stdio/__stdio_close.c b/src/stdio/__stdio_close.c
index 24fef33f..9f7ee18c 100644
--- a/src/stdio/__stdio_close.c
+++ b/src/stdio/__stdio_close.c
@@ -2,5 +2,5 @@
 
 int __stdio_close(FILE *f)
 {
-	return __syscall_close(f->fd);
+	return syscall(SYS_close, f->fd);
 }
diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c
index ee7e1258..d9bb3269 100644
--- a/src/stdio/__stdio_read.c
+++ b/src/stdio/__stdio_read.c
@@ -2,5 +2,5 @@
 
 size_t __stdio_read(FILE *f, unsigned char *buf, size_t len)
 {
-	return __syscall_read(f->fd, buf, len);
+	return syscall(SYS_read, f->fd, buf, len);
 }
diff --git a/src/stdio/__stdio_seek.c b/src/stdio/__stdio_seek.c
index c7a5b730..c205ab82 100644
--- a/src/stdio/__stdio_seek.c
+++ b/src/stdio/__stdio_seek.c
@@ -8,11 +8,11 @@ static off_t retneg1(FILE *f, off_t off, int whence)
 off_t __stdio_seek(FILE *f, off_t off, int whence)
 {
 	off_t ret;
-#ifdef __NR__llseek
-	if (syscall5(__NR__llseek, f->fd, off>>32, off, (long)&ret, whence)<0)
+#ifdef SYS__llseek
+	if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
 		ret = -1;
 #else
-	ret = syscall3(__NR_lseek, f->fd, off, whence);
+	ret = syscall(SYS_lseek, f->fd, off, whence);
 #endif
 	/* Detect unseekable files and optimize future failures out */
 	if (ret < 0 && off == 0 && whence == SEEK_CUR)
diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c
index 78545626..d4264eff 100644
--- a/src/stdio/__stdio_write.c
+++ b/src/stdio/__stdio_write.c
@@ -4,6 +4,6 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
 {
 	const unsigned char *stop = buf+len;
 	ssize_t cnt = 1;
-	for (; buf<stop && (cnt=__syscall_write(f->fd, buf, len))>0; buf+=cnt);
+	for (; buf<stop && (cnt=syscall(SYS_write, f->fd, buf, len))>0; buf+=cnt);
 	return len-(stop-buf);
 }
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index 670cf5f3..c2a350d1 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -21,13 +21,13 @@ FILE *fopen(const char *filename, const char *mode)
 	if (*mode == 'w') flags |= O_TRUNC;
 	if (*mode == 'a') flags |= O_APPEND;
 
-	fd = __syscall_open(filename, flags, 0666);
+	fd = syscall(SYS_open, filename, flags|O_LARGEFILE, 0666);
 	if (fd < 0) return 0;
 
 	f = __fdopen(fd, mode);
 	if (f) return f;
 
-	__syscall_close(fd);
+	syscall(SYS_close, fd);
 	return 0;
 }
 
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index 8d3af9fc..958dbd20 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -17,13 +17,13 @@ FILE *freopen(const char *filename, const char *mode, FILE *f)
 	if (!filename) {
 		f2 = fopen("/dev/null", mode);
 		if (!f2) goto fail;
-		fl = __syscall_fcntl(f2->fd, F_GETFL, 0);
-		if (fl < 0 || __syscall_fcntl(f->fd, F_SETFL, fl) < 0)
+		fl = syscall(SYS_fcntl, f2->fd, F_GETFL, 0);
+		if (fl < 0 || syscall(SYS_fcntl, f->fd, F_SETFL, fl) < 0)
 			goto fail2;
 	} else {
 		f2 = fopen(filename, mode);
 		if (!f2) goto fail;
-		if (__syscall_dup2(f2->fd, f->fd) < 0)
+		if (syscall(SYS_dup2, f2->fd, f->fd) < 0)
 			goto fail2;
 	}
 
diff --git a/src/stdio/remove.c b/src/stdio/remove.c
index 8e338277..9e1de7f2 100644
--- a/src/stdio/remove.c
+++ b/src/stdio/remove.c
@@ -3,5 +3,5 @@
 
 int remove(const char *path)
 {
-	return __syscall_unlink(path);
+	return syscall(SYS_unlink, path);
 }
diff --git a/src/stdio/rename.c b/src/stdio/rename.c
index 4eced08a..97f14535 100644
--- a/src/stdio/rename.c
+++ b/src/stdio/rename.c
@@ -3,5 +3,5 @@
 
 int rename(const char *old, const char *new)
 {
-	return syscall2(__NR_rename, (long)old, (long)new);
+	return syscall(SYS_rename, old, new);
 }
diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c
index 185025f1..b050f7fd 100644
--- a/src/stdio/tmpfile.c
+++ b/src/stdio/tmpfile.c
@@ -11,7 +11,7 @@ FILE *tmpfile(void)
 	for (;;) {
 		s = tmpnam(buf);
 		if (!s) return NULL;
-		fd = __syscall_open(s, O_RDWR | O_CREAT | O_EXCL, 0600);
+		fd = syscall(SYS_open, s, O_RDWR|O_CREAT|O_EXCL|O_LARGEFILE, 0600);
 		if (fd >= 0) {
 			f = __fdopen(fd, "w+");
 			remove(s);
diff --git a/src/thread/__futex.c b/src/thread/__futex.c
index 93352fa3..96307c08 100644
--- a/src/thread/__futex.c
+++ b/src/thread/__futex.c
@@ -3,6 +3,5 @@
 
 int __futex(volatile int *addr, int op, int val, void *ts)
 {
-	return syscall4(__NR_futex, (long)addr, op, val, (long)ts);
+	return syscall(SYS_futex, addr, op, val, ts);
 }
-
diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c
index 3716f75a..17a47f6a 100644
--- a/src/thread/pthread_create.c
+++ b/src/thread/pthread_create.c
@@ -36,7 +36,7 @@ void __pthread_unwind_next(struct __ptcb *cb)
 		__unmapself(self->map_base, self->map_size);
 	}
 
-	__syscall_exit(0);
+	syscall(SYS_exit, 0);
 }
 
 static void docancel(struct pthread *self)
diff --git a/src/thread/pthread_mutex_trylock.c b/src/thread/pthread_mutex_trylock.c
index f48aaade..232e172b 100644
--- a/src/thread/pthread_mutex_trylock.c
+++ b/src/thread/pthread_mutex_trylock.c
@@ -14,8 +14,8 @@ int pthread_mutex_trylock(pthread_mutex_t *m)
 
 	if (m->_m_type >= 4) {
 		if (!self->robust_list.off)
-			syscall2(__NR_set_robust_list,
-				(long)&self->robust_list, 3*sizeof(long));
+			syscall(SYS_set_robust_list,
+				&self->robust_list, 3*sizeof(long));
 		self->robust_list.off = (char*)&m->_m_lock-(char *)&m->_m_next;
 		self->robust_list.pending = &m->_m_next;
 	}
diff --git a/src/thread/pthread_self.c b/src/thread/pthread_self.c
index d2de2cb8..c3d1be78 100644
--- a/src/thread/pthread_self.c
+++ b/src/thread/pthread_self.c
@@ -27,7 +27,7 @@ static int init_main_thread()
 	main_thread.errno_ptr = __errno_location();
 	libc.errno_location = errno_location;
 	main_thread.tid = main_thread.pid = 
-		syscall1(__NR_set_tid_address, (long)&main_thread.tid);
+		syscall(SYS_set_tid_address, &main_thread.tid);
 	return 0;
 }
 
diff --git a/src/time/clock_getres.c b/src/time/clock_getres.c
index 539d4f94..36a0d695 100644
--- a/src/time/clock_getres.c
+++ b/src/time/clock_getres.c
@@ -3,5 +3,5 @@
 
 int clock_getres(clockid_t clk, struct timespec *ts)
 {
-	return syscall2(__NR_clock_getres, clk, (long)ts);
+	return syscall(SYS_clock_getres, clk, ts);
 }
diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index dab09d50..c345c46e 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -3,5 +3,5 @@
 
 int clock_gettime(clockid_t clk, struct timespec *ts)
 {
-	return syscall2(__NR_clock_gettime, clk, (long)ts);
+	return syscall(SYS_clock_gettime, clk, ts);
 }
diff --git a/src/time/clock_settime.c b/src/time/clock_settime.c
index a80b94e1..66b8162d 100644
--- a/src/time/clock_settime.c
+++ b/src/time/clock_settime.c
@@ -3,5 +3,5 @@
 
 int clock_settime(clockid_t clk, const struct timespec *ts)
 {
-	return syscall2(__NR_clock_settime, clk, (long)ts);
+	return syscall(SYS_clock_settime, clk, ts);
 }
diff --git a/src/time/nanosleep.c b/src/time/nanosleep.c
index 5ac4c359..2f65762f 100644
--- a/src/time/nanosleep.c
+++ b/src/time/nanosleep.c
@@ -7,7 +7,7 @@ int nanosleep(const struct timespec *req, struct timespec *rem)
 {
 	int ret;
 	CANCELPT_BEGIN;
-	ret = syscall2(__NR_nanosleep, (long)req, (long)rem);
+	ret = syscall(SYS_nanosleep, req, rem);
 	CANCELPT_END;
 	return ret;
 }
diff --git a/src/time/times.c b/src/time/times.c
index d63cd203..9c50144f 100644
--- a/src/time/times.c
+++ b/src/time/times.c
@@ -3,5 +3,5 @@
 
 clock_t times(struct tms *tms)
 {
-	return syscall1(__NR_times, (long)tms);
+	return syscall(SYS_times, tms);
 }
diff --git a/src/time/utime.c b/src/time/utime.c
index 56e9e13a..856315b4 100644
--- a/src/time/utime.c
+++ b/src/time/utime.c
@@ -3,10 +3,5 @@
 
 int utime(const char *path, const struct utimbuf *times)
 {
-	long ktimes[2];
-	if (times) {
-		ktimes[0] = times->actime;
-		ktimes[1] = times->modtime;
-	}
-	return syscall2(__NR_utime, (long)path, times ? (long)ktimes : 0);
+	return syscall(SYS_utime, path, times);
 }
diff --git a/src/unistd/access.c b/src/unistd/access.c
index 2c10e58c..e7ce73a2 100644
--- a/src/unistd/access.c
+++ b/src/unistd/access.c
@@ -3,5 +3,5 @@
 
 int access(const char *filename, int amode)
 {
-	return syscall2(__NR_access, (long)filename, amode);
+	return syscall(SYS_access, filename, amode);
 }
diff --git a/src/unistd/alarm.c b/src/unistd/alarm.c
index bba444d8..244af1c0 100644
--- a/src/unistd/alarm.c
+++ b/src/unistd/alarm.c
@@ -3,5 +3,5 @@
 
 unsigned alarm(unsigned seconds)
 {
-	return syscall1(__NR_alarm, seconds);
+	return syscall(SYS_alarm, seconds);
 }
diff --git a/src/unistd/chdir.c b/src/unistd/chdir.c
index c89bda38..5ba78b63 100644
--- a/src/unistd/chdir.c
+++ b/src/unistd/chdir.c
@@ -3,5 +3,5 @@
 
 int chdir(const char *path)
 {
-	return syscall1(__NR_chdir, (long)path);
+	return syscall(SYS_chdir, path);
 }
diff --git a/src/unistd/chown.c b/src/unistd/chown.c
index b89b1735..95f6f61e 100644
--- a/src/unistd/chown.c
+++ b/src/unistd/chown.c
@@ -3,5 +3,5 @@
 
 int chown(const char *path, uid_t uid, gid_t gid)
 {
-	return syscall3(__NR_chown, (long)path, uid, gid);
+	return syscall(SYS_chown, path, uid, gid);
 }
diff --git a/src/unistd/close.c b/src/unistd/close.c
index 97302f67..f52c0ef3 100644
--- a/src/unistd/close.c
+++ b/src/unistd/close.c
@@ -4,7 +4,7 @@
 
 int close(int fd)
 {
-	int ret = __syscall_close(fd);
+	int ret = syscall(SYS_close, fd);
 	CANCELPT_BEGIN;
 	CANCELPT_END;
 	return ret;
diff --git a/src/unistd/dup.c b/src/unistd/dup.c
index b11cd715..7fee0120 100644
--- a/src/unistd/dup.c
+++ b/src/unistd/dup.c
@@ -3,5 +3,5 @@
 
 int dup(int fd)
 {
-	return syscall1(__NR_dup, fd);
+	return syscall(SYS_dup, fd);
 }
diff --git a/src/unistd/dup2.c b/src/unistd/dup2.c
index 93325446..7945f853 100644
--- a/src/unistd/dup2.c
+++ b/src/unistd/dup2.c
@@ -3,5 +3,5 @@
 
 int dup2(int old, int new)
 {
-	return __syscall_dup2(old, new);
+	return syscall(SYS_dup2, old, new);
 }
diff --git a/src/unistd/faccessat.c b/src/unistd/faccessat.c
index 99a93785..1efbb778 100644
--- a/src/unistd/faccessat.c
+++ b/src/unistd/faccessat.c
@@ -3,5 +3,5 @@
 
 int faccessat(int fd, const char *filename, int amode, int flag)
 {
-	return syscall4(__NR_faccessat, fd, (long)filename, amode, flag);
+	return syscall(SYS_faccessat, fd, filename, amode, flag);
 }
diff --git a/src/unistd/fchdir.c b/src/unistd/fchdir.c
index b2acbc29..e5595f77 100644
--- a/src/unistd/fchdir.c
+++ b/src/unistd/fchdir.c
@@ -3,5 +3,5 @@
 
 int fchdir(int fd)
 {
-	return syscall1(__NR_fchdir, fd);
+	return syscall(SYS_fchdir, fd);
 }
diff --git a/src/unistd/fchown.c b/src/unistd/fchown.c
index 6050b774..b05f0be4 100644
--- a/src/unistd/fchown.c
+++ b/src/unistd/fchown.c
@@ -3,5 +3,5 @@
 
 int fchown(int fd, uid_t uid, gid_t gid)
 {
-	return syscall3(__NR_fchown, fd, uid, gid);
+	return syscall(SYS_fchown, fd, uid, gid);
 }
diff --git a/src/unistd/fchownat.c b/src/unistd/fchownat.c
index 70626428..62457a3e 100644
--- a/src/unistd/fchownat.c
+++ b/src/unistd/fchownat.c
@@ -3,5 +3,5 @@
 
 int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag)
 {
-	return syscall5(__NR_fchownat, fd, (long)path, uid, gid, flag);
+	return syscall(SYS_fchownat, fd, path, uid, gid, flag);
 }
diff --git a/src/unistd/fsync.c b/src/unistd/fsync.c
index 7cfedc98..5991c66b 100644
--- a/src/unistd/fsync.c
+++ b/src/unistd/fsync.c
@@ -3,6 +3,6 @@
 
 int fsync(int fd)
 {
-	//return syscall1(__NR_fsync, fd);
+	//return syscall(SYS_fsync, fd);
 	return 0;
 }
diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c
index 4910f42c..b64b560f 100644
--- a/src/unistd/getcwd.c
+++ b/src/unistd/getcwd.c
@@ -4,5 +4,5 @@
 
 char *getcwd(char *buf, size_t size)
 {
-	return syscall2(__NR_getcwd, (long)buf, size) < 0 ? NULL : buf;
+	return syscall(SYS_getcwd, buf, size) < 0 ? NULL : buf;
 }
diff --git a/src/unistd/getegid.c b/src/unistd/getegid.c
index 33ee2057..76038f63 100644
--- a/src/unistd/getegid.c
+++ b/src/unistd/getegid.c
@@ -3,5 +3,5 @@
 
 gid_t getegid(void)
 {
-	return syscall0(__NR_getegid);
+	return syscall(SYS_getegid);
 }
diff --git a/src/unistd/geteuid.c b/src/unistd/geteuid.c
index cdec631a..187ba0a1 100644
--- a/src/unistd/geteuid.c
+++ b/src/unistd/geteuid.c
@@ -3,5 +3,5 @@
 
 uid_t geteuid(void)
 {
-	return syscall0(__NR_geteuid);
+	return syscall(SYS_geteuid);
 }
diff --git a/src/unistd/getgid.c b/src/unistd/getgid.c
index 8a4590be..84823103 100644
--- a/src/unistd/getgid.c
+++ b/src/unistd/getgid.c
@@ -3,5 +3,5 @@
 
 gid_t getgid(void)
 {
-	return syscall0(__NR_getgid);
+	return syscall(SYS_getgid);
 }
diff --git a/src/unistd/getgroups.c b/src/unistd/getgroups.c
index 37619b9a..0e6e63af 100644
--- a/src/unistd/getgroups.c
+++ b/src/unistd/getgroups.c
@@ -3,5 +3,5 @@
 
 int getgroups(int count, gid_t list[])
 {
-	return syscall2(__NR_getgroups, count, (long)list);
+	return syscall(SYS_getgroups, count, list);
 }
diff --git a/src/unistd/getpgid.c b/src/unistd/getpgid.c
index 50d716b5..d295bfd5 100644
--- a/src/unistd/getpgid.c
+++ b/src/unistd/getpgid.c
@@ -3,5 +3,5 @@
 
 pid_t getpgid(pid_t pid)
 {
-	return syscall1(__NR_getpgid, pid);
+	return syscall(SYS_getpgid, pid);
 }
diff --git a/src/unistd/getpgrp.c b/src/unistd/getpgrp.c
index 2004630a..02449da9 100644
--- a/src/unistd/getpgrp.c
+++ b/src/unistd/getpgrp.c
@@ -3,5 +3,5 @@
 
 pid_t getpgrp(void)
 {
-	return syscall0(__NR_getpgrp);
+	return syscall(SYS_getpgrp);
 }
diff --git a/src/unistd/getpid.c b/src/unistd/getpid.c
index 31cbe1cb..4ab2b7f1 100644
--- a/src/unistd/getpid.c
+++ b/src/unistd/getpid.c
@@ -3,5 +3,5 @@
 
 pid_t getpid(void)
 {
-	return syscall0(__NR_getpid);
+	return syscall(SYS_getpid);
 }
diff --git a/src/unistd/getppid.c b/src/unistd/getppid.c
index a3241829..7d103207 100644
--- a/src/unistd/getppid.c
+++ b/src/unistd/getppid.c
@@ -3,5 +3,5 @@
 
 pid_t getppid(void)
 {
-	return syscall0(__NR_getppid);
+	return syscall(SYS_getppid);
 }
diff --git a/src/unistd/getsid.c b/src/unistd/getsid.c
index 064229cf..93ba690e 100644
--- a/src/unistd/getsid.c
+++ b/src/unistd/getsid.c
@@ -3,5 +3,5 @@
 
 pid_t getsid(pid_t pid)
 {
-	return syscall1(__NR_getsid, pid);
+	return syscall(SYS_getsid, pid);
 }
diff --git a/src/unistd/getuid.c b/src/unistd/getuid.c
index cd7233d1..0bf9e714 100644
--- a/src/unistd/getuid.c
+++ b/src/unistd/getuid.c
@@ -3,5 +3,5 @@
 
 uid_t getuid(void)
 {
-	return syscall0(__NR_getuid);
+	return syscall(SYS_getuid);
 }
diff --git a/src/unistd/lchown.c b/src/unistd/lchown.c
index a8402132..de871aeb 100644
--- a/src/unistd/lchown.c
+++ b/src/unistd/lchown.c
@@ -3,5 +3,5 @@
 
 int lchown(const char *path, uid_t uid, gid_t gid)
 {
-	return syscall3(__NR_lchown, (long)path, uid, gid);
+	return syscall(SYS_lchown, path, uid, gid);
 }
diff --git a/src/unistd/link.c b/src/unistd/link.c
index f121bb9e..20193f2a 100644
--- a/src/unistd/link.c
+++ b/src/unistd/link.c
@@ -3,5 +3,5 @@
 
 int link(const char *existing, const char *new)
 {
-	return syscall2(__NR_link, (long)existing, (long)new);
+	return syscall(SYS_link, existing, new);
 }
diff --git a/src/unistd/linkat.c b/src/unistd/linkat.c
index 0eb51221..6a9a0b77 100644
--- a/src/unistd/linkat.c
+++ b/src/unistd/linkat.c
@@ -3,5 +3,5 @@
 
 int linkat(int fd1, const char *existing, int fd2, const char *new, int flag)
 {
-	return syscall5(__NR_linkat, fd1, (long)existing, fd2, (long)new, flag);
+	return syscall(SYS_linkat, fd1, existing, fd2, new, flag);
 }
diff --git a/src/unistd/lseek.c b/src/unistd/lseek.c
index 0152866f..63cea588 100644
--- a/src/unistd/lseek.c
+++ b/src/unistd/lseek.c
@@ -6,9 +6,9 @@ off_t lseek(int fd, off_t offset, int whence)
 {
 #ifdef __NR__llseek
 	off_t result;
-	return syscall5(__NR__llseek, fd, offset>>32, offset, (long)&result, whence) ? -1 : result;
+	return syscall(SYS__llseek, fd, offset>>32, offset, &result, whence) ? -1 : result;
 #else
-	return syscall3(__NR_lseek, fd, offset, whence);
+	return syscall(SYS_lseek, fd, offset, whence);
 #endif
 }
 
diff --git a/src/unistd/nice.c b/src/unistd/nice.c
index f38db678..34f7c7f9 100644
--- a/src/unistd/nice.c
+++ b/src/unistd/nice.c
@@ -5,7 +5,7 @@
 int nice(int inc)
 {
 #ifdef __NR_nice
-	return syscall1(__NR_nice, inc);
+	return syscall(SYS_nice, inc);
 #else
 	return setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS, 0)+inc);
 #endif
diff --git a/src/unistd/pause.c b/src/unistd/pause.c
index 14720651..57ed25e5 100644
--- a/src/unistd/pause.c
+++ b/src/unistd/pause.c
@@ -6,7 +6,7 @@ int pause(void)
 {
 	int r;
 	CANCELPT_BEGIN;
-	r = syscall0(__NR_pause);
+	r = syscall(SYS_pause);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/unistd/pipe.c b/src/unistd/pipe.c
index 2dfc9c99..36c6f13e 100644
--- a/src/unistd/pipe.c
+++ b/src/unistd/pipe.c
@@ -3,5 +3,5 @@
 
 int pipe(int fd[2])
 {
-	return syscall1(__NR_pipe, (long)fd);
+	return syscall(SYS_pipe, fd);
 }
diff --git a/src/unistd/read.c b/src/unistd/read.c
index 87ff1f10..194b389e 100644
--- a/src/unistd/read.c
+++ b/src/unistd/read.c
@@ -6,7 +6,7 @@ ssize_t read(int fd, void *buf, size_t count)
 {
 	ssize_t r;
 	CANCELPT_BEGIN;
-	r = __syscall_read(fd, buf, count);
+	r = syscall(SYS_read, fd, buf, count);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/unistd/readlink.c b/src/unistd/readlink.c
index f6b1635c..11f45c01 100644
--- a/src/unistd/readlink.c
+++ b/src/unistd/readlink.c
@@ -3,5 +3,5 @@
 
 int readlink(const char *path, char *buf, size_t bufsize)
 {
-	return syscall3(__NR_readlink, (long)path, (long)buf, bufsize);
+	return syscall(SYS_readlink, path, buf, bufsize);
 }
diff --git a/src/unistd/readlinkat.c b/src/unistd/readlinkat.c
index 8171050d..9565b89a 100644
--- a/src/unistd/readlinkat.c
+++ b/src/unistd/readlinkat.c
@@ -3,5 +3,5 @@
 
 int readlinkat(int fd, const char *path, char *buf, size_t bufsize)
 {
-	return syscall4(__NR_readlinkat, fd, (long)path, (long)buf, bufsize);
+	return syscall(SYS_readlinkat, fd, path, buf, bufsize);
 }
diff --git a/src/unistd/readv.c b/src/unistd/readv.c
index e311f9de..9b87728e 100644
--- a/src/unistd/readv.c
+++ b/src/unistd/readv.c
@@ -6,7 +6,7 @@ ssize_t readv(int fd, const struct iovec *iov, int count)
 {
 	ssize_t r;
 	CANCELPT_BEGIN;
-	r = syscall3(__NR_readv, fd, (long)iov, count);
+	r = syscall(SYS_readv, fd, iov, count);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/unistd/renameat.c b/src/unistd/renameat.c
index 0dae9f11..12574822 100644
--- a/src/unistd/renameat.c
+++ b/src/unistd/renameat.c
@@ -3,5 +3,5 @@
 
 int renameat(int oldfd, const char *old, int newfd, const char *new)
 {
-	return syscall4(__NR_renameat, oldfd, (long)old, newfd, (long)new);
+	return syscall(SYS_renameat, oldfd, old, newfd, new);
 }
diff --git a/src/unistd/rmdir.c b/src/unistd/rmdir.c
index 8e18c7a8..dfe1605d 100644
--- a/src/unistd/rmdir.c
+++ b/src/unistd/rmdir.c
@@ -3,5 +3,5 @@
 
 int rmdir(const char *path)
 {
-	return syscall1(__NR_rmdir, (long)path);
+	return syscall(SYS_rmdir, path);
 }
diff --git a/src/unistd/setgid.c b/src/unistd/setgid.c
index 42976d95..e98a2982 100644
--- a/src/unistd/setgid.c
+++ b/src/unistd/setgid.c
@@ -5,5 +5,5 @@
 int setgid(gid_t gid)
 {
 	if (libc.rsyscall) return libc.rsyscall(__NR_setgid, gid, 0, 0, 0, 0, 0);
-	return syscall1(__NR_setgid, gid);
+	return syscall(SYS_setgid, gid);
 }
diff --git a/src/unistd/setpgid.c b/src/unistd/setpgid.c
index 748d2907..4a5a3d6b 100644
--- a/src/unistd/setpgid.c
+++ b/src/unistd/setpgid.c
@@ -3,5 +3,5 @@
 
 pid_t setpgid(pid_t pid, pid_t pgid)
 {
-	return syscall2(__NR_setpgid, pid, pgid);
+	return syscall(SYS_setpgid, pid, pgid);
 }
diff --git a/src/unistd/setregid.c b/src/unistd/setregid.c
index 158753be..ff2607dc 100644
--- a/src/unistd/setregid.c
+++ b/src/unistd/setregid.c
@@ -5,5 +5,5 @@
 int setregid(gid_t rgid, gid_t egid)
 {
 	if (libc.rsyscall) return libc.rsyscall(__NR_setregid, rgid, egid, 0, 0, 0, 0);
-	return syscall2(__NR_setregid, rgid, egid);
+	return syscall(SYS_setregid, rgid, egid);
 }
diff --git a/src/unistd/setreuid.c b/src/unistd/setreuid.c
index 47c67306..505e8bc1 100644
--- a/src/unistd/setreuid.c
+++ b/src/unistd/setreuid.c
@@ -5,5 +5,5 @@
 int setreuid(uid_t ruid, uid_t euid)
 {
 	if (libc.rsyscall) return libc.rsyscall(__NR_setreuid, ruid, euid, 0, 0, 0, 0);
-	return syscall2(__NR_setreuid, ruid, euid);
+	return syscall(SYS_setreuid, ruid, euid);
 }
diff --git a/src/unistd/setsid.c b/src/unistd/setsid.c
index e2c5690c..609bbe4a 100644
--- a/src/unistd/setsid.c
+++ b/src/unistd/setsid.c
@@ -3,5 +3,5 @@
 
 pid_t setsid(void)
 {
-	return syscall0(__NR_setsid);
+	return syscall(SYS_setsid);
 }
diff --git a/src/unistd/setuid.c b/src/unistd/setuid.c
index 9e9da61f..61e8be55 100644
--- a/src/unistd/setuid.c
+++ b/src/unistd/setuid.c
@@ -5,5 +5,5 @@
 int setuid(uid_t uid)
 {
 	if (libc.rsyscall) return libc.rsyscall(__NR_setuid, uid, 0, 0, 0, 0, 0);
-	return syscall1(__NR_setuid, uid);
+	return syscall(SYS_setuid, uid);
 }
diff --git a/src/unistd/symlink.c b/src/unistd/symlink.c
index 8d380d85..5902d45a 100644
--- a/src/unistd/symlink.c
+++ b/src/unistd/symlink.c
@@ -3,5 +3,5 @@
 
 int symlink(const char *existing, const char *new)
 {
-	return syscall2(__NR_symlink, (long)existing, (long)new);
+	return syscall(SYS_symlink, existing, new);
 }
diff --git a/src/unistd/symlinkat.c b/src/unistd/symlinkat.c
index 9693b226..d1c59b4d 100644
--- a/src/unistd/symlinkat.c
+++ b/src/unistd/symlinkat.c
@@ -3,5 +3,5 @@
 
 int symlinkat(const char *existing, int fd, const char *new)
 {
-	return syscall3(__NR_symlinkat, (long)existing, fd, (long)new);
+	return syscall(SYS_symlinkat, existing, fd, new);
 }
diff --git a/src/unistd/sync.c b/src/unistd/sync.c
index a49808fd..20fafb4a 100644
--- a/src/unistd/sync.c
+++ b/src/unistd/sync.c
@@ -3,5 +3,5 @@
 
 void sync(void)
 {
-	syscall0(__NR_sync);
+	syscall(SYS_sync);
 }
diff --git a/src/unistd/unlink.c b/src/unistd/unlink.c
index fb577920..bdb37bea 100644
--- a/src/unistd/unlink.c
+++ b/src/unistd/unlink.c
@@ -3,5 +3,5 @@
 
 int unlink(const char *path)
 {
-	return __syscall_unlink(path);
+	return syscall(SYS_unlink, path);
 }
diff --git a/src/unistd/unlinkat.c b/src/unistd/unlinkat.c
index 47fccc17..e0e25d22 100644
--- a/src/unistd/unlinkat.c
+++ b/src/unistd/unlinkat.c
@@ -3,5 +3,5 @@
 
 int unlinkat(int fd, const char *path, int flag)
 {
-	return syscall3(__NR_unlinkat, fd, (long)path, flag);
+	return syscall(SYS_unlinkat, fd, path, flag);
 }
diff --git a/src/unistd/write.c b/src/unistd/write.c
index 426cfc5b..a8284b32 100644
--- a/src/unistd/write.c
+++ b/src/unistd/write.c
@@ -6,7 +6,7 @@ ssize_t write(int fd, const void *buf, size_t count)
 {
 	int r;
 	CANCELPT_BEGIN;
-	r = __syscall_write(fd, buf, count);
+	r = syscall(SYS_write, fd, buf, count);
 	CANCELPT_END;
 	return r;
 }
diff --git a/src/unistd/writev.c b/src/unistd/writev.c
index a6a118af..a45afeb7 100644
--- a/src/unistd/writev.c
+++ b/src/unistd/writev.c
@@ -6,7 +6,7 @@ ssize_t writev(int fd, const struct iovec *iov, int count)
 {
 	ssize_t r;
 	CANCELPT_BEGIN;
-	r = syscall3(__NR_writev, fd, (long)iov, count);
+	r = syscall(SYS_writev, fd, iov, count);
 	CANCELPT_END;
 	return r;
 }