logoalt Hacker News

waherntoday at 9:27 AM1 replyview on HN

All true, but note that BSD introduced, and both Linux/glibc and Linux/musl support, a syscall(2) wrapper routine that takes a syscall number, a list of arguments (usually as long's), and performs the syscall magic. The syscall numbers are defined as macros beginning with SYS_. The Linux kernel headers export syscall numbers with macros using the prefix __NR_, but to match the BSD interface Linux libc headers usually translate or otherwise define them using a SYS_ prefix. Using the macros is much better because the numbers often vary by architecture for the same syscall.

See https://man7.org/linux/man-pages/man2/syscall.2.html


Replies

pjmlptoday at 9:30 AM

Except with BSDs you are on your own if you go down that route, because there are no stability guarantees.

It is more of an implementation detail for the rest of the C APIs than anything else.

show 1 reply