Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Relevant/related topic & HN discussion which can help contextualize the value add I think maybe

“C isnt a programming language, it’s a protocol”

https://faultlore.com/blah/c-isnt-a-language/

https://news.ycombinator.com/item?id=33509223



These articles about ABIs are really good, thank you. I'd like to comment on the following:

> Um sorry what? This is Bappyscript, not C. Where’s the Bappyscript interface for Linux?

Right here!

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

On Linux, you don't need C at all since you can interface with the kernel directly. The ABI is stable and simple enough that a new programming language could have a system_call keyword that makes the compiler emit the system call code.

With this one piece of functionality, it's possible to do literally anything on Linux. No need for C libraries and their legacy at all. The hardest part will be describing the Linux user space API data structures in the new language so that they can be passed to and from the kernel.


Yes, but that only works for Linux. That's not the case for many other OSes where syscalls are not stable.


And even for Linux,

- you still have to take C ideas in account because you don’t know how much stack a syscall wants

- vdso are C-ABI objects


> you don’t know how much stack a syscall wants

There are no such considerations when issuing Linux system calls. You place parameters in specific registers, trap into kernel mode and then read back the result from a specific register.

There is one MIPS architecture where you have to pass some arguments on the stack but that's about it.

> vdso are C-ABI objects

Yes, unfortunately. It is not necessary to use the vDSO though. It is a performance optimization. The normal system calls will work just fine.


Well, alright, but then you still need to parse C to be able to divine the shape of the data structures, as they're defined in C (or you have to make some assumptions).


Yes. Fortunately, these definitions are significantly less complex than libc stuff. They all use typedefs prefixed with __kernel that are defined in asm and asm-generic headers.

The Linux kernel headers with all relevant structure definitions are here:

https://github.com/torvalds/linux/tree/master/include/uapi


They're actually defined in weird pseudo-C in some cases.


TBF, the whole point of any ABI is that you don't need a specific programming language to call into functions implementing that ABI, could even use assembly.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: