errno in system calls.

David Venhoek
Tue Aug 29 17:59:00 GMT 2017

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