-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syscalls #212
Comments
Could you propose a way to do it? |
you could start with the syscall() library call, to get all the functionality with some overhead and then use inline ASM (in inline C) on a per-architecture basis to drop the overhead. I would expect that one of the libc-lite libraries already does this, though. |
For instance, of x86_64, the code would look like: %{^
long syscall1(long value) {
long result;
__asm__("mov %1, %%rax;"
"syscall"
: "=r"(result)
:"r"(value)
:"%rax", "%rdi");
return result;
}
long syscall2(long value1, long value2) {
long result;
__asm__("mov %1, %%rax;"
"mov %2, %%rdi;"
"syscall"
: "=r"(result)
:"r"(value1), "r"(value2)
:"%rax", "%rdi");
return result;
}
%}
extern fn syscall1(value: lint): lint =
"ext#"
extern fn syscall2(value1: lint, value2: lint): lint =
"ext#" (or perhaps using variadics) |
cc @master-q - seems like may be of interest |
Hi.
Could you please add a way to do system calls in the language?
That would be useful when you want to do low-level stuff without using C.
Thanks.
The text was updated successfully, but these errors were encountered: