diff options
author | Zack Weinberg <zackw@panix.com> | 2016-11-20 20:46:30 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2017-05-11 19:27:59 -0400 |
commit | 7c3018f9e4de2e9d1f03a749be41b5eced6f9834 (patch) | |
tree | bbbdf74cdb0ea68929a780292d494ac3687a88dc /include | |
parent | 171199159214f2f548132a98988435f9a450d3ef (diff) | |
download | glibc-7c3018f9e4de2e9d1f03a749be41b5eced6f9834.zip glibc-7c3018f9e4de2e9d1f03a749be41b5eced6f9834.tar.gz glibc-7c3018f9e4de2e9d1f03a749be41b5eced6f9834.tar.bz2 |
Suppress internal declarations for most of the testsuite.
This patch adds a new build module called 'testsuite'.
IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
(which means several ad-hoc tests for __cplusplus can go away).
libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
defined; in particular, _ISOMAC mode does not get config.h
automatically anymore.
There are still quite a few tests that need to see internal gunk of
one variety or another. For them, we now have 'tests-internal' and
'test-internal-extras'; files in this category will still be compiled
with MODULE_NAME=nonlib, and everything proceeds as it always has.
The bulk of this patch is moving tests from 'tests' to
'tests-internal'. There is also 'tests-static-internal', which has
the same effect on files in 'tests-static', and 'modules-names-tests',
which has the *inverse* effect on files in 'modules-names' (it's
inverted because most of the things in modules-names are *not* tests).
For both of these, the file must appear in *both* the new variable and
the old one.
There is also now a special case for when libc-symbols.h is included
without MODULE_NAME being defined at all. (This happens during the
creation of libc-modules.h, and also when preprocessing Versions
files.) When this happens, IS_IN is set to be always false and
_ISOMAC is *not* defined, which was the status quo, but now it's
explicit.
The remaining changes to C source files in this patch seemed likely to
cause problems in the absence of the main change. They should be
relatively self-explanatory. In a few cases I duplicated a definition
from an internal header rather than move the test to tests-internal;
this was a judgement call each time and I'm happy to change those
however reviewers feel is more appropriate.
* Makerules: New subdir configuration variables 'tests-internal'
and 'test-internal-extras'. Test files in these categories will
still be compiled with MODULE_NAME=nonlib. Test files in the
existing categories (tests, xtests, test-srcs, test-extras) are
now compiled with MODULE_NAME=testsuite.
New subdir configuration variable 'modules-names-tests'. Files
which are in both 'modules-names' and 'modules-names-tests' will
be compiled with MODULE_NAME=testsuite instead of
MODULE_NAME=extramodules.
(gen-as-const-headers): Move to tests-internal.
(do-tests-clean, common-mostlyclean): Support tests-internal.
* Makeconfig (built-modules): Add testsuite.
* Makefile: Change libof-check-installed-headers-c and
libof-check-installed-headers-cxx to 'testsuite'.
* Rules: Likewise. Support tests-internal.
* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
Remove extra-modules.mk.
* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
very top of the file and rationalize their order.
If MODULE_NAME is not defined at all, define IS_IN to always be
false, and don't define _ISOMAC.
If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
true, define _ISOMAC and suppress everything else in this file,
starting with the inclusion of config.h.
Do check for inappropriate definitions of __OPTIMIZE__ and
__FAST_MATH__ here, but only if _ISOMAC is not defined.
Correct some out-of-date commentary.
* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
and _Mlong_double_ before including math.h.
* include/string.h: If _ISOMAC is defined, don't expose
_STRING_ARCH_unaligned. Move a comment to a more appropriate
location.
* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
* include/time.h, include/unistd.h, include/wchar.h: No need to
check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.
* misc/sys/cdefs.h (__NTHNL): New macro.
* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
(__m81_defun): Use __NTHNL to avoid errors with GCC 6.
* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
defined, for HAVE_TUNABLES.
* inet/tst-checks-posix.c: No need to define _ISOMAC.
* intl/tst-gettext2.c: Provide own definition of N_.
* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
* math/test-signgam-main.c: No need to define _ISOMAC.
* stdlib/tst-strtod.c: Convert to test-driver. Split locale_test to...
* stdlib/tst-strtod1i.c: ...this new file.
* stdlib/tst-strtod5.c: Convert to test-driver and add copyright notice.
Split tests of __strtod_internal to...
* stdlib/tst-strtod5i.c: ...this new file.
* string/test-string.h: Include stdint.h. Duplicate definition of
inhibit_loop_to_libcall here (from libc-symbols.h).
* string/test-strstr.c: Provide dummy definition of
libc_hidden_builtin_def when including strstr.c.
* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
Don't include init-arch.h.
* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
Don't include init-arch.h.
* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
unload, unload2, circleload1, neededtest, neededtest2,
neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
tst-stackguard1, tst-_dl_addr_inside_object, and all of the
ifunc tests to tests-internal.
Don't add $(modules-names) to test-extras.
* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
Add tst-deadline to tests-static-internal.
* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
tests-internal.
* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
tst-sem12-static, and tst-stackguard1-static to tests-internal.
Link tests-internal with libpthread also.
Don't add $(modules-names) to test-extras.
* nss/Makefile: Move tst-field to tests-internal.
* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
tests-internal.
* sunrpc/Makefile: Move tst-svc_register to tests-internal.
* sysdeps/powerpc/Makefile: Move test-get_hwcap and
test-get_hwcap-static to tests-internal.
* sysdeps/unix/sysv/linux/Makefile: Move tst-setgetname to
tests-internal.
* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
modules-names-tests.
Diffstat (limited to 'include')
-rw-r--r-- | include/errno.h | 2 | ||||
-rw-r--r-- | include/libc-symbols.h | 68 | ||||
-rw-r--r-- | include/math.h | 5 | ||||
-rw-r--r-- | include/stdio.h | 7 | ||||
-rw-r--r-- | include/stdlib.h | 4 | ||||
-rw-r--r-- | include/string.h | 10 | ||||
-rw-r--r-- | include/time.h | 4 | ||||
-rw-r--r-- | include/unistd.h | 3 | ||||
-rw-r--r-- | include/wchar.h | 2 |
9 files changed, 61 insertions, 44 deletions
diff --git a/include/errno.h b/include/errno.h index 7df41df..73fc32e 100644 --- a/include/errno.h +++ b/include/errno.h @@ -2,7 +2,7 @@ #include <stdlib/errno.h> -#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus +#if defined _ERRNO_H && !defined _ISOMAC # if IS_IN (rtld) # include <dl-sysdep.h> diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 18f26b2..3310e3a 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -20,26 +20,46 @@ #ifndef _LIBC_SYMBOLS_H #define _LIBC_SYMBOLS_H 1 -#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME) -#define IS_IN(lib) (IN_MODULE == MODULE_##lib) +/* This file is included implicitly in the compilation of every source file, + using -include. It includes config.h. */ -/* Returns true if the current module is a versioned library. Versioned - library names culled from shlib-versions files are assigned a MODULE_* - value lower than MODULE_LIBS_BEGIN. */ -#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN) - -#define PASTE_NAME(a,b) PASTE_NAME1 (a,b) -#define PASTE_NAME1(a,b) a##b - -/* This file's macros are included implicitly in the compilation of every - file in the C library by -imacros. - - We include config.h which is generated by configure. - It should define for us the following symbol: +/* Enable declarations of GNU extensions, since we are compiling them. */ +#define _GNU_SOURCE 1 + +#ifdef MODULE_NAME + +/* Use `#if IS_IN (module)` to detect what component is being compiled. */ +#define PASTE_NAME1(a,b) a##b +#define PASTE_NAME(a,b) PASTE_NAME1 (a,b) +#define IN_MODULE PASTE_NAME (MODULE_, MODULE_NAME) +#define IS_IN(lib) (IN_MODULE == MODULE_##lib) + +/* True if the current module is a versioned library. Versioned + library names culled from shlib-versions files are assigned a + MODULE_* value greater than MODULE_LIBS_BEGIN. */ +#define IS_IN_LIB (IN_MODULE > MODULE_LIBS_BEGIN) + +/* The testsuite, and some other ancillary code, should be compiled against + as close an approximation to the installed headers as possible. + Defining this symbol disables most internal-use-only declarations + provided by this header, and all those provided by other internal + wrapper headers. */ +#if IS_IN (testsuite) || defined IS_IN_build || defined __cplusplus +# define _ISOMAC 1 +#endif - * HAVE_ASM_SET_DIRECTIVE if we have `.set B, A' instead of `A = B'. +#else +/* The generation process for a few files created very early in the + build (notably libc-modules.h itself) involves preprocessing this + header without defining MODULE_NAME. Under these conditions, + internal declarations (especially from config.h) must be visible, + but IS_IN should always evaluate as false. */ +# define IS_IN(lib) 0 +# define IS_IN_LIB 0 +# define IN_MODULE (-1) +#endif - */ +#ifndef _ISOMAC /* This is defined for the compilation of all C library code. features.h tests this to avoid inclusion of stubs.h while compiling the library, @@ -50,8 +70,17 @@ itself is being compiled, or just some generator program. */ #define _LIBC 1 -/* Enable declarations of GNU extensions, since we are compiling them. */ -#define _GNU_SOURCE 1 +/* Some files must be compiled with optimization on. */ +#if !defined __ASSEMBLER__ && !defined __OPTIMIZE__ +# error "glibc cannot be compiled without optimization" +#endif + +/* -ffast-math cannot be applied to the C library, as it alters the ABI. + Some test components that use -ffast-math are currently not part of + IS_IN (testsuite) for technical reasons, so we have a secondary override. */ +#if defined __FAST_MATH__ && !defined TEST_FAST_MATH +# error "glibc must not be compiled with -ffast-math" +#endif #include <config.h> @@ -936,4 +965,5 @@ for linking") # define _GL_ATTRIBUTE_CONST /* empty */ #endif +#endif /* !_ISOMAC */ #endif /* libc-symbols.h */ diff --git a/include/math.h b/include/math.h index a4f5562..6ff6783 100644 --- a/include/math.h +++ b/include/math.h @@ -1,5 +1,10 @@ #ifndef _MATH_H +#ifdef _ISOMAC +# undef NO_LONG_DOUBLE +# undef _Mlong_double_ +#endif + #include <math/math.h> #ifndef _ISOMAC diff --git a/include/stdio.h b/include/stdio.h index 4e7cfa1..ed6593b 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,11 +1,10 @@ #ifndef _STDIO_H -# if defined __need_FILE || defined __need___FILE || defined _ISOMAC +# if defined _ISOMAC || defined __need_FILE || defined __need___FILE # include <libio/stdio.h> # else # include <libio/stdio.h> /* Now define the internal interfaces. */ -__BEGIN_DECLS extern int __fcloseall (void); extern int __snprintf (char *__restrict __s, size_t __maxlen, @@ -30,7 +29,6 @@ extern int __vsscanf (const char *__restrict __s, _G_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))); -# ifndef __cplusplus extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW; extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...) __THROW; @@ -52,7 +50,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) __THROW; extern int __obstack_vprintf_chk (struct obstack *, int, const char *, _G_va_list) __THROW; -# endif extern int __isoc99_fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; @@ -186,7 +183,5 @@ libc_hidden_proto (__obstack_vprintf_chk) extern FILE * __fmemopen (void *buf, size_t len, const char *mode); libc_hidden_proto (__fmemopen) -__END_DECLS # endif - #endif diff --git a/include/stdlib.h b/include/stdlib.h index 929cead..c3ee680 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -9,8 +9,6 @@ #if !defined _ISOMAC # include <sys/stat.h> -__BEGIN_DECLS - extern __typeof (strtol_l) __strtol_l; extern __typeof (strtoul_l) __strtoul_l; extern __typeof (strtoll_l) __strtoll_l; @@ -261,8 +259,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden; extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; # endif -__END_DECLS - #endif #endif /* include/stdlib.h */ diff --git a/include/string.h b/include/string.h index f166de9..ce71674 100644 --- a/include/string.h +++ b/include/string.h @@ -1,6 +1,8 @@ #ifndef _STRING_H -#if !defined _ISOMAC && !defined __cplusplus +#ifndef _ISOMAC +/* Some of these are defined as macros in the real string.h, so we must + prototype them before including it. */ #include <sys/types.h> extern void *__memccpy (void *__dest, const void *__src, @@ -46,16 +48,14 @@ extern void __bzero (void *__s, size_t __n) __THROW __nonnull ((1)); extern int __ffs (int __i) __attribute__ ((const)); extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen); -#endif /* Get _STRING_ARCH_unaligned. */ #include <string_private.h> +#endif -/* Now the real definitions. We do this here since some of the functions - above are defined as macros in the headers. */ #include <string/string.h> -#if !defined _ISOMAC && !defined __cplusplus +#ifndef _ISOMAC extern __typeof (strcoll_l) __strcoll_l; extern __typeof (strxfrm_l) __strxfrm_l; extern __typeof (strcasecmp_l) __strcasecmp_l; diff --git a/include/time.h b/include/time.h index 6badf0e..3a828e0 100644 --- a/include/time.h +++ b/include/time.h @@ -4,8 +4,6 @@ #ifndef _ISOMAC # include <xlocale.h> -__BEGIN_DECLS - extern __typeof (strftime_l) __strftime_l; libc_hidden_proto (__strftime_l) extern __typeof (strptime_l) __strptime_l; @@ -104,7 +102,5 @@ extern double __difftime (time_t time1, time_t time0); actual clock ID. */ #define CLOCK_IDFIELD_SIZE 3 -__END_DECLS - #endif #endif diff --git a/include/unistd.h b/include/unistd.h index 0cdf06e..5b2a414 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -2,7 +2,6 @@ # include <posix/unistd.h> # ifndef _ISOMAC -__BEGIN_DECLS libc_hidden_proto (_exit, __noreturn__) rtld_hidden_proto (_exit, __noreturn__) @@ -190,7 +189,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize) extern __typeof (__access) __access_noerrno attribute_hidden; # endif -__END_DECLS # endif - #endif diff --git a/include/wchar.h b/include/wchar.h index 6272130..e2579a1 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s, const wchar_t *__restrict __format, __gnuc_va_list __arg) /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */; -#ifndef __cplusplus extern int __vfwprintf_chk (FILE *__restrict __s, int __flag, const wchar_t *__restrict __format, __gnuc_va_list __arg) @@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; libc_hidden_proto (__vfwprintf_chk) libc_hidden_proto (__vswprintf_chk) -#endif extern int __isoc99_fwscanf (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...); |