global cleanup to use the new syscall interface

This commit is contained in:
Rich Felker 2011-03-20 00:16:43 -04:00
parent be82e122bf
commit aa398f56fa
160 changed files with 180 additions and 238 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -2,5 +2,5 @@
int brk(void *end)
{
return -(syscall1(__NR_brk, (long)end) == -1);
return -(syscall(SYS_brk, end) == -1);
}

View File

@ -3,5 +3,5 @@
int chroot(const char *path)
{
return syscall1(__NR_chroot, (long)path);
return syscall(SYS_chroot, path);
}

View File

@ -3,5 +3,5 @@
int epoll_create(int size)
{
return syscall1(__NR_epoll_create, size);
return syscall(SYS_epoll_create, size);
}

View File

@ -3,5 +3,5 @@
int epoll_create1(int flags)
{
return syscall1(__NR_epoll_create1, flags);
return syscall(SYS_epoll_create1, flags);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int inotify_init()
{
return syscall0(__NR_inotify_init);
return syscall(SYS_inotify_init);
}

View File

@ -3,5 +3,5 @@
int inotify_init1(int flags)
{
return syscall1(__NR_inotify_init1, flags);
return syscall(SYS_inotify_init1, flags);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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]);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int swapoff(const char *path)
{
return syscall1(__NR_swapoff, (long)path);
return syscall(SYS_swapoff, path);
}

View File

@ -3,5 +3,5 @@
int swapon(const char *path, int flags)
{
return syscall2(__NR_swapon, (long)path, flags);
return syscall(SYS_swapon, path, flags);
}

View File

@ -4,5 +4,5 @@ struct sysinfo;
int sysinfo(struct sysinfo *info)
{
return syscall1(__NR_sysinfo, (long)info);
return syscall(SYS_sysinfo, info);
}

View File

@ -3,5 +3,5 @@
int umount(const char *special)
{
return syscall2(__NR_umount2, (long)special, 0);
return syscall(SYS_umount2, special, 0);
}

View File

@ -3,5 +3,5 @@
int umount2(const char *special, int flags)
{
return syscall2(__NR_umount2, (long)special, flags);
return syscall(SYS_umount2, special, flags);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
uintptr_t __brk(uintptr_t newbrk)
{
return syscall1(__NR_brk, newbrk);
return syscall(SYS_brk, newbrk);
}

View File

@ -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;
}

View File

@ -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];

View File

@ -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);
}

View File

@ -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);
}

View File

@ -4,7 +4,7 @@
int __yield()
{
return syscall0(__NR_sched_yield);
return syscall(SYS_sched_yield);
}
weak_alias(__yield, sched_yield);

View File

@ -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);
}

View File

@ -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);

View File

@ -4,5 +4,5 @@
int uname(struct utsname *uts)
{
return syscall1(__NR_uname, (long)uts);
return syscall(SYS_uname, uts);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int mlockall(int flags)
{
return syscall1(__NR_mlockall, flags);
return syscall(SYS_mlockall, flags);
}

View File

@ -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
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int munlockall(void)
{
return syscall0(__NR_munlockall);
return syscall(SYS_munlockall);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -4,5 +4,5 @@
pid_t vfork(void)
{
/* vfork syscall cannot be made from C code */
return syscall0(__NR_fork);
return syscall(SYS_fork);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int kill(pid_t pid, int sig)
{
return syscall2(__NR_kill, pid, sig);
return syscall(SYS_kill, pid, sig);
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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);
}

View File

@ -3,5 +3,5 @@
int fchmod(int fd, mode_t mode)
{
return syscall2(__NR_fchmod, fd, mode);
return syscall(SYS_fchmod, fd, mode);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -3,5 +3,5 @@
mode_t umask(mode_t mode)
{
return syscall1(__NR_umask, mode);
return syscall(SYS_umask, mode);
}

View File

@ -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);
}

View File

@ -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. */

View File

@ -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;

View File

@ -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;
}

View File

@ -2,5 +2,5 @@
int __stdio_close(FILE *f)
{
return __syscall_close(f->fd);
return syscall(SYS_close, f->fd);
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -3,5 +3,5 @@
int remove(const char *path)
{
return __syscall_unlink(path);
return syscall(SYS_unlink, path);
}

View File

@ -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);
}

Some files were not shown because too many files have changed in this diff Show More