diff options
79 files changed, 382 insertions, 588 deletions
diff --git a/.gitmodules b/.gitmodules index eeeb9819..ef83fe40 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ +======= [submodule "test"] path = tests url = git@github.com:jkaivo/libc-tests.git diff --git a/src/_syscall.h b/src/_syscall.h new file mode 100644 index 00000000..f29c2a58 --- /dev/null +++ b/src/_syscall.h @@ -0,0 +1,122 @@ +#ifndef ___SYSCALL_H__ +#define ___SYSCALL_H__ + +#include <errno.h> +#ifndef ENOSYS +#include "errno/ENOSYS.c" +#endif + +#define SYSCALL(_name, _type, _err, _a1, _a2, _a3, _a4, _a5, _a6) \ + static int _scno = -2; \ + if (_scno == -2) { \ + _scno = __syscall_lookup(_name); \ + } \ + long _ret = __syscall(_scno, _a1, _a2, _a3, _a4, _a5, _a6); \ + if (_ret < 0) { \ + errno = -_ret; \ + return _err; \ + } \ + return (_type)_ret + +#define SYSCALL_NUMBER(_var, _name, _notfound) \ + static long _var = -2; \ + do { \ + if (_var == -2) { \ + (_var) = __syscall_lookup(_name); \ + } \ + if (_var == -1) { \ + errno = ENOSYS; \ + return (_notfound); } \ + } while (0) + +long __syscall(long __number, ...); + +#if defined __linux__ && defined __x86_64__ +#define __sys_alarm 37 +#define __sys_brk 12 +#define __sys_chdir 80 +#define __sys_chmod 90 +#define __sys_chown 92 +#define __sys_chroot 161 +#define __sys_clock_adjtime 305 +#define __sys_clock_getres 229 +#define __sys_clock_gettime 228 +#define __sys_clock_nanosleep 230 +#define __sys_clock_settime 227 +#define __sys_close 3 +#define __sys_dup 32 +#define __sys_dup2 33 +#define __sys_execve 59 +#define __sys_execveat 322 +#define __sys_exit 60 +#define __sys_fchdir 81 +#define __sys_fchmod 91 +#define __sys_fchmodat 268 +#define __sys_fchown 93 +#define __sys_fchownat 260 +#define __sys_fcntl 72 +#define __sys_flock 73 +#define __sys_fork 57 +#define __sys_fstat 5 +#define __sys_fstatfs 138 +#define __sys_fsync 74 +#define __sys_ftruncate 77 +#define __sys_getcwd 79 +#define __sys_getegid 108 +#define __sys_geteuid 107 +#define __sys_getgid 104 +#define __sys_getgroups 115 +#define __sys_getpgid 121 +#define __sys_getpgrp 111 +#define __sys_getpid 39 +#define __sys_getppid 110 +#define __sys_getsid 124 +#define __sys_getuid 102 +#define __sys_kill 62 +#define __sys_link 86 +#define __sys_linkat 265 +#define __sys_lseek 8 +#define __sys_lstat 6 +#define __sys_mkdir 83 +#define __sys_mkdirat 258 +#define __sys_mknod 133 +#define __sys_mknodat 259 +#define __sys_mmap 9 +#define __sys_modify_ldt 154 +#define __sys_munmap 11 +#define __sys_open 2 +#define __sys_openat 257 +#define __sys_pause 34 +#define __sys_pipe 22 +#define __sys_read 0 +#define __sys_readlink 89 +#define __sys_readlinkat 267 +#define __sys_rename 82 +#define __sys_renameat 264 +#define __sys_rmdir 84 +#define __sys_setgid 106 +#define __sys_setpgid 109 +#define __sys_setregid 114 +#define __sys_setresgid 119 +#define __sys_setresuid 117 +#define __sys_setreuid 113 +#define __sys_setsid 112 +#define __sys_setuid 105 +#define __sys_stat 4 +#define __sys_statfs 137 +#define __sys_swapoff 168 +#define __sys_symlink 88 +#define __sys_symlinkat 266 +#define __sys_time 201 +#define __sys_umask 95 +#define __sys_uname 63 +#define __sys_unlink 87 +#define __sys_unlinkat 263 +#define __sys_wait4 61 +#define __sys_waitid 247 +#define __sys_write 1 +#endif + +#define __syscall_lookup(_name) (__sys_##_name) + +#endif diff --git a/src/dirent/closedir.c b/src/dirent/closedir.c index 60ea8a57..c12abfff 100644 --- a/src/dirent/closedir.c +++ b/src/dirent/closedir.c @@ -1,11 +1,14 @@ #include <dirent.h> #include "nonstd/assert.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int closedir(DIR *dirp) { + /* ASSERT_NONNULL(dirp); - SYSCALL("closedir", int, -1, dirp, 0, 0, 0, 0, 0); + SYSCALL(closedir, int, -1, dirp, 0, 0, 0, 0, 0); + */ + return -1; } /* POSIX(1) diff --git a/src/fcntl/fcntl.c b/src/fcntl/fcntl.c index b02745e9..a588ef54 100644 --- a/src/fcntl/fcntl.c +++ b/src/fcntl/fcntl.c @@ -2,11 +2,11 @@ #include <fcntl.h> #include "errno.h" #include "stdarg.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int fcntl(int fildes, int cmd, ...) { - SYSCALL_NUMBER(scno, "fcntl", -1); + SYSCALL_NUMBER(scno, fcntl, -1); int r = -ENOSYS; enum { NONE, INT, FLOCK } arg = NONE; diff --git a/src/fcntl/open.c b/src/fcntl/open.c index 07bf7f6d..15cee2e4 100644 --- a/src/fcntl/open.c +++ b/src/fcntl/open.c @@ -3,11 +3,11 @@ #include "sys/stat.h" /* OH */ #include "errno.h" #include "stdarg.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int open(const char *path, int oflag, ...) { - SYSCALL_NUMBER(scno, "open", -1); + SYSCALL_NUMBER(scno, open, -1); mode_t mode = 0; if (oflag & O_CREAT) { diff --git a/src/math/_tgmath.h b/src/math/_tgmath.h index 950fbdee..a84614a9 100644 --- a/src/math/_tgmath.h +++ b/src/math/_tgmath.h @@ -33,4 +33,35 @@ #define TYPE double #define TGHUGE HUGE_VAL +#ifndef FP_ZERO +#include "FP_ZERO.c" +#endif + +#ifndef FP_INFINITE +#include "FP_INFINITE.c" +#endif + +#ifndef FP_NAN +#include "FP_NAN.c" +#endif + +#ifndef NAN +#include "NAN.c" +#endif + +#ifndef INFINITY +#include "INFINITY.c" +#endif + +#undef feraiseexcept +#define feraiseexcept(_) + +#ifndef fpclassify +#include "fpclassify.c" +#endif + +#ifndef signbit +#include "signbit.c" +#endif + #endif diff --git a/src/nonstd/ENOSYS.ref b/src/nonstd/ENOSYS.ref deleted file mode 100644 index 79435d21..00000000 --- a/src/nonstd/ENOSYS.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include <nonstd/syscall.h> -REFERENCE(errno/ENOSYS.c) diff --git a/src/nonstd/LIBC_INTERNAL.c b/src/nonstd/LIBC_INTERNAL.c index 578688ec..a00a0c98 100644 --- a/src/nonstd/LIBC_INTERNAL.c +++ b/src/nonstd/LIBC_INTERNAL.c @@ -1,9 +1,6 @@ #include <nonstd/internal.h> typedef enum { - /* nonstd/syscall.h */ - SYSCALL_LOOKUP, - /* errno.h */ ERRNO, @@ -17,13 +14,4 @@ typedef enum { CTYPE, TOLOWER, TOUPPER, - - /* stdio.h */ - FILE_STREAMS, - PRINTF, - SCANF, - - /* stdlib.h */ - ATEXIT, - RAND } LIBC_INTERNAL; diff --git a/src/nonstd/SYSCALL.c b/src/nonstd/SYSCALL.c deleted file mode 100644 index 4f4ce61a..00000000 --- a/src/nonstd/SYSCALL.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <nonstd/syscall.h> - -#define SYSCALL(_name, _type, _err, _a1, _a2, _a3, _a4, _a5, _a6) \ - static int _scno = -2; \ - if (_scno == -2) { _scno = ((long (*)(const char *))__libc(SYSCALL_LOOKUP))(_name); } \ - long _ret = __syscall(_scno, _a1, _a2, _a3, _a4, _a5, _a6); \ - if (_ret < 0) { \ - errno = -_ret; \ - return _err; \ - } \ - return (_type)_ret diff --git a/src/nonstd/SYSCALL_NUMBER.c b/src/nonstd/SYSCALL_NUMBER.c deleted file mode 100644 index 10f2aeeb..00000000 --- a/src/nonstd/SYSCALL_NUMBER.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <nonstd/syscall.h> - -#define SYSCALL_NUMBER(_var, _name, _notfound) \ - static long _var = -2; do { \ - if (_var == -2) { (_var) = ((long (*)(char*))__libc(SYSCALL_LOOKUP))(_name); } \ - if (_var == -1) { errno = ENOSYS; return (_notfound); } \ - } while (0) diff --git a/src/nonstd/__libc.c b/src/nonstd/__libc.c index 9471558d..752dcab0 100644 --- a/src/nonstd/__libc.c +++ b/src/nonstd/__libc.c @@ -4,13 +4,11 @@ #include "../stdio/_stdio.h" #include "_locale.h" -#include "_syscall.h" void *__libc(LIBC_INTERNAL variable) { extern void *__libc_per_thread(LIBC_INTERNAL __variable); static struct __locale_t locale; - static struct __FILE file_streams[FOPEN_MAX]; void *r = (void*)0; @@ -61,14 +59,6 @@ void *__libc(LIBC_INTERNAL variable) r = &(((struct __locale_t*)r)->mn); break; - case SYSCALL_LOOKUP: - r = (void*)__syscall_lookup; - break; - - case FILE_STREAMS: - r = file_streams; - break; - case LOAD_LOCALE: r = (void*)(__load_locale); break; diff --git a/src/nonstd/__libc_start.c b/src/nonstd/__libc_start.c index 4b0b773e..d8fd5875 100644 --- a/src/nonstd/__libc_start.c +++ b/src/nonstd/__libc_start.c @@ -8,33 +8,32 @@ #include "unistd.h" #else #define DEFAULT_LOCALE "C" -#include "nonstd/syscall.h" +#include "../_syscall.h" #include "../termios/NCCS.c" #include "../termios/cc_t.c" #include "../termios/tcflag_t.c" #include "../termios/struct_termios.c" static struct termios __tios; -#define isatty(fd) (__syscall(__lookup("tcgetattr"), fd, &__tios) == 0) +#define isatty(fd) (__syscall(__syscall_lookup(tcgetattr), fd, &__tios) == 0) #endif void __libc_start(int argc, char **argv) { extern int main(int, char*[]); - struct __FILE *files = __libc(FILE_STREAMS); - stdin = files + 0; + stdin = __stdio.FILES + 0; stdin->fd = 0; - freopen(NULL, "r", stdin); + /* freopen(", "r", stdin); */ setvbuf(stdin, NULL, isatty(0) ? _IOLBF : _IOFBF, BUFSIZ); - stdout = files + 1; + stdout = __stdio.FILES + 1; stdout->fd = 1; - freopen(NULL, "w", stdout); + /* freopen(NULL, "w", stdout); */ setvbuf(stdin, NULL, isatty(1) ? _IOLBF : _IOFBF, BUFSIZ); - stderr = files + 2; + stderr = __stdio.FILES + 2; stderr->fd = 2; - freopen(NULL, "w", stderr); + /* freopen(NULL, "w", stderr); */ setvbuf(stderr, NULL, _IONBF, 0); stdin->next = stdout; @@ -43,8 +42,7 @@ void __libc_start(int argc, char **argv) stdout->prev = stdin; stderr->prev = stdout; - setlocale(LC_ALL, DEFAULT_LOCALE); - + /* setlocale(LC_ALL, DEFAULT_LOCALE); */ exit(main(argc, argv)); } diff --git a/src/nonstd/__lookup.c b/src/nonstd/__lookup.c deleted file mode 100644 index dca2f6a9..00000000 --- a/src/nonstd/__lookup.c +++ /dev/null @@ -1,3 +0,0 @@ -#include <nonstd/syscall.h> - -#define __lookup(_name) ((long (*)(const char *))__libc(SYSCALL_LOOKUP))(_name) diff --git a/src/nonstd/__syscall.c b/src/nonstd/__syscall.c deleted file mode 100644 index a1d0d1ed..00000000 --- a/src/nonstd/__syscall.c +++ /dev/null @@ -1,4 +0,0 @@ -#include <nonstd/syscall.h> - -long __syscall(long number, ...) -; diff --git a/src/nonstd/_syscall.h b/src/nonstd/_syscall.h deleted file mode 100644 index 9d9264c1..00000000 --- a/src/nonstd/_syscall.h +++ /dev/null @@ -1,357 +0,0 @@ -#include "string.h" - -static long __syscall_lookup(const char *name) -{ - #ifdef __linux__ - size_t i; - - struct { - long num; - char *name; - } syscalls[] = { - { 43, "accept" }, - { 288, "accept4" }, - { 21, "access" }, - { 163, "acct" }, - { 248, "add_key" }, - { 159, "adjtimex" }, - { 183, "afs_syscall" }, - { 37, "alarm" }, - { 158, "arch_prctl" }, - { 49, "bind" }, - { 321, "bpf" }, - { 12, "brk" }, - { 125, "capget" }, - { 126, "capset" }, - { 80, "chdir" }, - { 90, "chmod" }, - { 92, "chown" }, - { 161, "chroot" }, - { 305, "clock_adjtime" }, - { 229, "clock_getres" }, - { 228, "clock_gettime" }, - { 230, "clock_nanosleep" }, - { 227, "clock_settime" }, - { 56, "clone" }, - { 3, "close" }, - { 42, "connect" }, - { 326, "copy_file_range" }, - { 85, "creat" }, - { 174, "create_module" }, - { 176, "delete_module" }, - { 32, "dup" }, - { 33, "dup2" }, - { 292, "dup3" }, - { 213, "epoll_create" }, - { 291, "epoll_create1" }, - { 233, "epoll_ctl" }, - { 214, "epoll_ctl_old" }, - { 281, "epoll_pwait" }, - { 232, "epoll_wait" }, - { 215, "epoll_wait_old" }, - { 284, "eventfd" }, - { 290, "eventfd2" }, - { 59, "execve" }, - { 322, "execveat" }, - { 60, "exit" }, - { 231, "exit_group" }, - { 269, "faccessat" }, - { 221, "fadvise64" }, - { 285, "fallocate" }, - { 300, "fanotify_init" }, - { 301, "fanotify_mark" }, - { 81, "fchdir" }, - { 91, "fchmod" }, - { 268, "fchmodat" }, - { 93, "fchown" }, - { 260, "fchownat" }, - { 72, "fcntl" }, - { 75, "fdatasync" }, - { 193, "fgetxattr" }, - { 313, "finit_module" }, - { 196, "flistxattr" }, - { 73, "flock" }, - { 57, "fork" }, - { 199, "fremovexattr" }, - { 190, "fsetxattr" }, - { 5, "fstat" }, - { 138, "fstatfs" }, - { 74, "fsync" }, - { 77, "ftruncate" }, - { 202, "futex" }, - { 261, "futimesat" }, - { 309, "getcpu" }, - { 79, "getcwd" }, - { 78, "getdents" }, - { 217, "getdents64" }, - { 108, "getegid" }, - { 107, "geteuid" }, - { 104, "getgid" }, - { 115, "getgroups" }, - { 36, "getitimer" }, - { 177, "get_kernel_syms" }, - { 239, "get_mempolicy" }, - { 52, "getpeername" }, - { 121, "getpgid" }, - { 111, "getpgrp" }, - { 39, "getpid" }, - { 181, "getpmsg" }, - { 110, "getppid" }, - { 140, "getpriority" }, - { 318, "getrandom" }, - { 120, "getresgid" }, - { 118, "getresuid" }, - { 97, "getrlimit" }, - { 274, "get_robust_list" }, - { 98, "getrusage" }, - { 124, "getsid" }, - { 51, "getsockname" }, - { 55, "getsockopt" }, - { 211, "get_thread_area" }, - { 186, "gettid" }, - { 96, "gettimeofday" }, - { 102, "getuid" }, - { 191, "getxattr" }, - { 175, "init_module" }, - { 254, "inotify_add_watch" }, - { 253, "inotify_init" }, - { 294, "inotify_init1" }, - { 255, "inotify_rm_watch" }, - { 210, "io_cancel" }, - { 16, "ioctl" }, - { 207, "io_destroy" }, - { 208, "io_getevents" }, - { 173, "ioperm" }, - { 172, "iopl" }, - { 252, "ioprio_get" }, - { 251, "ioprio_set" }, - { 206, "io_setup" }, - { 209, "io_submit" }, - { 312, "kcmp" }, - { 320, "kexec_file_load" }, - { 246, "kexec_load" }, - { 250, "keyctl" }, - { 62, "kill" }, - { 94, "lchown" }, - { 192, "lgetxattr" }, - { 86, "link" }, - { 265, "linkat" }, - { 50, "listen" }, - { 194, "listxattr" }, - { 195, "llistxattr" }, - { 212, "lookup_dcookie" }, - { 198, "lremovexattr" }, - { 8, "lseek" }, - { 189, "lsetxattr" }, - { 6, "lstat" }, - { 28, "madvise" }, - { 237, "mbind" }, - { 324, "membarrier" }, - { 319, "memfd_create" }, - { 256, "migrate_pages" }, - { 27, "mincore" }, - { 83, "mkdir" }, - { 258, "mkdirat" }, - { 133, "mknod" }, - { 259, "mknodat" }, - { 149, "mlock" }, - { 325, "mlock2" }, - { 151, "mlockall" }, - { 9, "mmap" }, - { 154, "modify_ldt" }, - { 165, "mount" }, - { 279, "move_pages" }, - { 10, "mprotect" }, - { 245, "mq_getsetattr" }, - { 244, "mq_notify" }, - { 240, "mq_open" }, - { 243, "mq_timedreceive" }, - { 242, "mq_timedsend" }, - { 241, "mq_unlink" }, - { 25, "mremap" }, - { 71, "msgctl" }, - { 68, "msgget" }, - { 70, "msgrcv" }, - { 69, "msgsnd" }, - { 26, "msync" }, - { 150, "munlock" }, - { 152, "munlockall" }, - { 11, "munmap" }, - { 303, "name_to_handle_at" }, - { 35, "nanosleep" }, - { 262, "newfstatat" }, - { 180, "nfsservctl" }, - { 2, "open" }, - { 257, "openat" }, - { 304, "open_by_handle_at" }, - { 34, "pause" }, - { 298, "perf_event_open" }, - { 135, "personality" }, - { 22, "pipe" }, - { 293, "pipe2" }, - { 155, "pivot_root" }, - { 330, "pkey_alloc" }, - { 331, "pkey_free" }, - { 329, "pkey_mprotect" }, - { 7, "poll" }, - { 271, "ppoll" }, - { 157, "prctl" }, - { 17, "pread64" }, - { 295, "preadv" }, - { 327, "preadv2" }, - { 302, "prlimit64" }, - { 310, "process_vm_readv" }, - { 311, "process_vm_writev" }, - { 270, "pselect6" }, - { 101, "ptrace" }, - { 182, "putpmsg" }, - { 18, "pwrite64" }, - { 296, "pwritev" }, - { 328, "pwritev2" }, - { 178, "query_module" }, - { 179, "quotactl" }, - { 0, "read" }, - { 187, "readahead" }, - { 89, "readlink" }, - { 267, "readlinkat" }, - { 19, "readv" }, - { 169, "reboot" }, - { 45, "recvfrom" }, - { 299, "recvmmsg" }, - { 47, "recvmsg" }, - { 216, "remap_file_pages" }, - { 197, "removexattr" }, - { 82, "rename" }, - { 264, "renameat" }, - { 316, "renameat2" }, - { 249, "request_key" }, - { 219, "restart_syscall" }, - { 84, "rmdir" }, - { 13, "rt_sigaction" }, - { 127, "rt_sigpending" }, - { 14, "rt_sigprocmask" }, - { 129, "rt_sigqueueinfo" }, - { 15, "rt_sigreturn" }, - { 130, "rt_sigsuspend" }, - { 128, "rt_sigtimedwait" }, - { 297, "rt_tgsigqueueinfo" }, - { 204, "sched_getaffinity" }, - { 315, "sched_getattr" }, - { 143, "sched_getparam" }, - { 146, "sched_get_priority_max" }, - { 147, "sched_get_priority_min" }, - { 145, "sched_getscheduler" }, - { 148, "sched_rr_get_interval" }, - { 203, "sched_setaffinity" }, - { 314, "sched_setattr" }, - { 142, "sched_setparam" }, - { 144, "sched_setscheduler" }, - { 24, "sched_yield" }, - { 317, "seccomp" }, - { 185, "security" }, - { 23, "select" }, - { 66, "semctl" }, - { 64, "semget" }, - { 65, "semop" }, - { 220, "semtimedop" }, - { 40, "sendfile" }, - { 307, "sendmmsg" }, - { 46, "sendmsg" }, - { 44, "sendto" }, - { 171, "setdomainname" }, - { 123, "setfsgid" }, - { 122, "setfsuid" }, - { 106, "setgid" }, - { 116, "setgroups" }, - { 170, "sethostname" }, - { 38, "setitimer" }, - { 238, "set_mempolicy" }, - { 308, "setns" }, - { 109, "setpgid" }, - { 141, "setpriority" }, - { 114, "setregid" }, - { 119, "setresgid" }, - { 117, "setresuid" }, - { 113, "setreuid" }, - { 160, "setrlimit" }, - { 273, "set_robust_list" }, - { 112, "setsid" }, - { 54, "setsockopt" }, - { 205, "set_thread_area" }, - { 218, "set_tid_address" }, - { 164, "settimeofday" }, - { 105, "setuid" }, - { 188, "setxattr" }, - { 30, "shmat" }, - { 31, "shmctl" }, - { 67, "shmdt" }, - { 29, "shmget" }, - { 48, "shutdown" }, - { 131, "sigaltstack" }, - { 282, "signalfd" }, - { 289, "signalfd4" }, - { 41, "socket" }, - { 53, "socketpair" }, - { 275, "splice" }, - { 4, "stat" }, - { 137, "statfs" }, - { 168, "swapoff" }, - { 167, "swapon" }, - { 88, "symlink" }, - { 266, "symlinkat" }, - { 162, "sync" }, - { 277, "sync_file_range" }, - { 306, "syncfs" }, - { 156, "_sysctl" }, - { 139, "sysfs" }, - { 99, "sysinfo" }, - { 103, "syslog" }, - { 276, "tee" }, - { 234, "tgkill" }, - { 201, "time" }, - { 222, "timer_create" }, - { 226, "timer_delete" }, - { 283, "timerfd_create" }, - { 287, "timerfd_gettime" }, - { 286, "timerfd_settime" }, - { 225, "timer_getoverrun" }, - { 224, "timer_gettime" }, - { 223, "timer_settime" }, - { 100, "times" }, - { 200, "tkill" }, - { 76, "truncate" }, - { 184, "tuxcall" }, - { 95, "umask" }, - { 166, "umount2" }, - { 63, "uname" }, - { 87, "unlink" }, - { 263, "unlinkat" }, - { 272, "unshare" }, - { 134, "uselib" }, - { 323, "userfaultfd" }, - { 136, "ustat" }, - { 132, "utime" }, - { 280, "utimensat" }, - { 235, "utimes" }, - { 58, "vfork" }, - { 153, "vhangup" }, - { 278, "vmsplice" }, - { 236, "vserver" }, - { 61, "wait4" }, - { 247, "waitid" }, - { 1, "write" }, - { 20, "writev" }, - }; - - for (i = 0; i < sizeof(syscalls) / sizeof(syscalls[0]); i++) { - if (!strcmp(name, syscalls[i].name)) { - return syscalls[i].num; - } - } - - #else - (void)name; - #endif - - return -1; -} diff --git a/src/nonstd/errno.ref b/src/nonstd/errno.ref deleted file mode 100644 index 231a4835..00000000 --- a/src/nonstd/errno.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include <nonstd/syscall.h> -REFERENCE(<errno.h>) diff --git a/src/nonstd/lib-internal.ref b/src/nonstd/lib-internal.ref deleted file mode 100644 index 3361d2f6..00000000 --- a/src/nonstd/lib-internal.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include <nonstd/lib.h> -REFERENCE(<nonstd/internal.h>) diff --git a/src/nonstd/struct_atexit.c b/src/nonstd/struct_atexit.c deleted file mode 100644 index 482bbed1..00000000 --- a/src/nonstd/struct_atexit.c +++ /dev/null @@ -1,8 +0,0 @@ -#include <nonstd/internal.h> - -struct atexit { - int nfns; - void (*fns[32])(void); - struct atexit *next; - struct atexit *prev; -}; diff --git a/src/nonstd/syscall-internal.ref b/src/nonstd/syscall-internal.ref deleted file mode 100644 index 839537f1..00000000 --- a/src/nonstd/syscall-internal.ref +++ /dev/null @@ -1,2 +0,0 @@ -#include <nonstd/syscall.h> -REFERENCE(<nonstd/internal.h>) diff --git a/src/nonstd/x86-64.s b/src/nonstd/x86-64.s index f78a09fb..87ff1637 100644 --- a/src/nonstd/x86-64.s +++ b/src/nonstd/x86-64.s @@ -10,64 +10,12 @@ __syscall: syscall ret -.global __setjmp -__setjmp: - /* setjmp() in C sets env[0] to 0 */ - mov %rbx, 0x08(%rdi) - mov %rcx, 0x10(%rdi) - mov %rdx, 0x18(%rdi) - mov %rsp, 0x20(%rdi) - mov %rbp, 0x28(%rdi) - mov %rsi, 0x30(%rdi) - mov %rdi, 0x38(%rdi) - mov %r8, 0x40(%rdi) - mov %r9, 0x48(%rdi) - mov %r10, 0x50(%rdi) - mov %r11, 0x58(%rdi) - mov %r12, 0x60(%rdi) - mov %r13, 0x68(%rdi) - mov %r14, 0x70(%rdi) - mov %r15, 0x78(%rdi) - mov 0x00(%rbp), %rax - mov %rax, 0x80(%rdi) - mov 0x08(%rbp), %rax - mov %rax, 0x88(%rdi) - mov 0x00(%rsp), %rax - mov %rax, 0x90(%rdi) - xor %rax, %rax - ret - -.global __longjmp -__longjmp: - mov %rdi, %rax - mov 0x08(%rax), %rbx - mov 0x18(%rax), %rdx - mov 0x20(%rax), %rsp - mov 0x28(%rax), %rbp - mov 0x30(%rax), %rsi - mov 0x38(%rax), %rdi - mov 0x40(%rax), %r8 - mov 0x48(%rax), %r9 - mov 0x50(%rax), %r10 - mov 0x58(%rax), %r11 - mov 0x60(%rax), %r12 - mov 0x68(%rax), %r13 - mov 0x70(%rax), %r14 - mov 0x78(%rax), %r15 - mov 0x80(%rax), %rcx - mov %rcx, 0x00(%rbp) - mov 0x88(%rax), %rcx - mov %rcx, 0x08(%rbp) - mov 0x90(%rax), %rcx - mov %rcx, 0x00(%rsp) - mov 0x10(%rax), %rcx - mov 0x00(%rax), %rax - ret - -/* FIXME: this seems to be unpossible to put in a shared library */ -/* FIXME: it may be worthwhile to separate this into crt1.s */ .global _start _start: popq %rdi movq %rsp, %rsi call __libc_start + +.global __stack_chk_fail +__stack_chk_fail: + ret diff --git a/src/setjmp/__longjmp.x86-64.s b/src/setjmp/__longjmp.x86-64.s new file mode 100644 index 00000000..de666dce --- /dev/null +++ b/src/setjmp/__longjmp.x86-64.s @@ -0,0 +1,26 @@ +.global __longjmp +__longjmp: + mov %rdi, %rax + mov 0x08(%rax), %rbx + mov 0x18(%rax), %rdx + mov 0x20(%rax), %rsp + mov 0x28(%rax), %rbp + mov 0x30(%rax), %rsi + mov 0x38(%rax), %rdi + mov 0x40(%rax), %r8 + mov 0x48(%rax), %r9 + mov 0x50(%rax), %r10 + mov 0x58(%rax), %r11 + mov 0x60(%rax), %r12 + mov 0x68(%rax), %r13 + mov 0x70(%rax), %r14 + mov 0x78(%rax), %r15 + mov 0x80(%rax), %rcx + mov %rcx, 0x00(%rbp) + mov 0x88(%rax), %rcx + mov %rcx, 0x08(%rbp) + mov 0x90(%rax), %rcx + mov %rcx, 0x00(%rsp) + mov 0x10(%rax), %rcx + mov 0x00(%rax), %rax + ret diff --git a/src/setjmp/__setjmp.x86-64.s b/src/setjmp/__setjmp.x86-64.s new file mode 100644 index 00000000..d5b095e1 --- /dev/null +++ b/src/setjmp/__setjmp.x86-64.s @@ -0,0 +1,26 @@ +.global __setjmp +__setjmp: + /* setjmp() in C sets env[0] to 0 */ + mov %rbx, 0x08(%rdi) + mov %rcx, 0x10(%rdi) + mov %rdx, 0x18(%rdi) + mov %rsp, 0x20(%rdi) + mov %rbp, 0x28(%rdi) + mov %rsi, 0x30(%rdi) + mov %rdi, 0x38(%rdi) + mov %r8, 0x40(%rdi) + mov %r9, 0x48(%rdi) + mov %r10, 0x50(%rdi) + mov %r11, 0x58(%rdi) + mov %r12, 0x60(%rdi) + mov %r13, 0x68(%rdi) + mov %r14, 0x70(%rdi) + mov %r15, 0x78(%rdi) + mov 0x00(%rbp), %rax + mov %rax, 0x80(%rdi) + mov 0x08(%rbp), %rax + mov %rax, 0x88(%rdi) + mov 0x00(%rsp), %rax + mov %rax, 0x90(%rdi) + xor %rax, %rax + ret diff --git a/src/signal/kill.c b/src/signal/kill.c index 05949d52..ccbb6123 100644 --- a/src/signal/kill.c +++ b/src/signal/kill.c @@ -1,10 +1,10 @@ #include "sys/types.h" #include <signal.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int kill(pid_t pid, int sig) { - SYSCALL("kill", int, -1, pid, sig, 0, 0, 0, 0); + SYSCALL(kill, int, -1, pid, sig, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/signal/raise.c b/src/signal/raise.c index 0f0c5e69..f61ddbdc 100644 --- a/src/signal/raise.c +++ b/src/signal/raise.c @@ -2,9 +2,9 @@ #include "sys/types.h" #include "unistd.h" #else -#include "nonstd/syscall.h" -#define kill(pid, sig) __syscall(__lookup("kill"), pid, sig) -#define getpid() __syscall(__lookup("getpid")) +#include "../_syscall.h" +#define kill(pid, sig) __syscall(__syscall_lookup(kill), pid, sig) +#define getpid() __syscall(__syscall_lookup(getpid)) #endif #include <signal.h> diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c index 26197b4a..87d9368b 100644 --- a/src/stdio/__printf.c +++ b/src/stdio/__printf.c @@ -1,4 +1,17 @@ #include "_stdio.h" +#include "stddef.h" +#include "wchar.h" +#include "inttypes.h" +#include "unistd.h" + +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L +#include "../stdint/intmax_t.c" +#include "../stdint/uintmax_t.c" +#include "../stdint/intptr_t.c" +#include "../stdint/UINTMAX_MAX.c" +#define strtoumax __strtoumax +#include "../inttypes/strtoumax.c" +#endif #define NUMBUFLEN 64 @@ -311,3 +324,7 @@ int (__printf)(struct io_options *opt, const char * format, va_list arg) return nout; } + +/* +STDC(0) +*/ diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c new file mode 100644 index 00000000..d607bde6 --- /dev/null +++ b/src/stdio/__stdio.c @@ -0,0 +1,2 @@ +#include "_stdio.h" +struct __stdio __stdio; diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h index 84ad60ca..dac25c13 100644 --- a/src/stdio/_stdio.h +++ b/src/stdio/_stdio.h @@ -3,7 +3,6 @@ #include <stdarg.h> #include <stdio.h> -#include "nonstd/internal.h" #ifdef _POSIX_C_SOURCE #include <sys/types.h> @@ -14,7 +13,8 @@ struct __FILE { fpos_t pos; char *buf; - enum { SUPPLIED, ALLOCED, UNSET } buftype; + char ibuf[BUFSIZ]; + enum { INTERNAL, SUPPLIED, ALLOCED, UNSET } buftype; int buffering; int bsize; int isopen; @@ -54,6 +54,12 @@ struct io_options { int __printf(struct io_options * restrict, const char * restrict, va_list); int __scanf(struct io_options * restrict, const char * restrict, va_list); +struct __stdio { + struct __FILE FILES[FOPEN_MAX]; +}; + +extern struct __stdio __stdio; + #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L #define flockfile(_file) (void)(_file) #define funlockfile(_file) (void)(_file) diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 9030a39f..1b70d8b0 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -7,7 +7,7 @@ int fflush(FILE *stream) flockfile(stream); if (stream == NULL) { FILE *p; - for (p = __libc(FILE_STREAMS); p != NULL; p = p->prev) { + for (p = __stdio.FILES; p != NULL; p = p->prev) { fflush(p); } } diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 8abf7709..95130917 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -5,7 +5,7 @@ /** open a file stream **/ FILE * fopen(const char * restrict filename, const char * restrict mode) { - struct __FILE *base = __libc(FILE_STREAMS); + struct __FILE *base = __stdio.FILES; struct __FILE *f = base; /* find the next available stream */ diff --git a/src/stdio/fputc.c b/src/stdio/fputc.c index c392a19c..20cf5c6b 100644 --- a/src/stdio/fputc.c +++ b/src/stdio/fputc.c @@ -5,8 +5,8 @@ #include "sys/types.h" #include "unistd.h" #else -#include "nonstd/syscall.h" -#define write(_fd, _buf, _size) __syscall(__lookup("write"), _fd, _buf, _size) +#include "../_syscall.h" +#define write(_fd, _buf, _size) __syscall(__syscall_lookup(write), _fd, _buf, _size) #endif /** write a character to a file stream **/ diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 068cd73d..d213707b 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,11 +1,11 @@ #include <stdio.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" /** rename a file **/ int rename(const char *old, const char *new) { - SYSCALL_NUMBER(sc, "rename", -1); + SYSCALL_NUMBER(sc, rename, -1); int err = 0; err = __syscall(sc, old, new); diff --git a/src/stdlib/_Exit.c b/src/stdlib/_Exit.c index a199b457..b4f6f1a8 100644 --- a/src/stdlib/_Exit.c +++ b/src/stdlib/_Exit.c @@ -1,10 +1,10 @@ #include <stdlib.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" /** cause normal program termination without handlers **/ _Noreturn void _Exit(int status) { - long scno = __lookup("exit"); + SYCALL_NUMBER(scno, "exit"); for (;;) { __syscall(scno, status); } diff --git a/src/stdlib/__stdlib.c b/src/stdlib/__stdlib.c new file mode 100644 index 00000000..bfc601d9 --- /dev/null +++ b/src/stdlib/__stdlib.c @@ -0,0 +1,3 @@ +#include "_stdlib.h" + +struct __stdlib __stdlib; diff --git a/src/stdlib/_rand.h b/src/stdlib/_rand.h deleted file mode 100644 index 7f7102ef..00000000 --- a/src/stdlib/_rand.h +++ /dev/null @@ -1,4 +0,0 @@ -#include <limits.h> - -#define _rand(_n) \ - (((_n) = (_n) * 1103515245 + 12345) ? (_n) / UINT_MAX % RAND_MAX : 0) diff --git a/src/stdlib/_stdlib.h b/src/stdlib/_stdlib.h new file mode 100644 index 00000000..b0aa3cd2 --- /dev/null +++ b/src/stdlib/_stdlib.h @@ -0,0 +1,22 @@ +#ifndef ___STDLIB_H__ +#define ___STDLIB_H__ + +#include <stdlib.h> +#include <limits.h> + +#define _rand(_n) \ + (((_n) = (_n) * 1103515245 + 12345) ? (_n) / UINT_MAX % RAND_MAX : 0) + +struct __stdlib { + struct atexit { + int nfns; + void (*fns[32])(void); + struct atexit *next; + struct atexit *prev; + } atexit; + unsigned int rand; +}; + +extern struct __stdlib __stdlib; + +#endif diff --git a/src/stdlib/atexit.c b/src/stdlib/atexit.c index aeb9172c..37f0ef72 100644 --- a/src/stdlib/atexit.c +++ b/src/stdlib/atexit.c @@ -1,12 +1,12 @@ #include <stdlib.h> #include "errno.h" -#include "nonstd/lib.h" +#include "_stdlib.h" /** register a function to run at program exit **/ int atexit(void (*func)(void)) { - struct atexit *ae = __libc(ATEXIT); + struct atexit *ae = &(__stdlib.atexit); while (ae->nfns == sizeof(ae->fns) / sizeof(ae->fns[0])) { if (ae->next == NULL) { ae->next = calloc(1, sizeof(*ae->next)); diff --git a/src/stdlib/exit.c b/src/stdlib/exit.c index 501131e4..5fc1f2fc 100644 --- a/src/stdlib/exit.c +++ b/src/stdlib/exit.c @@ -1,13 +1,14 @@ #include <stdlib.h> #include "limits.h" #include "stddef.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" +#include "_stdlib.h" /** cause normal program termination **/ _Noreturn void exit(int status) { - long scno = __lookup("exit"); - struct atexit *ae = __libc(ATEXIT); + long scno = __syscall_lookup(exit); + struct atexit *ae = &(__stdlib.atexit); /* execute all atexit() registered functions in reverse order */ while (ae) { diff --git a/src/stdlib/rand.c b/src/stdlib/rand.c index f1a3e3e1..d8f3fcff 100644 --- a/src/stdlib/rand.c +++ b/src/stdlib/rand.c @@ -1,11 +1,10 @@ #include <stdlib.h> -#include "nonstd/lib.h" -#include "_rand.h" +#include "_stdlib.h" /** get a pseudo-random number **/ int rand(void) { - return _rand(*(unsigned*)__libc(RAND)); + return (int)_rand(__stdlib.rand); } /*** diff --git a/src/stdlib/srand.c b/src/stdlib/srand.c index 97ed2fec..af61570b 100644 --- a/src/stdlib/srand.c +++ b/src/stdlib/srand.c @@ -1,11 +1,11 @@ #include <stdlib.h> -#include "nonstd/lib.h" +#include "_stdlib.h" /** seed the pseudo-random number generator **/ void srand(unsigned int seed) { - *((int*)__libc(RAND)) = seed; + __stdlib.rand = seed; } /*** diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c index ba6c9636..b866f47c 100644 --- a/src/stdlib/strtod.c +++ b/src/stdlib/strtod.c @@ -4,6 +4,14 @@ #include "float.h" #include "math.h" +#ifndef INFINITY +#include "../math/INFINITY.c" +#endif + +#ifndef NAN +#include "../math/NAN.c" +#endif + /** convert string to floating-point **/ double strtod(const char * restrict nptr, char ** restrict endptr) diff --git a/src/strings/index.c b/src/strings/index.c index 86e92b4a..22126d81 100644 --- a/src/strings/index.c +++ b/src/strings/index.c @@ -1,4 +1,5 @@ #include <strings.h> +#include "string.h" char *index(const char *s, int c) { diff --git a/src/sys/mman/mprotect.c b/src/sys/mman/mprotect.c index ebce6e68..e2aa6b3b 100644 --- a/src/sys/mman/mprotect.c +++ b/src/sys/mman/mprotect.c @@ -1,6 +1,6 @@ #include <sys/mman.h> -int mprotect(void *addr, size_t len, int prot); +int mprotect(void *addr, size_t len, int prot) { return prot; } diff --git a/src/sys/sem/semget.c b/src/sys/sem/semget.c index 604675f1..331bb37c 100644 --- a/src/sys/sem/semget.c +++ b/src/sys/sem/semget.c @@ -1,6 +1,6 @@ #include <sys/sem.h> -int semget(key_t, int nsems, int semflg) +int semget(key_t key, int nsems, int semflg) { return 0; } diff --git a/src/sys/stat/chmod.c b/src/sys/stat/chmod.c index 6f77e75e..975cf01a 100644 --- a/src/sys/stat/chmod.c +++ b/src/sys/stat/chmod.c @@ -1,10 +1,10 @@ #include "sys/types.h" #include <sys/stat.h> -#include "nonstd/syscall.h" +#include "../../_syscall.h" int chmod(const char *path, mode_t mode) { - SYSCALL("chmod", int, -1, path, mode, 0, 0, 0, 0); + SYSCALL(chmod, int, -1, path, mode, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/sys/stat/mkdir.c b/src/sys/stat/mkdir.c index 7b3f510d..24ddc4a6 100644 --- a/src/sys/stat/mkdir.c +++ b/src/sys/stat/mkdir.c @@ -1,6 +1,6 @@ #include "sys/types.h" #include <sys/stat.h> -#include "nonstd/syscall.h" +#include "../../_syscall.h" int mkdir(const char *path, mode_t mode) { diff --git a/src/time/time.c b/src/time/time.c index 8af4131b..96e8ed19 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -1,13 +1,13 @@ #include <time.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" /** get current time **/ time_t time(time_t * timer) { long int now; - SYSCALL_NUMBER(sc, "time", 0); + SYSCALL_NUMBER(sc, time, 0); now = __syscall(sc); diff --git a/src/ulimit/ulimit.c b/src/ulimit/ulimit.c index c326640a..1588ea3a 100644 --- a/src/ulimit/ulimit.c +++ b/src/ulimit/ulimit.c @@ -1,6 +1,8 @@ #include <ulimit.h> #include "sys/resource.h" #include "stdarg.h" +#include "stddef.h" +#include "errno.h" long ulimit(int cmd, ...) { @@ -13,7 +15,7 @@ long ulimit(int cmd, ...) return -1; } else if (cmd == UL_SETFSIZE) { va_list ap; - va_start(cmd); + va_start(ap, cmd); rl.rlim_cur = va_arg(ap, rlim_t) * 512; va_end(ap); if (setrlimit(RLIMIT_FSIZE, NULL) == 0) { diff --git a/src/unistd/_exit.c b/src/unistd/_exit.c index 0a61e87c..f892dd59 100644 --- a/src/unistd/_exit.c +++ b/src/unistd/_exit.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" void _exit(int status) { - long scno = __lookup("exit"); + long scno = __syscall_lookup(exit); for (;;) { __syscall(scno, status); } diff --git a/src/unistd/alarm.c b/src/unistd/alarm.c index ff96dbaa..00130347 100644 --- a/src/unistd/alarm.c +++ b/src/unistd/alarm.c @@ -1,7 +1,7 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" unsigned alarm(unsigned seconds) { diff --git a/src/unistd/chdir.c b/src/unistd/chdir.c index 828487d3..e4061feb 100644 --- a/src/unistd/chdir.c +++ b/src/unistd/chdir.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int chdir(const char *path) { - SYSCALL("chdir", int, -1, path, 0, 0, 0, 0, 0); + SYSCALL(chdir, int, -1, path, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/chown.c b/src/unistd/chown.c index 08c52364..9f931765 100644 --- a/src/unistd/chown.c +++ b/src/unistd/chown.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int chown(const char *path, uid_t owner, gid_t group) { - SYSCALL("chown", int, -1, path, owner, group, 0, 0, 0); + SYSCALL(chown, int, -1, path, owner, group, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/close.c b/src/unistd/close.c index 3744aa86..e3e038cc 100644 --- a/src/unistd/close.c +++ b/src/unistd/close.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int close(int fildes) { - SYSCALL("close", int, -1, fildes, 0, 0, 0, 0, 0); + SYSCALL(close, int, -1, fildes, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/execve.c b/src/unistd/execve.c index 8d7a1225..81e39b93 100644 --- a/src/unistd/execve.c +++ b/src/unistd/execve.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int execve(const char *path, char *const argv[], char *const envp[]) { - SYSCALL_NUMBER(scno, "execve", -1); + SYSCALL_NUMBER(scno, execve, -1); errno = -__syscall(scno, path, argv, envp); return -1; } diff --git a/src/unistd/fork.c b/src/unistd/fork.c index 4efcc0f4..298de865 100644 --- a/src/unistd/fork.c +++ b/src/unistd/fork.c @@ -2,11 +2,11 @@ #include "sys/types.h" #include <unistd.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" pid_t fork(void) { - SYSCALL("fork", pid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(fork, pid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/fsync.c b/src/unistd/fsync.c index 35d70cbb..b0dd3820 100644 --- a/src/unistd/fsync.c +++ b/src/unistd/fsync.c @@ -1,12 +1,13 @@ #include <unistd.h> -#include "__nonstd.h" int fsync(int fildes) { + /* __POSIX_MIN(199309L); __POSIX_OPTION(_FSYNC); __XOPEN_MIN(4); __SC(int, fildes); + */ } /* diff --git a/src/unistd/ftruncate.c b/src/unistd/ftruncate.c index 8e6cf27f..6723321f 100644 --- a/src/unistd/ftruncate.c +++ b/src/unistd/ftruncate.c @@ -1,12 +1,13 @@ #include <unistd.h> -#include "__nonstd.h" int ftruncate(int fildes, off_t length) { + /* __POSIX_MIN(199309L); __POSIX_OPTION_OR(_MAPPED_FILES, _SHARED_MEMORY); __XOPEN_MIN(450); __SC(int, fildes, length); + */ } /* diff --git a/src/unistd/getcwd.c b/src/unistd/getcwd.c index 904e2c7d..7a37a7c2 100644 --- a/src/unistd/getcwd.c +++ b/src/unistd/getcwd.c @@ -1,12 +1,12 @@ #include "sys/types.h" #include <unistd.h> #include "nonstd/assert.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" char * getcwd(char *buf, size_t size) { ASSERT_NONNULL(buf); - SYSCALL("getcwd", char *, NULL, buf, size, 0, 0, 0, 0); + SYSCALL(getcwd, char *, NULL, buf, size, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getegid.c b/src/unistd/getegid.c index da8a372f..0c39a84a 100644 --- a/src/unistd/getegid.c +++ b/src/unistd/getegid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" gid_t getegid(void) { - SYSCALL("getegid", gid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getegid, gid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/geteuid.c b/src/unistd/geteuid.c index 2bc4c054..9ccb56de 100644 --- a/src/unistd/geteuid.c +++ b/src/unistd/geteuid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" uid_t geteuid(void) { - SYSCALL("geteuid", uid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(geteuid, uid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getgid.c b/src/unistd/getgid.c index 0d4a070d..28888be0 100644 --- a/src/unistd/getgid.c +++ b/src/unistd/getgid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" gid_t getgid(void) { - SYSCALL("getgid", gid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getgid, gid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getgroups.c b/src/unistd/getgroups.c index 8af2634b..b7df2896 100644 --- a/src/unistd/getgroups.c +++ b/src/unistd/getgroups.c @@ -2,7 +2,7 @@ #include "sys/types.h" #include <unistd.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" #include "nonstd/assert.h" int getgroups(int gidsetsize, gid_t grouplist[]) @@ -10,7 +10,7 @@ int getgroups(int gidsetsize, gid_t grouplist[]) if (gidsetsize != 0) { ASSERT_NONNULL(grouplist); } - SYSCALL("getgroups", int, -1, gidsetsize, grouplist, 0, 0, 0, 0); + SYSCALL(getgroups, int, -1, gidsetsize, grouplist, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getpgrp.c b/src/unistd/getpgrp.c index 897cd6be..7654afcb 100644 --- a/src/unistd/getpgrp.c +++ b/src/unistd/getpgrp.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" pid_t getpgrp(void) { - SYSCALL("getpgrp", pid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getpgrp, pid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getpid.c b/src/unistd/getpid.c index eb6be595..2c638c3c 100644 --- a/src/unistd/getpid.c +++ b/src/unistd/getpid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" pid_t getpid(void) { - SYSCALL("getpid", pid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getpid, pid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getppid.c b/src/unistd/getppid.c index 2fc880a2..642501f0 100644 --- a/src/unistd/getppid.c +++ b/src/unistd/getppid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" pid_t getppid(void) { - SYSCALL("getppid", pid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getppid, pid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/getuid.c b/src/unistd/getuid.c index d85814d4..baccfa34 100644 --- a/src/unistd/getuid.c +++ b/src/unistd/getuid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" uid_t getuid(void) { - SYSCALL("getuid", uid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(getuid, uid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/link.c b/src/unistd/link.c index 96e1e7b4..93726cb3 100644 --- a/src/unistd/link.c +++ b/src/unistd/link.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int link(const char *path1, const char *path2) { - SYSCALL("link", int, -1, path1, path2, 0, 0, 0, 0); + SYSCALL(link, int, -1, path1, path2, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/lseek.c b/src/unistd/lseek.c index dd194761..a277efbd 100644 --- a/src/unistd/lseek.c +++ b/src/unistd/lseek.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" off_t lseek(int fildes, off_t offset, int whence) { - SYSCALL("lseek", off_t, -1, fildes, offset, whence, 0, 0, 0); + SYSCALL(lseek, off_t, -1, fildes, offset, whence, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/pause.c b/src/unistd/pause.c index 41e25101..d69900f9 100644 --- a/src/unistd/pause.c +++ b/src/unistd/pause.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int pause(void) { - SYSCALL("pause", int, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(pause, int, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/pipe.c b/src/unistd/pipe.c index 5ab8b5e7..26e97dea 100644 --- a/src/unistd/pipe.c +++ b/src/unistd/pipe.c @@ -2,12 +2,12 @@ #include "sys/types.h" #include <unistd.h> #include "nonstd/assert.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int pipe(int fildes[2]) { ASSERT_NONNULL(fildes); - SYSCALL("pipe", int, -1, fildes, 0, 0, 0, 0, 0); + SYSCALL(pipe, int, -1, fildes, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/read.c b/src/unistd/read.c index c44e406d..f7b91a9b 100644 --- a/src/unistd/read.c +++ b/src/unistd/read.c @@ -2,11 +2,11 @@ #include "sys/types.h" #include <unistd.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" ssize_t read(int fildes, void *buf, size_t nbyte) { - SYSCALL("read", ssize_t, -1, fildes, buf, nbyte, 0, 0, 0); + SYSCALL(read, ssize_t, -1, fildes, buf, nbyte, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/rmdir.c b/src/unistd/rmdir.c index 6c6df741..b1944f80 100644 --- a/src/unistd/rmdir.c +++ b/src/unistd/rmdir.c @@ -2,11 +2,11 @@ #include "sys/types.h" #include <unistd.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int rmdir(const char *path) { - SYSCALL("rmdir", int, -1, path, 0, 0, 0, 0, 0); + SYSCALL(rmdir, int, -1, path, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/setgid.c b/src/unistd/setgid.c index 79f9695b..30aa5223 100644 --- a/src/unistd/setgid.c +++ b/src/unistd/setgid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int setgid(gid_t gid) { - SYSCALL("setgid", int, -1, gid, 0, 0, 0, 0, 0); + SYSCALL(setgid, int, -1, gid, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/setpgid.c b/src/unistd/setpgid.c index 28769713..2206446e 100644 --- a/src/unistd/setpgid.c +++ b/src/unistd/setpgid.c @@ -2,11 +2,11 @@ #include "sys/types.h" #include <unistd.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int setpgid(pid_t pid, pid_t pgid) { - SYSCALL("setpgid", int, -1, pid, pgid, 0, 0, 0, 0); + SYSCALL(setpgid, int, -1, pid, pgid, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/setsid.c b/src/unistd/setsid.c index 8c1aa0c7..8dbc9d1c 100644 --- a/src/unistd/setsid.c +++ b/src/unistd/setsid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" pid_t setsid(void) { - SYSCALL("setsid", pid_t, -1, 0, 0, 0, 0, 0, 0); + SYSCALL(setsid, pid_t, -1, 0, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/setuid.c b/src/unistd/setuid.c index 4c6053df..4599b083 100644 --- a/src/unistd/setuid.c +++ b/src/unistd/setuid.c @@ -1,11 +1,11 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" int setuid(uid_t uid) { - SYSCALL("setuid", int, -1, uid, 0, 0, 0, 0, 0); + SYSCALL(setuid, int, -1, uid, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/sleep.c b/src/unistd/sleep.c index 1e884f8e..29ffee7b 100644 --- a/src/unistd/sleep.c +++ b/src/unistd/sleep.c @@ -1,7 +1,7 @@ #include "stddef.h" #include "sys/types.h" #include <unistd.h> -#include "nonstd/syscall.h" +#include "../_syscall.h" unsigned sleep(unsigned seconds) { diff --git a/src/unistd/unlink.c b/src/unistd/unlink.c index 09fc20b0..f658872d 100644 --- a/src/unistd/unlink.c +++ b/src/unistd/unlink.c @@ -2,12 +2,12 @@ #include "sys/types.h" #include <unistd.h> #include "nonstd/assert.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" int unlink(const char *path) { ASSERT_NONNULL(path); - SYSCALL("unlink", int, -1, path, 0, 0, 0, 0, 0); + SYSCALL(unlink, int, -1, path, 0, 0, 0, 0, 0); } /* POSIX(1) diff --git a/src/unistd/write.c b/src/unistd/write.c index 352ef43f..6982a359 100644 --- a/src/unistd/write.c +++ b/src/unistd/write.c @@ -2,14 +2,14 @@ #include "sys/types.h" #include <unistd.h> #include "nonstd/assert.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" ssize_t write(int fildes, const void *buf, size_t nbyte) { if (nbyte != 0) { ASSERT_NONNULL(buf); } - SYSCALL("write", ssize_t, -1, fildes, buf, nbyte, 0, 0, 0); + SYSCALL(write, ssize_t, -1, fildes, buf, nbyte, 0, 0, 0); } /* POSIX(1) diff --git a/tests b/tests deleted file mode 160000 -Subproject 9d20f3f30dec9cc33057ee4a9e7ce75961664dd |
