Rical Jasan [Mon, 19 Feb 2018 12:32:35 +0000 (04:32 -0800)]
manual: Update the _ISOC99_SOURCE description.
The current description refers to ISO C99 not being widely adopted,
which it is believed to be now.
* manual/creature.texi (_ISOC99_SOURCE): Update the dated
description.
Rical Jasan [Mon, 19 Feb 2018 11:30:06 +0000 (03:30 -0800)]
manual: Document missing feature test macros.
Several feature test macros are documented in features.h but absent in
the manual, and some documented macros accept undocumented values.
This commit updates the manual to mention all the accepted macros,
along with any values that hold special meaning.
* manual/creature.texi (_POSIX_C_SOURCE): Document special
values of 199606L, 200112L, and 200809L.
(_XOPEN_SOURCE): Document special values of 600 and 700.
(_ISOC11_SOURCE): Document macro.
(_ATFILE_SOURCE): Likewise.
(_FORTIFY_SOURCE): Likewise.
Joseph Myers [Mon, 19 Feb 2018 17:32:34 +0000 (17:32 +0000)]
Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for ferror_unlocked.
The usual approach is followed of adding __ferror_unlocked (inlined
when ferror_unlocked is), making calls use it when required for
namespace reasons (only one such call), and using libc_hidden_proto /
libc_hidden_weak for the ferror_unlocked weak alias when only localplt
but not namespace issues are involved.
Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved). Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.
[BZ #15105]
[BZ #19463]
* libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked
and define as weak alias of __ferror_unlocked. Use
libc_hidden_weak.
* include/stdio.h [!_ISOMAC] (ferror_unlocked): Use
libc_hidden_proto.
[!_ISOMAC] (__ferror_unlocked) New declaration, and inline
function if [__USE_EXTERN_INLINES].
* time/getdate.c (__getdate_r): Call __ferror_unlocked instead of
ferror_unlocked.
Rical Jasan [Fri, 16 Feb 2018 16:47:20 +0000 (08:47 -0800)]
manual: Improve documentation of get_current_dir_name. [BZ #6889]
This is a minor rewording to clarify the behaviour of
get_current_dir_name. Additionally, the @vindex is moved above the
@deftypefun so that following links give a better result with regard
to context.
[BZ #6889]
* manual/filesys.texi (get_current_dir_name): Clarify
behaviour.
Aurelien Jarno [Sun, 18 Feb 2018 17:23:14 +0000 (18:23 +0100)]
Fix posix/tst-glob_lstat_compat on alpha [BZ #22818]
The tst-glob_lstat_compat test needs to run tests on the previous
version of glob. On alpha, there are three versions of glob, GLIBC_2.0,
GLIBC_2.1 and GLIBC_2.27, while on other architectures there are only
the GLIBC_2.0 and GLIBC_2.27 version. Therefore on alpha the previous
version is GLIBC_2.1 and not GLIBC_2.0.
Changelog:
[BZ #22818]
* posix/tst-glob_lstat_compat.c [__alpha__] (glob): Access
the GLIBC_2.1 version.
Aurelien Jarno [Sun, 18 Feb 2018 17:15:47 +0000 (18:15 +0100)]
intl/tst-gettext: fix failure with newest msgfmt
Since upstream gettext commit
d13f165b83 (msgfmt: Remove
POT-Creation-Date field from the header in the output.), msgfmt does not
copy the POT-Creation-Date field in the header entry from the po file to
the mo file anymore. This breaks the assumption that we can test gettext
by comparing each message in the po files with the corresponding string
return by gettext. This makes the intl/tst-gettext to fail.
While it would have been possible to modify the po2test.awk script to
also strip the line POT-Creation-Date field when creating the msgs.h
file, it would not work with both the old and new msgfmt.
Instead create a tst-gettext-de.po file from de.po by removing the
POT-Creation-Date line. Another alternative would be to use a static
tst-gettext-de.po file, but I guess the reason for using de.po is to
also catch issues caused by newly added strings.
As tst-catgets also uses msg.h, it should also be updated. Instead of
using the new tst-gettext-de.po file, the patch modifies xopen-msg.awk
to avoid creating a second catgets->intl dependency.
Changelog:
[BZ #21508]
* catgets/xopen-msg.awk: Ignore POT-Creation-Date line.
* intl/Makefile ($(objpfx)tst-gettext-de.po): Generate
intl/tst-gettext-de.po from po/de.po by removing the
POT-Creation-Date line.
($(objpfx)msgs.h): Depend on $(objpfx)tst-gettext-de.po instead of
../po/de.po.
* intl/tst-gettext.sh: Use ${objpfx}tst-gettext-de.po instead of
../po/de.po.
Samuel Thibault [Sat, 17 Feb 2018 22:26:45 +0000 (23:26 +0100)]
hurd: Fix build on missing __ptsname_internal function
* sysdeps/mach/hurd/ptsname.c: Include <sys/stat.h>.
(__ptsname_r): Move implementation to...
(__ptsname_internal): ... new function. Add filling the STP
structure.
Samuel Thibault [Sat, 17 Feb 2018 21:57:26 +0000 (22:57 +0100)]
hurd: Define EXEC_PAGESIZE
* mach/Makefile (headers): Add mach/param.h.
* sysdeps/mach/hurd/bits/param.h: Include <mach/param.h>.
* sysdeps/mach/i386/mach/param.h: New file, defines EXEC_PAGESIZE
John David Anglin [Sat, 17 Feb 2018 18:46:50 +0000 (13:46 -0500)]
Fix ulps for pow on hppa.
* sysdeps/hppa/fpu/libm-test-ulps (pow): Increase double and
idouble to 1 ULP.
Rical Jasan [Fri, 16 Feb 2018 16:21:47 +0000 (08:21 -0800)]
manual: Fix a syntax error.
The opening parenthesis for function arguments in an @deftypefun need
to be separated from the function name. This isn't just a matter of
the GNU coding style---it causes the "(void" (in this case) to be
rendered as a part of the function name, causing a visual defect, and
also results in a warning to the following effect during `make pdf':
Warning: unbalanced parentheses in @def...)
* manual/platform.texi (__riscv_flush_icache): Fix @deftypefun
syntax.
Stefan Liebler [Fri, 16 Feb 2018 08:57:30 +0000 (09:57 +0100)]
Add runtime check if mutex will be elided in tst-mutex8 testcases.
An elided mutex don't fail destroy. Elision was disabled for the
test nptl/tst-mutex8 in nptl/Makefile. Thus we can run tests which
destroy a locked mutex.
As elision is only disabled for tst-mutex8, the variants
tst-mutex8-static, tst-mutexpi8 and tst-mutexpi8-static are still
failing if lock elision is enabled.
This patch adds a runtime check, if the checked type of mutex will
be elided. This check is using TUNABLE_GET_FULL to determine if
elision is enabled via the tunables framework.
The pthread_mutex_destroy tests are only run if we dont't assume an
elided mutex.
This way, we can run the whole glibc testsuite with or without enabled
lock elision.
ChangeLog:
* nptl/Makefile (tst-mutex8-ENV): Delete.
* nptl/tst-mutex8.c (check_type):
Add runtime check if mutex will be elided.
Joseph Myers [Thu, 15 Feb 2018 23:48:47 +0000 (23:48 +0000)]
Document use of CC and CFLAGS in more detail (bug 20980, bug 21234).
There are some bug reports from people setting CFLAGS not including a
-O option and then being confused when the build fails. This patch
addresses this by documenting the proper use of CC and CFLAGS in more
detail - saying what options should go where and specifying the
requirement to compile with optimization.
The previous text incorrectly used @var markup with CC and CFLAGS.
The correct markup for environment variables is @env, but it's also
the case that passing such variables explicitly on the configure
command line is preferred to passing them in the environment, so this
patch changes the documentation to describe passing them on the
command line (and uses @code).
In many cases putting options in the wrong place may in fact work, but
I believe what I've specified is the correct rule for which options to
put where.
[BZ #20980]
[BZ #21234]
* manual/install.texi (Configuring and compiling): Describe
passing CC and CFLAGS on configure command line, not as
environment variables. Use @code markup on those variables.
Specify what options go in CC and what go in CFLAGS. Note the
requirement to compile with optimization.
* INSTALL: Regenerated.
Joseph Myers [Thu, 15 Feb 2018 21:01:25 +0000 (21:01 +0000)]
Fix hppa local PLT entries for sigprocmask (bug 18124).
When adding/updating localplt.data for various architectures to get
the compilation tests passing everywhere, I generally made it reflect
the existing state of what local PLT entries were actually seen,
rather than an ideal state with as few as possible such entries,
mainly for functions that are intended to be interposable.
This patch eliminates some local PLT entries for hppa by using
__sigprocmask instead of sigprocmask in getcontext and setcontext.
The specific case of sigprocmask called by setcontext is the third of
four items in bug 18124 (the other three have already been fixed for
2.26 or earlier releases). Note that hppa-specific localplt.data
entries for __sigsetjmp, _IO_funlockfile and __errno_location remain,
but the causes / fixes are less immediately obvious from source
inspection.
Tested (compilation tests only) with build-many-glibcs.py for
hppa-linux-gnu.
[BZ #18124]
* sysdeps/hppa/bsd-setjmp.S: Include <sysdep.h>.
(setjmp): Use HIDDEN_JUMPTARGET with __sigsetjmp.
* sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Call
__sigprocmask instead of sigprocmask.
* sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext):
Likewise.
* sysdeps/unix/sysv/linux/hppa/localplt.data: Remove entries for
__sigsetjmp and sigprocmask.
Joseph Myers [Thu, 15 Feb 2018 21:00:02 +0000 (21:00 +0000)]
Use libc_hidden_* for argz_next, __argz_next (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for argz_next and __argz_next. This is a
simple case of functions that are inlined for -O2 but not for -Os;
this patch adds libc_hidden_proto / libc_hidden_def for them to avoid
localplt failures even when not inlined.
Tested for x86_64 (both that it removes these particular localplt
failures for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).
[BZ #15105]
* include/argz.h (argz_next): Use libc_hidden_proto.
(__argz_next): Likewise.
* string-argz-next.c (__argz_next): Use libc_hidden_def.
(argz_next): Use libc_hidden_weak.
Joseph Myers [Thu, 15 Feb 2018 20:59:12 +0000 (20:59 +0000)]
Use libc_hidden_* for __cmsg_nxthdr (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for __cmsg_nxthdr. This is a simple case of a
function that is inlined for -O2 but not for -Os; this patch adds
libc_hidden_proto / libc_hidden_def for it to avoid a localplt failure
even when it is not inlined.
Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).
[BZ #15105]
* include/sys/socket.h [!_ISOMAC] (__cmsg_nxthdr): Use
libc_hidden_proto.
* sysdeps/unix/sysv/linux/cmsg_nxthdr.c (__cmsg_nxthdr): Use
libc_hidden_def.
Joseph Myers [Thu, 15 Feb 2018 20:58:16 +0000 (20:58 +0000)]
Use libc_hidden_* for fputs (bug 15105).
Among other localplt test failures when building with -Os, there are
libc.so PLT references for fputs. fputs calls normally get redirected
to _IO_fputs by a macro in include/stdio.h (and _IO_fputs in turn uses
libc_hidden_proto), but GCC can convert an fprintf call with a
constant string argument into an fputs call, which of course is then
unaffected by the macro redirection. (I don't know why this issue
only appears with -Os.)
This patch duly adds a use of libc_hidden_proto for fputs. I see no
obvious reason why the fputs macro redirection is needed at all, but
this patch does not change it.
Tested for x86_64 (both that it removes this particular localplt
failure for -Os - but other such failures remain so the bug can't yet
be closed - and that the testsuite continues to pass without -Os).
[BZ #15105]
* include/stdio.h [!_ISOMAC && IS_IN (libc)] (fputs): Use
libc_hidden_proto.
* libio/iofputs.c (fputs): Use libc_hidden_weak.
Joseph Myers [Thu, 15 Feb 2018 20:57:15 +0000 (20:57 +0000)]
Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).
Continuing the fixes for linknamespace and localplt test failures with
-Os that arise from functions not being inlined in that case, this
patch fixes such failures for feof_unlocked.
The usual approach is followed of adding __feof_unlocked (inlined when
feof_unlocked is), making calls use it when required for namespace
reasons, and using libc_hidden_proto / libc_hidden_weak for the
feof_unlocked weak alias when only localplt but not namespace issues
are involved. In the case of getaddrinfo.c, use of __feof_unlocked
needs to be conditional since that code is also used in nscd (where
__feof_unlocked is not available).
Tested for x86_64 (both without -Os to make sure that case continues
to work, and with -Os to make sure all the relevant linknamespace and
localplt test failures are resolved). Because of other such failures
that remain after this patch, neither of the bugs can yet be closed.
[BZ #15105]
[BZ #19463]
* libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and
define as weak alias of __feof_unlocked. Use libc_hidden_weak.
* include/stdio.h (feof_unlocked): Use libc_hidden_proto.
(__feof_unlocked): New declaration, and inline function if
[__USE_EXTERN_INLINES].
* iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked
instead of feof_unlocked.
* intl/localealias.c [_LIBC] (FEOF): Likewise.
* nss/nsswitch.c (nss_parse_file): Likewise.
* sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area):
Likewise.
* time/getdate.c (__getdate_r): Likewise.
* sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked):
Define as macro to call __feof_unlocked.
Wilco Dijkstra [Thu, 15 Feb 2018 12:38:10 +0000 (12:38 +0000)]
[AArch64] Fix include.
Fix include to use <>.
* sysdeps/aarch64/fpu/fpu_control.h: Use <> in include.
Wilco Dijkstra [Thu, 15 Feb 2018 12:35:54 +0000 (12:35 +0000)]
Remove mplog and mpexp
Remove the now unused mplog and mpexp files.
* math/Makefile: Remove mpexp.c and mplog.c
* sysdeps/i386/fpu/mpexp.c: Delete file.
* sysdeps/i386/fpu/mplog.c: Likewise.
* sysdeps/ia64/fpu/mpexp.c: Likewise.
* sysdeps/ia64/fpu/mplog.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp.c: Remove mention of mpexp and mplog.
* sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): Remove unused function.
* sysdeps/ieee754/dbl-64/mpexp.c: Delete file.
* sysdeps/ieee754/dbl-64/mplog.c: Likewise.
* sysdeps/m68k/m680x0/fpu/mpexp.c: Likewise.
* sysdeps/m68k/m680x0/fpu/mplog.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/Makefile: Remove mpexp* and mplog*.
* sysdeps/x86_64/fpu/multiarch/e_log-avx.c: Remove unused defines.
* sysdeps/x86_64/fpu/multiarch/e_log-fma.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/mpexp-avx.c: Delete file.
* sysdeps/x86_64/fpu/multiarch/mpexp-fma.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/mplog-avx.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/mplog-fma.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise.
Stefan Liebler [Thu, 15 Feb 2018 08:06:18 +0000 (09:06 +0100)]
S390: Regenerate ULPs.
Regenerated ulps file from scratch due to recent pow changes.
ChangeLog:
* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
Adhemerval Zanella [Wed, 14 Feb 2018 16:03:13 +0000 (14:03 -0200)]
Update SH libm-tests-ulps
* sysdeps/sh/libm-test-ulps: Update.
Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Tulio Magno Quites Machado Filho [Mon, 12 Feb 2018 14:10:21 +0000 (12:10 -0200)]
powerpc: Update pow() ULPs
* sysdeps/powerpc/fpu/libm-test-ulps (pow): Increase double and
idouble to 1 ULP.
Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Zack Weinberg [Wed, 7 Feb 2018 20:45:58 +0000 (15:45 -0500)]
[BZ #19239] Don't include sys/sysmacros.h from sys/types.h.
This completes the deprecation and removal of this inclusion, which
was begun in the 2.25 release.
* posix/sys/types.h: Don't include sys/sysmacros.h.
* misc/sys/sysmacros.h: Remove the conditional deprecation
warnings for the macros defined by this header.
Szabolcs Nagy [Tue, 30 Jan 2018 14:48:22 +0000 (14:48 +0000)]
Remove slow paths from exp
Remove the __slowexp code, so exp is no longer correctly rounded. The
result is computed to about 70 bits precision so the worst case ulp
error is about 0.500007 in nearest rounding mode.
* manual/probes.texi: Remove slowexp probes.
* math/Makefile: Remove slowexp.
* sysdeps/generic/math_private.h (__slowexp): Remove.
* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Remove __slowexp and
document error bounds.
* sysdeps/i386/fpu/slowexp.c: Remove.
* sysdeps/ia64/fpu/slowexp.c: Remove.
* sysdeps/ieee754/dbl-64/slowexp.c: Remove.
* sysdeps/ieee754/dbl-64/uexp.h (err_0): Remove.
* sysdeps/m68k/m680x0/fpu/slowexp.c: Remove.
* sysdeps/powerpc/power4/fpu/Makefile (CPPFLAGS-slowexp.c): Remove.
* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowexp-fma.
* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Remove.
* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Remove.
* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Remove.
* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Remove.
* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Remove.
* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Remove.
Wilco Dijkstra [Mon, 12 Feb 2018 10:42:42 +0000 (10:42 +0000)]
Remove slow paths from pow
Remove the slow paths from pow. Like several other double precision math
functions, pow is exactly rounded. This is not required from math functions
and causes major overheads as it requires multiple fallbacks using higher
precision arithmetic if a result is close to 0.5ULP. Ridiculous slowdowns
of up to 100000x have been reported when the highest precision path triggers.
All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1).
The worst case error is ~0.506ULP. A simple test over a few hundred million
values shows pow is 10% faster on average. This fixes BZ #13932.
[BZ #13932]
* sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove.
* benchtests/pow-inputs: Update comment for slow path cases.
* manual/probes.texi (slowpow_p10): Delete removed probe.
(slowpow_p10): Likewise.
* math/Makefile: Remove halfulp.c and slowpow.c.
* sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1.
* sysdeps/generic/math_private.h (__exp1): Remove error argument.
(__halfulp): Remove.
(__slowpow): Remove.
* sysdeps/i386/fpu/halfulp.c: Delete file.
* sysdeps/i386/fpu/slowpow.c: Likewise.
* sysdeps/ia64/fpu/halfulp.c: Likewise.
* sysdeps/ia64/fpu/slowpow.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument,
improve comments and add error analysis.
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis.
(power1): Remove function:
(log1): Remove error argument, add error analysis.
(my_log2): Remove function.
* sysdeps/ieee754/dbl-64/halfulp.c: Delete file.
* sysdeps/ieee754/dbl-64/slowpow.c: Likewise.
* sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise.
* sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise.
* sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c.
* sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1.
* sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c,
slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c.
* sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define.
* sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise.
* sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file.
* sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
Samuel Thibault [Sun, 28 Jan 2018 10:58:33 +0000 (11:58 +0100)]
nscd: don't unconditionally use PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP is Linux-only.
* nscd/connections.c (RWLOCK_INITIALIZER): Define to
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP or
PTHREAD_RWLOCK_INITIALIZER if that is not available.
(dbs): Use RWLOCK_INITIALIZER instead of
PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP.
Dmitry V. Levin [Fri, 29 Dec 2017 23:19:32 +0000 (23:19 +0000)]
linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #22433]
Remove compat-specific constants that were never exported by kernel
headers under these names. Before linux commit v3.7-rc1~16^2~1 they
were exported with COMPAT_ prefix, and since that commit they are not
exported at all.
* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request):
Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS,
and PTRACE_SETHBPREGS.
Zack Weinberg [Sat, 10 Feb 2018 21:24:17 +0000 (16:24 -0500)]
[BZ #22830] malloc_stats: restore cancellation for stderr correctly.
malloc_stats means to disable cancellation for writes to stderr while
it runs, but it restores stderr->_flags2 with |= instead of =, so what
it actually does is disable cancellation on stderr permanently.
[BZ #22830]
* malloc/malloc.c (__malloc_stats): Restore stderr->_flags2
correctly.
* malloc/tst-malloc-stats-cancellation.c: New test case.
* malloc/Makefile: Add new test case.
Wilco Dijkstra [Sat, 10 Feb 2018 15:02:51 +0000 (15:02 +0000)]
[AArch64] Fix testsuite error due to fpsr/fscr change
Add features.h include for __GNUC_PREREQ.
* sysdeps/aarch64/fpu/fpu_control.h: Add features.h to fix build error.
Joseph Myers [Sat, 10 Feb 2018 02:08:43 +0000 (02:08 +0000)]
Add narrowing add functions.
This patch adds the narrowing add functions from TS 18661-1 to glibc's
libm: fadd, faddl, daddl,
f32addf64, f32addf32x, f32xaddf64 for all
configurations; f32addf64x,
f32addf128, f64addf64x,
f64addf128,
f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with
_Float64x and _Float128; __nldbl_daddl for ldbl-opt. As discussed for
the build infrastructure patch, tgmath.h support is deliberately
deferred, and FP_FAST_* macros are not applicable without optimized
function implementations.
Function implementations are added for all relevant pairs of formats
(including certain cases of a format and itself where more than one
type has that format). The main implementations use round-to-odd, or
a trivial computation in the case where both formats are the same or
where the wider format is IBM long double (in which case we don't
attempt to be correctly rounding). The sysdeps/ieee754/soft-fp
implementations use soft-fp, and are used automatically for
configurations without exceptions and rounding modes by virtue of
existing Implies files. As previously discussed, optimized versions
for particular architectures are possible, but not included.
i386 gets a special version of f32xaddf64 to avoid problems with
double rounding (similar to the existing fdim version), since this
function must round just once without an intermediate rounding to long
double. (No such special version is needed for any other function,
because the nontrivial functions use round-to-odd, which does the
intermediate computation with the rounding mode set to round-to-zero,
and double rounding is OK except in round-to-nearest mode, so is OK
for that intermediate round-to-zero computation.) mul and div will
need slightly different special versions for i386 (using round-to-odd
on long double instead of precision control) because of the
possibility of inexact intermediate results in the subnormal range for
double.
To reduce duplication among the different function implementations,
math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD
and NARROW_ADD_TRIVIAL.
In the trivial cases and for any architecture-specific optimized
implementations, the overhead of the errno setting might be
significant, but I think that's best handled through compiler built-in
functions rather than providing separate no-errno versions in glibc
(and likewise there are no __*_finite entry points for these function
provided, __*_finite effectively being no-errno versions at present in
most cases).
Tested for x86_64 and x86, with both GCC 6 and GCC 7. Tested for
mips64 (all three ABIs, both hard and soft float) and powerpc with GCC
7. Tested with build-many-glibcs.py with both GCC 6 and GCC 7.
* math/Makefile (libm-narrow-fns): Add add.
(libm-test-funcs-narrow): Likewise.
* math/Versions (GLIBC_2.28): Add narrowing add functions.
* math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW .
* math/gen-auto-libm-tests.c (test_functions): Add add.
* math/math-narrow.h (CHECK_NARROW_ADD): New macro.
(NARROW_ADD_ROUND_TO_ODD): Likewise.
(NARROW_ADD_TRIVIAL): Likewise.
* sysdeps/ieee754/float128/float128_private.h (__faddl): New
macro.
(__daddl): Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and
dadd.
(CFLAGS-nldbl-dadd.c): New variable.
(CFLAGS-nldbl-fadd.c): Likewise.
* sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add
__nldbl_daddl.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New
prototype.
* manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl,
daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx.
* math/auto-libm-test-in: Add tests of add.
* math/auto-libm-test-out-narrow-add: New generated file.
* math/libm-test-narrow-add.inc: New file.
* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
* sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fadd.c: Likewise.
* sysdeps/ieee754/float128/s_f32addf128.c: Likewise.
* sysdeps/ieee754/float128/s_f64addf128.c: Likewise.
* sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise.
* sysdeps/ieee754/soft-fp/s_daddl.c: Likewise.
* sysdeps/ieee754/soft-fp/s_fadd.c: Likewise.
* sysdeps/ieee754/soft-fp/s_faddl.c: Likewise.
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
* sysdeps/mach/hurd/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
Joseph Myers [Sat, 10 Feb 2018 01:52:33 +0000 (01:52 +0000)]
Fix narrowing function tests build for powerpc64le.
Testing narrowing functions with build-many-glibcs.py showed up a
further testsuite fix needed to enable building such functions for
powerpc64le: tests test-<narrower-type>-float128-<function> (and
likewise for float64x) needed the same special handling for
powerpc64le as test-float128-* and test-float64x-*. This patch adds
that special handling.
Tested with build-many-glibcs.py for powerpc64le in conjunction with
the main patch adding narrowing add functions.
* sysdeps/powerpc/powerpc64le/Makefile [$(subdir) = math]
(f128-pairs): New variable.
[$(subdir) = math] ($(foreach suf,$(all-object-suffixes),$(foreach
pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf)))): Add -mfloat128
to CFLAGS.
[$(subdir) = math] ($(foreach pair,$(f128-pairs),test-$(pair)%)):
Also make tests add $(f128-loader-link) to gnulib-tests.
DJ Delorie [Fri, 9 Feb 2018 23:37:15 +0000 (18:37 -0500)]
[RISC-V] Fix parsing flags in ELF64 files.
When ldconfig reads Elf64 files to determine the ABI, it used the
Elf32 type, so read the wrong location, and stored the wrong ABI
type in the cache, making the cache useless. This patch uses
an Elf64 type for Elf64 objects instead.
Note that pre-patch caches might need to be manually removed and
regenerated to get the correct ABIs stored.
[BZ #22827]
* sysdeps/unix/sysv/linux/riscv/readelflib.c (process_elf_file): Use
64-bit ELF type for 64-bit ELF objects.
Joseph Myers [Fri, 9 Feb 2018 22:56:35 +0000 (22:56 +0000)]
Handle narrowing function sNaN test disabling based on argument format.
Testing narrowing functions for x86_64 with GCC 6 showed up a further
testsuite fix needed: there is no _Float128 sNaN support before GCC 7
on x86_64 / x86, and the existing tests of SNAN_TESTS only checked it
for the return type, not for the argument type. This patch fixes the
code to check SNAN_TESTS (ARG_FLOAT) as well (in a variable set in
libm-test-driver.c, since libm-test-support.c is compiled only once
for each choice of FLOAT).
Tested for x86_64 and x86 with GCC 6 in conjunction with the main
patch adding narrowing add functions.
* math/libm-test-driver.c (snan_tests_arg): New variable.
* math/libm-test-support.h (snan_tests_arg): New declaration.
* math/libm-test-support.c (enable_test): Check snan_tests_arg.
Joseph Myers [Fri, 9 Feb 2018 21:55:48 +0000 (21:55 +0000)]
Add test infrastructure for narrowing libm functions.
This patch continues preparations for adding TS 18661-1 narrowing libm
functions by adding the required testsuite infrastructure to test such
functions through the libm-test infrastructure.
That infrastructure is based around testing for a single type, FLOAT.
For the narrowing functions, FLOAT, the "main" type for testing, is
the function return type; the argument type is ARG_FLOAT. This is
consistent with how the code built once for each type,
libm-test-support.c, depends on FLOAT for such things as calculating
ulps errors in results but can already handle different argument types
(pointers, integers, long double for nexttoward).
Makefile machinery is added to handle building tests for all pairs of
types for which there are narrowing functions (as with non-narrowing
functions, aliases are tested just the same as the functions they
alias). gen-auto-libm-tests gains a --narrow option for building
outputs for narrowing functions (so narrowing sqrt and fma will share
the same inputs as non-narrowing, but gen-auto-libm-tests will be run
with and without that option to generate different output files). In
the narrowing case, the auto-libm-test-out-narrow-* files include
annotations for each test about what properties ARG_FLOAT must have to
be able to represent all the inputs for that test; those annotations
result in calls to the TEST_COND_arg_fmt macro.
gen-libm-test.pl has some minor updates to handle narrowing tests (for
example, arguments in such tests must be surrounded by ARG_LIT calls
instead of LIT calls). Various new macros are added to the C test
support code (for example, sNaN initializers need to be properly
typed, so arg_snan_value is added; other such arg_* macros are added
as it seems cleanest to do so, though some are not strictly required).
Special-casing of the ibm128 format to allow for its limitations is
adjusted to handle it as the argument format as well as as the result
format; thus, the tests of the new functions allow nonzero ulps only
in the case where ibm128 is the argument format, as otherwise the
functions correspond to fully-defined IEEE operations. The ulps in
question appear as e.g. 'Function: "add_ldouble"' in libm-test-ulps
(with 1ulp errors then listed for double and float for that function
in powerpc); no support is added to generate corresponding faddl /
daddl ulps listings in the ulps table in the manual.
For the previous patch, I noted the need to avoid spurious macro
expansions of identifiers such as "add". A test test-narrow-macros.c
is added to verify such macro expansions are successfully avoided, and
there is also a -mlong-double-64 version of that test for ldbl-opt.
This test is set up to cover the full set of relevant identifiers from
the start rather than adding functions one at a time as each function
group is added.
Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with the actual addition of
"add" functions).
* math/Makefile (test-type-pairs): New variable.
(test-type-pairs-f64xf128-yes): Likewise.
(tests): Add test-narrow-macros.
(libm-test-funcs-narrow): New variable.
(libm-test-c-narrow): Likewise.
(generated): Add $(libm-test-c-narrow).
(libm-tests-base-narrow): New variable.
(libm-tests-narrow): Likewise.
(libm-tests): Add $(libm-tests-narrow).
(libm-tests-for-type): Handle $(libm-tests-narrow).
(libm-test-c-narrow-obj): New variable.
($(libm-test-c-narrow-obj)): New rule.
($(foreach t,$(libm-tests-narrow),$(objpfx)$(t).c)): Likewise.
($(foreach f,$(libm-test-funcs-narrow),$(objpfx)$(o)-$(f).o)): Use
$(o-iterator) to set dependencies and CFLAGS.
* math/gen-auto-libm-tests.c: Document use for narrowing
functions.
(output_for_one_input_case): Take argument NARROW.
(generate_output): Likewise. Update call to
output_for_one_input_case.
(main): Take --narrow option. Update call to generate_output.
* math/gen-libm-test.pl (_apply_lit): Take macro name as argument.
(apply_lit): Update call to _apply_lit.
(apply_arglit): New function.
(parse_args): Handle "a" arguments.
(parse_auto_input): Handle format names using ":".
* math/README.libm-test: Document "a" parameter type.
* math/libm-test-support.h (ARG_TYPE_MIN): New macro.
(ARG_TYPE_TRUE_MIN): Likewise.
(ARG_TYPE_MAX): Likwise.
(ARG_MIN_EXP): Likewise.
(ARG_MAX_EXP): Likewise.
(ARG_MANT_DIG): Likewise.
(TEST_COND_arg_ibm128): Likewise.
(TEST_COND_ibm128_libgcc): Define conditional on [ARG_FLOAT].
(TEST_COND_arg_fmt): New macro.
(init_max_error): Update prototype.
* math/libm-test-support.c (test_ibm128): New variable.
(init_max_error): Take argument testing_ibm128 and set test_ibm128
instead of using [TEST_COND_ibm128] conditional.
(test_exceptions): Use test_ibm128 instead of TEST_COND_ibm128.
* math/libm-test-driver.c (STR_ARG_FLOAT): New macro.
[TEST_NARROW] (TEST_MSG): New definition.
(arg_plus_zero): New macro.
(arg_minus_zero): Likewise.
(arg_plus_infty): Likewise.
(arg_minus_infty): Likewise.
(arg_qnan_value_pl): Likewise.
(arg_qnan_value): Likewise.
(arg_snan_value_pl): Likewise.
(arg_snan_value): Likewise.
(arg_max_value): Likewise.
(arg_min_value): Likewise.
(arg_min_subnorm_value): Likewise.
[ARG_FLOAT] (struct test_aa_f_data): New struct type.
(RUN_TEST_LOOP_aa_f): New macro.
(TEST_SUFF): New macro.
(TEST_SUFF_STR): Likewise.
[!TEST_MATHVEC] (VEC_SUFF): Don't define.
(TEST_COND_any_ibm128): New macro.
(START): Use TEST_SUFF and TEST_SUFF_STR in initializer for
this_func. Update call to init_max_error.
* math/test-double.h (FUNC_NARROW_PREFIX): New macro.
* math/test-float.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-float128.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-float32.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-float32x.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-float64.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-float64x.h (FUNC_NARROW_PREFIX): Likewise.
* math/test-math-scalar.h (TEST_NARROW): Likewise.
* math/test-math-vector.h (TEST_NARROW): Likewise.
* math/test-arg-double.h: New file.
* math/test-arg-float128.h: Likewise.
* math/test-arg-float32x.h: Likewise.
* math/test-arg-float64.h: Likewise.
* math/test-arg-float64x.h: Likewise.
* math/test-arg-ldouble.h: Likewise.
* math/test-math-narrow.h: Likewise.
* math/test-narrow-macros.c: Likewise.
* sysdeps/ieee754/ldbl-opt/test-narrow-macros-ldbl-64.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (tests): Add
test-narrow-macros-ldbl-64.
(CFLAGS-test-narrow-macros-ldbl-64.c): New variable.
Joseph Myers [Fri, 9 Feb 2018 21:18:52 +0000 (21:18 +0000)]
Add build infrastructure for narrowing libm functions.
TS 18661-1 defines libm functions that carry out an operation (+ - * /
sqrt fma) on their arguments and return a result rounded to a
(usually) narrower type, as if the original result were computed to
infinite precision and then rounded directly to the result type
without any intermediate rounding to the argument type. For example,
fadd, faddl and daddl for addition. These are the last remaining TS
18661-1 functions left to be added to glibc. TS 18661-3 extends this
to corresponding functions for _FloatN and _FloatNx types.
As functions parametrized by two rather than one varying
floating-point types, these functions require infrastructure in glibc
that was not required for previous libm functions. This patch
provides such infrastructure - excluding test support, and actual
function implementations, which will be in subsequent patches.
Declaring the functions uses a header bits/mathcalls-narrow.h, which
is included many times, for each relevant pair of types. This will
end up containing macro calls of the form
__MATHCALL_NARROW (__MATHCALL_NAME (add), __MATHCALL_REDIR_NAME (add), 2);
for each family of narrowing functions. (The structure of this macro
call, with the calls to __MATHCALL_NAME and __MATHCALL_REDIR_NAME
there rather than in the definition of __MATHCALL_NARROW, arises from
the names such as "add" *not* themselves being reserved identifiers -
meaning it's necessary to avoid any indirection that would result in a
user-defined "add" macro being expanded.) Whereas for existing
functions declaring long double functions is disabled if _LIBC in the
case where they alias double functions, to facilitate defining the
long double functions as aliases of the double ones, there is no such
logic for the narrowing functions in this patch. Rather, the files
defining such functions are expected to use #define to hide the
original declarations of the alias names, to avoid errors about
defining aliases with incompatible types.
math/Makefile support is added for building the functions (listed in
libm-narrow-fns, currently empty) for all relevant pairs of types. An
internal header math-narrow.h is added for macros shared between
multiple function implementations - currently a ROUND_TO_ODD macro to
facilitate writing functions using the round-to-odd implementation
approach, and alias macros to create all the required function
aliases. libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128
are added for use when required (only for x86_64). float128_private.h
support is added for ldbl-128 narrowing functions to be used for
_Float128.
Certain things are specifically omitted from this patch and the
immediate followups. tgmath.h support is deferred; there remain
unresolved questions about how the type-generic macros for these
functions are supposed to work, especially in the case of arguments of
integer type. The math.h / bits/mathcalls-narrow.h logic, and the
logic for determining what functions / aliases to define, will need
some adjustments to support the sqrt and fma functions, where
e.g. f32xsqrtf64 can just be an alias for sqrt rather than a separate
function. TS 18661-1 defines FP_FAST_* macros but no support is
included for defining them (they won't in general be true without
architecture-specific optimized function versions).
For each of the function groups (add sub mul div sqrt fma) there are
always six functions present (e.g. fadd, faddl, daddl,
f32addf64,
f32addf32x, f32xaddf64). When _Float64x and _Float128 are supported,
there are seven more (e.g. f32addf64x,
f32addf128, f64addf64x,
f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128). In addition, in
the ldbl-opt case there are function names such as __nldbl_daddl (an
alias for f32xaddf64, which is not a reserved name in TS 18661-1, only
in TS 18661-3), for calls to daddl to be mapped to in the
-mlong-double-64 case. (Calls to faddl just get mapped to fadd, and
for sqrt and fma there won't be __nldbl_* functions because dsqrtl and
dfmal can just be mapped to sqrt and fma with -mlong-double-64.)
While there are six or thirteen functions present in each group (plus
__nldbl_* names only as an ABI, not an API), not all are distinct;
they fall in various groups of aliases. There are two distinct
versions built if long double has the same format as double; four if
they have distinct formats but there is no _Float64x or _Float128
support; five if long double has binary128 format; seven when
_Float128 is distinct from long double.
Architecture-specific optimized versions are possible, but not
included in my patches. For example, IA64 generally supports
narrowing the result of most floating-point instructions; Power ISA
2.07 (POWER8) supports double values as arguments to float
instructions, with the results narrowed as expected; Power ISA 3
(POWER9) supports round-to-odd for float128 instructions, so meaning
that approach can be used without needing to set and restore the
rounding mode and test "inexact". I intend to leave any such
optimized versions to the architecture maintainers. Generally in such
cases it would also make sense for calls to these functions to be
expanded inline (given -fno-math-errno); I put a suggestion for TS
18661-1 built-in functions at <https://gcc.gnu.org/wiki/SummerOfCode>.
Tested for x86_64 (this patch in isolation, as well as testing for
various configurations in conjunction with further patches).
* math/bits/mathcalls-narrow.h: New file.
* include/bits/mathcalls-narrow.h: Likewise.
* math/math-narrow.h: Likewise.
* math/math.h (__MATHCALL_NARROW_ARGS_1): New macro.
(__MATHCALL_NARROW_ARGS_2): Likewise.
(__MATHCALL_NARROW_ARGS_3): Likewise.
(__MATHCALL_NARROW_NORMAL): Likewise.
(__MATHCALL_NARROW_REDIR): Likewise.
(__MATHCALL_NARROW): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)]: Repeatedly include
<bits/mathcalls-narrow.h> with _Mret_, _Marg_ and __MATHCALL_NAME
defined.
[__GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
* math/Makefile (headers): Add bits/mathcalls-narrow.h.
(libm-narrow-fns): New variable.
(libm-narrow-types-basic): Likewise.
(libm-narrow-types-ldouble-yes): Likewise.
(libm-narrow-types-float128-yes): Likewise.
(libm-narrow-types-float128-alias-yes): Likewise.
(libm-narrow-types): Likewise.
(libm-routines): Add narrowing functions.
* sysdeps/i386/fpu/fenv_private.h [__x86_64__]
(libc_feholdexcept_setroundf128): New macro.
[__x86_64__] (libc_feupdateenv_testf128): Likewise.
* sysdeps/ieee754/float128/float128_private.h: Include
<math/math-narrow.h>.
[libc_feholdexcept_setroundf128] (libc_feholdexcept_setroundl):
Undefine and redefine.
[libc_feupdateenv_testf128] (libc_feupdateenv_testl): Likewise.
(libm_alias_float_ldouble): Undefine and redefine.
(libm_alias_double_ldouble): Likewise.
Joseph Myers [Fri, 9 Feb 2018 18:15:32 +0000 (18:15 +0000)]
Remove unused math/Makefile variable libm-test-incs.
The math/Makefile variable libm-test-incs was formerly used, but no
longer is. This patch removes it.
Tested for x86_64.
* math/Makefile [$(PERL) != no] (libm-test-incs): Remove variable.
Wilco Dijkstra [Fri, 9 Feb 2018 16:59:23 +0000 (16:59 +0000)]
[AArch64] Use builtins for fpcr/fpsr
Since GCC has support for accessing FPSR/FPCR, use them when possible
so that the asm instructions can be removed eventually. Although GCC 5
supports the builtins, it has an optimization bug, so use them from GCC 6
onwards.
* sysdeps/aarch64/fpu/fpu_control.h: Use builtins for accessing
FPCR/FPSR.
Rical Jasan [Wed, 24 Jan 2018 09:03:38 +0000 (01:03 -0800)]
manual: Fix Texinfo warnings about improper node names.
A number of cross-references to the GCC info manual cause Texinfo
warnings; e.g.:
./creature.texi:11: warning: @xref node name should not contain `.'
This is due to "gcc.info" being used in the INFO-FILE-NAME (fourth)
argument. Changing it to "gcc" removes these warnings. (Manually
confirmed equivalent behaviour for make info, html, and pdf.)
* manual/creature.texi: Convert references to gcc.info to gcc.
* manual/stdio.texi: Likewise.
* manual/string.texi: Likewise.
Joseph Myers [Wed, 7 Feb 2018 20:33:55 +0000 (20:33 +0000)]
Define char16_t, char32_t consistently with uint_least16_t, uint_least32_t (bug 17979).
As noted in bug 17979 (and as I noted earlier in
<https://sourceware.org/ml/libc-alpha/2012-02/msg00647.html>), uchar.h
has gratuitously complicated code to determine the types for char16_t
and char32_t, and to reject including that header for pre-C11
compilers not defining __CHAR16_TYPE__ and __CHAR32_TYPE__. Since
those types are always required to match uint_least16_t and
uint_least32_t, which glibc knows how to define without reference to
such predefined macros, it's safe just to define those types the same
as the *least* types are defined in stdint.h, so allowing the header
to work with (for example) GCC 4.3.
This patch implements that. bits/types.h is made to define
__int_leastN_t and __uint_leastN_t so the logic for those types can
stay in a single place, and stdint.h is made to use those __*_t to
define the public *_t types. uchar.h is then made to use
__uint_least16_t and __uint_least32_t to define char16_t and char32_t,
so simplifying the logic there. A new test is added that verifies the
types chosen for char16_t and char32_t do indeed match the types the
compiler uses for u"" and U"" string literals.
Tested for x86_64. (I have not tested with any of the older compilers
for which this would actually make a difference to whether you can
include uchar.h.)
[BZ #17979]
* posix/bits/types.h (__int_least8_t): New typedef.
(__uint_least8_t): Likewise.
(__int_least16_t): Likewise.
(__uint_least16_t): Likewise.
(__int_least32_t): Likewise.
(__uint_least32_t): Likewise.
(__int_least64_t): Likewise.
(__uint_least64_t): Likewise.
* sysdeps/generic/stdint.h (int_least8_t): Define using
__int_least8_t.
(int_least16_t): Define using __int_least16_t.
(int_least32_t): Define using __int_least32_t.
(int_least64_t): Define using __int_least64_t.
(uint_least8_t): Define using __uint_least8_t.
(uint_least16_t): Define using __uint_least16_t.
(uint_least32_t): Define using __uint_least32_t.
(uint_least64_t): Define using __uint_least64_t.
* wcsmbs/uchar.h: Include <bits/types.h>.
(char16_t): Define using __uint_least16_t conditional only on
[!__USE_ISOCXX11].
(char32_t): Define using __uint_least32_t conditional only on
[!__USE_ISOCXX11].
* wcsmbs/test-char-types.c: New file.
* wcsmbs/Makefile (tests): Add test-char-types.
Joseph Myers [Wed, 7 Feb 2018 17:38:13 +0000 (17:38 +0000)]
Use MPFR 4.0.1 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default MPFR
version to 4.0.1.
Zack Weinberg [Mon, 5 Feb 2018 19:13:41 +0000 (14:13 -0500)]
Post-cleanup 2: minimize _G_config.h.
Nearly everything in _G_config.h is either junk or more appropriately
defined elsewhere:
* _G_fpos_t, _G_fpos64_t, and _G_BUFSIZ are already completely unused.
* All remaining uses of _G_va_list have been changed to __gnuc_va_list.
* The definition of _G_HAVE_ST_BLKSIZE/_IO_HAVE_ST_BLKSIZE has
been inlined into its sole use.
* The complete definition of _G_iconv_t has been moved to libio.h and
renamed _IO_iconv_t (all actual users used that name).
* _G_IO_IO_FILE_VERSION is vestigial; some code cares whether
_IO_stdin_used exists, but nothing looks at its value. I've
preserved the value as a hardwired constant in csu/init.c.
This means csu/init.c no longer needs to include anything.
* Many of the headers included by _G_config.h were already being
included directly by either either libio.h or stdio.h; the
remaining ones were moved to libio.h.
* _G_HAVE_MREMAP is still relevant, because mremap genuinely is a
Linux extension; it's not in POSIX and as far as I can tell it's
not available on the Hurd either. I also preserved _G_HAVE_MMAP,
since it's conceivable someone would want to port glibc to a
MMU-less, mmap-less environment in the future. Both are now always
defined to 1/0 as is the current convention, instead of the older
1/undef convention. These are the only symbols still defined in
_G_config.h.
* The actual inclusion of _G_config.h moves from libio.h to libioP.h,
as this is where a potential override of _G_HAVE_MMAP happens.
* The #ifdef logic in libioP.h controlling _IO_JUMPS_OFFSET has been
simplified.
After this patch, the only surviving _G_ symbols are the struct tag
names _G_fpos_t and _G_fpos64_t, which are preserved for the sake of
C++ mangled names in applications, and _G_HAVE_MMAP and _G_HAVE_MREMAP,
which do not seem worth renaming.
Installed stripped libraries are unchanged by this patch.
* bits/_G_config.h: Move back to sysdeps/generic/_G_config.h.
Delete all contents except for definitions of _G_HAVE_MMAP and
_G_HAVE_MREMAP. Add commentary explaining those two symbols.
* sysdeps/unix/sysv/linux/bits/_G_config.h: Move back to
sysdeps/unix/sysv/linux/_G_config.h. Make same content
change as above.
* libio/libio.h: Don't include bits/_G_config.h here.
Include stddef.h with __need_wchar_t defined. Include
bits/types/__mbstate_t.h, bits/types/wint_t.h, and gconv.h.
Define _IO_iconv_t here, directly.
Don't define _IO_HAVE_ST_BLKSIZE.
* libio/libioP.h: Include _G_config.h here. Move include of
shlib-compat.h up with rest of includes. Simplify conditionals
controlling definition of _IO_JUMPS_OFFSET.
* csu/init.c: Remove always-true #if around entire file.
Don't include stdio.h. Set _IO_stdin_used to hardwired
constant 0x20001, and update commentary.
* include/stdio.h, sysdeps/ieee754/ldbl-opt/nldbl-compat.h:
Replace all uses of _G_va_list with __gnuc_va_list.
* libio/filedoalloc.c: Use #if defined _STATBUF_ST_BLKSIZE
instead of #if _IO_HAVE_ST_BLKSIZE.
* libio/fileops.c: Test _G_HAVE_MREMAP with #if, not #ifdef.
* libio/iofdopen.c, libio/iofopen.c: Test _G_HAVE_MMAP with #if,
not #ifdef.
Zack Weinberg [Mon, 5 Feb 2018 18:09:15 +0000 (13:09 -0500)]
Post-cleanup 1: move libio.h back out of bits/.
We can't go very far with libio cleanups as long as we still have
_IO_MTSAFE_IO, and I am not tackling that in this patch series,
but we can at least make the maze of stdio-related headers a
little less complicated.
In this patch, libio.h moves back out of bits/ into the top level of
the libio subdirectory, and is merged with libio/bits/libio-ldbl.h
(which also used to be installed) and include/libio.h. Since almost
no files include libio.h directly, this is quite straightforward.
libio.h is now always used with _LIBC defined, so all of the _LIBC ||
_GLIBCPP_USE_WCHAR_T conditionals are unnecessary. Similarly, the
ifdef nest surrounding the definition of _IO_fwide_maybe_incompatible
can collapse down to a single SHLIB_COMPAT check. I also took the
opportunity to add some checks for configuration botches to libio.h.
Installed stripped libraries are unchanged by this patch.
* libio/bits/libio.h: Move back to libio/libio.h and adjust
multiple-include guard to match.
Merge contents of libio/bits/libio-ldbl.h and include/libio.h
into this file.
Remove preprocessor conditionals that are always true and/or
redundant to other preprocessor conditionals in the same nest.
Include shlib-compat.h unconditionally.
Error out if _LIBC is not defined, or if _ISOMAC is defined,
or if _IO_MTSAFE_IO is defined but _IO_lock_t_defined is not
defined after including stdio.h.
Use __BEGIN_DECLS/__END_DECLS.
* libio/bits/libio-ldbl.h, include/bits/libio.h: Delete file.
* include/stdio.h, libio/iolibio.h, libio/libioP.h: Include
libio.h as <libio/libio.h> rather than as <bits/libio.h>.
Zack Weinberg [Sat, 3 Feb 2018 00:36:42 +0000 (19:36 -0500)]
Don't install libio.h or _G_config.h.
We shipped 2.27 with libio.h and _G_config.h still installed but
issuing warnings when used. Let's stop installing them early in 2.28
so that we have plenty of time to think of another plan if there are
problems.
The public stdio.h had a genuine dependency on libio.h for the
complete definitions of FILE and cookie_io_functions_t, and a genuine
dependency on _G_config.h for the complete definitions of fpos_t and
fpos64_t; these are moved to single-type headers.
bits/types/struct_FILE.h also provides a handful of accessor and
bitflags macros so that code is not duplicated between bits/stdio.h
and libio.h. All the other _IO_ and _G_ names used by the public
stdio.h can be replaced with either public names or __-names.
In order to minimize the risk of breaking our own compatibility code,
bits/types/struct_FILE.h preserves the _IO_USE_OLD_IO_FILE mechanism
exactly as it was in libio.h, but you have to define _LIBC to use it,
or it'll error out. Similarly, _IO_lock_t_defined is preserved
exactly, but will error out if used without defining _LIBC.
Internally, include/stdio.h continues to include libio.h, and libio.h
scrupulously provides every _IO_* and _G_* name that it always did,
perhaps now defined in terms of the public names. This is how this
patch avoids touching dozens of files throughout glibc and becoming
entangled with the _IO_MTSAFE_IO mess. The remaining patches in this
series eliminate most of the _G_ names.
Tested on x86_64-linux; in addition to the test suite, I installed the
library in a sysroot and verified that a simple program that uses
stdio.h could be compiled against the installed library, and I also
verified that installed stripped libraries are unchanged.
* libio/bits/types/__fpos_t.h, libio/bits/types/__fpos64_t.h:
New single-type headers split from _G_config.h.
* libio/bits/types/cookie_io_functions_t.h
* libio/bits/types/struct_FILE.h
New single-type headers split from libio.h.
* libio/Makefile: Install the above new headers. Don't install
libio.h, _G_config.h, bits/libio.h, bits/_G_config.h, or
bits/libio-ldbl.h.
* libio/_G_config.h, libio/libio.h: Delete file.
* libio/bits/libio.h: Remove improper-inclusion guard.
Include stdio.h and don't repeat anything that it does.
Define _IO_fpos_t as __fpos_t, _IO_fpos64_t as __fpos64_t,
_IO_BUFSIZ as BUFSIZ, _IO_va_list as __gnuc_va_list,
__io_read_fn as cookie_read_function_t,
__io_write_fn as cookie_write_function_t,
__io_seek_fn as cookie_seek_function_t,
__io_close_fn as cookie_close_function_t,
and _IO_cookie_io_functions_t as cookie_io_functions_t.
Define _STDIO_USES_IOSTREAM, __HAVE_COLUMN, and _IO_file_flags
here, in the "compatibility defines" section. Remove an #if 0
block. Use the "body" macros from bits/types/struct_FILE.h to
define _IO_getc_unlocked, _IO_putc_unlocked, _IO_feof_unlocked,
and _IO_ferror_unlocked.
Move prototypes of __uflow and __overflow...
* libio/stdio.h: ...here. Don't include bits/libio.h.
Don't define _STDIO_USES_IOSTREAM. Get __gnuc_va_list
directly from stdarg.h. Include bits/types/__fpos_t.h,
bits/types/__fpos64_t.h, bits/types/struct_FILE.h,
and, when __USE_GNU, bits/types/cookie_io_functions_t.h.
Use __gnuc_va_list, not _G_va_list; __fpos_t, not _G_fpos_t;
__fpos64_t, not _G_fpos64_t; FILE, not struct _IO_FILE;
cookie_io_functions_t, not _IO_cookie_io_functions_t;
__ssize_t, not _IO_ssize_t. Unconditionally define
BUFSIZ as 8192 and EOF as (-1).
* libio/bits/stdio.h: Add multiple-include guard. Use the "body"
macros from bits/types/struct_FILE.h instead of _IO_* macros
from libio.h; use __gnuc_va_list instead of va_list and __ssize_t
instead of _IO_ssize_t.
* libio/bits/stdio2.h: Similarly.
* libio/iolibio.h: Add multiple-include guard.
Include bits/libio.h after stdio.h.
* libio/libioP.h: Add multiple-include guard.
Include stdio.h and bits/libio.h before iolibio.h.
* include/bits/types/__fpos_t.h, include/bits/types/__fpos64_t.h
* include/bits/types/cookie_io_functions_t.h
* include/bits/types/struct_FILE.h: New wrappers.
* bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h:
Get definitions of _G_fpos_t and _G_fpos64_t from
bits/types/__fpos_t.h and bits/types/__fpos64_t.h
respectively. Remove improper-inclusion guards.
* conform/data/stdio.h-data: Update expectations of va_list.
* scripts/check-installed-headers.sh: Remove special case for
libio.h and _G_config.h.
Joseph Myers [Wed, 7 Feb 2018 14:57:31 +0000 (14:57 +0000)]
Fix -Os gnu_dev_* linknamespace, localplt issues (bug 15105, bug 19463).
Building with -Os produces linknamespace and localplt failures for,
among other functions, gnu_dev_major, gnu_dev_minor and
gnu_dev_makedev.
The issue is that those functions are not inlined when building with
-Os. While one could force them to be inlined in that case, it seems
more natural to fix this issue similarly to other namespace issues.
Thus, this patch makes gnu_dev_* into weak aliases for hidden symbols
__gnu_dev_*; __gnu_dev_* are then defined as inlines in the internal
include/sys/sysmacros.h, and uses of gnu_dev_* (often via the macros
major, minor and makedev) for which there are namespace issues are
changed to use __gnu_dev_*; where there are no namespace issues, use
of libc_hidden_proto serves to avoid unnecessary local PLT entry use.
Tested for x86_64, (a) without -Os, to verify the testsuite continues
to pass without problems and that the functions called under their new
names continue to be inlined as expected in that case; (b) with -Os,
to verify that the linknamespace and localplt failures in question go
away (but because of other such failures present, neither of the
relevant bugs can yet be closed).
[BZ #15105]
[BZ #19463]
* include/sys/sysmacros.h [!_ISOMAC]
(__SYSMACROS_NEED_IMPLEMENTATION): Define macro.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC]
(_SYS_SYSMACROS_H_WRAPPER): Likewise.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_major): Use
libc_hidden_proto.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_minor): Likewise.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (gnu_dev_makedev):
Likewise.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__SYSMACROS_DECL_TEMPL):
Undefine and redefine to add use __gnu_dev_ prefix.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__SYSMACROS_IMPL_TEMPL):
Likewise.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_major): Declare
and define as hidden inline function.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_minor):
Likewise.
[!_SYS_SYSMACROS_H_WRAPPER && !_ISOMAC] (__gnu_dev_makedev):
Likewise.
* misc/makedev.c (OUT_OF_LINE_IMPL_TEMPL): Use __gnu_dev_ prefix.
(gnu_dev_major): Use weak_alias and libc_hidden_weak.
(gnu_dev_minor): Likewise.
(gnu_dev_makedev): Likewise.
* csu/check_fds.c (check_one_fd): Use __gnu_dev_makedev instead of
makedev.
* posix/wordexp.c (exec_comm_child): Likewise.
* sysdeps/mach/hurd/xmknodat.c (__xmknodat): Use __gnu_dev_minor
instead of minor and __gnu_dev_major instead of major.
* sysdeps/unix/sysv/linux/device-nrs.h (DEV_TTY_P): Use
__gnu_dev_major instead of major.
* sysdeps/unix/sysv/linux/pathconf.c (distinguish_extX): Use
__gnu_dev_major instead of gnu_dev_major and __gnu_dev_minor
instead of gnu_dev_minor.
* sysdeps/unix/sysv/linux/ptsname.c (MASTER_P): Likewise.
(SLAVE_P): Likewise.
(__ptsname_internal): Use __gnu_dev_minor instead of minor.
* sysdeps/unix/sysv/linux/ttyname.h (is_pty): Use __gnu_dev_major
instead of major.
Joseph Myers [Wed, 7 Feb 2018 13:36:14 +0000 (13:36 +0000)]
Fix -Os strcoll, wcscoll, build (bug 21313).
The findidx functions used in implementing strcoll / wcscoll already
use DIAG_IGNORE_Os_NEEDS_COMMENT for spurious -Wmaybe-uninitialized
warnings that appear with -Os. In building with GCC 7 for x86_64 with
-Os, I find there are additional such warnings, for the same structure
elements, which are spurious for the same reasons given in the
existing comments (and this was also reported for MIPS with GCC 5 in
bug 21313). This patch adds corresponding uses of DIAG_* in the
places that get the additional warnings.
Tested for x86_64 with -Os that this eliminates those warnings and so
allows the build to progress further.
[BZ #21313]
* locale/weight.h (findidx): Disable -Wmaybe-uninitialized for -Os
in another place.
* locale/weightwc.h (findidx): Likewise.
Wilco Dijkstra [Wed, 7 Feb 2018 12:24:43 +0000 (12:24 +0000)]
Remove slow paths from log
Remove the slow paths from log. Like several other double precision math
functions, log is exactly rounded. This is not required from math functions
and causes major overheads as it requires multiple fallbacks using higher
precision arithmetic if a result is close to 0.5ULP. Ridiculous slowdowns
of up to 100000x have been reported when the highest precision path triggers.
Interestingly removing the slow paths makes hardly any difference in practice:
the worst case error is still ~0.502ULP, and exp(log(x)) shows identical results
before/after on many millions of random cases. All GLIBC math tests pass on
AArch64 and x64 with no change in ULP error. A simple test over a few hundred
million values shows log is now 18% faster on average.
* manual/probes.texi (slowlog): Delete documentation of removed probe.
(slowlog_inexact): Likewise
* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Remove slow paths.
* sysdeps/ieee754/dbl-64/ulog.h: Remove unused declarations.
Igor Gnatenko [Wed, 7 Feb 2018 11:11:39 +0000 (12:11 +0100)]
Linux: use reserved name __key in pkey_get [BZ #22797]
_key is not reserved name and we should avoid using that. It seems that
it was simple typo when pkey_* was implemented.
Joseph Myers [Tue, 6 Feb 2018 21:55:08 +0000 (21:55 +0000)]
Unify and simplify bits/byteswap.h, bits/byteswap-16.h headers (bug 14508, bug 15512, bug 17082, bug 20530).
We have a general principle of preferring optimizations for library
facilities to use compiler built-in functions rather than being
located in library headers, where the compiler can reasonably optimize
code without needing to know glibc implementation details.
This patch applies this principle to bits/byteswap.h, eliminating all
the architecture-specific variants and bits/byteswap-16.h. The
__bswap_16, __bswap_32 and __bswap_64 interfaces all become inline
functions, never macros, using the GCC built-in functions where
available and otherwise a single architecture-independent definition
using shifts and masking (which compilers may well be able to detect
and optimize; GCC has detection of various byte-swapping idioms).
The __bswap_constant_32 macro needs to stay around because of uses in
static initializers within glibc and its tests, and so for consistency
all __bswap_constant_* are kept rather than just being inlined into
the old-GCC-or-non-GCC parts of the __bswap_* inline function
definitions.
Various open bugs are addressed by this cleanup, with caveats about
exactly what is covered by those bugs and when the bugs applied at
all.
Bug 14508 reports -Wformat warnings building glibc because __bswap_*
sometimes returned the wrong types. Obviously we already don't have
such warnings any more or the build would be failing, given -Werror,
and I suspect that bug was originally for wrong types for x86_64, as
fixed by commit
d394eb742a3565d7fe7a4b02710a60b5f219ee64 (glibc 2.17).
The only case I saw removed by this patch where the types would still
have been wrong was the non-__GNUC__ case of __bswap_64 in the s390
header (using unsigned long long int, but uint64_t would be unsigned
long int for 64-bit). In any case, the single header consistently
uses __uintN_t types after this patch, thereby eliminating all such
bugs. The existing string/test-endian-types.c test already suffices
to verify that the types are correct with the compiler used to build
glibc and its tests.
Bug 15512 reports an error from __bswap_constant_16 with -Werror
-Wsign-conversion. I am unable to reproduce this with any GCC version
supporting -Wsign-conversion - all seem to be able to avoid warning
for ((x) >> 8) & 0xffu, where x is uint16_t, which while it formally
does involve an implicit conversion from int to unsigned int, is also
a case where it should be easy for the compiler to see that the value
converted is never negative. But in this patch __bswap_constant_16 is
changed to use signed 0xff so that no such implicit conversion occurs
at all, and a test with -Werror -Wsign-conversion is added.
Bug 17082 objects to the use of ({}) statement expressions in these
macros preventing use at file scope (in C, that's in sizeof etc.; in
C++, more generally in static initializers). The particular case of
these interfaces is fixed by this patch as it changes them to inline
functions, eliminating all uses of ({}) in bits/byteswap.h, and a
corresponding testcase is added. The bug tries to raise a more
general policy question about use of ({}) in macros in installed
headers, referring to "many other libc functions" (unspecified which
functions are being considered).
Since such policy questions belong on libc-alpha, and since there
*are* macros in installed headers which can't really avoid using ({})
(where they are type-generic, so can't use an inline function, but
need a temporary variable, and a few where the interface involves
returning memory from alloca so can't use an inline function either),
I propose to consider that bug fixed with this change. That is
without prejudice to any other new bugs anyone wishes to file *for
precisely defined sets of macros* requesting moving away from ({})
*where it is clearly possible for those interfaces*. Where ({}) can
be avoided, typically by use of an inline function, I think that's a
good idea - that inline functions are typically to be preferred to
({}) for header interfaces where such optimizations are useful but the
interface is suited to being defined using an inline function.
Bug 20530 requests use of __builtin_bswap16 when available (GCC 4.8
and later), which this patch implements.
Tested for x86_64, and with build-many-glibcs.py. Also did an x86_64
test with the __GNUC_PREREQ conditionals changed to "#if 0" to verify
the old-GCC/non-GCC case in the headers. (There are already existing
tests for correctness of results of these interfaces.)
[BZ #14508]
[BZ #15512]
[BZ #17082]
[BZ #20530]
* bits/byteswap.h: Update file comment. Do not include
<bits/byteswap-16.h>.
(__bswap_constant_16): Cast result to __uint16_t. Use signed 0xff
constant.
(__bswap_16): Define as inline function.
(__bswap_constant_32): Reformat definition.
(__bswap_32): Always define as inline function, not macro, using
__uint32_t. Use __builtin_bswap32 if [__GNUC_PREREQ (4, 3)],
otherwise __bswap_constant_32.
(__bswap_constant_64): Reformat definition. Do not use
__extension__ here.
(__bswap_64): Always define as inline function, not macro. Use
__extension__ on function definition. Use __builtin_bswap64 if
[__GNUC_PREREQ (4, 3)], otherwise __bswap_constant_64.
* string/test-endian-file-scope.c: New file.
* string/test-endian-sign-conversion.c: Likewise.
* string/Makefile (headers): Remove bits/byteswap-16.h.
(tests): Add test-endian-file-scope and
test-endian-sign-conversion.
(CFLAGS-test-endian-sign-conversion.c): New variable.
* bits/byteswap-16.h: Remove file.
* sysdeps/ia64/bits/byteswap-16.h: Likewise.
* sysdeps/ia64/bits/byteswap.h: Likewise.
* sysdeps/m68k/bits/byteswap.h: Likewise.
* sysdeps/s390/bits/byteswap-16.h: Likewise.
* sysdeps/s390/bits/byteswap.h: Likewise.
* sysdeps/tile/bits/byteswap.h: Likewise.
* sysdeps/x86/bits/byteswap-16.h: Likewise.
* sysdeps/x86/bits/byteswap.h: Likewise.
Joseph Myers [Tue, 6 Feb 2018 21:48:35 +0000 (21:48 +0000)]
Fix non-__GNUC__ definitions of __inline and __restrict (bug 17721).
Bug 17721 reports that the non-__GNUC__ definitions of __inline and
__restrict are suboptimal, in that they are defined to empty when they
could be defined to inline and restrict for appropriate language
versions. This patch makes those fixes.
Tested for x86_64 (however, I have not done any testing with an actual
non-__GNUC__ compiler and it's likely such compilers may have other
problems with glibc headers).
[BZ #17721]
* misc/sys/cdefs.h [!__GNUC__ && (__cplusplus || (__STDC_VERSION__
&& __STDC_VERSION__ >= 199901L))] (__inline): Define to inline.
[!__GNUC_PREREQ (2,92) && __STDC_VERSION__ && __STDC_VERSION__ >=
199901L] (__restrict): Define to restrict.
Joseph Myers [Tue, 6 Feb 2018 21:43:20 +0000 (21:43 +0000)]
Move string/testcopy.c to test-driver.c and xmalloc (bug 19667).
Bug 19667 reports unchecked malloc calls in the test
string/testcopy.c. This patch makes that test use xmalloc and the
support/test-driver.c test framework.
Tested for x86_64.
[BZ #19667]
* string/testcopy.c: Include <support/support.h>. Do not include
<malloc.h>. Use <support/test-driver.c>.
(main): Rename to do_test. Make static. Use xmalloc instead of
malloc.
Joseph Myers [Tue, 6 Feb 2018 21:38:51 +0000 (21:38 +0000)]
Correct type of SSIZE_MAX for 32-bit (bug 13575).
Bug 13575 reports that SSIZE_MAX is wrongly defined as LONG_MAX on
32-bit systems where ssize_t is defined as int (which is most 32-bit
systems supported by glibc).
This patch fixes the definition, using a conditional on
__WORDSIZE32_SIZE_ULONG to determine the appropriate type in the
32-bit case. Formally ssize_t need not be the signed type
corresponding to size_t, but as it is for all current glibc
configurations, there is no need for a new macro different from the
one used for defining SIZE_MAX. A testcase is added for both the type
and the value of SSIZE_MAX.
There is a relevant peculiarity in
sysdeps/unix/sysv/linux/s390/bits/typesizes.h:
/* Compatibility with g++ 2.95.x. */
/* size_t is unsigned long int on s390 -m31. */
This has the effect that for GCC 2 for s390, ssize_t does not match
__WORDSIZE32_SIZE_ULONG. I don't think such a conditional on the GCC
version makes sense - to have a well-defined ABI, the choices of
standard types should not depend on the GCC version. It's also the
case that upstream GCC 2.95 did not support s390, and glibc headers
don't in general try to support past development GCC versions - only
actual releases and current mainline development. But whether or not
that GCC 2 case should be removed (with or without a NEWS entry for
such a change), this patch does not result in any changes for s390;
the value is always still LONG_MAX in the s390 case because
__WORDSIZE32_SIZE_ULONG is always defined for 32-bit s390. I don't
think any such oddity in code only active for unofficial or unreleased
old compiler versions should block closing the present bug as fixed
once this patch is in.
Tested for x86_64 and x86, and with build-many-glibcs.py.
[BZ #13575]
* posix/bits/posix1_lim.h: Include <bits/wordsize.h>.
[!SSIZE_MAX && !(__WORDSIZE == 64 || __WORDSIZE32_SIZE_ULONG)]
(SSIZE_MAX): Define to INT_MAX.
* posix/test-ssize-max.c: New file.
* posix/Makefile (tests): Add test-ssize-max.
Joseph Myers [Tue, 6 Feb 2018 21:32:53 +0000 (21:32 +0000)]
Use xmalloc in tst-setcontext-fpscr.c (bug 19668).
Bug 19668 reports an unchecked malloc call in the test
sysdeps/powerpc/fpu/tst-setcontext-fpscr.c. This patch makes that
test use xmalloc. It does not otherwise move this test to the
support/ infrastructure or support/test-driver.c; the test has various
uses of exit and _exit on error cases, and uses atexit, and while I
think those things would all still work in the context of
test-driver.c, it's not an immediately obvious conversion the way it
would be for many tests that don't use test-driver.c.
Tested for powerpc.
[BZ #19668]
* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Include
<support/support.h>. Do not include <malloc.h>.
(query_auxv): Use xmalloc instead of malloc.
Joseph Myers [Tue, 6 Feb 2018 21:29:50 +0000 (21:29 +0000)]
Only define loff_t for __USE_MISC (bug 14553).
Bug 14553 reports that sys/types.h defines loff_t unconditionally,
despite it not being part of any supported standard. This is
permitted by the POSIX *_t reservation, but as a
quality-of-implementation issue it's still best not to define it
except for __USE_MISC. This patch conditions the definition
accordingly, updating a macro in sysdeps/unix/sysv/linux/sys/quota.h
to use __loff_t so it still works even if __USE_MISC is not defined.
codesearch.debian.net suggests there are quite a lot of loff_t uses
outside glibc, but it might well make sense to change all (few) uses
of loff_t or __loff_t inside glibc to use off64_t or __off64_t
instead, leaving only the definitions, treating this name as
obsolescent.
Tested for x86_64.
[BZ #14553]
* posix/sys/types.h (loff_t): Only define for [__USE_MISC].
* sysdeps/unix/sysv/linux/sys/quota.h (dqoff): Use __loff_t
instead of loff_t.
Florian Weimer [Wed, 24 Jan 2018 17:40:29 +0000 (15:40 -0200)]
getlogin_r: switch Linux variant to struct scratch_buffer
[BZ #18023]
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Use scratch_buffer instead of extend_alloca.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Tue, 6 Feb 2018 08:19:03 +0000 (09:19 +0100)]
Record CVE-2018-6551 in NEWS and ChangeLog [BZ #22774]
Zack Weinberg [Mon, 5 Feb 2018 19:42:29 +0000 (14:42 -0500)]
Remove getc and putc macros from the public stdio.h.
The getc and putc macros in the public stdio.h expand to call _IO_getc
and _IO_putc respectively. As _IO_getc, fgetc, and getc are all aliases
for the same function, and _IO_putc, fputc, and putc are also all aliases
for the same function, the macros are pointless. The C standard does
not require getc and putc to be macros, so let's just not have macros.
All four symbols are exported from libc.so at the same, ancient symbol
version, so there should be no risks for binary compatibility. Similarly,
the getchar and putchar inlines in bits/stdio.h forward to getc and putc
instead of their _IO_ aliases.
As a change from longstanding historical practice, this does seem
like it might break _something_, so there is a note in NEWS, which
is also a convenient place to advise people that if they thought getc
and putc had reduced per-character overhead they should consider using
getc_unlocked and putc_unlocked instead. (These are also not macros,
but when optimizing, they are inlines.)
* libio/stdio.h: Don't define getc or putc as macros.
* libio/bits/stdio.h (getchar, putchar): Use getc and putc,
not _IO_getc and _IO_putc.
Zack Weinberg [Mon, 5 Feb 2018 19:38:46 +0000 (14:38 -0500)]
Remove some unnecessary redefinitions of std symbols.
Two files in stdio-common were unnecessarily redefining some standard
symbols as their _IO_ aliases.
* stdio-common/vfprintf.c: Don't redefine FILE, va_list, or BUFSIZ.
* stdio-common/tstgetln.c: Don't redefine ssize_t.
Joseph Myers [Tue, 6 Feb 2018 00:42:22 +0000 (00:42 +0000)]
Add TCP_FASTOPEN_KEY, TCP_FASTOPEN_NO_COOKIE from Linux 4.15.
This patch adds the TCP_FASTOPEN_KEY and TCP_FASTOPEN_NO_COOKIE macros
from Linux 4.15 to sysdeps/gnu/netinet/tcp.h.
Tested for x86_64.
* sysdeps/gnu/netinet/tcp.h (TCP_FASTOPEN_KEY): New macro.
(TCP_FASTOPEN_NO_COOKIE): Likewise.
Joseph Myers [Tue, 6 Feb 2018 00:41:34 +0000 (00:41 +0000)]
Add IPV6_FREEBIND from Linux 4.15.
This patch adds the IPV6_FREEBIND macro from Linux 4.15 to
sysdeps/unix/sysv/linux/bits/in.h.
Tested for x86_64.
* sysdeps/unix/sysv/linux/bits/in.h (IPV6_FREEBIND): New macro.
Joseph Myers [Tue, 6 Feb 2018 00:37:17 +0000 (00:37 +0000)]
Add elf.h NT_* macros from Linux 4.15 (bug 14890).
Linux 4.15 adds NT_S390_RI_CB to linux/elf.h (and NT_ARM_SVE, which we
already have in glibc). This shows up that various other ELF note
values from linux/elf.h are missing from glibc's elf.h.
This patch adds the missing values that are relevant to glibc
architectures. As elf.h is a general description of the ELF format,
not necessarily limited to glibc configurations, there's an argument
for having the remaining NT_* values that Linux uses for non-glibc
architectures in glibc's elf.h as well, but this patch does not add
them.
Adding the NT_PRFPREG name is bug 14890. That bug also requests
making the NT_FPREGSET name obsolete. Given that elf.h is not just
for Linux but can describe ELF for other operating systems, I don't
think that a change of name in the Linux kernel is sufficient
justification for declaring the other name obsolete; there can be
multiple names for the same note value, even with incompatible
semantics, if those reflect variants of the ELF format in actual use.
For example, FreeBSD appears still to have the name NT_FPREGSET
<https://github.com/freebsd/freebsd/blob/master/sys/sys/elf_common.h>
(note: I haven't checked whether the FreeBSD kernel actually generates
such notes or whether this is actually an other-OS definition present
in FreeBSD's header).
[BZ #14890]
* elf/elf.h (NT_PRFPREG): New macro.
(NT_S390_VXRS_LOW): Likewise.
(NT_S390_VXRS_HIGH): Likewise.
(NT_S390_GS_CB): Likewise.
(NT_S390_GS_BC): Likewise.
(NT_S390_RI_CB): Likewise.
Joseph Myers [Tue, 6 Feb 2018 00:36:14 +0000 (00:36 +0000)]
Add MAP_SYNC from Linux 4.15.
This patch adds the MAP_SYNC macro from Linux 4.15 to various
bits/mman.h headers. Note that this is *not* added to all
architectures: in Linux 4.15, this macro is only in
asm-generic/mman.h, and only some architectures' asm/mman.h include
the asm-generic file - the architectures not using the asm-generic
file will need their own values of MAP_SYNC allocated to support this
functionality (some of them also already have conflicting mmap flags
so the value there will have to be different from the generic
0x80000). Specifically, for glibc architectures, alpha hppa mips
powerpc sparc tile lack allocations of values for MAP_SYNC.
Tested for x86_64.
* sysdeps/unix/sysv/linux/aarch64/bits/mman.h [__USE_MISC]
(MAP_SYNC): New macro.
* sysdeps/unix/sysv/linux/arm/bits/mman.h [__USE_MISC] (MAP_SYNC):
Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/m68k/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/microblaze/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/nios2/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/riscv/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/s390/bits/mman.h [__USE_MISC]
(MAP_SYNC): Likewise.
* sysdeps/unix/sysv/linux/sh/bits/mman.h [__USE_MISC] (MAP_SYNC):
Likewise.
* sysdeps/unix/sysv/linux/x86/bits/mman.h [__USE_MISC] (MAP_SYNC):
Likewise.
Joseph Myers [Tue, 6 Feb 2018 00:35:09 +0000 (00:35 +0000)]
Add MAP_SHARED_VALIDATE from Linux 4.15.
This patch adds the MAP_SHARED_VALIDATE macro from Linux 4.15 to
bits/mman-linux.h and the hppa bits/mman.h.
Tested for x86_64.
* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_MISC]
(MAP_SHARED_VALIDATE): New macro.
* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_MISC]
(MAP_SHARED_VALIDATE): Likewise.
H.J. Lu [Mon, 5 Feb 2018 22:58:39 +0000 (14:58 -0800)]
Use ADDRIDX with DT_GNU_HASH
The only differences in ld.so are line numbers for asserts.
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
* elf/dl-addr.c (determine_info): Use ADDRIDX with DT_GNU_HASH.
* elf/dl-lookup.c (_dl_setup_hash): Likewise.
* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
H.J. Lu [Mon, 5 Feb 2018 14:30:04 +0000 (06:30 -0800)]
Add DT_SYMTAB_SHNDX from gABI
* elf/elf.h (DT_SYMTAB_SHNDX): New. Set to 34.
(DT_NUM): Updated to 35.
H.J. Lu [Mon, 5 Feb 2018 14:13:31 +0000 (06:13 -0800)]
i386: Use __glibc_likely/__glibc_likely in dl-machine.h
The differences in elf/dl-reloc.os are
--- before 2018-02-05 03:53:31.
970492246 -0800
+++ after 2018-02-05 03:53:49.
719902340 -0800
@@ -1202,9 +1202,9 @@ _dl_relocate_object:
movl -60(%ebp), %eax
testl %eax, %eax
je .L249
- movl 8(%eax), %eax
- movl 8(%ebx), %esi
- cmpl %esi, %eax
+ movl 8(%eax), %esi
+ movl 8(%ebx), %eax
+ cmpl %eax, %esi
ja .L284
jb .L707
.L285:
@@ -2255,7 +2255,7 @@ _dl_relocate_object:
cmpl $6, %edi
movl $4, %edx
je .L132
- cmpl %ecx, %eax
+ cmpl %eax, %ecx
je .L350
cmpl $7, %edi
je .L419
@@ -2735,7 +2735,7 @@ _dl_relocate_object:
je .L120
.L121:
movl -96(%ebp), %edx
- movl $640, 8(%esp)
+ movl $639, 8(%esp)
leal __PRETTY_FUNCTION__.9431@GOTOFF(%edx), %eax
movl %eax, 12(%esp)
leal .LC9@GOTOFF(%edx), %eax
@@ -3454,10 +3454,10 @@ _dl_relocate_object:
movl -152(%ebp), %eax
movl %eax, 4(%esp)
call _dl_dprintf
- movl -60(%ebp), %eax
- movl 8(%ebx), %esi
+ movl 8(%ebx), %eax
+ movl -60(%ebp), %ebx
movl -112(%ebp), %edx
- movl 8(%eax), %eax
+ movl 8(%ebx), %esi
jmp .L285
.L713:
movl %esi, (%esp)
* sysdeps/i386/dl-machine.h (elf_machine_rel): Replace
__builtin_expect with __glibc_likely and __glibc_unlikely.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
H.J. Lu [Mon, 5 Feb 2018 14:19:59 +0000 (06:19 -0800)]
Fix a typo in ChangeLog entry
H.J. Lu [Mon, 5 Feb 2018 14:17:18 +0000 (06:17 -0800)]
Add a missing ChangeLog item in commit
371b220f620
H.J. Lu [Mon, 5 Feb 2018 14:07:54 +0000 (06:07 -0800)]
x86-64: Use __glibc_likely/__glibc_likely in dl-machine.h
The differences in elf/dl-reloc.os are
--- before 2018-02-05 03:52:32.
803125207 -0800
+++ after 2018-02-05 03:52:14.
913711879 -0800
@@ -1129,7 +1129,7 @@ _dl_relocate_object:
leaq __PRETTY_FUNCTION__.9767(%rip), %rcx
leaq .LC11(%rip), %rsi
leaq .LC12(%rip), %rdi
- movl $540, %edx
+ movl $539, %edx
call __GI___assert_fail
.p2align 4,,10
.p2align 3
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Replace
__builtin_expect with __glibc_likely and __glibc_likely.
(elf_machine_lazy_rel): Likewise.
H.J. Lu [Mon, 5 Feb 2018 13:46:38 +0000 (05:46 -0800)]
sparc: Check PIC instead of SHARED in start.S [BZ #22638]
Since start.o may be compiled as PIC, we should check PIC instead of
SHARED.
[BZ #22638]
* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
SHARED.
* sysdeps/sparc/sparc64/start.S (_start): Likewise.
Andreas Schwab [Wed, 31 Jan 2018 09:52:14 +0000 (10:52 +0100)]
Fix uninitialized variable in assert_perror (bug 22761)
Samuel Thibault [Sun, 4 Feb 2018 12:48:49 +0000 (13:48 +0100)]
hurd: Fix build
* stdlib/test-atexit-race-common.c [!defined PTHREAD_STACK_MIN]: Do
not check against PTHREAD_STACK_MIN.
Sean McKean [Fri, 2 Feb 2018 10:59:31 +0000 (11:59 +0100)]
time: Reference CLOCKS_PER_SEC in clock comment [BZ #22735]
Florian Weimer [Fri, 2 Feb 2018 09:46:26 +0000 (10:46 +0100)]
preadv2/pwritev2: Handle offset == -1 [BZ #22753]
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Siddhesh Poyarekar [Fri, 2 Feb 2018 04:45:20 +0000 (10:15 +0530)]
aarch64: Use the L() macro for labels in memcmp
The L() macro makes the assembly a bit more readable.
* sysdeps/aarch64/memcmp.S: Use L() macro for labels.
Siddhesh Poyarekar [Fri, 2 Feb 2018 04:26:47 +0000 (09:56 +0530)]
benchtests: Make bench-memcmp print json
The benchamrk result can now be studied using the compare_strings.py
script.
* benchtests/bench-memcmp.c: Print json instead of plain text.
Siddhesh Poyarekar [Fri, 2 Feb 2018 04:25:45 +0000 (09:55 +0530)]
benchtests: Reallocate buffers for every test run
Keeping the buffers the same across test runs gives later invocations
the advantage since they access cached data. Reallocate so that all
test runs are on equal grounds.
* benchtests/bench-memcmp.c (do_test): Call realloc_buf for
every test run.
Joseph Myers [Thu, 1 Feb 2018 21:10:04 +0000 (21:10 +0000)]
Update syscall-names.list for 4.15.
This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.15. There only appears to be one new syscall to add to the
list. (The riscv_flush_icache syscall is *not* added because for
whatever reason it doesn't appear in the uapi asm/unistd.h; only in
arch/riscv/include/uapi/asm/syscalls.h, which is only included by the
non-uapi asm/unistd.h - and only syscalls whose __NR_* macros are
defined in the uapi asm/unistd.h are relevant for this list.)
Tested for x86_64, and with build-many-glibcs.py.
* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.15.
(s390_sthyi): New syscall.
Joseph Myers [Thu, 1 Feb 2018 21:01:00 +0000 (21:01 +0000)]
Move LDBL_CLASSIFY_COMPAT to its own header.
The general rule in glibc is that it's better for a macro to be always
defined, and tested with #if, than for it to be tested with #ifdef,
because the latter is prone to typos in the macro name as well as to
the header with the macro accidentally not being included in a file
testing it. (Testing with an "if" statement is even better, in those
cases where it's possible to do things that way, as it then means both
cases in the code get checked for syntax in glibc builds with either
value of the condition.)
math_private.h has several different groups of macros, meaning that
architectures wanting to override some of them need to define those
then include the generic version, which then defines macros if not
already defined. It's hard to avoid that arrangement completely, but
various cases can be improved by splitting out macros or groups of
macros into separate files.
This patch splits out the LDBL_CLASSIFY_COMPAT macro into a separate
ldbl-classify-compat.h header. This macro is tested with #ifdef; this
patch changes it to testing with #if, with a default definition to 0
in the generic header and then architecture-specific headers defining
it to 1.
Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.
* sysdeps/generic/ldbl-classify-compat.h: New file.
* sysdeps/arm/ldbl-classify-compat.h: Likewise.
* sysdeps/m68k/coldfire/ldbl-classify-compat.h: Likewise.
* sysdeps/microblaze/ldbl-classify-compat.h: Likewise.
* sysdeps/mips/ldbl-classify-compat.h: Likewise.
* sysdeps/nios2/ldbl-classify-compat.h: Likewise.
* sysdeps/sh/ldbl-classify-compat.h: Likewise.
* sysdeps/ieee754/dbl-64/s_finite.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/s_isinf.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/s_isnan.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c: Include
<ldbl-classify-compat.h>.
[LDBL_CLASSIFY_COMPAT]: Test value, not whether defined.
* sysdeps/arm/math_private.h (LDBL_CLASSIFY_COMPAT): Remove macro.
* sysdeps/mips/math_private.h (LDBL_CLASSIFY_COMPAT): Likewise.
* sysdeps/m68k/coldfire/math_private.h: Remove file.
* sysdeps/microblaze/math_private.h: Likewise.
* sysdeps/nios2/math_private.h: Likewise.
* sysdeps/sh/math_private.h: Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:58:57 +0000 (20:58 +0000)]
Remove some math_private.h libc_feholdexcept_setround overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define
libc_feholdexcept_setround to override the default version with one
that discards its rounding mode argument.
Unlike other such libc_fe* macros that I removed, this one is actually
used for such configurations (in dbl-64/e_sqrt.c). However, this does
not make the macro required. It's only used for such configurations
with FE_TONEAREST as the rounding mode (anything needing another mode
should not be used when that mode is unavailable), and the default
definition just calls __feholdexcept and __fesetround. Since we now
have suitable inline do-nothing definitions of __feholdexcept and
__fesetround for the cases of no exceptions and rounding modes, we can
just rely on those inlines to achieve the same optimization as this
macro definition. Thus, this patch removes those macro definitions
(and the math_private.h headers containing them, when no longer needed
after that removal).
Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.
* sysdeps/m68k/coldfire/fpu/math_private.h: Move to ....
* sysdeps/m68k/coldfire/math_private.h: ... here.
* sysdeps/m68k/coldfire/nofpu/math_private.h: Remove file.
* sysdeps/tile/math_private.h: Likewise.
* sysdeps/microblaze/math_private.h (libc_feholdexcept_setround):
Remove macro.
* sysdeps/nios2/math_private.h (libc_feholdexcept_setround):
Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:57:22 +0000 (20:57 +0000)]
Remove some math_private.h libc_fe* overrides.
math_private.h headers for configurations lacking support for
floating-point exceptions and rounding modes define various libc_fe*
macros to override the default versions with ones that discard any
exception or rounding mode arguments.
Three of the four macros defined in these headers are no longer needed
there: those macros are only used in fma implementations that are not
used for such configurations, now all those configurations properly
use soft-fp fma implementations instead. (Effectively, those macros
were a workaround to allow glibc to build in the absence of a proper
fma implementation for this case - now there is such an
implementation, there is no need to support building the wrong
implementation for those configurations.) Thus, this patch removes
the unnecessary macros.
Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by the patch.
* sysdeps/m68k/coldfire/nofpu/math_private.h (libc_fesetround):
Remove macro.
(libc_fetestexcept): Likewise.
(libc_feupdateenv_test): Likewise.
* sysdeps/microblaze/math_private.h (libc_fesetround): Likewise.
(libc_fetestexcept): Likewise.
(libc_feupdateenv_test): Likewise.
* sysdeps/nios2/math_private.h (libc_fesetround): Likewise.
(libc_fetestexcept): Likewise.
(libc_feupdateenv_test): Likewise.
* sysdeps/tile/math_private.h (libc_fesetround): Likewise.
(libc_fetestexcept): Likewise.
(libc_feupdateenv_test): Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:56:08 +0000 (20:56 +0000)]
Add feholdexcept inline in generic math_private.h.
Continuing the process of improving and cleaning up the handling of
configurations lacking support for floating-point exceptions and
rounding modes, this patch adds trivial inline definitions of
feholdexcept and __feholdexcept to the set of inlines for such
configurations in math_private.h. These inlines were missing from the
tile version used as a basis for the previous inlines, despite a few
such function calls ending up in libm.so.
Tested with build-many-glibcs.py. As expected, installed stripped
shared libraries are unchanged for architectures supporting exceptions
and rounding modes, but changed for architectures lacking such
support.
* sysdeps/generic/math_private.h
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feholdexcept):
New inline function.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feholdexcept):
Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:54:44 +0000 (20:54 +0000)]
Move fenv.h override inline functions to generic math_private.h.
The tile version of math_private.h defines some inline functions for
fenv.h functions, to optimize away internal calls to these functions
that do nothing given no support for floating-point exceptions and
rounding modes. (Some functions may have error cases for invalid
arguments, but those aren't applicable to the internal calls from
within glibc.) Other configurations lacking support for exceptions
and rounding modes lack such inline functions. This patch moves them
to the generic math_private.h, appropriately conditioned, so that all
such configurations can benefit from the.
include/fenv.h is made to check whether there are any non-default
rounding modes; that needs to be done there, rather than later,
because get-rounding-mode.h defines values for otherwise unsupported
FE_* rounding modes. It also gives an error for FE_TONEAREST
undefined, a case that already did not work for building the glibc
testsuite; the convention has by now been established that all
architectures need to provide a version of bits/fenv.h that at least
defines FE_TONEAREST.
Tested with build-many-glibcs.py. As expected, installed stripped
shared libraries are unchanged for tile and for architectures
supporting exceptions and rounding modes, but changed for non-tile
architectures not supporting exceptions and rounding modes that
previously lacked this optimization (e.g. Nios II libm.so is about 1kB
smaller).
The optimization is not in fact complete (does not cover feholdexcept
/ __feholdexcept, so a few calls to those remain unnecessarily within
libm even after this patch), but that can be dealt with separately.
* include/fenv.h [!_ISOMAC && !FE_TONEAREST]: Give #error.
[!_ISOMAC] (FE_HAVE_ROUNDING_MODES): New macro.
* sysdeps/generic/math_private.h
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fegetenv): New
inline function.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fegetenv):
Likewise.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (fesetenv):
Likewise.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__fesetenv):
Likewise.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (feupdateenv):
Likewise.
[!FE_HAVE_ROUNDING_MODES && FE_ALL_EXCEPT == 0] (__feupdateenv):
Likewise.
[!FE_HAVE_ROUNDING_MODES] (fegetround): Likewise.
[!FE_HAVE_ROUNDING_MODES] (__fegetround): Likewise.
[!FE_HAVE_ROUNDING_MODES] (fesetround): Likewise.
[!FE_HAVE_ROUNDING_MODES] (__fesetround): Likewise.
* sysdeps/tile/math_private.h (fegetenv): Remove inline function.
(__fegetenv): Likewise.
(fesetenv): Likewise.
(__fesetenv): Likewise.
(feupdateenv): Likewise.
(__feupdateenv): Likewise.
(fegetround): Likewise.
(__fegetround): Likewise.
(fesetround): Likewise.
(__fesetround): Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:52:59 +0000 (20:52 +0000)]
Move some fenv.h override macros to generic math_private.h.
Various configurations lacking support for floating-point exceptions
and rounding modes have a math_private.h that overrides certain
functions and macros, internal and external, to avoid references to
FE_* constants that are undefined in those configurations. For
example, there are unconditional feraiseexcept (FE_INVALID) calls in
generic libm code, and these macro definitions duly define
feraiseexcept to ignore its argument to avoid an error from FE_INVALID
being undefined.
In fact it is easy to tell in an architecture-independent way whether
this is needed, by testing whether FE_ALL_EXCEPT == 0. Thus, this
patch puts such a test, and feraiseexcept and __feraiseexcept macros,
in the generic math_private.h, so reducing the duplication between
architecture versions of this header. The feclearexcept macro present
in several versions of this header, and fetestexcept in the tile
version, are not needed; they would have been needed before there were
proper soft-fp fma implementations (when generic versions, that depend
on FE_TOWARDZERO and FE_INEXACT, were being used for configurations
not supporting those features), but aren't needed any more, and so are
removed.
The tile version of this header has several inline functions for
fenv.h functions to optimize calls to them away in such configurations
where they do nothing useful, and all these header versions also have
definitions of some of the libc_fe* internal macros. I intend to make
those generic in subsequent patches.
Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.
* sysdeps/generic/math_private.h [FE_ALL_EXCEPT == 0]
(feraiseexcept): New macro.
[FE_ALL_EXCEPT == 0] (__feraiseexcept): Likewise.
* sysdeps/m68k/coldfire/nofpu/math_private.h (feraiseexcept):
Remove macro.
(__feraiseexcept): Likewise.
(feclearexcept): Likewise.
* sysdeps/microblaze/math_private.h (feraiseexcept): Likewise.
(__feraiseexcept): Likewise.
(feclearexcept): Likewise.
* sysdeps/nios2/math_private.h (feraiseexcept): Likewise.
(__feraiseexcept): Likewise.
(feclearexcept): Likewise.
* sysdeps/tile/math_private.h (feraiseexcept): Likewise.
(__feraiseexcept): Likewise.
(feclearexcept): Likewise.
(fetestexcept): Likewise.
Joseph Myers [Thu, 1 Feb 2018 20:50:00 +0000 (20:50 +0000)]
Add ColdFire math-tests.h.
Since I've been fixing build issues for ColdFire, this patch adds a
math-tests.h file for ColdFire, reflecting the lack of support for
exceptions and rounding modes for soft float. I think it is logically
correct, but have not tested it beyond build-many-glibcs.py for both
hard and soft float.
* sysdeps/m68k/coldfire/math-tests.h: New file.
Joseph Myers [Thu, 1 Feb 2018 20:48:22 +0000 (20:48 +0000)]
Fix m68k bits/fenv.h for no-FPU ColdFire.
The m68k bits/fenv.h is in sysdeps/m68k/fpu/, meaning that no-FPU
ColdFire instead gets the generic (top-level) bits/fenv.h.
That top-level bits/fenv.h defines no rounding mode constants. That
no longer works for building glibc tests: some tests fail to build (at
least with warnings) if no rounding mode macros are defined, so at
least FE_TONEAREST must be defined in all cases (as various
architectures without rounding mode support indeed do), while
__FE_UNDEFINED must be defined in the case where not all the standard
rounding modes are supported.
On general principles of supporting multilib toolchains with a single
set of headers shared between multilibs for a given architecture, it's
also desirable for the same bits/fenv.h header to work for both FPU
and no-FPU configurations. Thus, this patch moves the m68k
bits/fenv.h to sysdeps/m68k/bits/fenv.h, and inserts appropriate
conditionals to handle the no-FPU case. All the exception macros, and
FE_NOMASK_ENV, are disabled in the no-FPU case; FE_ALL_EXCEPT is
defined to 0 in that case. All rounding modes except FE_TONEAREST are
disabled in that case, and __FE_UNDEFINED is defined accordingly. To
avoid an unnecessary ABI change, fenv_t is defined in the no-FPU case
to match the definition it would have got from the generic
bits/fenv.h.
This suffices to get a clean glibc and testsuite build for this
configuration with build-many-glibcs.py (and keeps a clean build for
the other m68k configurations); it has not been otherwise tested.
* sysdeps/m68k/fpu/bits/fenv.h: Move to ....
* sysdeps/m68k/bits/fenv.h: ... here.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_INEXACT): Do
not define.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_DIVBYZERO):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_UNDERFLOW):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_OVERFLOW):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_INVALID):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_ALL_EXCEPT):
Define to 0.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__]
(__FE_UNDEFINED): New enum constant.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_TOWARDZERO):
Do not define.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_DOWNWARD):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_UPWARD):
Likewise.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (fenv_t): Define
to match generic bits/fenv.h.
[!__HAVE_68881__ && !__HAVE_FPU__ && !__mcffpu__] (FE_NOMASK_ENV):
Do not define.
Joseph Myers [Thu, 1 Feb 2018 20:44:49 +0000 (20:44 +0000)]
Do not use packed structures in soft-fp.
Building for soft-float ColdFire produces an error in soft-fp:
In file included from ../sysdeps/ieee754/soft-fp/s_fmaf.c:42:
../soft-fp/single.h:85:3: error: 'packed' attribute ignored for field of type 'struct <anonymous>' [-Werror=attributes]
} bits __attribute__ ((packed));
^
While this error only appears in that particular case, this attribute
is in fact never useful, on any architecture. If you have
struct __attribute__ ((packed)) { ... } bits;
or
struct { ... } __attribute__ ((packed)) bits;
then the attribute affects the layout of the structure type. But with
the form used in this code
struct { ... } bits __attribute__ ((packed));
the field bits is being declared packed, but the layout of its type
has already been determined at that point. If on any platform the
layout of the sequence of bit-fields were wrong without the use of a
packed attribute, the attribute would need to be used via a definition
of _FP_STRUCT_LAYOUT, not in its present position.
So this patch removes the useless attribute to fix the build for
ColdFire soft-float. Tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by the patch.
* soft-fp/double.h (union _FP_UNION_D): Do not use attribute
packed on bits.
* soft-fp/extended.h (union _FP_UNION_E): Likewise.
* soft-fp/half.h (union _FP_UNION_H): Likewise.
* soft-fp/quad.h (union _FP_UNION_Q): Likewise.
* soft-fp/single.h (union _FP_UNION_S): Likewise.
Carlos O'Donell [Thu, 1 Feb 2018 20:40:48 +0000 (20:40 +0000)]
Fix -Os log1p, log1pf build (bug 21314).
As reported in bug 21314, building log1p and log1pf fails with -Os
because of a spurious -Wmaybe-uninitialized warning (reported there
for GCC 5 for MIPS, I see it also with GCC 7 for x86_64). This patch,
based on the patches in the bug, fixes this using the DIAG_* macros.
Tested for x86_64 with -Os that this eliminates those warnings and so
allows the build to progress further.
2018-02-01 Carlos O'Donell <carlos@redhat.com>
Ramin Seyed-Moussavi <lordrasmus@gmail.com>
Joseph Myers <joseph@codesourcery.com>
[BZ #21314]
* sysdeps/ieee754/dbl-64/s_log1p.c: Include <libc-diag.h>.
(__log1p): Disable -Wmaybe-uninitialized for -Os around
computation using c.
* sysdeps/ieee754/flt-32/s_log1pf.c: Include <libc-diag.h>.
(__log1pf): Disable -Wmaybe-uninitialized for -Os around
computation using c.
Dmitry V. Levin [Thu, 1 Feb 2018 17:18:19 +0000 (17:18 +0000)]
Open master branch for glibc 2.28 development
Dmitry V. Levin [Thu, 1 Feb 2018 16:17:18 +0000 (16:17 +0000)]
Update for 2.27 release
Dmitry V. Levin [Thu, 1 Feb 2018 16:17:18 +0000 (16:17 +0000)]
Fix ChangeLog formatting
Dmitry V. Levin [Thu, 1 Feb 2018 16:17:18 +0000 (16:17 +0000)]
NEWS: add the list of bugs fixed in 2.27
Florian Weimer [Thu, 1 Feb 2018 14:00:44 +0000 (15:00 +0100)]
Record CVE-2018-6485 in ChangeLog and NEWS [BZ #22343]
Adhemerval Zanella [Thu, 1 Feb 2018 12:31:57 +0000 (10:31 -0200)]
stdlib: Fixing test-*atexit*-race tests on ia64
These tests require a new thread stack size set to a value (0x20000)
lower than the architecture minimum (0x30000). Set the stack size
to PTHREAD_STACK_MIN in this case.
Checked on ia64-linux-gnu.
* stdlib/test-atexit-race-common.c (do_test): Check stack size
against PTHREAD_STACK_MIN.
Dmitry V. Levin [Thu, 1 Feb 2018 13:07:39 +0000 (13:07 +0000)]
Update contributions in the manual
* manual/contrib.texi (Palmer Dabbelt, Arjun Shankar, Florian Weimer):
New entries.
(Rafal Luzynski, Andreas Schwab): Update.
Rafal Luzynski [Thu, 1 Feb 2018 00:45:43 +0000 (01:45 +0100)]
NEWS: List the languages which use the alternative months.
[BZ #10871]
* NEWS: List the languages which actually use the alternative
months feature in this release. Also explain that "alt_mon" and
"ab_alt_mon" are optional.
Il'ya Malakhov [Wed, 31 Jan 2018 22:32:19 +0000 (14:32 -0800)]
crypt: Fix badsalttest test (Bug 22765)
The value of 'cd.initialized' is left uninitialized before the
first invocation of 'crypt_r ()' in this test despite the fact
that it should be set to zero according to the API.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Dmitry V. Levin [Wed, 31 Jan 2018 23:13:00 +0000 (23:13 +0000)]
Fix typo in the previous commit
The version of GCC was 7.3, not 7.3.1.
Dmitry V. Levin [Wed, 31 Jan 2018 14:20:10 +0000 (14:20 +0000)]
Update information about the newest versions of tools used to build glibc
* manual/install.texi (Tools for Compilation): Update the newest
versions of gcc, binutils, texinfo, gawk, bison, and sed.
* INSTALL: Regenerated.
Samuel Thibault [Tue, 30 Jan 2018 20:42:21 +0000 (21:42 +0100)]
allocalim.h: use __glibc_likely instead of __builtin_expect
* sysdeps/pthread/allocalim.h (__libc_use_alloca): Use __glibc_likely
instead of __builtin_expect.
Samuel Thibault [Tue, 30 Jan 2018 18:56:07 +0000 (19:56 +0100)]
hurd: Fix ChangeLog date