diff options
author | Zack Weinberg <zackw@panix.com> | 2017-03-21 16:30:53 -0400 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-06-14 08:14:34 -0400 |
commit | fd860eaaa8757b221d9169e460c9ec41ea51f317 (patch) | |
tree | 5e5037486db89c12cd4a7dc89a545767481aff29 /stdlib/errno.h | |
parent | 37f802f86400684c8d13403958b2c598721d6360 (diff) | |
download | glibc-fd860eaaa8757b221d9169e460c9ec41ea51f317.zip glibc-fd860eaaa8757b221d9169e460c9ec41ea51f317.tar.gz glibc-fd860eaaa8757b221d9169e460c9ec41ea51f317.tar.bz2 |
Remove __need macros from errno.h (__need_Emath, __need_error_t).
This is fairly complicated, not because the users of __need_Emath and
__need_error_t have complicated requirements, but because the core
changes had a lot of fallout.
__need_error_t exists for gnulib compatibility in argz.h and argp.h.
error_t itself is a Hurdism, an enum containing all the E-constants,
so you can do 'p (error_t) errno' in gdb and get a symbolic value.
argz.h and argp.h use it for function return values, and they want to
fall back to 'int' when that's not available. There is no reason why
these nonstandard headers cannot just go ahead and include all of
errno.h; so we do that.
__need_Emath is defined only by .S files; what they _really_ need is
for errno.h to avoid declaring anything other than the E-constants
(e.g. 'extern int __errno_location(void);' is a syntax error in
assembly language). This is replaced with a check for __ASSEMBLER__ in
errno.h, plus a carefully documented requirement for bits/errno.h not
to define anything other than macros. That in turn has the
consequence that bits/errno.h must not define errno - fortunately, all
live ports use the same definition of errno, so I've moved it to
errno.h. The Hurd bits/errno.h must also take care not to define
error_t when __ASSEMBLER__ is defined, which involves repeating all of
the definitions twice, but it's a generated file so that's okay.
* stdlib/errno.h: Remove __need_Emath and __need_error_t logic.
Reorganize file. Declare errno here. When __ASSEMBLER__ is
defined, don't declare anything other than the E-constants.
* include/errno.h: Change conditional for exposing internal
declarations to (not _ISOMAC and not __ASSEMBLER__).
* bits/errno.h: Remove logic for __need_Emath. Document
requirements for a port-specific bits/errno.h.
* sysdeps/unix/sysv/linux/bits/errno.h
* sysdeps/unix/sysv/linux/alpha/bits/errno.h
* sysdeps/unix/sysv/linux/hppa/bits/errno.h
* sysdeps/unix/sysv/linux/mips/bits/errno.h
* sysdeps/unix/sysv/linux/sparc/bits/errno.h:
Add multiple-include guard and check against improper inclusion.
Remove __need_Emath logic. Don't declare errno here. Ensure all
constants are defined as simple integer literals. Consistent
formatting.
* sysdeps/mach/hurd/errnos.awk: Likewise. Only define error_t and
enum __error_t_codes if __ASSEMBLER__ is not defined.
* sysdeps/mach/hurd/bits/errno.h: Regenerate.
* argp/argp.h, string/argz.h: Don't define __need_error_t before
including errno.h.
* sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S
* sysdeps/i386/i686/fpu/multiarch/s_sincosf-sse2.S
* sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S
* sysdeps/x86_64/fpu/s_cosf.S
* sysdeps/x86_64/fpu/s_sincosf.S
* sysdeps/x86_64/fpu/s_sinf.S:
Just include errno.h; don't define __need_Emath or include
bits/errno.h directly.
Diffstat (limited to 'stdlib/errno.h')
-rw-r--r-- | stdlib/errno.h | 62 |
1 files changed, 25 insertions, 37 deletions
diff --git a/stdlib/errno.h b/stdlib/errno.h index c42514b..fe08365 100644 --- a/stdlib/errno.h +++ b/stdlib/errno.h @@ -20,53 +20,41 @@ */ #ifndef _ERRNO_H +#define _ERRNO_H 1 -/* The includer defined __need_Emath if he wants only the definitions - of EDOM and ERANGE, and not everything else. */ -#ifndef __need_Emath -# define _ERRNO_H 1 -# include <features.h> -#endif +#include <features.h> -__BEGIN_DECLS - -/* Get the error number constants from the system-specific file. - This file will test __need_Emath and _ERRNO_H. */ +/* The system-specific definitions of the E* constants, as macros. */ #include <bits/errno.h> -#undef __need_Emath -#ifdef _ERRNO_H +/* When included from assembly language, this header only provides the + E* constants. */ +#ifndef __ASSEMBLER__ -/* Declare the `errno' variable, unless it's defined as a macro by - bits/errno.h. This is the case in GNU, where it is a per-thread - variable. This redeclaration using the macro still works, but it - will be a function declaration without a prototype and may trigger - a -Wstrict-prototypes warning. */ -#ifndef errno -extern int errno; -#endif +__BEGIN_DECLS -#ifdef __USE_GNU +/* The error code set by various library functions. */ +extern int *__errno_location (void) __THROW __attribute_const__; +# define errno (*__errno_location ()) + +# ifdef __USE_GNU /* The full and simple forms of the name with which the program was invoked. These variables are set up automatically at startup based on the value of argv[0]. */ -extern char *program_invocation_name, *program_invocation_short_name; -#endif /* __USE_GNU */ -#endif /* _ERRNO_H */ +extern char *program_invocation_name; +extern char *program_invocation_short_name; -__END_DECLS +/* bits/errno.h may have defined this type. If it didn't, provide a + fallback definition. */ +# ifndef __error_t_defined +# define __error_t_defined 1 +typedef int error_t; +# endif -#endif /* _ERRNO_H */ +# endif /* __USE_GNU */ -/* The Hurd <bits/errno.h> defines `error_t' as an enumerated type so - that printing `error_t' values in the debugger shows the names. We - might need this definition sometimes even if this file was included - before. */ -#if defined __USE_GNU || defined __need_error_t -# ifndef __error_t_defined -typedef int error_t; -# define __error_t_defined 1 -# endif -# undef __need_error_t -#endif +__END_DECLS + +#endif /* !__ASSEMBLER__ */ +#endif /* errno.h */ |