hare

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

commit 744272c30230d9c56917109e186c4a8fbae4326c
parent e191f7c268b44ea88aefd993d7536bde4ca8ba2c
Author: Sebastian <sebastian@sebsite.pw>
Date:   Tue, 23 Jan 2024 03:58:34 -0500

rt: add exported syscall function

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mrt/+freebsd/syscalls.ha | 13+++++++++++++
Mrt/+linux/syscalls.ha | 13+++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha @@ -1,6 +1,19 @@ // SPDX-License-Identifier: MPL-2.0 // (c) Hare authors <https://harelang.org> +export fn syscall(num: u64, args: u64...) u64 = { + switch (len(args)) { + case 0 => return syscall0(num); + case 1 => return syscall1(num, args[0]); + case 2 => return syscall2(num, args[0], args[1]); + case 3 => return syscall3(num, args[0], args[1], args[2]); + case 4 => return syscall4(num, args[0], args[1], args[2], args[3]); + case 5 => return syscall5(num, args[0], args[1], args[2], args[3], args[4]); + case 6 => return syscall6(num, args[0], args[1], args[2], args[3], args[4], args[5]); + case => abort("syscalls can't have more than 6 arguments"); + }; +}; + fn syscall0(u64) u64; fn syscall1(u64, u64) u64; fn syscall2(u64, u64, u64) u64; diff --git a/rt/+linux/syscalls.ha b/rt/+linux/syscalls.ha @@ -1,6 +1,19 @@ // SPDX-License-Identifier: MPL-2.0 // (c) Hare authors <https://harelang.org> +export fn syscall(num: u64, args: u64...) u64 = { + switch (len(args)) { + case 0 => return syscall0(num); + case 1 => return syscall1(num, args[0]); + case 2 => return syscall2(num, args[0], args[1]); + case 3 => return syscall3(num, args[0], args[1], args[2]); + case 4 => return syscall4(num, args[0], args[1], args[2], args[3]); + case 5 => return syscall5(num, args[0], args[1], args[2], args[3], args[4]); + case 6 => return syscall6(num, args[0], args[1], args[2], args[3], args[4], args[5]); + case => abort("syscalls can't have more than 6 arguments"); + }; +}; + fn syscall0(u64) u64; fn syscall1(u64, u64) u64; fn syscall2(u64, u64, u64) u64;