提交 aa398f56 编写于 作者: R Rich Felker

global cleanup to use the new syscall interface

上级 be82e122
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int __getdents(int fd, struct dirent *buf, size_t len) 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); weak_alias(__getdents, getdents);
......
...@@ -14,7 +14,7 @@ int fcntl(int fd, int cmd, ...) ...@@ -14,7 +14,7 @@ int fcntl(int fd, int cmd, ...)
va_end(ap); va_end(ap);
if (cmd == F_SETFL) arg |= O_LARGEFILE; if (cmd == F_SETFL) arg |= O_LARGEFILE;
if (cmd == F_SETLKW) CANCELPT_BEGIN; 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; if (cmd == F_SETLKW) CANCELPT_END;
return r; return r;
} }
......
...@@ -13,7 +13,7 @@ int open(const char *filename, int flags, ...) ...@@ -13,7 +13,7 @@ int open(const char *filename, int flags, ...)
mode = va_arg(ap, mode_t); mode = va_arg(ap, mode_t);
va_end(ap); va_end(ap);
CANCELPT_BEGIN; CANCELPT_BEGIN;
r = __syscall_open(filename, flags, mode); r = syscall(SYS_open, filename, flags|O_LARGEFILE, mode);
CANCELPT_END; CANCELPT_END;
return r; return r;
} }
......
...@@ -13,7 +13,7 @@ int openat(int fd, const char *filename, int flags, ...) ...@@ -13,7 +13,7 @@ int openat(int fd, const char *filename, int flags, ...)
mode = va_arg(ap, mode_t); mode = va_arg(ap, mode_t);
va_end(ap); va_end(ap);
CANCELPT_BEGIN; 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; CANCELPT_END;
return r; return r;
} }
......
...@@ -5,28 +5,6 @@ ...@@ -5,28 +5,6 @@
#include <sys/syscall.h> #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 #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 #endif
...@@ -11,8 +11,8 @@ int semctl(int id, int num, int cmd, ...) ...@@ -11,8 +11,8 @@ int semctl(int id, int num, int cmd, ...)
arg = va_arg(ap, long); arg = va_arg(ap, long);
va_end(ap); va_end(ap);
#ifdef __NR_semctl #ifdef __NR_semctl
return syscall4(__NR_semctl, id, num, cmd, arg); return syscall(SYS_semctl, id, num, cmd, arg);
#else #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 #endif
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
int semget(key_t key, int n, int fl) int semget(key_t key, int n, int fl)
{ {
#ifdef __NR_semget #ifdef __NR_semget
return syscall3(__NR_semget, key, n, fl); return syscall(SYS_semget, key, n, fl);
#else #else
return syscall4(__NR_ipc, IPCOP_semget, key, n, fl); return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
#endif #endif
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
int semop(int id, struct sembuf *buf, size_t n) int semop(int id, struct sembuf *buf, size_t n)
{ {
#ifdef __NR_semop #ifdef __NR_semop
return syscall3(__NR_semop, id, (long)buf, n); return syscall(SYS_semop, id, buf, n);
#else #else
return syscall5(__NR_ipc, IPCOP_semop, id, n, 0, (long)buf); return syscall(SYS_ipc, IPCOP_semop, id, n, 0, buf);
#endif #endif
} }
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#ifdef __NR_shmat #ifdef __NR_shmat
void *shmat(int id, const void *addr, int flag) 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 #else
void *shmat(int id, const void *addr, int flag) void *shmat(int id, const void *addr, int flag)
{ {
unsigned long ret; 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; return (ret > -(unsigned long)SHMLBA) ? (void *)ret : (void *)addr;
} }
#endif #endif
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
int shmctl(int id, int cmd, struct shmid_ds *buf) int shmctl(int id, int cmd, struct shmid_ds *buf)
{ {
#ifdef __NR_shmctl #ifdef __NR_shmctl
return syscall3(__NR_shmctl, id, cmd, (long)buf); return syscall(SYS_shmctl, id, cmd, buf);
#else #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 #endif
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
int shmdt(const void *addr) int shmdt(const void *addr)
{ {
#ifdef __NR_shmdt #ifdef __NR_shmdt
return syscall1(__NR_shmdt, (long)addr); return syscall(SYS_shmdt, addr);
#else #else
return syscall2(__NR_ipc, IPCOP_shmdt, (long)addr); return syscall(SYS_ipc, IPCOP_shmdt, addr);
#endif #endif
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
int shmget(key_t key, size_t size, int flag) int shmget(key_t key, size_t size, int flag)
{ {
#ifdef __NR_shmget #ifdef __NR_shmget
return syscall3(__NR_shmget, key, size, flag); return syscall(SYS_shmget, key, size, flag);
#else #else
return syscall4(__NR_ipc, IPCOP_shmget, key, size, flag); return syscall(SYS_ipc, IPCOP_shmget, key, size, flag);
#endif #endif
} }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
int brk(void *end) int brk(void *end)
{ {
return -(syscall1(__NR_brk, (long)end) == -1); return -(syscall(SYS_brk, end) == -1);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int chroot(const char *path) int chroot(const char *path)
{ {
return syscall1(__NR_chroot, (long)path); return syscall(SYS_chroot, path);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int epoll_create(int size) int epoll_create(int size)
{ {
return syscall1(__NR_epoll_create, size); return syscall(SYS_epoll_create, size);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int epoll_create1(int flags) int epoll_create1(int flags)
{ {
return syscall1(__NR_epoll_create1, flags); return syscall(SYS_epoll_create1, flags);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int inotify_add_watch(int fd, const char *pathname, uint32_t mask) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int inotify_init() int inotify_init()
{ {
return syscall0(__NR_inotify_init); return syscall(SYS_inotify_init);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int inotify_init1(int flags) int inotify_init1(int flags)
{ {
return syscall1(__NR_inotify_init1, flags); return syscall(SYS_inotify_init1, flags);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int inotify_rm_watch(int fd, uint32_t wd) 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);
} }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
int klogctl (int type, char *buf, int len) int klogctl (int type, char *buf, int len)
{ {
return syscall3(__NR_syslog, type, (long)buf, len); return syscall(SYS_syslog, type, buf, len);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mount(const char *special, const char *dir, const char *fstype, unsigned long flags, const void *data) 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);
} }
...@@ -9,5 +9,5 @@ int prctl(int op, ...) ...@@ -9,5 +9,5 @@ int prctl(int op, ...)
va_list ap; va_list ap;
va_start(ap, op); va_start(ap, op);
for (i=0; i<4; i++) x[i] = va_arg(ap, unsigned long); 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]);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
void *sbrk(ptrdiff_t inc) 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);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
ssize_t sendfile(int out_fd, int in_fd, off_t *ofs, size_t count) 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); LFS64(sendfile);
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int setgroups(int count, const gid_t list[]) int setgroups(int count, const gid_t list[])
{ {
return syscall2(__NR_setgroups, count, (long)list); return syscall(SYS_setgroups, count, list);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int sethostname(const char *name, size_t len) int sethostname(const char *name, size_t len)
{ {
return syscall2(__NR_sethostname, (long)name, len); return syscall(SYS_sethostname, name, len);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int settimeofday(const struct timeval *tv, void *tz) int settimeofday(const struct timeval *tv, void *tz)
{ {
return syscall2(__NR_settimeofday, (long)tv, 0); return syscall(SYS_settimeofday, tv, 0);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int signalfd(int fd, const sigset_t *sigs, int flags) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int swapoff(const char *path) int swapoff(const char *path)
{ {
return syscall1(__NR_swapoff, (long)path); return syscall(SYS_swapoff, path);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int swapon(const char *path, int flags) int swapon(const char *path, int flags)
{ {
return syscall2(__NR_swapon, (long)path, flags); return syscall(SYS_swapon, path, flags);
} }
...@@ -4,5 +4,5 @@ struct sysinfo; ...@@ -4,5 +4,5 @@ struct sysinfo;
int sysinfo(struct sysinfo *info) int sysinfo(struct sysinfo *info)
{ {
return syscall1(__NR_sysinfo, (long)info); return syscall(SYS_sysinfo, info);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int umount(const char *special) int umount(const char *special)
{ {
return syscall2(__NR_umount2, (long)special, 0); return syscall(SYS_umount2, special, 0);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int umount2(const char *special, int flags) int umount2(const char *special, int flags)
{ {
return syscall2(__NR_umount2, (long)special, flags); return syscall(SYS_umount2, special, flags);
} }
...@@ -3,10 +3,5 @@ ...@@ -3,10 +3,5 @@
int utimes(const char *path, const struct timeval times[2]) int utimes(const char *path, const struct timeval times[2])
{ {
long ktimes[2]; return syscall(SYS_utime, path, times);
if (times) {
ktimes[0] = times[0].tv_sec;
ktimes[1] = times[1].tv_sec;
}
return syscall2(__NR_utime, (long)path, times ? (long)ktimes : 0);
} }
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
pid_t wait4(pid_t pid, int *status, int options, struct rusage *usage) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
uintptr_t __brk(uintptr_t newbrk) uintptr_t __brk(uintptr_t newbrk)
{ {
return syscall1(__NR_brk, newbrk); return syscall(SYS_brk, newbrk);
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
int getpriority(int which, id_t who) 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; if (ret < 0) return ret;
return 20-ret; return 20-ret;
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int getrlimit(int resource, struct rlimit *rlim) int getrlimit(int resource, struct rlimit *rlim)
{ {
long k_rlim[2]; long k_rlim[2];
if (syscall2(__NR_getrlimit, resource, (long)k_rlim) < 0) if (syscall(SYS_getrlimit, resource, k_rlim) < 0)
return -1; return -1;
rlim->rlim_cur = k_rlim[0] == -1 ? -1 : (unsigned long)k_rlim[0]; 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]; rlim->rlim_max = k_rlim[1] == -1 ? -1 : (unsigned long)k_rlim[1];
......
...@@ -2,19 +2,7 @@ ...@@ -2,19 +2,7 @@
#include <string.h> #include <string.h>
#include "syscall.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) int getrusage(int who, struct rusage *ru)
{ {
struct { long tv_sec, tv_usec; } ktv[2]; return syscall(SYS_getrusage, who, ru);
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;
} }
...@@ -9,5 +9,5 @@ int ioctl(int fd, int req, ...) ...@@ -9,5 +9,5 @@ int ioctl(int fd, int req, ...)
va_start(ap, req); va_start(ap, req);
arg = va_arg(ap, void *); arg = va_arg(ap, void *);
va_end(ap); va_end(ap);
return syscall3(__NR_ioctl, fd, req, (long)arg); return syscall(SYS_ioctl, fd, req, arg);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int __yield() int __yield()
{ {
return syscall0(__NR_sched_yield); return syscall(SYS_sched_yield);
} }
weak_alias(__yield, sched_yield); weak_alias(__yield, sched_yield);
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int setpriority(int which, id_t who, int prio) int setpriority(int which, id_t who, int prio)
{ {
return syscall3(__NR_getpriority, which, who, prio); return syscall(SYS_getpriority, which, who, prio);
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int setrlimit(int resource, const struct rlimit *rlim) int setrlimit(int resource, const struct rlimit *rlim)
{ {
long k_rlim[2] = { rlim->rlim_cur, rlim->rlim_max }; 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); LFS64(setrlimit);
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
int uname(struct utsname *uts) int uname(struct utsname *uts)
{ {
return syscall1(__NR_uname, (long)uts); return syscall(SYS_uname, uts);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int __madvise(void *addr, size_t len, int advice) 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); weak_alias(__madvise, madvise);
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mlock(const void *addr, size_t len) int mlock(const void *addr, size_t len)
{ {
return syscall2(__NR_mlock, (long)addr, len); return syscall(SYS_mlock, addr, len);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mlockall(int flags) int mlockall(int flags)
{ {
return syscall1(__NR_mlockall, flags); return syscall(SYS_mlockall, flags);
} }
...@@ -11,9 +11,9 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) ...@@ -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)))))) if (((long)off & 0xfff) | ((long)((unsigned long long)off>>(12 + 8*(sizeof(off_t)-sizeof(long))))))
start = (void *)-1; start = (void *)-1;
#ifdef __NR_mmap2 #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 #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 #endif
} }
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mprotect(void *addr, size_t len, int prot) int mprotect(void *addr, size_t len, int prot)
{ {
return syscall3(__NR_mprotect, (long)addr, len, prot); return syscall(SYS_mprotect, addr, len, prot);
} }
...@@ -13,7 +13,7 @@ void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...) ...@@ -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 *); new_addr = va_arg(ap, void *);
va_end(ap); 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); weak_alias(__mremap, mremap);
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
int msync(void *start, size_t len, int flags) int msync(void *start, size_t len, int flags)
{ {
return syscall3(__NR_msync, (long)start, len, flags); return syscall(SYS_msync, start, len, flags);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int munlock(const void *addr, size_t len) int munlock(const void *addr, size_t len)
{ {
return syscall2(__NR_munlock, (long)addr, len); return syscall(SYS_munlock, addr, len);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int munlockall(void) int munlockall(void)
{ {
return syscall0(__NR_munlockall); return syscall(SYS_munlockall);
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
int __munmap(void *start, size_t len) int __munmap(void *start, size_t len)
{ {
return syscall2(__NR_munmap, (long)start, len); return syscall(SYS_munmap, start, len);
} }
weak_alias(__munmap, munmap); weak_alias(__munmap, munmap);
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
int execve(const char *path, char *const argv[], char *const envp[]) int execve(const char *path, char *const argv[], char *const envp[])
{ {
/* do we need to use environ if envp is null? */ /* 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);
} }
...@@ -7,11 +7,11 @@ pid_t fork(void) ...@@ -7,11 +7,11 @@ pid_t fork(void)
{ {
pid_t ret; pid_t ret;
if (libc.fork_handler) libc.fork_handler(-1); if (libc.fork_handler) libc.fork_handler(-1);
ret = syscall0(__NR_fork); ret = syscall(SYS_fork);
if (libc.lock && !ret) { if (libc.lock && !ret) {
pthread_t self = __pthread_self(); pthread_t self = __pthread_self();
self->pid = syscall0(__NR_getpid); self->pid = syscall(SYS_getpid);
self->tid = syscall0(__NR_gettid); self->tid = syscall(SYS_gettid);
libc.threads_minus_1 = 0; libc.threads_minus_1 = 0;
} }
if (libc.fork_handler) libc.fork_handler(!ret); if (libc.fork_handler) libc.fork_handler(!ret);
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
pid_t vfork(void) pid_t vfork(void)
{ {
/* vfork syscall cannot be made from C code */ /* vfork syscall cannot be made from C code */
return syscall0(__NR_fork); return syscall(SYS_fork);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int waitid(idtype_t type, id_t id, siginfo_t *info, int options) 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
pid_t waitpid(pid_t pid, int *status, int options) 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);
} }
...@@ -6,7 +6,7 @@ int poll(struct pollfd *fds, nfds_t n, int timeout) ...@@ -6,7 +6,7 @@ int poll(struct pollfd *fds, nfds_t n, int timeout)
{ {
int r; int r;
CANCELPT_BEGIN; CANCELPT_BEGIN;
r = syscall3(__NR_poll, (long)fds, n, timeout); r = syscall(SYS_poll, fds, n, timeout);
CANCELPT_END; CANCELPT_END;
return r; return r;
} }
...@@ -9,7 +9,7 @@ int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timesp ...@@ -9,7 +9,7 @@ int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timesp
struct timespec ts_tmp; struct timespec ts_tmp;
if (ts) ts_tmp = *ts; if (ts) ts_tmp = *ts;
CANCELPT_BEGIN; 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; CANCELPT_END;
return r; return r;
} }
...@@ -6,7 +6,7 @@ int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv) ...@@ -6,7 +6,7 @@ int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
{ {
int r; int r;
CANCELPT_BEGIN; 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; CANCELPT_END;
return r; return r;
} }
...@@ -3,10 +3,5 @@ ...@@ -3,10 +3,5 @@
int getitimer(int which, struct itimerval *old) int getitimer(int which, struct itimerval *old)
{ {
int ret; return syscall(SYS_getitimer, which, old);
long kold[4];
if (!(ret = syscall2(__NR_getitimer, which, (long)&kold)))
*old = (struct itimerval){ { kold[0], kold[1] }, { kold[2], kold[3] } };
return ret;
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int kill(pid_t pid, int sig) int kill(pid_t pid, int sig)
{ {
return syscall2(__NR_kill, pid, sig); return syscall(SYS_kill, pid, sig);
} }
...@@ -10,9 +10,9 @@ int raise(int sig) ...@@ -10,9 +10,9 @@ int raise(int sig)
sigset_t set; sigset_t set;
sigfillset(&set); sigfillset(&set);
__sigprocmask(SIG_BLOCK, &set, &set); __sigprocmask(SIG_BLOCK, &set, &set);
tid = syscall0(__NR_gettid); tid = syscall(SYS_gettid);
pid = syscall0(__NR_getpid); pid = syscall(SYS_getpid);
ret = syscall3(__NR_tgkill, pid, tid, sig); ret = syscall(SYS_tgkill, pid, tid, sig);
__sigprocmask(SIG_SETMASK, &set, 0); __sigprocmask(SIG_SETMASK, &set, 0);
return ret; return ret;
} }
...@@ -3,13 +3,5 @@ ...@@ -3,13 +3,5 @@
int setitimer(int which, const struct itimerval *new, struct itimerval *old) int setitimer(int which, const struct itimerval *new, struct itimerval *old)
{ {
int ret; return syscall(SYS_setitimer, which, new, old);
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;
} }
...@@ -23,7 +23,7 @@ int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old) ...@@ -23,7 +23,7 @@ int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
pksa = (long)&ksa; pksa = (long)&ksa;
} }
if (old) pkold = (long)&kold; 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; return -1;
if (old) { if (old) {
old->sa_handler = kold.handler; old->sa_handler = kold.handler;
......
...@@ -14,5 +14,5 @@ int sigaltstack(const stack_t *ss, stack_t *old) ...@@ -14,5 +14,5 @@ int sigaltstack(const stack_t *ss, stack_t *old)
return -1; return -1;
} }
} }
return syscall2(__NR_sigaltstack, (long)ss, (long)old); return syscall(SYS_sigaltstack, ss, old);
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old) 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) int __sigprocmask(int how, const sigset_t *set, sigset_t *old)
......
...@@ -12,5 +12,5 @@ int sigqueue(pid_t pid, int sig, const union sigval value) ...@@ -12,5 +12,5 @@ int sigqueue(pid_t pid, int sig, const union sigval value)
si.si_value = value; si.si_value = value;
si.si_pid = getpid(); si.si_pid = getpid();
si.si_uid = getuid(); si.si_uid = getuid();
return syscall3(__NR_rt_sigqueueinfo, pid, sig, (long)&si); return syscall(SYS_rt_sigqueueinfo, pid, sig, &si);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int chmod(const char *path, mode_t mode) int chmod(const char *path, mode_t mode)
{ {
return syscall2(__NR_chmod, (long)path, mode); return syscall(SYS_chmod, path, mode);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int fchmod(int fd, mode_t mode) int fchmod(int fd, mode_t mode)
{ {
return syscall2(__NR_fchmod, fd, mode); return syscall(SYS_fchmod, fd, mode);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int fchmodat(int fd, const char *path, mode_t mode, int flag) 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);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int fstat(int fd, struct stat *buf) int fstat(int fd, struct stat *buf)
{ {
return syscall2(__NR_fstat, fd, (long)buf); return syscall(SYS_fstat, fd, buf);
} }
LFS64(fstat); LFS64(fstat);
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int fstatat(int fd, const char *path, struct stat *buf, int flag) 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); LFS64(fstatat);
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int fstatvfs(int fd, struct statvfs *buf) int fstatvfs(int fd, struct statvfs *buf)
{ {
return syscall2(__NR_fstatfs, fd, (long)buf); return syscall(SYS_fstatfs, fd, buf);
} }
weak_alias(fstatvfs, fstatfs); weak_alias(fstatvfs, fstatfs);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int lstat(const char *path, struct stat *buf) int lstat(const char *path, struct stat *buf)
{ {
return syscall2(__NR_lstat, (long)path, (long)buf); return syscall(SYS_lstat, path, buf);
} }
LFS64(lstat); LFS64(lstat);
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mkdir(const char *path, mode_t mode) int mkdir(const char *path, mode_t mode)
{ {
return syscall2(__NR_mkdir, (long)path, mode); return syscall(SYS_mkdir, path, mode);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mkdirat(int fd, const char *path, mode_t mode) 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);
} }
...@@ -6,5 +6,5 @@ int mknod(const char *path, mode_t mode, dev_t dev) ...@@ -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 /* since dev_t is system-specific anyway we defer to the idiotic
* legacy-compatible bitfield mapping of the type.. at least we've * legacy-compatible bitfield mapping of the type.. at least we've
* made it large enough to leave space for future expansion.. */ * 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);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int mknodat(int fd, const char *path, mode_t mode, dev_t dev) 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);
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int stat(const char *path, struct stat *buf) int stat(const char *path, struct stat *buf)
{ {
return syscall2(__NR_stat, (long)path, (long)buf); return syscall(SYS_stat, path, buf);
} }
LFS64(stat); LFS64(stat);
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
int statvfs(const char *path, struct statvfs *buf) 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); weak_alias(statvfs, statfs);
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
mode_t umask(mode_t mode) mode_t umask(mode_t mode)
{ {
return syscall1(__NR_umask, mode); return syscall(SYS_umask, mode);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int utimensat(int fd, const char *path, const struct timespec times[2], int flags) 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);
} }
...@@ -20,8 +20,8 @@ FILE *__fdopen(int fd, const char *mode) ...@@ -20,8 +20,8 @@ FILE *__fdopen(int fd, const char *mode)
/* Set append mode on fd if opened for append */ /* Set append mode on fd if opened for append */
if (*mode == 'a') { if (*mode == 'a') {
int flags = __syscall_fcntl(fd, F_GETFL, 0); int flags = syscall(SYS_fcntl, fd, F_GETFL, 0);
__syscall_fcntl(fd, F_SETFL, flags | O_APPEND); syscall(SYS_fcntl, fd, F_SETFL, flags | O_APPEND);
} }
f->fd = fd; f->fd = fd;
...@@ -30,7 +30,7 @@ FILE *__fdopen(int fd, const char *mode) ...@@ -30,7 +30,7 @@ FILE *__fdopen(int fd, const char *mode)
/* Activate line buffered mode for terminals */ /* Activate line buffered mode for terminals */
f->lbf = EOF; 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'; f->lbf = '\n';
/* Initialize op ptrs. No problem if some are unneeded. */ /* Initialize op ptrs. No problem if some are unneeded. */
......
...@@ -4,7 +4,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le ...@@ -4,7 +4,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le
{ {
memset(f, 0, sizeof *f); 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; if (f->fd < 0) return 0;
f->flags = F_NOWR | F_PERM; f->flags = F_NOWR | F_PERM;
......
...@@ -13,7 +13,7 @@ void __lockfile(FILE *f) ...@@ -13,7 +13,7 @@ void __lockfile(FILE *f)
spins = 100000; spins = 100000;
while (a_swap(&f->lock, 1)) while (a_swap(&f->lock, 1))
if (spins) spins--, a_spin(); if (spins) spins--, a_spin();
else syscall0(__NR_sched_yield); else syscall(SYS_sched_yield);
f->owner = __pthread_self()->tid; f->owner = __pthread_self()->tid;
f->lockcount = 1; f->lockcount = 1;
} }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
int __stdio_close(FILE *f) int __stdio_close(FILE *f)
{ {
return __syscall_close(f->fd); return syscall(SYS_close, f->fd);
} }
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) 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);
} }
...@@ -8,11 +8,11 @@ static off_t retneg1(FILE *f, off_t off, int whence) ...@@ -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 __stdio_seek(FILE *f, off_t off, int whence)
{ {
off_t ret; off_t ret;
#ifdef __NR__llseek #ifdef SYS__llseek
if (syscall5(__NR__llseek, f->fd, off>>32, off, (long)&ret, whence)<0) if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0)
ret = -1; ret = -1;
#else #else
ret = syscall3(__NR_lseek, f->fd, off, whence); ret = syscall(SYS_lseek, f->fd, off, whence);
#endif #endif
/* Detect unseekable files and optimize future failures out */ /* Detect unseekable files and optimize future failures out */
if (ret < 0 && off == 0 && whence == SEEK_CUR) if (ret < 0 && off == 0 && whence == SEEK_CUR)
......
...@@ -4,6 +4,6 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) ...@@ -4,6 +4,6 @@ size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len)
{ {
const unsigned char *stop = buf+len; const unsigned char *stop = buf+len;
ssize_t cnt = 1; 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); return len-(stop-buf);
} }
...@@ -21,13 +21,13 @@ FILE *fopen(const char *filename, const char *mode) ...@@ -21,13 +21,13 @@ FILE *fopen(const char *filename, const char *mode)
if (*mode == 'w') flags |= O_TRUNC; if (*mode == 'w') flags |= O_TRUNC;
if (*mode == 'a') flags |= O_APPEND; 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; if (fd < 0) return 0;
f = __fdopen(fd, mode); f = __fdopen(fd, mode);
if (f) return f; if (f) return f;
__syscall_close(fd); syscall(SYS_close, fd);
return 0; return 0;
} }
......
...@@ -17,13 +17,13 @@ FILE *freopen(const char *filename, const char *mode, FILE *f) ...@@ -17,13 +17,13 @@ FILE *freopen(const char *filename, const char *mode, FILE *f)
if (!filename) { if (!filename) {
f2 = fopen("/dev/null", mode); f2 = fopen("/dev/null", mode);
if (!f2) goto fail; if (!f2) goto fail;
fl = __syscall_fcntl(f2->fd, F_GETFL, 0); fl = syscall(SYS_fcntl, f2->fd, F_GETFL, 0);
if (fl < 0 || __syscall_fcntl(f->fd, F_SETFL, fl) < 0) if (fl < 0 || syscall(SYS_fcntl, f->fd, F_SETFL, fl) < 0)
goto fail2; goto fail2;
} else { } else {
f2 = fopen(filename, mode); f2 = fopen(filename, mode);
if (!f2) goto fail; if (!f2) goto fail;
if (__syscall_dup2(f2->fd, f->fd) < 0) if (syscall(SYS_dup2, f2->fd, f->fd) < 0)
goto fail2; goto fail2;
} }
......
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int remove(const char *path) int remove(const char *path)
{ {
return __syscall_unlink(path); return syscall(SYS_unlink, path);
} }
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
int rename(const char *old, const char *new) int rename(const char *old, const char *new)
{ {
return syscall2(__NR_rename, (long)old, (long)new); return syscall(SYS_rename, old, new);
} }
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册