public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* errno in system calls.
@ 2017-08-29 17:59 David Venhoek
  2017-08-30  3:04 ` Giacomo Tesio
  0 siblings, 1 reply; 2+ messages in thread
From: David Venhoek @ 2017-08-29 17:59 UTC (permalink / raw)
  To: newlib

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: errno in system calls.
  2017-08-29 17:59 errno in system calls David Venhoek
@ 2017-08-30  3:04 ` Giacomo Tesio
  0 siblings, 0 replies; 2+ messages in thread
From: Giacomo Tesio @ 2017-08-30  3:04 UTC (permalink / raw)
  To: newlib

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
derivative).

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

https://github.com/JehanneOS/newlib/blob/master/newlib/libc/sys/jehanne/syscalls.c#L58-L63


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

https://github.com/JehanneOS/newlib/blob/master/newlib/libc/sys/jehanne/syscalls.c#L211-L216


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



Giacomo

2017-08-29 16:56 GMT+02:00, David Venhoek <david@venhoek.nl>:
> 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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-08-29 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29 17:59 errno in system calls David Venhoek
2017-08-30  3:04 ` Giacomo Tesio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).