errno in system calls.

Giacomo Tesio
Wed Aug 30 03:04:00 GMT 2017

Hi, I'm not a newlib developer, just one walking through the same path, so
take this with a grain of salt.

I'm using newlib as a POSIX facade to my non-POSIX system (a Plan 9

Here you can see how I implemented the reentrant syscalls are using errno,
for example

Here an example of a syscall that does not provide the reentrant version in

(the POSIX_* functions are provided by a library, libposix, that contains
the code that I hope to reuse)


2017-08-29 16:56 GMT+02:00, David Venhoek <>:
> Dear newlib developers,
> I am currently working on porting newlib towards a hobby operating
> system, and I am having the feeling that I don't have a full grasp on
> how the interactions between errno and the reentrancy system works.
> I currently implements the system calls required by newlib as
> non-reentrant functions, using their direct (non-underscored names,
> e.g. open). For this I undef errno, and refer to the extern int errno
> as specified in the documentation.
> As I understand it, this works correctly when interacting with these
> functions through the reentrant covers, as the rest of the newlib
> does, as these functions take care of picking up the errno. However, I
> don't fully understand how this is supposed to work when calling these
> functions directly from user programs. How do these programs pick up
> the value of errno? Or is this use case not possible when implementing
> them these ways, and if so, what is the recommended approach to
> implementing these system calls so as to achieve this?
> Thank you in advance for your time.
> Kind regards,
> David Venhoek

More information about the Newlib mailing list