4 ms·
Wow, that cosmopolitan C library is absolutely awesome. The ABI specialization is extremely interesting. Never seen anything like that before. I thought compile
by matheusmoreira 6y ago
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/lib/syscall.h https://github.com/jart/cosmopolitan/blob/master/tool/build/...
https://github.com/jart/cosmopolitan/blob/master/tool/build/lib/syscall.c 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/systemfive.S https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s...
https://github.com/jart/cosmopolitan/blob/master/libc/sysv/syscall.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/macros.internal.h https://github.com/jart/cosmopolitan/blob/master/libc/sysv/m...
System call numbers:
https://github.com/jart/cosmopolitan/blob/master/libc/sysv/consts/nr.h https://github.com/jart/cosmopolitan/blob/master/libc/sysv/c...
https://github.com/jart/cosmopolitan/blob/master/libc/sysv/syscalls.sh 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 https://github.com/jart/cosmopolitan/tree/master/libc/linux
More related files:
https://github.com/jart/cosmopolitan/blob/master/libc/calls/calls.mk https://github.com/jart/cosmopolitan/blob/master/libc/calls/...
https://github.com/jart/cosmopolitan/blob/master/libc/calls/internal.h https://github.com/jart/cosmopolitan/blob/master/libc/calls/...
Also funny how it calls Linux "GNU/Systemd"!
- Mister_X 6y ago"...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.