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);
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;
}
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;
}
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;
}
#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
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
}
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
}
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
}
#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
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
}
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
}
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
}
int brk(void *end)
{
- return -(syscall1(__NR_brk, (long)end) == -1);
+ return -(syscall(SYS_brk, end) == -1);
}
int chroot(const char *path)
{
- return syscall1(__NR_chroot, (long)path);
+ return syscall(SYS_chroot, path);
}
int epoll_create(int size)
{
- return syscall1(__NR_epoll_create, size);
+ return syscall(SYS_epoll_create, size);
}
int epoll_create1(int flags)
{
- return syscall1(__NR_epoll_create1, flags);
+ return syscall(SYS_epoll_create1, flags);
}
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);
}
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);
}
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);
}
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);
}
int inotify_init()
{
- return syscall0(__NR_inotify_init);
+ return syscall(SYS_inotify_init);
}
int inotify_init1(int flags)
{
- return syscall1(__NR_inotify_init1, flags);
+ return syscall(SYS_inotify_init1, flags);
}
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);
}
int klogctl (int type, char *buf, int len)
{
- return syscall3(__NR_syslog, type, (long)buf, len);
+ return syscall(SYS_syslog, type, buf, len);
}
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);
}
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]);
}
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);
}
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);
int setgroups(int count, const gid_t list[])
{
- return syscall2(__NR_setgroups, count, (long)list);
+ return syscall(SYS_setgroups, count, list);
}
int sethostname(const char *name, size_t len)
{
- return syscall2(__NR_sethostname, (long)name, len);
+ return syscall(SYS_sethostname, name, len);
}
int settimeofday(const struct timeval *tv, void *tz)
{
- return syscall2(__NR_settimeofday, (long)tv, 0);
+ return syscall(SYS_settimeofday, tv, 0);
}
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);
}
int swapoff(const char *path)
{
- return syscall1(__NR_swapoff, (long)path);
+ return syscall(SYS_swapoff, path);
}
int swapon(const char *path, int flags)
{
- return syscall2(__NR_swapon, (long)path, flags);
+ return syscall(SYS_swapon, path, flags);
}
int sysinfo(struct sysinfo *info)
{
- return syscall1(__NR_sysinfo, (long)info);
+ return syscall(SYS_sysinfo, info);
}
int umount(const char *special)
{
- return syscall2(__NR_umount2, (long)special, 0);
+ return syscall(SYS_umount2, special, 0);
}
int umount2(const char *special, int flags)
{
- return syscall2(__NR_umount2, (long)special, flags);
+ return syscall(SYS_umount2, special, flags);
}
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);
}
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);
}
uintptr_t __brk(uintptr_t newbrk)
{
- return syscall1(__NR_brk, newbrk);
+ return syscall(SYS_brk, newbrk);
}
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;
}
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];
#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);
}
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);
}
int __yield()
{
- return syscall0(__NR_sched_yield);
+ return syscall(SYS_sched_yield);
}
weak_alias(__yield, sched_yield);
int setpriority(int which, id_t who, int prio)
{
- return syscall3(__NR_getpriority, which, who, prio);
+ return syscall(SYS_getpriority, which, who, prio);
}
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);
int uname(struct utsname *uts)
{
- return syscall1(__NR_uname, (long)uts);
+ return syscall(SYS_uname, uts);
}
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);
int mlock(const void *addr, size_t len)
{
- return syscall2(__NR_mlock, (long)addr, len);
+ return syscall(SYS_mlock, addr, len);
}
int mlockall(int flags)
{
- return syscall1(__NR_mlockall, flags);
+ return syscall(SYS_mlockall, flags);
}
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
}
int mprotect(void *addr, size_t len, int prot)
{
- return syscall3(__NR_mprotect, (long)addr, len, prot);
+ return syscall(SYS_mprotect, addr, len, prot);
}
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);
int msync(void *start, size_t len, int flags)
{
- return syscall3(__NR_msync, (long)start, len, flags);
+ return syscall(SYS_msync, start, len, flags);
}
int munlock(const void *addr, size_t len)
{
- return syscall2(__NR_munlock, (long)addr, len);
+ return syscall(SYS_munlock, addr, len);
}
int munlockall(void)
{
- return syscall0(__NR_munlockall);
+ return syscall(SYS_munlockall);
}
int __munmap(void *start, size_t len)
{
- return syscall2(__NR_munmap, (long)start, len);
+ return syscall(SYS_munmap, start, len);
}
weak_alias(__munmap, munmap);
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);
}
{
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);
pid_t vfork(void)
{
/* vfork syscall cannot be made from C code */
- return syscall0(__NR_fork);
+ return syscall(SYS_fork);
}
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);
}
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);
}
{
int r;
CANCELPT_BEGIN;
- r = syscall3(__NR_poll, (long)fds, n, timeout);
+ r = syscall(SYS_poll, fds, n, timeout);
CANCELPT_END;
return r;
}
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;
}
{
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;
}
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);
}
int kill(pid_t pid, int sig)
{
- return syscall2(__NR_kill, pid, sig);
+ return syscall(SYS_kill, pid, 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;
}
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);
}
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;
return -1;
}
}
- return syscall2(__NR_sigaltstack, (long)ss, (long)old);
+ return syscall(SYS_sigaltstack, ss, 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)
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);
}
int chmod(const char *path, mode_t mode)
{
- return syscall2(__NR_chmod, (long)path, mode);
+ return syscall(SYS_chmod, path, mode);
}
int fchmod(int fd, mode_t mode)
{
- return syscall2(__NR_fchmod, fd, mode);
+ return syscall(SYS_fchmod, fd, mode);
}
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);
}
int fstat(int fd, struct stat *buf)
{
- return syscall2(__NR_fstat, fd, (long)buf);
+ return syscall(SYS_fstat, fd, buf);
}
LFS64(fstat);
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);
int fstatvfs(int fd, struct statvfs *buf)
{
- return syscall2(__NR_fstatfs, fd, (long)buf);
+ return syscall(SYS_fstatfs, fd, buf);
}
weak_alias(fstatvfs, fstatfs);
int lstat(const char *path, struct stat *buf)
{
- return syscall2(__NR_lstat, (long)path, (long)buf);
+ return syscall(SYS_lstat, path, buf);
}
LFS64(lstat);
int mkdir(const char *path, mode_t mode)
{
- return syscall2(__NR_mkdir, (long)path, mode);
+ return syscall(SYS_mkdir, path, 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);
}
/* 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);
}
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);
}
int stat(const char *path, struct stat *buf)
{
- return syscall2(__NR_stat, (long)path, (long)buf);
+ return syscall(SYS_stat, path, buf);
}
LFS64(stat);
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);
mode_t umask(mode_t mode)
{
- return syscall1(__NR_umask, mode);
+ return syscall(SYS_umask, mode);
}
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);
}
/* 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;
/* 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. */
{
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;
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;
}
int __stdio_close(FILE *f)
{
- return __syscall_close(f->fd);
+ return syscall(SYS_close, f->fd);
}
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);
}
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)
{
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);
}
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;
}
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;
}
int remove(const char *path)
{
- return __syscall_unlink(path);
+ return syscall(SYS_unlink, path);
}
int rename(const char *old, const char *new)
{
- return syscall2(__NR_rename, (long)old, (long)new);
+ return syscall(SYS_rename, old, new);
}
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);
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);
}
-
__unmapself(self->map_base, self->map_size);
}
- __syscall_exit(0);
+ syscall(SYS_exit, 0);
}
static void docancel(struct pthread *self)
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;
}
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;
}
int clock_getres(clockid_t clk, struct timespec *ts)
{
- return syscall2(__NR_clock_getres, clk, (long)ts);
+ return syscall(SYS_clock_getres, clk, ts);
}
int clock_gettime(clockid_t clk, struct timespec *ts)
{
- return syscall2(__NR_clock_gettime, clk, (long)ts);
+ return syscall(SYS_clock_gettime, clk, ts);
}
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);
}
{
int ret;
CANCELPT_BEGIN;
- ret = syscall2(__NR_nanosleep, (long)req, (long)rem);
+ ret = syscall(SYS_nanosleep, req, rem);
CANCELPT_END;
return ret;
}
clock_t times(struct tms *tms)
{
- return syscall1(__NR_times, (long)tms);
+ return syscall(SYS_times, tms);
}
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);
}
int access(const char *filename, int amode)
{
- return syscall2(__NR_access, (long)filename, amode);
+ return syscall(SYS_access, filename, amode);
}
unsigned alarm(unsigned seconds)
{
- return syscall1(__NR_alarm, seconds);
+ return syscall(SYS_alarm, seconds);
}
int chdir(const char *path)
{
- return syscall1(__NR_chdir, (long)path);
+ return syscall(SYS_chdir, path);
}
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);
}
int close(int fd)
{
- int ret = __syscall_close(fd);
+ int ret = syscall(SYS_close, fd);
CANCELPT_BEGIN;
CANCELPT_END;
return ret;
int dup(int fd)
{
- return syscall1(__NR_dup, fd);
+ return syscall(SYS_dup, fd);
}
int dup2(int old, int new)
{
- return __syscall_dup2(old, new);
+ return syscall(SYS_dup2, old, new);
}
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);
}
int fchdir(int fd)
{
- return syscall1(__NR_fchdir, fd);
+ return syscall(SYS_fchdir, fd);
}
int fchown(int fd, uid_t uid, gid_t gid)
{
- return syscall3(__NR_fchown, fd, uid, gid);
+ return syscall(SYS_fchown, fd, uid, gid);
}
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);
}
int fsync(int fd)
{
- //return syscall1(__NR_fsync, fd);
+ //return syscall(SYS_fsync, fd);
return 0;
}
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;
}
gid_t getegid(void)
{
- return syscall0(__NR_getegid);
+ return syscall(SYS_getegid);
}
uid_t geteuid(void)
{
- return syscall0(__NR_geteuid);
+ return syscall(SYS_geteuid);
}
gid_t getgid(void)
{
- return syscall0(__NR_getgid);
+ return syscall(SYS_getgid);
}
int getgroups(int count, gid_t list[])
{
- return syscall2(__NR_getgroups, count, (long)list);
+ return syscall(SYS_getgroups, count, list);
}
pid_t getpgid(pid_t pid)
{
- return syscall1(__NR_getpgid, pid);
+ return syscall(SYS_getpgid, pid);
}
pid_t getpgrp(void)
{
- return syscall0(__NR_getpgrp);
+ return syscall(SYS_getpgrp);
}
pid_t getpid(void)
{
- return syscall0(__NR_getpid);
+ return syscall(SYS_getpid);
}
pid_t getppid(void)
{
- return syscall0(__NR_getppid);
+ return syscall(SYS_getppid);
}
pid_t getsid(pid_t pid)
{
- return syscall1(__NR_getsid, pid);
+ return syscall(SYS_getsid, pid);
}
uid_t getuid(void)
{
- return syscall0(__NR_getuid);
+ return syscall(SYS_getuid);
}
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);
}
int link(const char *existing, const char *new)
{
- return syscall2(__NR_link, (long)existing, (long)new);
+ return syscall(SYS_link, existing, new);
}
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);
}
{
#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
}
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
{
int r;
CANCELPT_BEGIN;
- r = syscall0(__NR_pause);
+ r = syscall(SYS_pause);
CANCELPT_END;
return r;
}
int pipe(int fd[2])
{
- return syscall1(__NR_pipe, (long)fd);
+ return syscall(SYS_pipe, fd);
}
{
ssize_t r;
CANCELPT_BEGIN;
- r = __syscall_read(fd, buf, count);
+ r = syscall(SYS_read, fd, buf, count);
CANCELPT_END;
return r;
}
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);
}
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);
}
{
ssize_t r;
CANCELPT_BEGIN;
- r = syscall3(__NR_readv, fd, (long)iov, count);
+ r = syscall(SYS_readv, fd, iov, count);
CANCELPT_END;
return r;
}
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);
}
int rmdir(const char *path)
{
- return syscall1(__NR_rmdir, (long)path);
+ return syscall(SYS_rmdir, path);
}
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);
}
pid_t setpgid(pid_t pid, pid_t pgid)
{
- return syscall2(__NR_setpgid, pid, pgid);
+ return syscall(SYS_setpgid, pid, pgid);
}
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);
}
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);
}
pid_t setsid(void)
{
- return syscall0(__NR_setsid);
+ return syscall(SYS_setsid);
}
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);
}
int symlink(const char *existing, const char *new)
{
- return syscall2(__NR_symlink, (long)existing, (long)new);
+ return syscall(SYS_symlink, existing, new);
}
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);
}
void sync(void)
{
- syscall0(__NR_sync);
+ syscall(SYS_sync);
}
int unlink(const char *path)
{
- return __syscall_unlink(path);
+ return syscall(SYS_unlink, path);
}
int unlinkat(int fd, const char *path, int flag)
{
- return syscall3(__NR_unlinkat, fd, (long)path, flag);
+ return syscall(SYS_unlinkat, fd, path, flag);
}
{
int r;
CANCELPT_BEGIN;
- r = __syscall_write(fd, buf, count);
+ r = syscall(SYS_write, fd, buf, count);
CANCELPT_END;
return r;
}
{
ssize_t r;
CANCELPT_BEGIN;
- r = syscall3(__NR_writev, fd, (long)iov, count);
+ r = syscall(SYS_writev, fd, iov, count);
CANCELPT_END;
return r;
}