about summary refs log tree commit diff
path: root/stdlib/errno.h
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-22 18:06:15 -0400
committerZack Weinberg <zackw@panix.com>2017-06-22 18:06:15 -0400
commitbf7aa82eab0f1f9c78d39cf57a3f6b25eefc47c1 (patch)
tree9b86e7bb3439877c3b9ab90cc78379908add6cc9 /stdlib/errno.h
parent6e5e73539b3fc122df96d653fab3c357a08071a4 (diff)
downloadglibc-bf7aa82eab0f1f9c78d39cf57a3f6b25eefc47c1.tar.gz
glibc-bf7aa82eab0f1f9c78d39cf57a3f6b25eefc47c1.tar.xz
glibc-bf7aa82eab0f1f9c78d39cf57a3f6b25eefc47c1.zip
Make error_t always int; make __errno_location return an __error_t.
error_t is a Hurdism whose purpose, as far as I know, is to make it so
you can get GDB to tell you the E-constant corresponding to the
current value of errno by typing 'p (error_t) errno'.  I tried to
generalize this to all platforms a few weeks ago and it was suggested
to me that this is maybe a job for a GDB pretty-printer, instead.
This patch clears the ground for that, by removing the Hurd-specific
definition of error_t.

error_t is also used to make the return values of a few GNU extension
functions (in argp.h and argz.h) a little more self-documenting, so it
can't completely go away, and it will be useful to be able to write
'p (error_t) err' where err is some ordinary int variable that happens
to have an errno value stashed in it.  So now stdlib/errno.h defines it
and it's always just a typedef for 'int'.

This patch also changes all definitions of __errno_location and the
underlying thread-local errno to have type __error_t instead of int.
__error_t is also just a typedef for int, but this is how we will cue
the GDB pretty-printer to print errno specially.  I believe that this
does not have any standards-compliance consequences, because it's just
a typedef for int.  This part of the change doesn't make sense in the
absence of the pretty-printer itself, but this split-up seemed more
useful to reviewers.

	* stdlib/errno.h (__error_t): New type (typedef as int).
	(__errno_location): Declare as returning __error_t.
	(error_t): Typedef as __error_t, if not already defined.

	* csu/errno-loc.c, csu/errno.c, include/errno.h
	* sysdeps/mach/hurd/dl-sysdep.c, sysdeps/mach/hurd/errno-loc.c:
	Change type of errno, __libc_errno, and rtld_errno, and
	return type of __errno_location to __error_t.

	* sysdeps/mach/hudr/errnos.awk: Do not emit enum __error_t_codes
	or a definition of error_t.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
	* sysdeps/mach/hurd/errno.c: Delete file.
	* bits/errno.h: Update commentary.
Diffstat (limited to 'stdlib/errno.h')
-rw-r--r--stdlib/errno.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/stdlib/errno.h b/stdlib/errno.h
index fe08365e40..c5ba522ac0 100644
--- a/stdlib/errno.h
+++ b/stdlib/errno.h
@@ -33,8 +33,12 @@
 
 __BEGIN_DECLS
 
+/* This type cues the GDB pretty-printer for errno (errno-printer.py)
+   to show a symbolic name for the error.  */
+typedef int __error_t;
+
 /* The error code set by various library functions.  */
-extern int *__errno_location (void) __THROW __attribute_const__;
+extern __error_t *__errno_location (void) __THROW __attribute_const__;
 # define errno (*__errno_location ())
 
 # ifdef __USE_GNU
@@ -45,11 +49,11 @@ extern int *__errno_location (void) __THROW __attribute_const__;
 extern char *program_invocation_name;
 extern char *program_invocation_short_name;
 
-/* bits/errno.h may have defined this type.  If it didn't, provide a
-   fallback definition.  */
+/* User namespace version of __error_t.  This is used to make the return
+   values of certain GNU extension functions more self-documenting.  */
 #  ifndef __error_t_defined
 #   define __error_t_defined 1
-typedef int error_t;
+typedef __error_t error_t;
 #  endif
 
 # endif /* __USE_GNU */