3 ms·
> Why can't we have a compiler with built in system call support? Just add a system_call keyword that inlines Linux system call code using the supplied paramete
by kazinator 5y ago
> Why can't we have a compiler with built in system call support? Just add a system_call keyword that inlines Linux system call code using the supplied parameters
It can be implemented as a small function, that first appeared in 4 BSD. It's available in Linux.
$ man syscall
(Unfortunately, this function, lives in glibc. Obviously, though, it doesn't have to. All I'm saying is that this, or a similar function, can be a linkable symbol in some small compiled object file, and not an inline primitive that has to live in the compiler.)
- matheusmoreira 5y agoYou're of course correct about all this. I believe the glibc thing has created mainly cultural problems. People don't look at Linux as a separate thing. If I look up Linux system calls on Wikipedia I get diagrams showing glibc wrapping the Linux system call interface because that's what you're supposed to be using. If I look at Linux man pages what I really get is glibc man pages with the actual system calls being almost an afterthought. Glibc wrappers actually do a ton of stuff like add cancellation mechanisms. Glibc also drops support for system calls that break their threading model such as clone. It's the same problem with systemd. I look up Linux init system man pages and get systemd stuff instead. I expected to see kernel APIs useful for writing my own.
- kazinator 5y agoThis isn't any different from any current or historic Unix. The system interface has been a C library going back to early Unix. The library and kernel interface are more separated in Linux systems than in prior Unixes, with user space C libs being totally separate projects. Over a Linux kernel you can find glibc, ucLibc, musl, Android s Bionic (newlib derivative from BSD), ...