Rusty error handling
Currently, relibc primarily does C-like error handling (returning -1 and setting errno). A better alternative would be to use Result<T, Errno>
, which AFAIK currently only the inner pthread implementation does. If Errno
is defined as NonZeroU32
, then the common "zero for success or -1 with errno" can be represented zero-cost as Result<(), Errno>
. Only the outer C functions would convert the inner OS-abstracted platform functions into "-1 and errno", or other types of error handling (such as pthread's "0 or error code").
Worth noting both Redox and Linux represent syscall errors as negative error numbers (in Linux's case, between -4096 and -1, and currently in Redox's case, all negative numbers), so this change would most likely not lead to performance degradation.