1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
3 * Syscall definitions for NOLIBC (those in man(2))
4 * Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
14 #include <asm/unistd.h>
15 #include <asm/signal.h> /* for SIGCHLD */
16 #include <asm/ioctls.h>
19 #include <linux/loop.h>
20 #include <linux/time.h>
21 #include <linux/auxvec.h>
22 #include <linux/fcntl.h> /* for O_* and AT_* */
23 #include <linux/stat.h> /* for statx() */
24 #include <linux/reboot.h> /* for LINUX_REBOOT_* */
25 #include <linux/prctl.h>
32 /* Functions in this file only describe syscalls. They're declared static so
33 * that the compiler usually decides to inline them while still being allowed
34 * to pass a pointer to one of their instances. Each syscall exists in two
36 * - the "internal" ones, which matches the raw syscall interface at the
37 * kernel level, which may sometimes slightly differ from the documented
38 * libc-level ones. For example most of them return either a valid value
39 * or -errno. All of these are prefixed with "sys_". They may be called
40 * by non-portable applications if desired.
42 * - the "exported" ones, whose interface must closely match the one
43 * documented in man(2), that applications are supposed to expect. These
44 * ones rely on the internal ones, and set errno.
46 * Each syscall will be defined with the two functions, sorted in alphabetical
47 * order applied to the exported names.
49 * In case of doubt about the relevance of a function here, only those which
50 * set errno should be defined here. Wrappers like those appearing in man(3)
51 * should not be placed here.
56 * int brk(void *addr);
57 * void *sbrk(intptr_t inc)
60 static __attribute__((unused))
61 void *sys_brk(void *addr)
63 return (void *)my_syscall1(__NR_brk, addr);
66 static __attribute__((unused))
69 void *ret = sys_brk(addr);
78 static __attribute__((unused))
79 void *sbrk(intptr_t inc)
83 /* first call to find current end */
84 if ((ret = sys_brk(0)) && (sys_brk(ret + inc) == ret + inc))
93 * int chdir(const char *path);
96 static __attribute__((unused))
97 int sys_chdir(const char *path)
99 return my_syscall1(__NR_chdir, path);
102 static __attribute__((unused))
103 int chdir(const char *path)
105 int ret = sys_chdir(path);
116 * int chmod(const char *path, mode_t mode);
119 static __attribute__((unused))
120 int sys_chmod(const char *path, mode_t mode)
123 return my_syscall4(__NR_fchmodat, AT_FDCWD, path, mode, 0);
124 #elif defined(__NR_chmod)
125 return my_syscall2(__NR_chmod, path, mode);
127 #error Neither __NR_fchmodat nor __NR_chmod defined, cannot implement sys_chmod()
131 static __attribute__((unused))
132 int chmod(const char *path, mode_t mode)
134 int ret = sys_chmod(path, mode);
145 * int chown(const char *path, uid_t owner, gid_t group);
148 static __attribute__((unused))
149 int sys_chown(const char *path, uid_t owner, gid_t group)
152 return my_syscall5(__NR_fchownat, AT_FDCWD, path, owner, group, 0);
153 #elif defined(__NR_chown)
154 return my_syscall3(__NR_chown, path, owner, group);
156 #error Neither __NR_fchownat nor __NR_chown defined, cannot implement sys_chown()
160 static __attribute__((unused))
161 int chown(const char *path, uid_t owner, gid_t group)
163 int ret = sys_chown(path, owner, group);
174 * int chroot(const char *path);
177 static __attribute__((unused))
178 int sys_chroot(const char *path)
180 return my_syscall1(__NR_chroot, path);
183 static __attribute__((unused))
184 int chroot(const char *path)
186 int ret = sys_chroot(path);
200 static __attribute__((unused))
201 int sys_close(int fd)
203 return my_syscall1(__NR_close, fd);
206 static __attribute__((unused))
209 int ret = sys_close(fd);
223 static __attribute__((unused))
226 return my_syscall1(__NR_dup, fd);
229 static __attribute__((unused))
232 int ret = sys_dup(fd);
243 * int dup2(int old, int new);
246 static __attribute__((unused))
247 int sys_dup2(int old, int new)
250 return my_syscall3(__NR_dup3, old, new, 0);
251 #elif defined(__NR_dup2)
252 return my_syscall2(__NR_dup2, old, new);
254 #error Neither __NR_dup3 nor __NR_dup2 defined, cannot implement sys_dup2()
258 static __attribute__((unused))
259 int dup2(int old, int new)
261 int ret = sys_dup2(old, new);
272 * int dup3(int old, int new, int flags);
276 static __attribute__((unused))
277 int sys_dup3(int old, int new, int flags)
279 return my_syscall3(__NR_dup3, old, new, flags);
282 static __attribute__((unused))
283 int dup3(int old, int new, int flags)
285 int ret = sys_dup3(old, new, flags);
297 * int execve(const char *filename, char *const argv[], char *const envp[]);
300 static __attribute__((unused))
301 int sys_execve(const char *filename, char *const argv[], char *const envp[])
303 return my_syscall3(__NR_execve, filename, argv, envp);
306 static __attribute__((unused))
307 int execve(const char *filename, char *const argv[], char *const envp[])
309 int ret = sys_execve(filename, argv, envp);
320 * void exit(int status);
323 static __attribute__((noreturn,unused))
324 void sys_exit(int status)
326 my_syscall1(__NR_exit, status & 255);
327 while(1); /* shut the "noreturn" warnings. */
330 static __attribute__((noreturn,unused))
331 void exit(int status)
342 static __attribute__((unused))
346 /* note: some archs only have clone() and not fork(). Different archs
347 * have a different API, but most archs have the flags on first arg and
348 * will not use the rest with no other flag.
350 return my_syscall5(__NR_clone, SIGCHLD, 0, 0, 0, 0);
351 #elif defined(__NR_fork)
352 return my_syscall0(__NR_fork);
354 #error Neither __NR_clone nor __NR_fork defined, cannot implement sys_fork()
359 static __attribute__((unused))
362 pid_t ret = sys_fork();
376 static __attribute__((unused))
377 int sys_fsync(int fd)
379 return my_syscall1(__NR_fsync, fd);
382 static __attribute__((unused))
385 int ret = sys_fsync(fd);
396 * int getdents64(int fd, struct linux_dirent64 *dirp, int count);
399 static __attribute__((unused))
400 int sys_getdents64(int fd, struct linux_dirent64 *dirp, int count)
402 return my_syscall3(__NR_getdents64, fd, dirp, count);
405 static __attribute__((unused))
406 int getdents64(int fd, struct linux_dirent64 *dirp, int count)
408 int ret = sys_getdents64(fd, dirp, count);
419 * uid_t geteuid(void);
422 static __attribute__((unused))
423 uid_t sys_geteuid(void)
425 #ifdef __NR_geteuid32
426 return my_syscall0(__NR_geteuid32);
428 return my_syscall0(__NR_geteuid);
432 static __attribute__((unused))
435 return sys_geteuid();
440 * pid_t getpgid(pid_t pid);
443 static __attribute__((unused))
444 pid_t sys_getpgid(pid_t pid)
446 return my_syscall1(__NR_getpgid, pid);
449 static __attribute__((unused))
450 pid_t getpgid(pid_t pid)
452 pid_t ret = sys_getpgid(pid);
463 * pid_t getpgrp(void);
466 static __attribute__((unused))
467 pid_t sys_getpgrp(void)
469 return sys_getpgid(0);
472 static __attribute__((unused))
475 return sys_getpgrp();
480 * pid_t getpid(void);
483 static __attribute__((unused))
484 pid_t sys_getpid(void)
486 return my_syscall0(__NR_getpid);
489 static __attribute__((unused))
497 * pid_t getppid(void);
500 static __attribute__((unused))
501 pid_t sys_getppid(void)
503 return my_syscall0(__NR_getppid);
506 static __attribute__((unused))
509 return sys_getppid();
514 * pid_t gettid(void);
517 static __attribute__((unused))
518 pid_t sys_gettid(void)
520 return my_syscall0(__NR_gettid);
523 static __attribute__((unused))
529 static unsigned long getauxval(unsigned long key);
532 * long getpagesize(void);
535 static __attribute__((unused))
536 long getpagesize(void)
540 ret = getauxval(AT_PAGESZ);
551 * int gettimeofday(struct timeval *tv, struct timezone *tz);
554 static __attribute__((unused))
555 int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
557 return my_syscall2(__NR_gettimeofday, tv, tz);
560 static __attribute__((unused))
561 int gettimeofday(struct timeval *tv, struct timezone *tz)
563 int ret = sys_gettimeofday(tv, tz);
574 * uid_t getuid(void);
577 static __attribute__((unused))
578 uid_t sys_getuid(void)
581 return my_syscall0(__NR_getuid32);
583 return my_syscall0(__NR_getuid);
587 static __attribute__((unused))
595 * int ioctl(int fd, unsigned long req, void *value);
598 static __attribute__((unused))
599 int sys_ioctl(int fd, unsigned long req, void *value)
601 return my_syscall3(__NR_ioctl, fd, req, value);
604 static __attribute__((unused))
605 int ioctl(int fd, unsigned long req, void *value)
607 int ret = sys_ioctl(fd, req, value);
617 * int kill(pid_t pid, int signal);
620 static __attribute__((unused))
621 int sys_kill(pid_t pid, int signal)
623 return my_syscall2(__NR_kill, pid, signal);
626 static __attribute__((unused))
627 int kill(pid_t pid, int signal)
629 int ret = sys_kill(pid, signal);
640 * int link(const char *old, const char *new);
643 static __attribute__((unused))
644 int sys_link(const char *old, const char *new)
647 return my_syscall5(__NR_linkat, AT_FDCWD, old, AT_FDCWD, new, 0);
648 #elif defined(__NR_link)
649 return my_syscall2(__NR_link, old, new);
651 #error Neither __NR_linkat nor __NR_link defined, cannot implement sys_link()
655 static __attribute__((unused))
656 int link(const char *old, const char *new)
658 int ret = sys_link(old, new);
669 * off_t lseek(int fd, off_t offset, int whence);
672 static __attribute__((unused))
673 off_t sys_lseek(int fd, off_t offset, int whence)
675 return my_syscall3(__NR_lseek, fd, offset, whence);
678 static __attribute__((unused))
679 off_t lseek(int fd, off_t offset, int whence)
681 off_t ret = sys_lseek(fd, offset, whence);
692 * int mkdir(const char *path, mode_t mode);
695 static __attribute__((unused))
696 int sys_mkdir(const char *path, mode_t mode)
699 return my_syscall3(__NR_mkdirat, AT_FDCWD, path, mode);
700 #elif defined(__NR_mkdir)
701 return my_syscall2(__NR_mkdir, path, mode);
703 #error Neither __NR_mkdirat nor __NR_mkdir defined, cannot implement sys_mkdir()
707 static __attribute__((unused))
708 int mkdir(const char *path, mode_t mode)
710 int ret = sys_mkdir(path, mode);
721 * int mknod(const char *path, mode_t mode, dev_t dev);
724 static __attribute__((unused))
725 long sys_mknod(const char *path, mode_t mode, dev_t dev)
728 return my_syscall4(__NR_mknodat, AT_FDCWD, path, mode, dev);
729 #elif defined(__NR_mknod)
730 return my_syscall3(__NR_mknod, path, mode, dev);
732 #error Neither __NR_mknodat nor __NR_mknod defined, cannot implement sys_mknod()
736 static __attribute__((unused))
737 int mknod(const char *path, mode_t mode, dev_t dev)
739 int ret = sys_mknod(path, mode, dev);
749 #define MAP_SHARED 0x01 /* Share changes */
750 #define MAP_PRIVATE 0x02 /* Changes are private */
751 #define MAP_SHARED_VALIDATE 0x03 /* share + validate extension flags */
755 #define MAP_FAILED ((void *)-1)
759 static __attribute__((unused))
760 void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd,
764 /* Function not implemented. */
765 return (void *)-ENOSYS;
770 #if defined(__NR_mmap2)
777 return (void *)my_syscall6(n, addr, length, prot, flags, fd, offset);
782 static __attribute__((unused))
783 void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
785 void *ret = sys_mmap(addr, length, prot, flags, fd, offset);
787 if ((unsigned long)ret >= -4095UL) {
788 SET_ERRNO(-(long)ret);
794 static __attribute__((unused))
795 int sys_munmap(void *addr, size_t length)
797 return my_syscall2(__NR_munmap, addr, length);
800 static __attribute__((unused))
801 int munmap(void *addr, size_t length)
803 int ret = sys_munmap(addr, length);
813 * int mount(const char *source, const char *target,
814 * const char *fstype, unsigned long flags,
817 static __attribute__((unused))
818 int sys_mount(const char *src, const char *tgt, const char *fst,
819 unsigned long flags, const void *data)
821 return my_syscall5(__NR_mount, src, tgt, fst, flags, data);
824 static __attribute__((unused))
825 int mount(const char *src, const char *tgt,
826 const char *fst, unsigned long flags,
829 int ret = sys_mount(src, tgt, fst, flags, data);
840 * int open(const char *path, int flags[, mode_t mode]);
843 static __attribute__((unused))
844 int sys_open(const char *path, int flags, mode_t mode)
847 return my_syscall4(__NR_openat, AT_FDCWD, path, flags, mode);
848 #elif defined(__NR_open)
849 return my_syscall3(__NR_open, path, flags, mode);
851 #error Neither __NR_openat nor __NR_open defined, cannot implement sys_open()
855 static __attribute__((unused))
856 int open(const char *path, int flags, ...)
861 if (flags & O_CREAT) {
864 va_start(args, flags);
865 mode = va_arg(args, int);
869 ret = sys_open(path, flags, mode);
880 * int prctl(int option, unsigned long arg2, unsigned long arg3,
881 * unsigned long arg4, unsigned long arg5);
884 static __attribute__((unused))
885 int sys_prctl(int option, unsigned long arg2, unsigned long arg3,
886 unsigned long arg4, unsigned long arg5)
888 return my_syscall5(__NR_prctl, option, arg2, arg3, arg4, arg5);
891 static __attribute__((unused))
892 int prctl(int option, unsigned long arg2, unsigned long arg3,
893 unsigned long arg4, unsigned long arg5)
895 int ret = sys_prctl(option, arg2, arg3, arg4, arg5);
906 * int pivot_root(const char *new, const char *old);
909 static __attribute__((unused))
910 int sys_pivot_root(const char *new, const char *old)
912 return my_syscall2(__NR_pivot_root, new, old);
915 static __attribute__((unused))
916 int pivot_root(const char *new, const char *old)
918 int ret = sys_pivot_root(new, old);
929 * int poll(struct pollfd *fds, int nfds, int timeout);
932 static __attribute__((unused))
933 int sys_poll(struct pollfd *fds, int nfds, int timeout)
935 #if defined(__NR_ppoll)
939 t.tv_sec = timeout / 1000;
940 t.tv_nsec = (timeout % 1000) * 1000000;
942 return my_syscall5(__NR_ppoll, fds, nfds, (timeout >= 0) ? &t : NULL, NULL, 0);
943 #elif defined(__NR_poll)
944 return my_syscall3(__NR_poll, fds, nfds, timeout);
946 #error Neither __NR_ppoll nor __NR_poll defined, cannot implement sys_poll()
950 static __attribute__((unused))
951 int poll(struct pollfd *fds, int nfds, int timeout)
953 int ret = sys_poll(fds, nfds, timeout);
964 * ssize_t read(int fd, void *buf, size_t count);
967 static __attribute__((unused))
968 ssize_t sys_read(int fd, void *buf, size_t count)
970 return my_syscall3(__NR_read, fd, buf, count);
973 static __attribute__((unused))
974 ssize_t read(int fd, void *buf, size_t count)
976 ssize_t ret = sys_read(fd, buf, count);
987 * int reboot(int cmd);
988 * <cmd> is among LINUX_REBOOT_CMD_*
991 static __attribute__((unused))
992 ssize_t sys_reboot(int magic1, int magic2, int cmd, void *arg)
994 return my_syscall4(__NR_reboot, magic1, magic2, cmd, arg);
997 static __attribute__((unused))
1000 int ret = sys_reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, cmd, 0);
1011 * int sched_yield(void);
1014 static __attribute__((unused))
1015 int sys_sched_yield(void)
1017 return my_syscall0(__NR_sched_yield);
1020 static __attribute__((unused))
1021 int sched_yield(void)
1023 int ret = sys_sched_yield();
1034 * int select(int nfds, fd_set *read_fds, fd_set *write_fds,
1035 * fd_set *except_fds, struct timeval *timeout);
1038 static __attribute__((unused))
1039 int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
1041 #if defined(__ARCH_WANT_SYS_OLD_SELECT) && !defined(__NR__newselect)
1042 struct sel_arg_struct {
1046 } arg = { .n = nfds, .r = rfds, .w = wfds, .e = efds, .t = timeout };
1047 return my_syscall1(__NR_select, &arg);
1048 #elif defined(__ARCH_WANT_SYS_PSELECT6) && defined(__NR_pselect6)
1052 t.tv_sec = timeout->tv_sec;
1053 t.tv_nsec = timeout->tv_usec * 1000;
1055 return my_syscall6(__NR_pselect6, nfds, rfds, wfds, efds, timeout ? &t : NULL, NULL);
1056 #elif defined(__NR__newselect) || defined(__NR_select)
1057 #ifndef __NR__newselect
1058 #define __NR__newselect __NR_select
1060 return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
1062 #error None of __NR_select, __NR_pselect6, nor __NR__newselect defined, cannot implement sys_select()
1066 static __attribute__((unused))
1067 int select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *timeout)
1069 int ret = sys_select(nfds, rfds, wfds, efds, timeout);
1080 * int setpgid(pid_t pid, pid_t pgid);
1083 static __attribute__((unused))
1084 int sys_setpgid(pid_t pid, pid_t pgid)
1086 return my_syscall2(__NR_setpgid, pid, pgid);
1089 static __attribute__((unused))
1090 int setpgid(pid_t pid, pid_t pgid)
1092 int ret = sys_setpgid(pid, pgid);
1103 * pid_t setsid(void);
1106 static __attribute__((unused))
1107 pid_t sys_setsid(void)
1109 return my_syscall0(__NR_setsid);
1112 static __attribute__((unused))
1115 pid_t ret = sys_setsid();
1124 #if defined(__NR_statx)
1126 * int statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf);
1129 static __attribute__((unused))
1130 int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf)
1132 return my_syscall5(__NR_statx, fd, path, flags, mask, buf);
1135 static __attribute__((unused))
1136 int statx(int fd, const char *path, int flags, unsigned int mask, struct statx *buf)
1138 int ret = sys_statx(fd, path, flags, mask, buf);
1149 * int stat(const char *path, struct stat *buf);
1150 * Warning: the struct stat's layout is arch-dependent.
1153 #if defined(__NR_statx) && !defined(__NR_newfstatat) && !defined(__NR_stat)
1155 * Maybe we can just use statx() when available for all architectures?
1157 static __attribute__((unused))
1158 int sys_stat(const char *path, struct stat *buf)
1163 ret = sys_statx(AT_FDCWD, path, AT_NO_AUTOMOUNT, STATX_BASIC_STATS, &statx);
1164 buf->st_dev = ((statx.stx_dev_minor & 0xff)
1165 | (statx.stx_dev_major << 8)
1166 | ((statx.stx_dev_minor & ~0xff) << 12));
1167 buf->st_ino = statx.stx_ino;
1168 buf->st_mode = statx.stx_mode;
1169 buf->st_nlink = statx.stx_nlink;
1170 buf->st_uid = statx.stx_uid;
1171 buf->st_gid = statx.stx_gid;
1172 buf->st_rdev = ((statx.stx_rdev_minor & 0xff)
1173 | (statx.stx_rdev_major << 8)
1174 | ((statx.stx_rdev_minor & ~0xff) << 12));
1175 buf->st_size = statx.stx_size;
1176 buf->st_blksize = statx.stx_blksize;
1177 buf->st_blocks = statx.stx_blocks;
1178 buf->st_atim.tv_sec = statx.stx_atime.tv_sec;
1179 buf->st_atim.tv_nsec = statx.stx_atime.tv_nsec;
1180 buf->st_mtim.tv_sec = statx.stx_mtime.tv_sec;
1181 buf->st_mtim.tv_nsec = statx.stx_mtime.tv_nsec;
1182 buf->st_ctim.tv_sec = statx.stx_ctime.tv_sec;
1183 buf->st_ctim.tv_nsec = statx.stx_ctime.tv_nsec;
1187 static __attribute__((unused))
1188 int sys_stat(const char *path, struct stat *buf)
1190 struct sys_stat_struct stat;
1193 #ifdef __NR_newfstatat
1194 /* only solution for arm64 */
1195 ret = my_syscall4(__NR_newfstatat, AT_FDCWD, path, &stat, 0);
1196 #elif defined(__NR_stat)
1197 ret = my_syscall2(__NR_stat, path, &stat);
1199 #error Neither __NR_newfstatat nor __NR_stat defined, cannot implement sys_stat()
1201 buf->st_dev = stat.st_dev;
1202 buf->st_ino = stat.st_ino;
1203 buf->st_mode = stat.st_mode;
1204 buf->st_nlink = stat.st_nlink;
1205 buf->st_uid = stat.st_uid;
1206 buf->st_gid = stat.st_gid;
1207 buf->st_rdev = stat.st_rdev;
1208 buf->st_size = stat.st_size;
1209 buf->st_blksize = stat.st_blksize;
1210 buf->st_blocks = stat.st_blocks;
1211 buf->st_atim.tv_sec = stat.st_atime;
1212 buf->st_atim.tv_nsec = stat.st_atime_nsec;
1213 buf->st_mtim.tv_sec = stat.st_mtime;
1214 buf->st_mtim.tv_nsec = stat.st_mtime_nsec;
1215 buf->st_ctim.tv_sec = stat.st_ctime;
1216 buf->st_ctim.tv_nsec = stat.st_ctime_nsec;
1221 static __attribute__((unused))
1222 int stat(const char *path, struct stat *buf)
1224 int ret = sys_stat(path, buf);
1235 * int symlink(const char *old, const char *new);
1238 static __attribute__((unused))
1239 int sys_symlink(const char *old, const char *new)
1241 #ifdef __NR_symlinkat
1242 return my_syscall3(__NR_symlinkat, old, AT_FDCWD, new);
1243 #elif defined(__NR_symlink)
1244 return my_syscall2(__NR_symlink, old, new);
1246 #error Neither __NR_symlinkat nor __NR_symlink defined, cannot implement sys_symlink()
1250 static __attribute__((unused))
1251 int symlink(const char *old, const char *new)
1253 int ret = sys_symlink(old, new);
1264 * mode_t umask(mode_t mode);
1267 static __attribute__((unused))
1268 mode_t sys_umask(mode_t mode)
1270 return my_syscall1(__NR_umask, mode);
1273 static __attribute__((unused))
1274 mode_t umask(mode_t mode)
1276 return sys_umask(mode);
1281 * int umount2(const char *path, int flags);
1284 static __attribute__((unused))
1285 int sys_umount2(const char *path, int flags)
1287 return my_syscall2(__NR_umount2, path, flags);
1290 static __attribute__((unused))
1291 int umount2(const char *path, int flags)
1293 int ret = sys_umount2(path, flags);
1304 * int unlink(const char *path);
1307 static __attribute__((unused))
1308 int sys_unlink(const char *path)
1310 #ifdef __NR_unlinkat
1311 return my_syscall3(__NR_unlinkat, AT_FDCWD, path, 0);
1312 #elif defined(__NR_unlink)
1313 return my_syscall1(__NR_unlink, path);
1315 #error Neither __NR_unlinkat nor __NR_unlink defined, cannot implement sys_unlink()
1319 static __attribute__((unused))
1320 int unlink(const char *path)
1322 int ret = sys_unlink(path);
1333 * pid_t wait(int *status);
1334 * pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
1335 * pid_t waitpid(pid_t pid, int *status, int options);
1338 static __attribute__((unused))
1339 pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
1341 return my_syscall4(__NR_wait4, pid, status, options, rusage);
1344 static __attribute__((unused))
1345 pid_t wait(int *status)
1347 pid_t ret = sys_wait4(-1, status, 0, NULL);
1356 static __attribute__((unused))
1357 pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage)
1359 pid_t ret = sys_wait4(pid, status, options, rusage);
1369 static __attribute__((unused))
1370 pid_t waitpid(pid_t pid, int *status, int options)
1372 pid_t ret = sys_wait4(pid, status, options, NULL);
1383 * ssize_t write(int fd, const void *buf, size_t count);
1386 static __attribute__((unused))
1387 ssize_t sys_write(int fd, const void *buf, size_t count)
1389 return my_syscall3(__NR_write, fd, buf, count);
1392 static __attribute__((unused))
1393 ssize_t write(int fd, const void *buf, size_t count)
1395 ssize_t ret = sys_write(fd, buf, count);
1406 * int memfd_create(const char *name, unsigned int flags);
1409 static __attribute__((unused))
1410 int sys_memfd_create(const char *name, unsigned int flags)
1412 return my_syscall2(__NR_memfd_create, name, flags);
1415 static __attribute__((unused))
1416 int memfd_create(const char *name, unsigned int flags)
1418 ssize_t ret = sys_memfd_create(name, flags);
1427 /* make sure to include all global symbols */
1430 #endif /* _NOLIBC_SYS_H */