back

by matheusmoreira·16d ago·view on hn ↗
> the Linux system calls are in the standard library anyway.

Nope. Not every system call is available. It took years before glibc got getrandom, for example. Others are straight up not supported because they break glibc's internals.

One could argue that it's always possible use the generic syscall function, but then what's the point of glibc? You can just get rid of it and use minimal shims, or compiler builtins, ideally.

> Having GCC builtins for them is of questionable utility at best.

It's useful if you're writing freestanding Linux programs. Great for eliminating all of the dependencies and writing minimal applications that target Linux directly. I wrote an entire lisp interpreter on top of nothing but Linux system calls.

> Even if the GP poster submitted these patches that may or may not exist, I'm not sure they would ever get merged.

Honestly I'm not sure either. The GCC maintainers didn't seem particularly convinced on the mailing list. It's the reason why I didn't bother to restart this work until years later. Claude made it easy enough to do it all over again.

Equally easy to drop. I'm gradually switching to Rust anyway.

1 comments
You just call syscall(syscall number, arguments) in glibc
I don't want to have to link against glibc. Nobody should need to do that.
then you first write syscall or copy it from glibc, and then you do that.
Not sure why you're telling me this. As I said in my previous comment, I did do just that. I created a liblinux project just for this that eventually became my own freestanding lisp interpreter with Linux system call support. I'm now reviving the liblinux Rust crate so I can use it in a Rust network stack project.