by BatmanAoD · 4y ago · 0 comments
The second sentence is:
> System calls are generally not invoked directly, but rather via wrapper functions in glibc (or perhaps some other library).
Okay, so we can't avoid C that way, but what's the "invoked directly" way? Well, it's syscall(2): https://man7.org/linux/man-pages/man2/syscall.2.html
This man page actually reiterates what the other one, that you shouldn't be making syscalls directly! But in any case, what is `syscall()`?
...it's a C macro.
So yeah, Linux does require programs to use C. You've just been isolated from it.
Zig solves interoperability by incorporating an entire copy of LLVM. Go does do bare metal syscalls, but as mentioned elsewhere in these comments, this has caused breakage on Mac when the kernel was updated, because this interface isn't stable.
No, in the syscall man page it tells you how to call a syscall. For x86_64 you put the syscall into rax and then use the syscall instruction (syscall is the name of an actual instruction). That man page includes more information like what registers arguments should be in or where to find the return value.
Programming language authors, writing their own stdglibbabbyscript, are exempt from that warning? That’s of course a big task nobody wants to do so many of them just piggyback on glibc with thin wrappers.