2 ms·
Hm. I thought libc traditionally handled errno, not the kernel, and the syscall return code was simply translated to errno by libc.
by jchw 9y ago
Hm. I thought libc traditionally handled errno, not the kernel, and the syscall return code was simply translated to errno by libc.
- sortie 9y agoAuthor 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.