mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-26 20:51:11 +00:00
fd860eaaa8
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.
51 lines
2.1 KiB
C
51 lines
2.1 KiB
C
/* Error constants. Generic version.
|
|
Copyright (C) 1991-2017 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
/* This file defines the errno constants. */
|
|
|
|
#ifndef _BITS_ERRNO_H
|
|
#define _BITS_ERRNO_H 1
|
|
|
|
#if !defined _ERRNO_H
|
|
# error "Never include <bits/errno.h> directly; use <errno.h> instead."
|
|
#endif
|
|
|
|
#error "Generic bits/errno.h included -- port is incomplete."
|
|
|
|
/* Authors of new ports of the GNU C Library must override this file
|
|
with their own bits/errno.h in an appropriate subdirectory of
|
|
sysdeps/. Its function is to define all of the error constants
|
|
from C2011 and POSIX.1-2008, with values appropriate to the
|
|
operating system, and any additional OS-specific error constants.
|
|
|
|
C2011 requires all error constants to be object-like macros that
|
|
expand to "integer constant expressions with type int, positive
|
|
values, and suitable for use in #if directives". Moreover, all of
|
|
their names must begin with a capital E, followed immediately by
|
|
either another capital letter, or a digit. It is OK to define
|
|
macros that are not error constants, but only in the implementation
|
|
namespace.
|
|
|
|
errno.h is sometimes included from assembly language. Therefore,
|
|
when __ASSEMBLER__ is defined, bits/errno.h may only define macros;
|
|
it may not make any other kind of C declaration or definition.
|
|
Also, the error constants should, if at all possible, expand to
|
|
simple decimal or hexadecimal numbers. */
|
|
|
|
#endif /* bits/errno.h. */
|