hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0dd718a611563ccad036e98a99159056a2945a90
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 12 Jan 2021 17:24:38 -0500

Initial commit

This includes a slightly more fleshed out runtime than harec provides,
and a little os module.

Diffstat:
ACOPYING | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aos/+linux/exit.ha | 4++++
Art/+linux/abort.ha | 7+++++++
Art/+linux/env.ha | 3+++
Art/+linux/errno.ha | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Art/+linux/start.ha | 29+++++++++++++++++++++++++++++
Art/+linux/start.s | 6++++++
Art/+linux/syscall+x86_64.s | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Art/+linux/syscallno+x86_64.ha | 345+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Art/+linux/syscalls.ha | 50++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 803 insertions(+), 0 deletions(-)

diff --git a/COPYING b/COPYING @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/os/+linux/exit.ha b/os/+linux/exit.ha @@ -0,0 +1,4 @@ +use rt; + +// Exit the program with the provided status code. +export @noreturn fn exit(status: int) void = rt::exit(status); diff --git a/rt/+linux/abort.ha b/rt/+linux/abort.ha @@ -0,0 +1,7 @@ +export @noreturn @symbol("rt.abort") fn _abort(msg: str) void = { + const prefix = "Abort: "; + write(2, prefix: *const char, len(prefix)); + write(2, msg: *const char, len(msg)); + write(2, "\n": *const char, 1z); + kill(getpid(), SIGABRT); +}; diff --git a/rt/+linux/env.ha b/rt/+linux/env.ha @@ -0,0 +1,3 @@ +export let argc: size = 0z; +export let argv: *[*]*char = null: *[*]*char; +export let envp: *[*]nullable *char = null: *[*]nullable *char; diff --git a/rt/+linux/errno.ha b/rt/+linux/errno.ha @@ -0,0 +1,131 @@ +export def EPERM: int = 1; +export def ENOENT: int = 2; +export def ESRCH: int = 3; +export def EINTR: int = 4; +export def EIO: int = 5; +export def ENXIO: int = 6; +export def E2BIG: int = 7; +export def ENOEXEC: int = 8; +export def EBADF: int = 9; +export def ECHILD: int = 10; +export def EAGAIN: int = 11; +export def ENOMEM: int = 12; +export def EACCES: int = 13; +export def EFAULT: int = 14; +export def ENOTBLK: int = 15; +export def EBUSY: int = 16; +export def EEXIST: int = 17; +export def EXDEV: int = 18; +export def ENODEV: int = 19; +export def ENOTDIR: int = 20; +export def EISDIR: int = 21; +export def EINVAL: int = 22; +export def ENFILE: int = 23; +export def EMFILE: int = 24; +export def ENOTTY: int = 25; +export def ETXTBSY: int = 26; +export def EFBIG: int = 27; +export def ENOSPC: int = 28; +export def ESPIPE: int = 29; +export def EROFS: int = 30; +export def EMLINK: int = 31; +export def EPIPE: int = 32; +export def EDOM: int = 33; +export def ERANGE: int = 34; +export def EDEADLK: int = 35; +export def ENAMETOOLONG: int = 36; +export def ENOLCK: int = 37; +export def ENOSYS: int = 38; +export def ENOTEMPTY: int = 39; +export def ELOOP: int = 40; +export def ENOMSG: int = 42; +export def EIDRM: int = 43; +export def ECHRNG: int = 44; +export def EL2NSYNC: int = 45; +export def EL3HLT: int = 46; +export def EL3RST: int = 47; +export def ELNRNG: int = 48; +export def EUNATCH: int = 49; +export def ENOCSI: int = 50; +export def EL2HLT: int = 51; +export def EBADE: int = 52; +export def EBADR: int = 53; +export def EXFULL: int = 54; +export def ENOANO: int = 55; +export def EBADRQC: int = 56; +export def EBADSLT: int = 57; +export def EBFONT: int = 59; +export def ENOSTR: int = 60; +export def ENODATA: int = 61; +export def ETIME: int = 62; +export def ENOSR: int = 63; +export def ENONET: int = 64; +export def ENOPKG: int = 65; +export def EREMOTE: int = 66; +export def ENOLINK: int = 67; +export def EADV: int = 68; +export def ESRMNT: int = 69; +export def ECOMM: int = 70; +export def EPROTO: int = 71; +export def EMULTIHOP: int = 72; +export def EDOTDOT: int = 73; +export def EBADMSG: int = 74; +export def EOVERFLOW: int = 75; +export def ENOTUNIQ: int = 76; +export def EBADFD: int = 77; +export def EREMCHG: int = 78; +export def ELIBACC: int = 79; +export def ELIBBAD: int = 80; +export def ELIBSCN: int = 81; +export def ELIBMAX: int = 82; +export def ELIBEXEC: int = 83; +export def EILSEQ: int = 84; +export def ERESTART: int = 85; +export def ESTRPIPE: int = 86; +export def EUSERS: int = 87; +export def ENOTSOCK: int = 88; +export def EDESTADDRREQ: int = 89; +export def EMSGSIZE: int = 90; +export def EPROTOTYPE: int = 91; +export def ENOPROTOOPT: int = 92; +export def EPROTONOSUPPORT: int = 93; +export def ESOCKTNOSUPPORT: int = 94; +export def EOPNOTSUPP: int = 95; +export def EPFNOSUPPORT: int = 96; +export def EAFNOSUPPORT: int = 97; +export def EADDRINUSE: int = 98; +export def EADDRNOTAVAIL: int = 99; +export def ENETDOWN: int = 100; +export def ENETUNREACH: int = 101; +export def ENETRESET: int = 102; +export def ECONNABORTED: int = 103; +export def ECONNRESET: int = 104; +export def ENOBUFS: int = 105; +export def EISCONN: int = 106; +export def ENOTCONN: int = 107; +export def ESHUTDOWN: int = 108; +export def ETOOMANYREFS: int = 109; +export def ETIMEDOUT: int = 110; +export def ECONNREFUSED: int = 111; +export def EHOSTDOWN: int = 112; +export def EHOSTUNREACH: int = 113; +export def EALREADY: int = 114; +export def EINPROGRESS: int = 115; +export def ESTALE: int = 116; +export def EUCLEAN: int = 117; +export def ENOTNAM: int = 118; +export def ENAVAIL: int = 119; +export def EISNAM: int = 120; +export def EREMOTEIO: int = 121; +export def EDQUOT: int = 122; +export def ENOMEDIUM: int = 123; +export def EMEDIUMTYPE: int = 124; +export def ECANCELED: int = 125; +export def ENOKEY: int = 126; +export def EKEYEXPIRED: int = 127; +export def EKEYREVOKED: int = 128; +export def EKEYREJECTED: int = 129; +export def EOWNERDEAD: int = 130; +export def ENOTRECOVERABLE: int = 131; +export def ERFKILL: int = 132; +export def EHWPOISON: int = 133; diff --git a/rt/+linux/start.ha b/rt/+linux/start.ha @@ -0,0 +1,29 @@ +@symbol("main") fn main() int; + +const @symbol("__init_array_start") init_start: [*]*fn() void; +const @symbol("__init_array_end") init_end: [*]*fn() void; +const @symbol("__fini_array_start") fini_start: [*]*fn() void; +const @symbol("__fini_array_end") fini_end: [*]*fn() void; + +export fn start_ha(iv: *[*]uintptr) void = { + // TODO: Find & parse auxv + argc = iv[0z]: size; + argv = &iv[1z]: *[*]*char; + envp = &iv[1z + argc * size(*char) + 1z]: *[*]nullable *char; + + const ninit = (&init_end: uintptr - &init_start: uintptr): size + / size(*fn() void); + for (let i = 0z; i < ninit; i += 1z) { + init_start[i](); + }; + + main(); + + const nfini = (&fini_end: uintptr - &fini_start: uintptr): size + / size(*fn() void); + for (let i = 0z; i < nfini; i += 1z) { + fini_start[i](); + }; + + exit(0); +}; diff --git a/rt/+linux/start.s b/rt/+linux/start.s @@ -0,0 +1,6 @@ +.text +.global _start +_start: + xor %rbp, %rbp + movq %rsp, %rdi + call rt.start_ha diff --git a/rt/+linux/syscall+x86_64.s b/rt/+linux/syscall+x86_64.s @@ -0,0 +1,63 @@ +.text +.global rt.syscall0 +rt.syscall0: + movq %rdi, %rax + syscall + ret + +.global rt.syscall1 +rt.syscall1: + movq %rdi, %rax + movq %rsi, %rdi + syscall + ret + +.global rt.syscall2 +rt.syscall2: + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + syscall + ret + +.global rt.syscall3 +rt.syscall3: + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + syscall + ret + +.global rt.syscall4 +rt.syscall4: + movq %rdi, %rax + movq %r8, %r10 + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + syscall + ret + +.global rt.syscall5 +rt.syscall5: + movq %rdi, %rax + movq %r8, %r10 + movq %rsi, %rdi + movq %r9, %r8 + movq %rdx, %rsi + movq %rcx, %rdx + syscall + ret + +.global rt.syscall6 +rt.syscall6: + movq %rdi, %rax + movq %r8, %r10 + movq %rsi, %rdi + movq %r9, %r8 + movq %rdx, %rsi + movq 8(%rsp), %r9 + movq %rcx, %rdx + syscall + ret diff --git a/rt/+linux/syscallno+x86_64.ha b/rt/+linux/syscallno+x86_64.ha @@ -0,0 +1,345 @@ +export def SYS_read: u64 = 0u64; +export def SYS_write: u64 = 1u64; +export def SYS_open: u64 = 2u64; +export def SYS_close: u64 = 3u64; +export def SYS_stat: u64 = 4u64; +export def SYS_fstat: u64 = 5u64; +export def SYS_lstat: u64 = 6u64; +export def SYS_poll: u64 = 7u64; +export def SYS_lseek: u64 = 8u64; +export def SYS_mmap: u64 = 9u64; +export def SYS_mprotect: u64 = 10u64; +export def SYS_munmap: u64 = 11u64; +export def SYS_brk: u64 = 12u64; +export def SYS_rt_sigaction: u64 = 13u64; +export def SYS_rt_sigprocmask: u64 = 14u64; +export def SYS_rt_sigreturn: u64 = 15u64; +export def SYS_ioctl: u64 = 16u64; +export def SYS_pread64: u64 = 17u64; +export def SYS_pwrite64: u64 = 18u64; +export def SYS_readv: u64 = 19u64; +export def SYS_writev: u64 = 20u64; +export def SYS_access: u64 = 21u64; +export def SYS_pipe: u64 = 22u64; +export def SYS_select: u64 = 23u64; +export def SYS_sched_yield: u64 = 24u64; +export def SYS_mremap: u64 = 25u64; +export def SYS_msync: u64 = 26u64; +export def SYS_mincore: u64 = 27u64; +export def SYS_madvise: u64 = 28u64; +export def SYS_shmget: u64 = 29u64; +export def SYS_shmat: u64 = 30u64; +export def SYS_shmctl: u64 = 31u64; +export def SYS_dup: u64 = 32u64; +export def SYS_dup2: u64 = 33u64; +export def SYS_pause: u64 = 34u64; +export def SYS_nanosleep: u64 = 35u64; +export def SYS_getitimer: u64 = 36u64; +export def SYS_alarm: u64 = 37u64; +export def SYS_setitimer: u64 = 38u64; +export def SYS_getpid: u64 = 39u64; +export def SYS_sendfile: u64 = 40u64; +export def SYS_socket: u64 = 41u64; +export def SYS_connect: u64 = 42u64; +export def SYS_accept: u64 = 43u64; +export def SYS_sendto: u64 = 44u64; +export def SYS_recvfrom: u64 = 45u64; +export def SYS_sendmsg: u64 = 46u64; +export def SYS_recvmsg: u64 = 47u64; +export def SYS_shutdown: u64 = 48u64; +export def SYS_bind: u64 = 49u64; +export def SYS_listen: u64 = 50u64; +export def SYS_getsockname: u64 = 51u64; +export def SYS_getpeername: u64 = 52u64; +export def SYS_socketpair: u64 = 53u64; +export def SYS_setsockopt: u64 = 54u64; +export def SYS_getsockopt: u64 = 55u64; +export def SYS_clone: u64 = 56u64; +export def SYS_fork: u64 = 57u64; +export def SYS_vfork: u64 = 58u64; +export def SYS_execve: u64 = 59u64; +export def SYS_exit: u64 = 60u64; +export def SYS_wait4: u64 = 61u64; +export def SYS_kill: u64 = 62u64; +export def SYS_uname: u64 = 63u64; +export def SYS_semget: u64 = 64u64; +export def SYS_semop: u64 = 65u64; +export def SYS_semctl: u64 = 66u64; +export def SYS_shmdt: u64 = 67u64; +export def SYS_msgget: u64 = 68u64; +export def SYS_msgsnd: u64 = 69u64; +export def SYS_msgrcv: u64 = 70u64; +export def SYS_msgctl: u64 = 71u64; +export def SYS_fcntl: u64 = 72u64; +export def SYS_flock: u64 = 73u64; +export def SYS_fsync: u64 = 74u64; +export def SYS_fdatasync: u64 = 75u64; +export def SYS_truncate: u64 = 76u64; +export def SYS_ftruncate: u64 = 77u64; +export def SYS_getdents: u64 = 78u64; +export def SYS_getcwd: u64 = 79u64; +export def SYS_chdir: u64 = 80u64; +export def SYS_fchdir: u64 = 81u64; +export def SYS_rename: u64 = 82u64; +export def SYS_mkdir: u64 = 83u64; +export def SYS_rmdir: u64 = 84u64; +export def SYS_creat: u64 = 85u64; +export def SYS_link: u64 = 86u64; +export def SYS_unlink: u64 = 87u64; +export def SYS_symlink: u64 = 88u64; +export def SYS_readlink: u64 = 89u64; +export def SYS_chmod: u64 = 90u64; +export def SYS_fchmod: u64 = 91u64; +export def SYS_chown: u64 = 92u64; +export def SYS_fchown: u64 = 93u64; +export def SYS_lchown: u64 = 94u64; +export def SYS_umask: u64 = 95u64; +export def SYS_gettimeofday: u64 = 96u64; +export def SYS_getrlimit: u64 = 97u64; +export def SYS_getrusage: u64 = 98u64; +export def SYS_sysinfo: u64 = 99u64; +export def SYS_times: u64 = 100u64; +export def SYS_ptrace: u64 = 101u64; +export def SYS_getuid: u64 = 102u64; +export def SYS_syslog: u64 = 103u64; +export def SYS_getgid: u64 = 104u64; +export def SYS_setuid: u64 = 105u64; +export def SYS_setgid: u64 = 106u64; +export def SYS_geteuid: u64 = 107u64; +export def SYS_getegid: u64 = 108u64; +export def SYS_setpgid: u64 = 109u64; +export def SYS_getppid: u64 = 110u64; +export def SYS_getpgrp: u64 = 111u64; +export def SYS_setsid: u64 = 112u64; +export def SYS_setreuid: u64 = 113u64; +export def SYS_setregid: u64 = 114u64; +export def SYS_getgroups: u64 = 115u64; +export def SYS_setgroups: u64 = 116u64; +export def SYS_setresuid: u64 = 117u64; +export def SYS_getresuid: u64 = 118u64; +export def SYS_setresgid: u64 = 119u64; +export def SYS_getresgid: u64 = 120u64; +export def SYS_getpgid: u64 = 121u64; +export def SYS_setfsuid: u64 = 122u64; +export def SYS_setfsgid: u64 = 123u64; +export def SYS_getsid: u64 = 124u64; +export def SYS_capget: u64 = 125u64; +export def SYS_capset: u64 = 126u64; +export def SYS_rt_sigpending: u64 = 127u64; +export def SYS_rt_sigtimedwait: u64 = 128u64; +export def SYS_rt_sigqueueinfo: u64 = 129u64; +export def SYS_rt_sigsuspend: u64 = 130u64; +export def SYS_sigaltstack: u64 = 131u64; +export def SYS_utime: u64 = 132u64; +export def SYS_mknod: u64 = 133u64; +export def SYS_uselib: u64 = 134u64; +export def SYS_personality: u64 = 135u64; +export def SYS_ustat: u64 = 136u64; +export def SYS_statfs: u64 = 137u64; +export def SYS_fstatfs: u64 = 138u64; +export def SYS_sysfs: u64 = 139u64; +export def SYS_getpriority: u64 = 140u64; +export def SYS_setpriority: u64 = 141u64; +export def SYS_sched_setparam: u64 = 142u64; +export def SYS_sched_getparam: u64 = 143u64; +export def SYS_sched_setscheduler: u64 = 144u64; +export def SYS_sched_getscheduler: u64 = 145u64; +export def SYS_sched_get_priority_max: u64 = 146u64; +export def SYS_sched_get_priority_min: u64 = 147u64; +export def SYS_sched_rr_get_interval: u64 = 148u64; +export def SYS_mlock: u64 = 149u64; +export def SYS_munlock: u64 = 150u64; +export def SYS_mlockall: u64 = 151u64; +export def SYS_munlockall: u64 = 152u64; +export def SYS_vhangup: u64 = 153u64; +export def SYS_modify_ldt: u64 = 154u64; +export def SYS_pivot_root: u64 = 155u64; +export def SYS__sysctl: u64 = 156u64; +export def SYS_prctl: u64 = 157u64; +export def SYS_arch_prctl: u64 = 158u64; +export def SYS_adjtimex: u64 = 159u64; +export def SYS_setrlimit: u64 = 160u64; +export def SYS_chroot: u64 = 161u64; +export def SYS_sync: u64 = 162u64; +export def SYS_acct: u64 = 163u64; +export def SYS_settimeofday: u64 = 164u64; +export def SYS_mount: u64 = 165u64; +export def SYS_umount2: u64 = 166u64; +export def SYS_swapon: u64 = 167u64; +export def SYS_swapoff: u64 = 168u64; +export def SYS_reboot: u64 = 169u64; +export def SYS_sethostname: u64 = 170u64; +export def SYS_setdomainname: u64 = 171u64; +export def SYS_iopl: u64 = 172u64; +export def SYS_ioperm: u64 = 173u64; +export def SYS_create_module: u64 = 174u64; +export def SYS_init_module: u64 = 175u64; +export def SYS_delete_module: u64 = 176u64; +export def SYS_get_kernel_syms: u64 = 177u64; +export def SYS_query_module: u64 = 178u64; +export def SYS_quotactl: u64 = 179u64; +export def SYS_nfsservctl: u64 = 180u64; +export def SYS_getpmsg: u64 = 181u64; +export def SYS_putpmsg: u64 = 182u64; +export def SYS_afs_syscall: u64 = 183u64; +export def SYS_tuxcall: u64 = 184u64; +export def SYS_security: u64 = 185u64; +export def SYS_gettid: u64 = 186u64; +export def SYS_readahead: u64 = 187u64; +export def SYS_setxattr: u64 = 188u64; +export def SYS_lsetxattr: u64 = 189u64; +export def SYS_fsetxattr: u64 = 190u64; +export def SYS_getxattr: u64 = 191u64; +export def SYS_lgetxattr: u64 = 192u64; +export def SYS_fgetxattr: u64 = 193u64; +export def SYS_listxattr: u64 = 194u64; +export def SYS_llistxattr: u64 = 195u64; +export def SYS_flistxattr: u64 = 196u64; +export def SYS_removexattr: u64 = 197u64; +export def SYS_lremovexattr: u64 = 198u64; +export def SYS_fremovexattr: u64 = 199u64; +export def SYS_tkill: u64 = 200u64; +export def SYS_time: u64 = 201u64; +export def SYS_futex: u64 = 202u64; +export def SYS_sched_setaffinity: u64 = 203u64; +export def SYS_sched_getaffinity: u64 = 204u64; +export def SYS_set_thread_area: u64 = 205u64; +export def SYS_io_setup: u64 = 206u64; +export def SYS_io_destroy: u64 = 207u64; +export def SYS_io_getevents: u64 = 208u64; +export def SYS_io_submit: u64 = 209u64; +export def SYS_io_cancel: u64 = 210u64; +export def SYS_get_thread_area: u64 = 211u64; +export def SYS_lookup_dcookie: u64 = 212u64; +export def SYS_epoll_create: u64 = 213u64; +export def SYS_epoll_ctl_old: u64 = 214u64; +export def SYS_epoll_wait_old: u64 = 215u64; +export def SYS_remap_file_pages: u64 = 216u64; +export def SYS_getdents64: u64 = 217u64; +export def SYS_set_tid_address: u64 = 218u64; +export def SYS_restart_syscall: u64 = 219u64; +export def SYS_semtimedop: u64 = 220u64; +export def SYS_fadvise64: u64 = 221u64; +export def SYS_timer_create: u64 = 222u64; +export def SYS_timer_settime: u64 = 223u64; +export def SYS_timer_gettime: u64 = 224u64; +export def SYS_timer_getoverrun: u64 = 225u64; +export def SYS_timer_delete: u64 = 226u64; +export def SYS_clock_settime: u64 = 227u64; +export def SYS_clock_gettime: u64 = 228u64; +export def SYS_clock_getres: u64 = 229u64; +export def SYS_clock_nanosleep: u64 = 230u64; +export def SYS_exit_group: u64 = 231u64; +export def SYS_epoll_wait: u64 = 232u64; +export def SYS_epoll_ctl: u64 = 233u64; +export def SYS_tgkill: u64 = 234u64; +export def SYS_utimes: u64 = 235u64; +export def SYS_vserver: u64 = 236u64; +export def SYS_mbind: u64 = 237u64; +export def SYS_set_mempolicy: u64 = 238u64; +export def SYS_get_mempolicy: u64 = 239u64; +export def SYS_mq_open: u64 = 240u64; +export def SYS_mq_unlink: u64 = 241u64; +export def SYS_mq_timedsend: u64 = 242u64; +export def SYS_mq_timedreceive: u64 = 243u64; +export def SYS_mq_notify: u64 = 244u64; +export def SYS_mq_getsetattr: u64 = 245u64; +export def SYS_kexec_load: u64 = 246u64; +export def SYS_waitid: u64 = 247u64; +export def SYS_add_key: u64 = 248u64; +export def SYS_request_key: u64 = 249u64; +export def SYS_keyctl: u64 = 250u64; +export def SYS_ioprio_set: u64 = 251u64; +export def SYS_ioprio_get: u64 = 252u64; +export def SYS_inotify_init: u64 = 253u64; +export def SYS_inotify_add_watch: u64 = 254u64; +export def SYS_inotify_rm_watch: u64 = 255u64; +export def SYS_migrate_pages: u64 = 256u64; +export def SYS_openat: u64 = 257u64; +export def SYS_mkdirat: u64 = 258u64; +export def SYS_mknodat: u64 = 259u64; +export def SYS_fchownat: u64 = 260u64; +export def SYS_futimesat: u64 = 261u64; +export def SYS_newfstatat: u64 = 262u64; +export def SYS_unlinkat: u64 = 263u64; +export def SYS_renameat: u64 = 264u64; +export def SYS_linkat: u64 = 265u64; +export def SYS_symlinkat: u64 = 266u64; +export def SYS_readlinkat: u64 = 267u64; +export def SYS_fchmodat: u64 = 268u64; +export def SYS_faccessat: u64 = 269u64; +export def SYS_pselect6: u64 = 270u64; +export def SYS_ppoll: u64 = 271u64; +export def SYS_unshare: u64 = 272u64; +export def SYS_set_robust_list: u64 = 273u64; +export def SYS_get_robust_list: u64 = 274u64; +export def SYS_splice: u64 = 275u64; +export def SYS_tee: u64 = 276u64; +export def SYS_sync_file_range: u64 = 277u64; +export def SYS_vmsplice: u64 = 278u64; +export def SYS_move_pages: u64 = 279u64; +export def SYS_utimensat: u64 = 280u64; +export def SYS_epoll_pwait: u64 = 281u64; +export def SYS_signalfd: u64 = 282u64; +export def SYS_timerfd_create: u64 = 283u64; +export def SYS_eventfd: u64 = 284u64; +export def SYS_fallocate: u64 = 285u64; +export def SYS_timerfd_settime: u64 = 286u64; +export def SYS_timerfd_gettime: u64 = 287u64; +export def SYS_accept4: u64 = 288u64; +export def SYS_signalfd4: u64 = 289u64; +export def SYS_eventfd2: u64 = 290u64; +export def SYS_epoll_create1: u64 = 291u64; +export def SYS_dup3: u64 = 292u64; +export def SYS_pipe2: u64 = 293u64; +export def SYS_inotify_init1: u64 = 294u64; +export def SYS_preadv: u64 = 295u64; +export def SYS_pwritev: u64 = 296u64; +export def SYS_rt_tgsigqueueinfo: u64 = 297u64; +export def SYS_perf_event_open: u64 = 298u64; +export def SYS_recvmmsg: u64 = 299u64; +export def SYS_fanotify_init: u64 = 300u64; +export def SYS_fanotify_mark: u64 = 301u64; +export def SYS_prlimit64: u64 = 302u64; +export def SYS_name_to_handle_at: u64 = 303u64; +export def SYS_open_by_handle_at: u64 = 304u64; +export def SYS_clock_adjtime: u64 = 305u64; +export def SYS_syncfs: u64 = 306u64; +export def SYS_sendmmsg: u64 = 307u64; +export def SYS_setns: u64 = 308u64; +export def SYS_getcpu: u64 = 309u64; +export def SYS_process_vm_readv: u64 = 310u64; +export def SYS_process_vm_writev: u64 = 311u64; +export def SYS_kcmp: u64 = 312u64; +export def SYS_finit_module: u64 = 313u64; +export def SYS_sched_setattr: u64 = 314u64; +export def SYS_sched_getattr: u64 = 315u64; +export def SYS_renameat2: u64 = 316u64; +export def SYS_seccomp: u64 = 317u64; +export def SYS_getrandom: u64 = 318u64; +export def SYS_memfd_create: u64 = 319u64; +export def SYS_kexec_file_load: u64 = 320u64; +export def SYS_bpf: u64 = 321u64; +export def SYS_execveat: u64 = 322u64; +export def SYS_userfaultfd: u64 = 323u64; +export def SYS_membarrier: u64 = 324u64; +export def SYS_mlock2: u64 = 325u64; +export def SYS_copy_file_range: u64 = 326u64; +export def SYS_preadv2: u64 = 327u64; +export def SYS_pwritev2: u64 = 328u64; +export def SYS_pkey_mprotect: u64 = 329u64; +export def SYS_pkey_alloc: u64 = 330u64; +export def SYS_pkey_free: u64 = 331u64; +export def SYS_statx: u64 = 332u64; +export def SYS_io_pgetevents: u64 = 333u64; +export def SYS_rseq: u64 = 334u64; +export def SYS_pidfd_send_signal: u64 = 424u64; +export def SYS_io_uring_setup: u64 = 425u64; +export def SYS_io_uring_enter: u64 = 426u64; +export def SYS_io_uring_register: u64 = 427u64; +export def SYS_open_tree: u64 = 428u64; +export def SYS_move_mount: u64 = 429u64; +export def SYS_fsopen: u64 = 430u64; +export def SYS_fsconfig: u64 = 431u64; +export def SYS_fsmount: u64 = 432u64; +export def SYS_fspick: u64 = 433u64; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -0,0 +1,50 @@ +fn syscall0(u64) u64; +fn syscall1(u64, u64) u64; +fn syscall2(u64, u64, u64) u64; +fn syscall3(u64, u64, u64, u64) u64; +fn syscall4(u64, u64, u64, u64, u64) u64; +fn syscall5(u64, u64, u64, u64, u64, u64) u64; +fn syscall6(u64, u64, u64, u64, u64, u64, u64) u64; + +export fn write(fd: int, buf: *const void, count: size) size = + syscall3(SYS_write, fd: u64, buf: uintptr: u64, count: u64): size; + +export fn getpid() int = syscall0(SYS_getpid): int; + +export @noreturn fn exit(status: int) void = syscall1(SYS_exit, status: u64); + +export fn kill(pid: int, signal: int) int = + syscall2(SYS_kill, pid: u64, signal: u64): int; + +export def SIGHUP: int = 1; +export def SIGINT: int = 2; +export def SIGQUIT: int = 3; +export def SIGILL: int = 4; +export def SIGTRAP: int = 5; +export def SIGABRT: int = 6; +export def SIGBUS: int = 7; +export def SIGFPE: int = 8; +export def SIGKILL: int = 9; +export def SIGUSR1: int = 10; +export def SIGSEGV: int = 11; +export def SIGUSR2: int = 12; +export def SIGPIPE: int = 13; +export def SIGALRM: int = 14; +export def SIGTERM: int = 15; +export def SIGSTKFLT: int = 16; +export def SIGCHLD: int = 17; +export def SIGCONT: int = 18; +export def SIGSTOP: int = 19; +export def SIGTSTP: int = 20; +export def SIGTTIN: int = 21; +export def SIGTTOU: int = 22; +export def SIGURG: int = 23; +export def SIGXCPU: int = 24; +export def SIGXFSZ: int = 25; +export def SIGVTALRM: int = 26; +export def SIGPROF: int = 27; +export def SIGWINCH: int = 28; +export def SIGIO: int = 29; +export def SIGPOLL: int = 29; +export def SIGPWR: int = 30; +export def SIGSYS: int = 31;