News for hackers. Stuff that matters.
Re:Show HN: Redbean – Single-file distributable web server by matheusmoreira on Friday February 26, 2021 @04:45PM (#26280218)
Wow, that cosmopolitan C library is absolutely awesome. The ABI specialization is extremely interesting. Never seen anything like that before. I thought compilers did that. I don't understand why they couldn't properly optimize memcpy.

I wonder how it handles system calls. Let me check the source...

https://github.com/jart/cosmopolitan/blob/master/tool/build/...

https://github.com/jart/cosmopolitan/blob/master/tool/build/...

> void OpSyscall(struct Machine *, uint32_t);

Pretty interesting... Need some time to figure out how it works.

The system call entry points:

https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s...

https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s...

It uses a jump slot technique which is interesting:

https://github.com/jart/cosmopolitan/blob/master/libc/sysv/m...

System call numbers:

https://github.com/jart/cosmopolitan/blob/master/libc/sysv/c...

https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s...

Looks like it packs the system call numbers of all operating systems into a single constant.

For some reason there are some dedicated implementations of Linux system calls using inline assembly rather than the entry point:

https://github.com/jart/cosmopolitan/tree/master/libc/linux

More related files:

https://github.com/jart/cosmopolitan/blob/master/libc/calls/...

https://github.com/jart/cosmopolitan/blob/master/libc/calls/...

Also funny how it calls Linux "GNU/Systemd"!

Re:Show HN: Redbean – Single-file distributable web server by Mister_X on Sunday February 28, 2021 @06:22PM (#26298080)
"...it calls Linux "GNU/Systemd""

Yeah, it would have taken less bits to use GNU/POS instead, because it ain't Linux anymore.

Poettering Operating System.