Re:Sortix: small self-hosting OS aiming to be a clean, moder...
by jchw on Friday March 02, 2018 @01:29PM
(#16504314)
Hm. I thought libc traditionally handled errno, not the kernel, and the syscall return code was simply translated to errno by libc.
[ Parent
| on HN ]
Re:Sortix: small self-hosting OS aiming to be a clean, moder...
by sortie on Saturday March 03, 2018 @10:11AM
(#16509545)
Author here. Like in Linux, libc provides errno on Sortix. The difference is that glibc does "#define errno (*__get_errno_location())" while Sortix libc does "__thread int errno;". linux syscalls return a negative value containing the negated errno, while Sortix system calls use two output registers: The return value register and the errno register. That allows Sortix system calls to legitimately return -42 if they want, which is not possible on Linux. Sortix libc assigns the errno register to the thread local errno if the errno register is non-zero.