global cleanup to use the new syscall interface
diff --git a/src/unistd/access.c b/src/unistd/access.c
index 2c10e58..e7ce73a 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 bba444d..244af1c 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 c89bda3..5ba78b6 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 b89b173..95f6f61 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 97302f6..f52c0ef 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 b11cd71..7fee012 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 9332544..7945f85 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 99a9378..1efbb77 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 b2acbc2..e5595f7 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 6050b77..b05f0be 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 7062642..62457a3 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 7cfedc9..5991c66 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 4910f42..b64b560 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 33ee205..76038f6 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 cdec631..187ba0a 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 8a4590b..8482310 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 37619b9..0e6e63a 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 50d716b..d295bfd 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 2004630..02449da 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 31cbe1c..4ab2b7f 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 a324182..7d10320 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 064229c..93ba690 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 cd7233d..0bf9e71 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 a840213..de871ae 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 f121bb9..20193f2 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 0eb5122..6a9a0b7 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 0152866..63cea58 100644
--- a/src/unistd/lseek.c
+++ b/src/unistd/lseek.c
@@ -6,9 +6,9 @@
 {
 #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 f38db67..34f7c7f 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 1472065..57ed25e 100644
--- a/src/unistd/pause.c
+++ b/src/unistd/pause.c
@@ -6,7 +6,7 @@
 {
 	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 2dfc9c9..36c6f13 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 87ff1f1..194b389 100644
--- a/src/unistd/read.c
+++ b/src/unistd/read.c
@@ -6,7 +6,7 @@
 {
 	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 f6b1635..11f45c0 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 8171050..9565b89 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 e311f9d..9b87728 100644
--- a/src/unistd/readv.c
+++ b/src/unistd/readv.c
@@ -6,7 +6,7 @@
 {
 	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 0dae9f1..1257482 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 8e18c7a..dfe1605 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 42976d9..e98a298 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 748d290..4a5a3d6 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 158753b..ff2607d 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 47c6730..505e8bc 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 e2c5690..609bbe4 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 9e9da61..61e8be5 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 8d380d8..5902d45 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 9693b22..d1c59b4 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 a49808f..20fafb4 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 fb57792..bdb37be 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 47fccc1..e0e25d2 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 426cfc5..a8284b3 100644
--- a/src/unistd/write.c
+++ b/src/unistd/write.c
@@ -6,7 +6,7 @@
 {
 	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 a6a118a..a45afeb 100644
--- a/src/unistd/writev.c
+++ b/src/unistd/writev.c
@@ -6,7 +6,7 @@
 {
 	ssize_t r;
 	CANCELPT_BEGIN;
-	r = syscall3(__NR_writev, fd, (long)iov, count);
+	r = syscall(SYS_writev, fd, iov, count);
 	CANCELPT_END;
 	return r;
 }