This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.
Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
On Fri, Sep 22, 2000 at 05:52:01PM +0200, Andreas Jaeger wrote: > > > Take a look at glibc and ask why we have to save/restore errno all > > over places where we support both new and old system calls. There are > > reasons behind that. I don't recall the details. Someone may remember > > it. > Initially we used to save/restore errno, later we noticed that this is > not needed. All new code (at least code that Ulrich and I recently > added) doesn't save/restore errno - only older code does. I agree, we > should unify this, but so far nobody spoke up. > > Btw. this issue of saving/restoring errno has been discussed already > on the list and we came to the conclusion that it's not needed in this > situation. > This is from glibc texinfo: The initial value of `errno' at program startup is zero. Many library functions are guaranteed to set it to certain nonzero values when they encounter certain kinds of errors. These error conditions are listed for each function. These functions do not change `errno' when they succeed; thus, the value of `errno' after a successful call is not necessarily zero, and you should not use `errno' to determine _whether_ a call failed. The proper way to do that is documented for each function. _If_ the call failed, you can examine `errno'. Many library functions can set `errno' to a nonzero value as a result of calling other library functions which might fail. You should assume that any library function might alter `errno' when the function returns an error. From here, I conclude "The glibc functions do not change `errno' when they succeed." By not saving/restoring errno, we have changed documented glibc behavior. We should be consistent on it. H.J.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |