Non-volatile errno

ricaljasan ricaljasan@pacific.net
Sat Oct 25 05:07:00 GMT 2014


Chapter Error Reporting, section Checking for Errors defines errno as:

@deftypevr {Variable} {volatile int} errno

and continues on to say:

Since @code{errno} is declared @code{volatile}, it might be changed
asynchronously by a signal handler; see @ref{Defining Handlers}.

but errno is not declared volatile.  On a system built with 2.19:

$ find /usr/include -name errno.h | xargs grep 'volatile.*errno'
$ find /usr/include -name errno.h | xargs grep 'int errno'
/usr/include/errno.h:extern int errno;

In the current git:
$ find . -name errno.h | xargs grep 'volatile.*errno'
$ find . -name errno.h | xargs grep 'int errno'
...
./stdlib/errno.h:extern int errno;

I assume extern is taken for granted since I don't see any other
variables declared extern in the manual.

Also, I'm not sure about the correctness of the subsequent description.
 Is it true that a signal handler can asynchronously change errno
*because* it is declared volatile?  If so, does removing the volatile
declaration warrant removing the comment about signal handlers, or
should that be reworded to say something else?

Thank you,
Rical Jasan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: errno.diff
Type: text/x-patch
Size: 435 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20141025/43a75cb1/attachment.bin>


More information about the Libc-help mailing list