]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
5 years agoUse rint functions not __rint functions in glibc libm.
Joseph Myers [Fri, 14 Sep 2018 13:10:39 +0000 (13:10 +0000)] 
Use rint functions not __rint functions in glibc libm.

Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __rint functions to call the
corresponding rint names instead, with asm redirection to __rint when
the calls are not inlined.  The x86_64 math_private.h is removed as no
longer useful after this patch.

This patch is relative to a tree with my floor patch
<https://sourceware.org/ml/libc-alpha/2018-09/msg00148.html> applied,
and much the same considerations arise regarding possibly replacing an
IFUNC call with a direct inline expansion.

Tested for x86_64, and with build-many-glibcs.py.

* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (rint): Redirect
using MATH_REDIRECT.
* sysdeps/aarch64/fpu/s_rint.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/aarch64/fpu/s_rintf.c: Likewise.
* sysdeps/alpha/fpu/s_rint.c: Likewise.
* sysdeps/alpha/fpu/s_rintf.c: Likewise.
* sysdeps/i386/fpu/s_rintl.c: Likewise.
* sysdeps/ieee754/dbl-64/s_rint.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c: Likewise.
* sysdeps/ieee754/float128/s_rintf128.c: Likewise.
* sysdeps/ieee754/flt-32/s_rintf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_rintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
* sysdeps/m68k/coldfire/fpu/s_rint.c: Likewise.
* sysdeps/m68k/coldfire/fpu/s_rintf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rint.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rintf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_rintl.c: Likewise.
* sysdeps/powerpc/fpu/s_rint.c: Likewise.
* sysdeps/powerpc/fpu/s_rintf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_rint.c: Likewise.
* sysdeps/riscv/rvf/s_rintf.c: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/x86_64/fpu/math_private.h: Remove file.
* math/e_scalb.c (invalid_fn): Use rint functions instead of
__rint variants.
* math/e_scalbf.c (invalid_fn): Likewise.
* math/e_scalbl.c (invalid_fn): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
Likewise.
* sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise.
* sysdeps/ieee754/k_standardl.c (__kernel_standard_l): Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_llrint.c (__llrint): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c (__llrintf): Likewise.

5 years agoUse floor functions not __floor functions in glibc libm.
Joseph Myers [Fri, 14 Sep 2018 13:09:01 +0000 (13:09 +0000)] 
Use floor functions not __floor functions in glibc libm.

Similar to the changes that were made to call sqrt functions directly
in glibc, instead of __ieee754_sqrt variants, so that the compiler
could inline them automatically without needing special inline
definitions in lots of math_private.h headers, this patch makes libm
code call floor functions directly instead of __floor variants,
removing the inlines / macros for x86_64 (SSE4.1) and powerpc
(POWER5).

The redirection used to ensure that __ieee754_sqrt does still get
called when the compiler doesn't inline a built-in function expansion
is refactored so it can be applied to other functions; the refactoring
is arranged so it's not limited to unary functions either (it would be
reasonable to use this mechanism for copysign - removing the inline in
math_private_calls.h but also eliminating unnecessary local PLT entry
use in the cases (powerpc soft-float and e500v1, for IBM long double)
where copysign calls don't get inlined).

The point of this change is that more architectures can get floor
calls inlined where they weren't previously (AArch64, for example),
without needing special inline definitions in their math_private.h,
and existing such definitions in math_private.h headers can be
removed.

Note that it's possible that in some cases an inline may be used where
an IFUNC call was previously used - this is the case on x86_64, for
example.  I think the direct calls to floor are still appropriate; if
there's any significant performance cost from inline SSE2 floor
instead of an IFUNC call ending up with SSE4.1 floor, that indicates
that either the function should be doing something else that's faster
than using floor at all, or it should itself have IFUNC variants, or
that the compiler choice of inlining for generic tuning should change
to allow for the possibility that, by not inlining, an SSE4.1 IFUNC
might be called at runtime - but not that glibc should avoid calling
floor internally.  (After all, all the same considerations would apply
to any user program calling floor, where it might either be inlined or
left as an out-of-line call allowing for a possible IFUNC.)

Tested for x86_64, and with build-many-glibcs.py.

* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (MATH_REDIRECT):
New macro.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (MATH_REDIRECT_LDBL): Likewise.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (MATH_REDIRECT_F128): Likewise.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (MATH_REDIRECT_UNARY_ARGS): Likewise.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (sqrt): Redirect using MATH_REDIRECT.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (floor): Likewise.
* sysdeps/aarch64/fpu/s_floor.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/aarch64/fpu/s_floorf.c: Likewise.
* sysdeps/ieee754/dbl-64/s_floor.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c: Likewise.
* sysdeps/ieee754/float128/s_floorf128.c: Likewise.
* sysdeps/ieee754/flt-32/s_floorf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_floorl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_floorl.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_floor_template.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floor.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floor.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
* sysdeps/riscv/rvf/s_floorf.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_floor.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_floorf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floor.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floorf.c: Likewise.
* sysdeps/powerpc/fpu/math_private.h [_ARCH_PWR5X] (__floor):
Remove macro.
[_ARCH_PWR5X] (__floorf): Likewise.
* sysdeps/x86_64/fpu/math_private.h [__SSE4_1__] (__floor): Remove
inline function.
[__SSE4_1__] (__floorf): Likewise.
* math/w_lgamma_main.c (LGFUNC (__lgamma)): Use floor functions
instead of __floor variants.
* math/w_lgamma_r_compat.c (__lgamma_r): Likewise.
* math/w_lgammaf_main.c (LGFUNC (__lgammaf)): Likewise.
* math/w_lgammaf_r_compat.c (__lgammaf_r): Likewise.
* math/w_lgammal_main.c (LGFUNC (__lgammal)): Likewise.
* math/w_lgammal_r_compat.c (__lgammal_r): Likewise.
* math/w_tgamma_compat.c (__tgamma): Likewise.
* math/w_tgamma_template.c (M_DECL_FUNC (__tgamma)): Likewise.
* math/w_tgammaf_compat.c (__tgammaf): Likewise.
* math/w_tgammal_compat.c (__tgammal): Likewise.
* sysdeps/ieee754/dbl-64/e_lgamma_r.c (sin_pi): Likewise.
* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
Likewise.
* sysdeps/ieee754/dbl-64/lgamma_neg.c (__lgamma_neg): Likewise.
* sysdeps/ieee754/flt-32/e_lgammaf_r.c (sin_pif): Likewise.
* sysdeps/ieee754/flt-32/lgamma_negf.c (__lgamma_negf): Likewise.
* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
* sysdeps/ieee754/ldbl-128/lgamma_negl.c (__lgamma_negl):
Likewise.
* sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_lgammal_r.c (__ieee754_lgammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c (__lgamma_negl):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_truncl.c (__truncl): Likewise.
* sysdeps/ieee754/ldbl-96/e_lgammal_r.c (sin_pi): Likewise.
* sysdeps/ieee754/ldbl-96/lgamma_negl.c (__lgamma_negl): Likewise.
* sysdeps/powerpc/power5+/fpu/s_modf.c (__modf): Likewise.
* sysdeps/powerpc/power5+/fpu/s_modff.c (__modff): Likewise.

5 years agoInclude most of elf/ modules-names in modules-names-tests.
Joseph Myers [Wed, 12 Sep 2018 20:31:24 +0000 (20:31 +0000)] 
Include most of elf/ modules-names in modules-names-tests.

I'm testing a patch to let the compiler expand calls to floor in libm
as built-in function calls as much as possible, instead of calling
__floor, so that no architecture-specific __floor inlines are needed,
and then to arrange for non-inlined calls to end up calling __floor,
as done with sqrt and __ieee754_sqrt.

This shows up elf/tst-relsort1mod2.c calling floor, which must not be
converted to a call to __floor.  Now, while an IS_IN (libm)
conditional could be added to the existing conditionals on such
redirections in include/math.h, the _ISOMAC conditional ought to
suffice (code in other glibc libraries shouldn't be calling floor or
sqrt anyway, as they aren't provided in libc and the other libraries
don't link with libm).  But while tests are mostly now built with
_ISOMAC defined, test modules in modules-names aren't unless also
listed in modules-names-tests.

As far as I can see, all the modules in modules-names in elf/ are in
fact parts of tests and so listing them in modules-names-tests is
appropriate, so they get built with something closer to the headers
used for user code, except in a few cases that actually rely on
something from internal headers.  This patch duly sets
modules-names-tests there accordingly (filtering out those tests that
fail to build without internal headers).

Tested for x86_64, and with build-many-glibcs.py.

* elf/Makefile (modules-names-tests): New variable.

5 years agoAdd new log2 implementation
Szabolcs Nagy [Wed, 13 Jun 2018 16:48:52 +0000 (17:48 +0100)] 
Add new log2 implementation

Similar algorithm is used as in log: log2(2^k x) = k + log2(c) + log2(x/c)
where the last term is approximated by a polynomial of x/c - 1, the first
order coefficient is about 1/ln2 in this case.

There is separate code path when fma instruction is not available for
computing x/c - 1 precisely, for which the table size is doubled.

The worst case error is 0.547 ULP (0.55 without fma), the read only
global data size is 1168 bytes (2192 without fma) on aarch64.  The
non-nearest rounding error is less than 1 ULP.

Improvements on Cortex-A72 compared to current glibc master:
log2 thruput: 2.00x in [0.01 11.1]
log2 latency: 2.04x in [0.01 11.1]
log2 thruput: 2.17x in [0.999 1.001]
log2 latency: 2.88x in [0.999 1.001]

Tested on
aarch64-linux-gnu (defined __FP_FAST_FMA)
arm-linux-gnueabihf (!defined __FP_FAST_FMA)
x86_64-linux-gnu (!defined __FP_FAST_FMA)
powerpc64le-linxu-gnu (defined __FP_FAST_FMA)
targets.

* NEWS: Mention log2 improvements.
* math/Makefile (type-double-routines): Add e_log2_data.
* sysdeps/i386/fpu/e_log2_data.c: New file.
* sysdeps/ia64/fpu/e_log2_data.c: New file.
* sysdeps/ieee754/dbl-64/e_log2.c: Rewrite.
* sysdeps/ieee754/dbl-64/e_log2_data.c: New file.
* sysdeps/ieee754/dbl-64/math_config.h (__log2_data): Add.
* sysdeps/ieee754/dbl-64/wordsize-64/e_log2.c: Remove.
* sysdeps/m68k/m680x0/fpu/e_log2_data.c: New file.

5 years agoAdd new log implementation
Szabolcs Nagy [Wed, 13 Jun 2018 16:40:19 +0000 (17:40 +0100)] 
Add new log implementation

Optimized log using carefully generated lookup table with 1/c and log(c)
values for small intervalls around 1.  The log(c) is very near a double
precision value, it has about 62 bits precision.  The algorithm is
log(2^k x) = k log(2) + log(c) + log(x/c), where the last term is
approximated by a polynomial of x/c - 1.  Near 1 a single polynomial of
x - 1 is used.

There is separate code path when fma instruction is not available for
computing x/c - 1 precisely, in which case the table size is doubled.
The code uses __builtin_fma under __FP_FAST_FMA to ensure it is inlined
as an instruction.

With the default configuration settings the worst case error is 0.519 ULP
(and 0.520 without fma), the rodata size is 2192 bytes (4240 without fma).
The non-nearest rounding error is less than 1 ULP.

Improvements on Cortex-A72 compared to current glibc master:
log thruput: 3.28x in [0.01 11.1]
log latency: 2.23x in [0.01 11.1]
log thruput: 1.56x in [0.999 1.001]
log latency: 1.57x in [0.999 1.001]

Tested on
aarch64-linux-gnu (defined __FP_FAST_FMA)
arm-linux-gnueabihf (!defined __FP_FAST_FMA)
x86_64-linux-gnu (!defined __FP_FAST_FMA)
powerpc64le-linux-gnu (defined __FP_FAST_FMA)
targets.

* NEWS: Mention log improvement.
* math/Makefile (type-double-routines): Add e_log_data.
* sysdeps/i386/fpu/e_log_data.c: New file.
* sysdeps/ia64/fpu/e_log_data.c: New file.
* sysdeps/ieee754/dbl-64/e_log.c: Rewrite.
* sysdeps/ieee754/dbl-64/e_log_data.c: New file.
* sysdeps/ieee754/dbl-64/math_config.h (__log_data): Add.
* sysdeps/ieee754/dbl-64/ulog.h: Remove.
* sysdeps/ieee754/dbl-64/ulog.tbl: Remove.
* sysdeps/m68k/m680x0/fpu/e_log_data.c: New file.

5 years agoi386: Use ENTRY and END in start.S [BZ #23606]
H.J. Lu [Wed, 12 Sep 2018 15:40:59 +0000 (08:40 -0700)] 
i386: Use ENTRY and END in start.S [BZ #23606]

Wrapping the _start function with ENTRY and END to insert ENDBR32 at
function entry when CET is enabled.  Since _start now includes CFI,
without "cfi_undefined (eip)", unwinder may not terminate at _start
and we will get

Program received signal SIGSEGV, Segmentation fault.
0xf7dc661e in ?? () from /lib/libgcc_s.so.1
Missing separate debuginfos, use: dnf debuginfo-install libgcc-8.2.1-3.0.fc28.i686
(gdb) bt
 #0  0xf7dc661e in ?? () from /lib/libgcc_s.so.1
 #1  0xf7dc7c18 in _Unwind_Backtrace () from /lib/libgcc_s.so.1
 #2  0xf7f0d809 in __GI___backtrace (array=array@entry=0xffffc7d0,
    size=size@entry=20) at ../sysdeps/i386/backtrace.c:127
 #3  0x08049254 in compare (p1=p1@entry=0xffffcad0, p2=p2@entry=0xffffcad4)
    at backtrace-tst.c:12
 #4  0xf7e2a28c in msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0,
    n=n@entry=2) at msort.c:65
 #5  0xf7e29f64 in msort_with_tmp (n=2, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #6  msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=5)
    at msort.c:53
 #7  0xf7e29f64 in msort_with_tmp (n=5, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #8  msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=10)
    at msort.c:53
 #9  0xf7e29f64 in msort_with_tmp (n=10, b=0xffffcad0, p=0xffffca5c)
    at msort.c:53
 #10 msort_with_tmp (p=p@entry=0xffffca5c, b=b@entry=0xffffcad0, n=n@entry=20)
    at msort.c:53
 #11 0xf7e2a5b6 in msort_with_tmp (n=20, b=0xffffcad0, p=0xffffca5c)
    at msort.c:297
 #12 __GI___qsort_r (b=b@entry=0xffffcad0, n=n@entry=20, s=s@entry=4,
    cmp=cmp@entry=0x8049230 <compare>, arg=arg@entry=0x0) at msort.c:297
 #13 0xf7e2a84d in __GI_qsort (b=b@entry=0xffffcad0, n=n@entry=20, s=s@entry=4,
    cmp=cmp@entry=0x8049230 <compare>) at msort.c:308
 #14 0x080490f6 in main (argc=2, argv=0xffffcbd4) at backtrace-tst.c:39

FAIL: debug/backtrace-tst

[BZ #23606]
* sysdeps/i386/start.S: Include <sysdep.h>
(_start): Use ENTRY/END to insert ENDBR32 at entry when CET is
enabled.  Add cfi_undefined (eip).

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
5 years agoRemove x86_64 math_private.h asms.
Joseph Myers [Tue, 11 Sep 2018 14:51:40 +0000 (14:51 +0000)] 
Remove x86_64 math_private.h asms.

The x86_64 math_private.h has asm versions of the macros to
reinterpret between floating-point and integer types.

This is the sort of thing we now strongly discourage; the expectation
in such cases, where the generic C code gives the compiler all the
information needed about the required semantics, is that you should
get the compiler to do the right thing for the generic C code rather
than writing an asm version.

Trivial tests showed GCC generates the expected single instructions
for reinterpretation from floating point to integer.  In the other
direction, it goes via memory when the asms don't; I asked about this
in GCC bug 87236 and was advised this was deliberate for generic
tuning because it was faster that way on some AMD processors (but
-mtune=intel, and -Os with the latest GCC, avoid going via memory).
The asms don't and can't know about those tuning details, so that's
evidence that they are actually making the code worse.

This patch removes the asms accordingly.  Tested for x86_64.

* sysdeps/x86_64/fpu/math_private.h (MOVD): Remove macro.
(MOVQ): Likewise.
(EXTRACT_WORDS64): Likewise.
(INSERT_WORDS64): Likewise.
(GET_FLOAT_WORD): Likewise.
(SET_FLOAT_WORD): Likewise.

5 years agoAdd build-many-glibcs.py support for building more GCC libraries.
Joseph Myers [Tue, 11 Sep 2018 12:02:28 +0000 (12:02 +0000)] 
Add build-many-glibcs.py support for building more GCC libraries.

Every so often we get libsanitizer or libgo builds breaking with new
glibc because of some change in the glibc headers.

glibc's build-many-glibcs.py deliberately disables libsanitizer and
GCC languages other than C and C++ because the point is to test glibc
and find glibc problems (including problems shown up by new compiler
warnings in new GCC), not to test libsanitizer or libgo; if the
compiler build fails because of libsanitizer or libgo failing to
build, that could hide the existence of new problems in glibc.
However, it seems reasonable to have a non-default mode where
build-many-glibcs.py does build those additional pieces, which this
patch adds.

Note that I do not intend to run a build-many-glibcs.py bot with this
new option.  If people concerned with libsanitizer, libgo or other
potentially affected GCC libraries wish to find out about such
problems more quickly, they may wish to run such a bot or bots (and to
monitor the results and fix issues found - obviously there will be
some overlap with issues found by my bots not using that option).

Note also that building a non-native Ada compiler requires a
sufficiently recent native (or build-x-host, in general) Ada compiler
to be used, possibly more or less the same version as being built.
That needs to be in the PATH when build-many-glibcs.py --full-gcc is
run; the script does not deal with setting up such a compiler (or any
of the other host tools needed for building GCC and glibc, beyond the
GMP / MPFR / MPC libraries), but perhaps it should, to avoid the need
to keep updating such a compiler manually when running a bot.

Tested by running build-many-glibcs.py with the new option, with
mainline GCC.  There are build failures for various configurations,
which may be of interest to Go / Ada people even if you're not
interested in running such a bot:

* mips64 / mips64el (all configuration): ICE building libstdc++, as
  seen without using the new option
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87156>.

* aarch64_be: error building libgo (little-endian aarch64 works fine):

version.go:67:13: error: expected ';' or ')' or newline
67 |   BigEndian =
   |             ^
version.go:67:3: error: reference to undefined name 'BigEndian'
67 |   BigEndian =
   |   ^

* arm (all configurations): error building libgo:

/scratch/jmyers/glibc/many9/src/gcc/libgo/go/internal/syscall/unix/getrandom_linux.go:29:5: error: reference to undefined name 'randomTrap'
29 |  if randomTrap == 0 {
   |     ^
/scratch/jmyers/glibc/many9/src/gcc/libgo/go/internal/syscall/unix/getrandom_linux.go:38:34: error: reference to undefined name 'randomTrap'
38 |  r1, _, errno := syscall.Syscall(randomTrap,
   |                                  ^

What's happening there is, I think, that the arm*b*-*-* case in
libgo/configure.ac is wrongly matching arm-glibc-linux-gnueabi with
the 'b' in the vendor part, and then something else is failing to
handle GOARCH=armbe.  Given that you can have configurations with
multilibs of both endiannesses, endianness should always be detected
by configure.ac, for all architectures, using a compile test of
whether __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__, not based on textual
matches to the host (= target at top-level) triplet.

* armeb (all configurations): error building libada (for some reason
  the Arm libada configuration seems to do different things for EH for
  big-endian, which makes no sense to me and doesn't actually work):

a-exexpr.adb:87:06: "System.Exceptions.Machine" is not a predefined library unit
a-exexpr.adb:87:06: "Ada.Exceptions (body)" depends on "Ada.Exceptions.Exception_Propagation (body)"
a-exexpr.adb:87:06: "Ada.Exceptions.Exception_Propagation (body)" depends on "System.Exceptions.Machine (spec)"

* hppa: error building libgo (same error as for aarch64_be).

* ia64: ICE building libgo.  I've filed
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87281> for this.

* m68k: ICE in the Go front end building libgo
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84948>.

* microblaze, microblazeel, nios2, sh3, sh3eb: build failure in libada
  for lack of a libada port to those systems (I'm not sure sh3 would
  actually need anything different from sh4):

a-cbdlli.ads:38:14: violation of restriction "No_Finalization" at system.ads:47

* i686-gnu: build failure in libada, might be fixed by the patch
  attached to <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81103>
  (not tested):

terminals.c:1115:13: fatal error: termio.h: No such file or directory

* scripts/build-many-glibcs.py (Context.__init__): Add full_gcc
argument.
(Config.build_gcc): Use --disable-libsanitizer for first GCC
build, but not for second build if --full-gcc.  Use
--enable-languages=all for second build if --full-gcc.
(get_parser): Add --full-gcc option.
(main): Update call to Context.

5 years agoItalian and Swiss locales: Use the correct separators (bug 10797).
Rafal Luzynski [Mon, 10 Sep 2018 14:00:45 +0000 (16:00 +0200)] 
Italian and Swiss locales: Use the correct separators (bug 10797).

CLDR and many other sources say that it_IT (Italian) should use a dot
(".") as a thousands separator and a comma (",") as a decimal separator.

For it_CH and de_CH CLDR says that they should use the Right Single
Quotation Mark ("’") as a thousands separator and a dot (".") as a
decimal separator.  Consequently, the same rules are copied to all other
locales in Switzerland.

These rules apply to both LC_MONETARY and LC_NUMERIC.

[BZ #10797]
* localedata/locales/de_CH (mon_thousands_sep): Use "<U2019>" (Right
Single Quotation Mark).
(thousands_sep): Likewise.
* localedata/locales/it_CH (LC_NUMERIC): Use “copy "de_CH"”.
* localedata/locales/it_IT (thousands_sep): Use ".".
(grouping): Use "3;3".

5 years agoAdd build-many-glibcs.py --enable-obsolete-* configs.
Joseph Myers [Mon, 10 Sep 2018 16:54:34 +0000 (16:54 +0000)] 
Add build-many-glibcs.py --enable-obsolete-* configs.

We've had issues before with build failures (with new GCC) in code
only built with --enable-obsolete-rpc or --enable-obsolete-nsl not
being reported for a while because build-many-glibcs.py does not test
those configure options.  This patch adds configurations (32-bit and
64-bit) using those options so that in future we can notice quickly if
they start failing to build.

Tested the new configurations do build with GCC 8.

* scripts/build-many-glibcs.py (Context.add_all_configs): Add
x86_64 and i686 configs using --enable-obsolete-rpc
--enable-obsolete-nsl.

5 years agoS390: Regenerate ULPs.
Stefan Liebler [Thu, 6 Sep 2018 12:29:01 +0000 (14:29 +0200)] 
S390: Regenerate ULPs.

Regenerated ulps from scratch after recent changes.

ChangeLog:

* sysdeps/s390/fpu/libm-test-ulps: Regenerated.

5 years agoFix segfault in maybe_script_execute.
Stefan Liebler [Thu, 6 Sep 2018 12:27:03 +0000 (14:27 +0200)] 
Fix segfault in maybe_script_execute.

If glibc is built with gcc 8 and -march=z900,
the testcase posix/tst-spawn4-compat crashes with a segfault.

In function maybe_script_execute, the new_argv array is dynamically
initialized on stack with (argc + 1) elements.
The function wants to add _PATH_BSHELL as the first argument
and writes out of bounds of new_argv.
There is an off-by-one because maybe_script_execute fails to count
the terminating NULL when sizing new_argv.

ChangeLog:

* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
Increment size of new_argv by one.

5 years agoIndian and similar locales: Set the correct date format (bug 17426).
Rafal Luzynski [Tue, 4 Sep 2018 22:40:04 +0000 (00:40 +0200)] 
Indian and similar locales: Set the correct date format (bug 17426).

This commit also fixes d_fmt in bn_BD which is identical to bn_IN,
in ne_NP which is identical to ne_IN (not supported by Glibc but supported
by CLDR), and in ta_LK which is identical to ta_IN.

For those locales which are supported by CLDR data is imported from
CLDR v33.  For others it is copied from those locales which were identical
before this commit.

[BZ #17426]
* localedata/locales/anp_IN (d_fmt): Use "%-d//%-m//%y".
* localedata/locales/ar_IN (d_fmt): Likewise.
* localedata/locales/bhb_IN (d_fmt): Likewise.
* localedata/locales/bho_IN (d_fmt): Likewise.
* localedata/locales/bn_BD (d_fmt): Likewise.
* localedata/locales/bn_IN (d_fmt): Likewise.
* localedata/locales/doi_IN (d_fmt): Likewise.
* localedata/locales/gu_IN (d_fmt): Likewise.
* localedata/locales/hi_IN (d_fmt): Likewise.
* localedata/locales/hne_IN (d_fmt): Likewise.
* localedata/locales/kn_IN (d_fmt): Likewise.
* localedata/locales/mag_IN (d_fmt): Likewise.
* localedata/locales/mai_IN (d_fmt): Likewise.
* localedata/locales/mjw_IN (d_fmt): Likewise.
* localedata/locales/ml_IN (d_fmt): Likewise.
* localedata/locales/mni_IN (d_fmt): Likewise.
* localedata/locales/mr_IN (d_fmt): Likewise.
* localedata/locales/pa_IN (d_fmt): Likewise.
* localedata/locales/raj_IN (d_fmt): Likewise.
* localedata/locales/sat_IN (d_fmt): Likewise.
* localedata/locales/sd_IN (d_fmt): Likewise.
* localedata/locales/sd_IN@devanagari (d_fmt): Likewise.
* localedata/locales/ta_IN (d_fmt): Likewise.
* localedata/locales/ta_LK (d_fmt): Likewise.
* localedata/locales/tcy_IN (d_fmt): Likewise.
* localedata/locales/ur_IN (d_fmt): Likewise.

* localedata/locales/brx_IN (d_fmt): Use "%-m//%-d//%y".
* localedata/locales/ks_IN (d_fmt): Likewise.
* localedata/locales/ks_IN@devanagari (d_fmt): Likewise.

* localedata/locales/kok_IN (d_fmt): Use "%-d-%-m-%y".
* localedata/locales/ne_NP (d_fmt): Use "%y//%-m//%-d".
* localedata/locales/sa_IN (d_fmt): Use "%-d-%m-%y".
* localedata/locales/te_IN (d_fmt): Use "%d-%m-%y".

5 years agoMissed ChangeLog
Szabolcs Nagy [Wed, 5 Sep 2018 15:30:17 +0000 (16:30 +0100)] 
Missed ChangeLog

5 years agoAdd new exp and exp2 implementations
Szabolcs Nagy [Mon, 12 Feb 2018 18:16:03 +0000 (18:16 +0000)] 
Add new exp and exp2 implementations

Optimized exp and exp2 implementations using a lookup table for
fractional powers of 2.  There are several variants, see e_exp_data.c,
they can be selected by modifying math_config.h allowing different
tradeoffs.

The default selection should be acceptable as generic libm code.
Worst case error is 0.509 ULP for exp and 0.507 ULP for exp2, on
aarch64 the rodata size is 2160 bytes, shared between exp and exp2.
On aarch64 .text + .rodata size decreased by 24912 bytes.

The non-nearest rounding error is less than 1 ULP even on targets
without efficient round implementation (although the error rate is
higher in that case).  Targets with single instruction, rounding mode
independent, to nearest integer rounding and conversion can use them
by setting TOINT_INTRINSICS and adding the necessary code to their
math_private.h.

The __exp1 code uses the same algorithm, so the error bound of pow
increased a bit.

New double precision error handling code was added following the
style of the single precision error handling code.

Improvements on Cortex-A72 compared to current glibc master:
exp thruput: 1.61x in [-9.9 9.9]
exp latency: 1.53x in [-9.9 9.9]
exp thruput: 1.13x in [0.5 1]
exp latency: 1.30x in [0.5 1]
exp2 thruput: 2.03x in [-9.9 9.9]
exp2 latency: 1.64x in [-9.9 9.9]

For small (< 1) inputs the current exp code uses a separate algorithm
so the speed up there is less.

Was tested on
aarch64-linux-gnu (TOINT_INTRINSICS, fma contraction) and
arm-linux-gnueabihf (!TOINT_INTRINSICS, no fma contraction) and
x86_64-linux-gnu (!TOINT_INTRINSICS, no fma contraction) and
powerpc64le-linux-gnu (!TOINT_INTRINSICS, fma contraction) targets,
only non-nearest rounding ulp errors increase and they are within
acceptable bounds (ulp updates are in separate patches).

* NEWS: Mention exp and exp2 improvements.
* math/Makefile (libm-support): Remove t_exp.
(type-double-routines): Add math_err and e_exp_data.
* sysdeps/aarch64/libm-test-ulps: Update.
* sysdeps/arm/libm-test-ulps: Update.
* sysdeps/i386/fpu/e_exp_data.c: New file.
* sysdeps/i386/fpu/math_err.c: New file.
* sysdeps/i386/fpu/t_exp.c: Remove.
* sysdeps/ia64/fpu/e_exp_data.c: New file.
* sysdeps/ia64/fpu/math_err.c: New file.
* sysdeps/ia64/fpu/t_exp.c: Remove.
* sysdeps/ieee754/dbl-64/e_exp.c: Rewrite.
* sysdeps/ieee754/dbl-64/e_exp2.c: Rewrite.
* sysdeps/ieee754/dbl-64/e_exp_data.c: New file.
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Update error bound.
* sysdeps/ieee754/dbl-64/eexp.tbl: Remove.
* sysdeps/ieee754/dbl-64/math_config.h: New file.
* sysdeps/ieee754/dbl-64/math_err.c: New file.
* sysdeps/ieee754/dbl-64/t_exp.c: Remove.
* sysdeps/ieee754/dbl-64/t_exp2.h: Remove.
* sysdeps/ieee754/dbl-64/uexp.h: Remove.
* sysdeps/ieee754/dbl-64/uexp.tbl: Remove.
* sysdeps/m68k/m680x0/fpu/e_exp_data.c: New file.
* sysdeps/m68k/m680x0/fpu/math_err.c: New file.
* sysdeps/m68k/m680x0/fpu/t_exp.c: Remove.
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
* sysdeps/x86_64/fpu/libm-test-ulps: Update.

5 years agoRemove alpha math_private.h.
Joseph Myers [Wed, 5 Sep 2018 12:42:51 +0000 (12:42 +0000)] 
Remove alpha math_private.h.

After some math_private.h cleanups (in particulat math-barriers.h
being split out), the only thing left in the alpha math_private.h was
macro definitions of __isnan and __isnanf, apparently (based on the
comments) intended to avoid problems with inline definitions in other
math_private.h files.  Those inline definitions were removed in commit
fe8c2b33aed067282ecac0cc3fdff1feef88548b, and the alpha math_private.h
is no longer needed; this patch removes it.

Tested with build-many-glibcs.py that installed stripped shared
libraries for alpha are unchanged by the patch.

* sysdeps/alpha/fpu/math_private.h: Remove.

5 years agoMove float128 inlines from sysdeps/generic/math_private.h to include/math.h.
Joseph Myers [Wed, 5 Sep 2018 11:53:35 +0000 (11:53 +0000)] 
Move float128 inlines from sysdeps/generic/math_private.h to include/math.h.

Continuing the cleanup of math_private.h, with a view to it becoming
the header for the APIs defined therein and not also a header with
inline variants of math.h APIs, this patch moves inline definitions of
__isinff128 and fabsf128 to include/math.h, so that any users of
math.h in glibc automatically get the optimized functions rather than
quietly missing them if they do not also include math_private.h.

Tested for x86_64 and x86, and with build-many-glibcs.py with GCC 6.
There are changes to installed stripped libc.so on configurations with
distinct _Float128, because of __printf_fp_l code that now gets the
__isinff128 inline where previously it called the out-of-line
function because of the lack of a math_private.h call.  It seems
appropriate that this code does get the inline (as it would
automatically with GCC 7 and later when the built-in function is used)
rather than being the only place in glibc that does not.

* sysdeps/generic/math_private.h
[__HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7, 0)] (__isinff128):
Move this inline function ....
[__HAVE_DISTINCT_FLOAT128] (fabsf128): And this one ....
* include/math.h [!_ISOMAC]: To here....

5 years agoMove fenv.h soft-float inlines from fenv_private.h to include/fenv.h.
Joseph Myers [Tue, 4 Sep 2018 19:52:06 +0000 (19:52 +0000)] 
Move fenv.h soft-float inlines from fenv_private.h to include/fenv.h.

<fenv_private.h> has inline versions of various <fenv.h> functions,
and their __fe* variants, for systems (generally soft-float) without
support for floating-point exceptions, rounding modes or both.

Having these inlines in a separate header introduces a risk of a
source file including <fenv.h> and compiling OK on x86_64, but failing
to compile (because the feraiseexcept inline is actually a macro that
discards its argument, to avoid the need for #ifdef FE_INVALID
conditionals), or not being properly optimized, on systems without the
exceptions and rounding modes support (when these inlines were in
math_private.h, we had a few cases where this broke the build because
there was no obvious reason for a file to need math_private.h and it
didn't need that header on x86_64).  By moving those inlines to
include/fenv.h, this risk can be avoided, and fenv_private.h becomes
more clearly defined as specifically the header for the internal
libc_fe* and SET_RESTORE_ROUND* interfaces.

This patch makes that move, removing fenv_private.h includes that are
no longer needed (or replacing them by fenv.h includes in a few cases
that didn't already have such an include).

Tested for x86_64 and x86, and tested with build-many-glibcs.py that
installed stripped shared libraries are unchanged by the patch.

* sysdeps/generic/fenv_private.h [FE_ALL_EXCEPT == 0]: Move this
code ....
[!FE_HAVE_ROUNDING_MODES]: And this code ....
* include/fenv.h [!_ISOMAC]: ... to here.
* math/fraiseexcpt.c (__feraiseexcept): Undefine as macro.
(feraiseexcept): Likewise.
* math/fromfp.h: Do not include <fenv_private.h>.
* math/s_cexp_template.c: Likewise.
* math/s_csin_template.c: Likewise.
* math/s_csinh_template.c: Likewise.
* math/s_ctan_template.c: Likewise.
* math/s_ctanh_template.c: Likewise.
* math/s_iseqsig_template.c: Likewise.
* math/w_acos_compat.c: Likewise.
* math/w_acosf_compat.c: Likewise.
* math/w_acosl_compat.c: Likewise.
* math/w_asin_compat.c: Likewise.
* math/w_asinf_compat.c: Likewise.
* math/w_asinl_compat.c: Likewise.
* math/w_j0_compat.c: Likewise.
* math/w_j0f_compat.c: Likewise.
* math/w_j0l_compat.c: Likewise.
* math/w_j1_compat.c: Likewise.
* math/w_j1f_compat.c: Likewise.
* math/w_j1l_compat.c: Likewise.
* math/w_jn_compat.c: Likewise.
* math/w_jnf_compat.c: Likewise.
* math/w_log10_compat.c: Likewise.
* math/w_log10f_compat.c: Likewise.
* math/w_log10l_compat.c: Likewise.
* math/w_log2_compat.c: Likewise.
* math/w_log2f_compat.c: Likewise.
* math/w_log2l_compat.c: Likewise.
* math/w_log_compat.c: Likewise.
* math/w_logf_compat.c: Likewise.
* math/w_logl_compat.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
* math/w_ilogb_template.c: Include <fenv.h> instead of
<fenv_private.h>.
* math/w_llogb_template.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.

5 years agoDo not include fenv_private.h in math_private.h.
Joseph Myers [Mon, 3 Sep 2018 21:09:04 +0000 (21:09 +0000)] 
Do not include fenv_private.h in math_private.h.

Continuing the clean-up related to the catch-all math_private.h
header, this patch stops math_private.h from including fenv_private.h.
Instead, fenv_private.h is included directly from those users of
math_private.h that also used interfaces from fenv_private.h.  No
attempt is made to remove unused includes of math_private.h, but that
is a natural followup.

(However, since math_private.h sometimes defines optimized versions of
math.h interfaces or __* variants thereof, as well as defining its own
interfaces, I think it might make sense to get all those optimized
versions included from include/math.h, not requiring a separate header
at all, before eliminating unused math_private.h includes - that
avoids a file quietly becoming less-optimized if someone adds a call
to one of those interfaces without restoring a math_private.h include
to that file.)

There is still a pitfall that if code uses plain fe* and __fe*
interfaces, but only includes fenv.h and not fenv_private.h or (before
this patch) math_private.h, it will compile on platforms with
exceptions and rounding modes but not get the optimized versions (and
possibly not compile) on platforms without exception and rounding mode
support, so making it easy to break the build for such platforms
accidentally.

I think it would be most natural to move the inlines / macros for fe*
and __fe* in the case of no exceptions and rounding modes into
include/fenv.h, so that all code including fenv.h with _ISOMAC not
defined automatically gets them.  Then fenv_private.h would be purely
the header for the libc_fe*, SET_RESTORE_ROUND etc. internal
interfaces and the risk of breaking the build on other platforms than
the one you tested on because of a missing fenv_private.h include
would be much reduced (and there would be some unused fenv_private.h
includes to remove along with unused math_private.h includes).

Tested for x86_64 and x86, and tested with build-many-glibcs.py that
installed stripped shared libraries are unchanged by this patch.

* sysdeps/generic/math_private.h: Do not include <fenv_private.h>.
* math/fromfp.h: Include <fenv_private.h>.
* math/math-narrow.h: Likewise.
* math/s_cexp_template.c: Likewise.
* math/s_csin_template.c: Likewise.
* math/s_csinh_template.c: Likewise.
* math/s_ctan_template.c: Likewise.
* math/s_ctanh_template.c: Likewise.
* math/s_iseqsig_template.c: Likewise.
* math/w_acos_compat.c: Likewise.
* math/w_acosf_compat.c: Likewise.
* math/w_acosl_compat.c: Likewise.
* math/w_asin_compat.c: Likewise.
* math/w_asinf_compat.c: Likewise.
* math/w_asinl_compat.c: Likewise.
* math/w_ilogb_template.c: Likewise.
* math/w_j0_compat.c: Likewise.
* math/w_j0f_compat.c: Likewise.
* math/w_j0l_compat.c: Likewise.
* math/w_j1_compat.c: Likewise.
* math/w_j1f_compat.c: Likewise.
* math/w_j1l_compat.c: Likewise.
* math/w_jn_compat.c: Likewise.
* math/w_jnf_compat.c: Likewise.
* math/w_llogb_template.c: Likewise.
* math/w_log10_compat.c: Likewise.
* math/w_log10f_compat.c: Likewise.
* math/w_log10l_compat.c: Likewise.
* math/w_log2_compat.c: Likewise.
* math/w_log2f_compat.c: Likewise.
* math/w_log2l_compat.c: Likewise.
* math/w_log_compat.c: Likewise.
* math/w_logf_compat.c: Likewise.
* math/w_logl_compat.c: Likewise.
* sysdeps/aarch64/fpu/feholdexcpt.c: Likewise.
* sysdeps/aarch64/fpu/fesetround.c: Likewise.
* sysdeps/aarch64/fpu/fgetexcptflg.c: Likewise.
* sysdeps/aarch64/fpu/ftestexcept.c: Likewise.
* sysdeps/ieee754/dbl-64/e_atan2.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp.c: Likewise.
* sysdeps/ieee754/dbl-64/e_exp2.c: Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c: Likewise.
* sysdeps/ieee754/dbl-64/e_jn.c: Likewise.
* sysdeps/ieee754/dbl-64/e_pow.c: Likewise.
* sysdeps/ieee754/dbl-64/e_remainder.c: Likewise.
* sysdeps/ieee754/dbl-64/e_sqrt.c: Likewise.
* sysdeps/ieee754/dbl-64/gamma_product.c: Likewise.
* sysdeps/ieee754/dbl-64/lgamma_neg.c: Likewise.
* sysdeps/ieee754/dbl-64/s_atan.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fmaf.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/s_nearbyint.c: Likewise.
* sysdeps/ieee754/dbl-64/s_sin.c: Likewise.
* sysdeps/ieee754/dbl-64/s_sincos.c: Likewise.
* sysdeps/ieee754/dbl-64/s_tan.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c: Likewise.
* sysdeps/ieee754/dbl-64/x2y2m1.c: Likewise.
* sysdeps/ieee754/float128/float128_private.h: Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
* sysdeps/ieee754/flt-32/e_j1f.c: Likewise.
* sysdeps/ieee754/flt-32/e_jnf.c: Likewise.
* sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
* sysdeps/ieee754/flt-32/s_nearbyintf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.
* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-128/gamma_productl.c: Likewise.
* sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
* sysdeps/ieee754/ldbl-128/x2y2m1l.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_expl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_j1l.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c: Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c: Likewise.
* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
* sysdeps/ieee754/ldbl-96/gamma_productl.c: Likewise.
* sysdeps/ieee754/ldbl-96/lgamma_negl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/x2y2m1l.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_ceil.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
* sysdeps/riscv/rvd/s_finite.c: Likewise.
* sysdeps/riscv/rvd/s_fmax.c: Likewise.
* sysdeps/riscv/rvd/s_fmin.c: Likewise.
* sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
* sysdeps/riscv/rvd/s_isinf.c: Likewise.
* sysdeps/riscv/rvd/s_isnan.c: Likewise.
* sysdeps/riscv/rvd/s_issignaling.c: Likewise.
* sysdeps/riscv/rvf/fegetround.c: Likewise.
* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
* sysdeps/riscv/rvf/fesetenv.c: Likewise.
* sysdeps/riscv/rvf/fesetround.c: Likewise.
* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
* sysdeps/riscv/rvf/s_finitef.c: Likewise.
* sysdeps/riscv/rvf/s_floorf.c: Likewise.
* sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
* sysdeps/riscv/rvf/s_fminf.c: Likewise.
* sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
* sysdeps/riscv/rvf/s_isinff.c: Likewise.
* sysdeps/riscv/rvf/s_isnanf.c: Likewise.
* sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
* sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
* sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
* sysdeps/riscv/rvf/s_roundf.c: Likewise.
* sysdeps/riscv/rvf/s_truncf.c: Likewise.

5 years ago[BZ #20271] Add newlines in __libc_fatal calls.
Paul Pluzhnikov [Sat, 1 Sep 2018 01:04:32 +0000 (18:04 -0700)] 
[BZ #20271] Add newlines in __libc_fatal calls.

5 years agoReplace conform/list-header-symbols.pl with a Python script.
Joseph Myers [Fri, 31 Aug 2018 21:19:51 +0000 (21:19 +0000)] 
Replace conform/list-header-symbols.pl with a Python script.

Continuing the move of test code from Perl to Python (which seems
uncontroversial, unlike dependencies on Python in the actual build of
glibc), this patch replaces conform/list-header-symbols.pl with a
Python script, as a first step in converting the conform/ tests.
(conform/glibcconform.py is an equivalent to GlibcConform.pm,
containing code that will be relevant to move than one of the conform/
scripts.)

Tested for x86_64, including verifying that the symbol lists generated
are identical to those generated by the Perl version.

* conform/glibcconform.py: New file.
* conform/list-header-symbols.py: Likewise.
* conform/list-header-symbols.pl: Remove.
* conform/Makefile (tests-special): Only add linknamespace tests
if [PYTHON].
($(linknamespace-symlists-tests)): Use list-header-symbols.py.

5 years agotest-container: Use xcopy_file_range for cross-device copy [BZ #23597]
H.J. Lu [Fri, 31 Aug 2018 20:07:47 +0000 (13:07 -0700)] 
test-container: Use xcopy_file_range for cross-device copy [BZ #23597]

copy_file_range can't be used to copy a file from glibc source directory
to glibc build directory since they may be on different filesystems.
This patch adds xcopy_file_range for cross-device copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
[BZ #23597]
* support/Makefile (libsupport-routines): Add
support_copy_file_range and xcopy_file_range.
* support/support.h: Include <sys/types.h>.
(support_copy_file_range): New prototype.
* support/support_copy_file_range.c: New file.  Copied and
modified from io/copy_file_range-compat.c.
* support/test-container.c (copy_one_file): Call xcopy_file_rang
instead of copy_file_range.
* support/xcopy_file_range.c: New file.
* support/xunistd.h (xcopy_file_range): New prototype.

5 years agoFix test failure with -DNDEBUG.
Carlos O'Donell [Thu, 30 Aug 2018 15:01:33 +0000 (11:01 -0400)] 
Fix test failure with -DNDEBUG.

The elf/tst-dlopen-aout.c test uses asserts to verify properties of the
test execution.  Instead of using assert it should use xpthread_create
and xpthread_join to catch errors starting the threads and fail the
test.  This shows up in Fedora 28 when building for i686-pc-linux-gnu
and using gcc 8.1.1.

Tested on i686, and fixes a check failure with -DNDEBUG.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
5 years agoreallocarray: Declare under _DEFAULT_SOURCE
Florian Weimer [Thu, 30 Aug 2018 12:14:53 +0000 (14:14 +0200)] 
reallocarray: Declare under _DEFAULT_SOURCE

Initially, this function was restricted to _GNU_SOURCE, but experience
shows that compatibility with existing build systems is improved if we
declare it under _DEFAULT_SOURCE as well.

5 years agoTest stdlib/test-bz22786 exits now with unsupported if malloc fails.
Stefan Liebler [Thu, 30 Aug 2018 06:44:32 +0000 (08:44 +0200)] 
Test stdlib/test-bz22786 exits now with unsupported if malloc fails.

The test tries to allocate more than 2^31 bytes which will always fail on s390
as it has maximum 2^31bit of memory.
Before commit 6c3a8a9d868a8deddf0d6dcc785b6d120de90523, this test returned
unsupported if malloc fails.  This patch re enables this behaviour.

Furthermore support_delete_temp_files() failed to remove the temp directory
in this case as it is not empty due to the created symlink.
Thus the creation of the symlink is moved behind malloc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog:

* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
if malloc fails.

5 years agoMake gen-libm-test.py treat plus_oflow and minus_oflow as non-finite.
Joseph Myers [Wed, 29 Aug 2018 20:01:57 +0000 (20:01 +0000)] 
Make gen-libm-test.py treat plus_oflow and minus_oflow as non-finite.

When converting gen-libm-test to Python, in one place I noted a bug in
the old Perl version that I preserved in the Python version so that
the generated output files were the same with both versions, as such
comparisons help give confidence in the correctness of such a rewrite
of a script.  Now that the conversion has been done, this patch fixes
that bug, by arranging for tests with plus_oflow or minus_oflow
results (manually written tests in libm-test-*.inc that have
overflowing results that thus depend on the rounding mode) to be
properly treated as having non-finite results, and thus not run for
the __FINITE_MATH_ONLY__ tests.  (As the affected tests in fact did
pass for __FINITE_MATH_ONLY__ testing, this is just a matter of
logical correctness in the choice of which tests run for that case,
rather than fixing any actual test failures.)

Tested for x86_64.

* math/gen-libm-test.py (gen_test_args_res): Also treat plus_oflow
and minus_oflow as non-finite.

5 years agoSplit fenv_private.h out of math_private.h more consistently.
Joseph Myers [Tue, 28 Aug 2018 20:48:49 +0000 (20:48 +0000)] 
Split fenv_private.h out of math_private.h more consistently.

On some architectures, the parts of math_private.h relating to the
floating-point environment are in a separate file fenv_private.h
included from math_private.h.  As this is purely an
architecture-specific convention used by several architectures,
however, all such architectures still need their own math_private.h,
even if it has nothing to do beyond #include <fenv_private.h> and
peculiarity of including the i386 file directly instead of having a
shared file in sysdeps/x86.

This patch makes the fenv_private.h name an architecture-independent
convention in glibc.  The include of fenv_private.h from
math_private.h becomes architecture-independent (until callers are
updated to include fenv_private.h directly so the include from
math_private.h is no longer needed).  Some architecture math_private.h
headers are removed if no longer needed, or renamed to fenv_private.h
if all they define belongs in that header; architecture fenv_private.h
headers now do require #include_next <fenv_private.h>.  The i386
fenv_private.h file moves to sysdeps/x86/fpu/ to reflect how it is
actually shared with x86_64.  The generic math_private.h gets a new
include of <stdbool.h>, as needed for bool in some prototypes in that
header (previously that was indirectly included via include/fenv.h,
which now only gets included too late in math_private.h, after those
prototypes).

Tested for x86_64 and x86, and tested with build-many-glibcs.py that
installed stripped shared libraries are unchanged by the patch.

* sysdeps/aarch64/fpu/fenv_private.h: New file.  Based on ....
* sysdeps/aarch64/fpu/math_private.h: ... this file.  All contents
moved to fenv_private.h except for ...
(TOINT_INTRINSICS): Kept in math_private.h.
(roundtoint): Likewise.
(converttoint): Likewise.
* sysdeps/arm/fenv_private.h: Change multiple-include guard to
[ARM_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/arm/math_private.h: Remove.
* sysdeps/generic/fenv_private.h: New file.  Contents moved from
....
* sysdeps/generic/math_private.h: ... this file.  Include
<stdbool.h>.  Do not include <fenv.h> or <get-rounding-mode.h>.
Include <fenv_private.h>.  Remove functions and macros moved to
fenv_private.h.
* sysdeps/i386/fpu/math_private.h: Remove.
* sysdeps/mips/math_private.h: Move to ....
* sysdeps/mips/fpu/fenv_private.h: ... here.  Change
multiple-include guard to [MIPS_FENV_PRIVATE_H].  Remove
[__mips_hard_float] conditional.  Include next <fenv_private.h>.
* sysdeps/powerpc/fpu/fenv_private.h: Change multiple-include
guard to [POWERPC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/powerpc/fpu/math_private.h: Do not include
<fenv_private.h>.
* sysdeps/riscv/rvf/math_private.h: Move to ....
* sysdeps/riscv/rvf/fenv_private.h: ... here.  Change
multiple-include guard to [RISCV_FENV_PRIVATE_H].  Include next
<fenv_private.h>.
* sysdeps/sparc/fpu/fenv_private.h: Change multiple-include guard
to [SPARC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
* sysdeps/sparc/fpu/math_private.h: Remove.
* sysdeps/i386/fpu/fenv_private.h: Move to ....
* sysdeps/x86/fpu/fenv_private.h: ... here.  Change
multiple-include guard to [X86_FENV_PRIVATE_H].  Include next
<fenv_private.h>.
* sysdeps/x86_64/fpu/math_private.h: Do not include
<sysdeps/i386/fpu/fenv_private.h>.

5 years agoregex: Add test tst-regcomp-truncated [BZ #23578]
Florian Weimer [Tue, 28 Aug 2018 10:57:46 +0000 (12:57 +0200)] 
regex: Add test tst-regcomp-truncated [BZ #23578]

5 years agotest-container: EPERM from unshare is UNSUPPORTED
Florian Weimer [Tue, 28 Aug 2018 12:02:47 +0000 (14:02 +0200)] 
test-container: EPERM from unshare is UNSUPPORTED

For example, the security policy on the Fedora build daemons results in
this EPERM error.

5 years agonscd: Fix use-after-free in addgetnetgrentX [BZ #23520]
Florian Weimer [Tue, 28 Aug 2018 11:19:27 +0000 (13:19 +0200)] 
nscd: Fix use-after-free in addgetnetgrentX [BZ #23520]

addinnetgrX may use the heap-allocated buffer, so free the buffer
in this function.

5 years agoSpeedup first memmem match
Rajalakshmi Srinivasaraghavan [Tue, 28 Aug 2018 07:12:19 +0000 (12:42 +0530)] 
Speedup first memmem match

As done in commit 284f42bc778e487dfd5dff5c01959f93b9e0c4f5, memcmp
can be used after memchr to avoid the initialization overhead of the
two-way algorithm for the first match.  This has shown improvement
>40% for first match.

5 years agoen_IN: Set the correct date format for "%x" (bug 17426).
Rafal Luzynski [Fri, 24 Aug 2018 10:06:05 +0000 (12:06 +0200)] 
en_IN: Set the correct date format for "%x" (bug 17426).

[BZ #17426]
* localedata/locales/en_IN (d_fmt): Use "%d/%m/%y".

5 years agolinks-dso-program: Fix build-programs=no build case.
DJ Delorie [Mon, 27 Aug 2018 20:31:33 +0000 (16:31 -0400)] 
links-dso-program: Fix build-programs=no build case.

* support/Makefile (others): Don't list programs explicitly as a
dependency of "others".

5 years agoMove EXCEPTION_SET_FORCES_TRAP out of math-tests.h.
Joseph Myers [Mon, 27 Aug 2018 18:52:41 +0000 (18:52 +0000)] 
Move EXCEPTION_SET_FORCES_TRAP out of math-tests.h.

Completing the move of macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_SET_FORCES_TRAP macro out to its own
math-tests-trap-force.h header.

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-trap-force.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-trap-force.h>.
(EXCEPTION_SET_FORCES_TRAP): Do not define here.
* sysdeps/powerpc/math-tests.h: Remove file.
* sysdeps/powerpc/fpu/math-tests-trap-force.h: New file.

5 years agopthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]
Martin Kuchta [Mon, 27 Aug 2018 15:03:35 +0000 (17:03 +0200)] 
pthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538]

5 years agoUpdate netinet/udp.h from Linux 4.18.
Joseph Myers [Mon, 27 Aug 2018 13:43:05 +0000 (13:43 +0000)] 
Update netinet/udp.h from Linux 4.18.

This patch adds the UDP_SEGMENT constant from Linux 4.18 to
netinet/udp.h.

Tested for x86_64.

* sysdeps/gnu/netinet/udp.h (UDP_SEGMENT): New macro.

5 years agoregex: fix uninitialized memory access
Paul Eggert [Sun, 26 Aug 2018 03:34:34 +0000 (20:34 -0700)] 
regex: fix uninitialized memory access

I introduced this bug into gnulib in commit
8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10;
eventually it was merged into glibc.  The bug was found by
project-repo <bugs@feusi.co> and reported here:
https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html
Diagnosis and draft fix reported by Assaf Gordon here:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html
* posix/regex_internal.c (build_wcs_upper_buffer):
Fix bug when mbrtowc returns 0.

5 years agoUpdate translations for be.
Carlos O'Donell [Sat, 25 Aug 2018 02:26:41 +0000 (22:26 -0400)] 
Update translations for be.

5 years agoFix IA64 links-dso-program link.
DJ Delorie [Sat, 25 Aug 2018 02:07:23 +0000 (22:07 -0400)] 
Fix IA64 links-dso-program link.

* support/Makefile (LDLIBS-links-dso-program): Add -lgcc and
$(libunwind).

5 years agoFix BZ#23400 (creating temporary files in source tree), and undefined behavior in...
Paul Pluzhnikov [Sat, 25 Aug 2018 01:08:51 +0000 (18:08 -0700)] 
Fix BZ#23400 (creating temporary files in source tree), and undefined behavior in test.

5 years agoMove EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.
Joseph Myers [Fri, 24 Aug 2018 19:18:16 +0000 (19:18 +0000)] 
Move EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_ENABLE_SUPPORTED macro out to its own
math-tests-trap.h header.

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-trap.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-trap.h>.
(EXCEPTION_ENABLE_SUPPORTED): Do not define here.
* sysdeps/aarch64/math-tests.h: Remove file.
* sysdeps/arm/math-tests.h: Likewise.
* sysdeps/riscv/math-tests.h: Likewise.
* sysdeps/aarch64/math-tests-trap.h: New file.
* sysdeps/arm/math-tests-trap.h: Likewise.
* sysdeps/riscv/math-tests-trap.h: Likewise.

5 years agoRemove unused math files
Wilco Dijkstra [Fri, 24 Aug 2018 14:31:25 +0000 (15:31 +0100)] 
Remove unused math files

Remove empty files due to the sin/cos improvements: k_sinf.c, k_cosf.c,
k_cos.c, k_sin.c.  After the tanf change s_rem_pio2f.c and k_rem_pio2f.c
(and the ia64, m68k and powerpc equivalents) are no longer used,
so remove them.  All e_rem_pio2.c files were already empty or commented
out, so remove them too.  Passes build-many-glibcs.

* math/Makefile: Remove empty files k_sin(f).c, k_cos(f).c.
Remove unused files e_rem_pio2(f).c, k_rem_pio2f.c.
* sysdeps/i386/fpu/e_rem_pio2.c: Delete file.
* sysdeps/ia64/fpu/e_rem_pio2.c: Likewise.
* sysdeps/ia64/fpu/e_rem_pio2f.c: Likewise.
* sysdeps/ia64/fpu/k_rem_pio2f.c: Likewise.
* sysdeps/ieee754/dbl-64/e_rem_pio2.c: Likewise.
* sysdeps/ieee754/dbl-64/k_cos.c: Likewise.
* sysdeps/ieee754/dbl-64/k_sin.c: Likewise.
* sysdeps/ieee754/flt-32/e_rem_pio2f.c: Likewise.
* sysdeps/ieee754/flt-32/k_cosf.c: Likewise.
* sysdeps/ieee754/flt-32/k_rem_pio2f.c: Likewise.
* sysdeps/ieee754/flt-32/k_sinf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/e_rem_pio2.c: Likewise
* sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c: Likewise
* sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c: Likewise
* sysdeps/powerpc/fpu/e_rem_pio2f.c: Likewise.
* sysdeps/powerpc/fpu/k_rem_pio2f.c: Likewise.

5 years agoMove EXCEPTION_TESTS_* out of math-tests.h
Joseph Myers [Thu, 23 Aug 2018 23:41:13 +0000 (23:41 +0000)] 
Move EXCEPTION_TESTS_* out of math-tests.h

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_TESTS_* macros for individual types out to their
own sysdeps header.

As with ROUNDING_TESTS_*, there is no need to define these macros if
FE_ALL_EXCEPT == 0 and the individual exception macros are undefined;
thus, math-tests-exceptions.h headers are only needed for soft-float
ARM and RISC-V, while the other cases that defined these macros do not
need to do so (and the associated math-tests.h headers are thus
removed without needing replacement by math-tests-exceptions.h
headers).

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-exceptions.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-exceptions.h>.
(EXCEPTION_TESTS_float): Do not define here.
(EXCEPTION_TESTS_double): Likewise.
(EXCEPTION_TESTS_long_double): Likewise.
(EXCEPTION_TESTS_float128): Likewise.
* sysdeps/arm/math-tests.h [__SOFTFP__] (EXCEPTION_TESTS_float):
Likewise.
[__SOFTFP__] (EXCEPTION_TESTS_double): Likewise.
[__SOFTFP__] (EXCEPTION_TESTS_long_double): Likewise.
* sysdeps/arm/nofpu/math-tests-exceptions.h: New file.
* sysdeps/m68k/coldfire/math-tests.h: Remove file.
* sysdeps/mips/math-tests.h: Likewise.
* sysdeps/nios2/math-tests.h: Likewise.
* sysdeps/riscv/math-tests.h [!__riscv_flen]
(EXCEPTION_TESTS_float): Do not define here.
[!__riscv_flen] (EXCEPTION_TESTS_double): Likewise.
[!__riscv_flen] (EXCEPTION_TESTS_long_double): Likewise.
* sysdeps/riscv/nofpu/math-tests-exceptions.h: New file.

5 years agoUpdate NEWS for sinf improvements
Wilco Dijkstra [Thu, 23 Aug 2018 11:55:28 +0000 (12:55 +0100)] 
Update NEWS for sinf improvements

The NEWS entry for sinf improvements is listed for 2.28, while it was
committed in 2.29, so move it there and mention tanf.

Committed as obvious.

* NEWS: Move optimized sinf entry to 2.29.

5 years agoSpeedup tanf range reduction
Wilco Dijkstra [Thu, 23 Aug 2018 11:38:16 +0000 (12:38 +0100)] 
Speedup tanf range reduction

Speedup tanf range reduction by using the new sincosf range
reduction algorithm.  Overall code quality is improved due to
inlining, so there is a speedup even if no range reduction is
required.

tanf throughput gains on Cortex-A72:
* |x| < M_PI_4  : 1.1x
* |x| < M_PI_2  : 1.2x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.6x
* |x| < Inf     : 12.1x

* sysdeps/ieee754/flt-32/s_tanf.c (__tanf): Use fast range reduction.

5 years agoAdd test-in-container infrastructure.
DJ Delorie [Fri, 6 Jul 2018 05:10:41 +0000 (01:10 -0400)] 
Add test-in-container infrastructure.

* Makefile (testroot.pristine): New rules to initialize the
test-in-container "testroot".
* Makerules (all-testsuite): Add tests-container.
* Rules (tests-expected): Add tests-container.
(binaries-all-tests): Likewise.
(tests-container): New, run these tests in the testroot container.
* support/Makefile (others): Add *-container, support_paths.c,
xmkdirp, and links-dso-program.
* support/links-dso-program-c.c: New.
* support/links-dso-program.cc: New.
* support/test-container.c: New.
* support/shell-container.c: New.
* support/echo-container.c: New.
* support/true-container.c: New.
* support/xmkdirp.c: New.
* support/xsymlink.c: New.
* support/support_paths.c: New.
* support/support.h: Add support paths prototypes.
* support/xunistd.h: Add xmkdirp () and xsymlink ().

* nss/tst-nss-test3.c: Convert to test-in-container.
* nss/tst-nss-test3.root/: New.

5 years agoregex: port Gnulib code to z/OS POSIX environment
Paul Eggert [Thu, 23 Aug 2018 00:46:32 +0000 (17:46 -0700)] 
regex: port Gnulib code to z/OS POSIX environment

Problem reported by Arnold Robbins in:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00129.html
* posix/regex_internal.h (__iswalnum, __towlower, __towupper) [!_LIBC]:
Undef.

5 years agoDon't redefine ROUNDING_TESTS_* in math/test-*-vlen*.h.
Joseph Myers [Wed, 22 Aug 2018 15:22:06 +0000 (15:22 +0000)] 
Don't redefine ROUNDING_TESTS_* in math/test-*-vlen*.h.

This patch completes the move of ROUNDING_TESTS_* macros to typo-proof
conventions by stopping redefining them in test-*-vlen*.h.  Instead,
libm-test-driver.c is made to check TEST_MATHVEC when setting
non-to-nearest rounding modes.

Tested for x86_64.

* math/test-double-vlen2.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-double-vlen4.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-double-vlen8.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Remove.
* math/test-float-vlen16.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/test-float-vlen4.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/test-float-vlen8.h: Don't include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Remove.
* math/libm-test-driver.c (IF_ROUND_INIT_FE_DOWNWARD): Check
!TEST_MATHVEC here.
(IF_ROUND_INIT_FE_TOWARDZERO): Likewise.
(IF_ROUND_INIT_FE_UPWARD): Likewise.

5 years agoMove ROUNDING_TESTS_* out of math-tests.h.
Joseph Myers [Wed, 22 Aug 2018 12:25:50 +0000 (12:25 +0000)] 
Move ROUNDING_TESTS_* out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the ROUNDING_TESTS_* macros for individual types out to their
own sysdeps header.

In the soft-float case where FE_TONEAREST is the only rounding mode
macro defined, there is no need to define ROUNDING_TESTS_*; it is only
necessary when rounding modes macros are defined that may not be
supported at runtime.  Thus, the ROUNDING_TESTS_* definitions for some
configurations are just removed, not moved to new
math-tests-rounding.h headers; the only architectures needing
math-tests-rounding.h are those where the macros are defined in
bits/fenv.h because of the possibility of a soft-float compilation
using a hard-float glibc with the same ABI (i.e., ARM and RISC-V).

The test-*-vlen*.h headers, by using #undef, do not yet follow
typo-proof conventions (but they no longer implicitly rely on being
included before math-tests.h, and this area can always be cleaned up
further in future).

Tested with build-many-glibcs.py.

* sysdeps/generic/math-tests-rounding.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Do not define here.
(ROUNDING_TESTS_double): Likewise.
(ROUNDING_TESTS_long_double): Likewise.
(ROUNDING_TESTS_float128): Likewise.
* math/test-double-vlen2.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-double-vlen4.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-double-vlen8.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_double): Undefine before defining.
* math/test-float-vlen16.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* math/test-float-vlen4.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* math/test-float-vlen8.h: Include <math-tests-rounding.h>.
(ROUNDING_TESTS_float): Undefine before defining.
* sysdeps/arm/nofpu/math-tests-rounding.h: New file.
* sysdeps/arm/math-tests.h [__SOFTFP__] (ROUNDING_TESTS_float): Do
not define here.
[__SOFTFP__] (ROUNDING_TESTS_double): Likewise.
[__SOFTFP__] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/riscv/nofpu/math-tests-rounding.h: New file.
* sysdeps/riscv/math-tests.h [!__riscv_flen]
(ROUNDING_TESTS_float): Do not define here.
[!__riscv_flen] (ROUNDING_TESTS_double): Likewise.
[!__risv_flen] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/m68k/coldfire/math-tests.h [!__mcffpu__]
(ROUNDING_TESTS_float): Likewise.
[!__mcffpu__] (ROUNDING_TESTS_double): Likewise.
[!__mcffpu__] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/mips/math-tests.h [__mips_soft_float]
(ROUNDING_TESTS_float): Likewise.
[__mips_soft_float] (ROUNDING_TESTS_double): Likewise.
[__mips_soft_float] (ROUNDING_TESTS_long_double): Likewise.
* sysdeps/nios2/math-tests.h (ROUNDING_TESTS_float): Likewise.
(ROUNDING_TESTS_double): Likewise.
(ROUNDING_TESTS_long_double): Likewise.

5 years agoAdd PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.
Tobias Klauser [Tue, 21 Aug 2018 17:22:53 +0000 (17:22 +0000)] 
Add PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.

This patch adds the PF_XDP, AF_XDP and SOL_XDP macros from Linux 4.18 to
sysdeps/unix/sysv/linux/bits/socket.h.

* sysdeps/unix/sysv/linux/bits/socket.h (PF_MAX): Set to 45.
(PF_XDP): New macro.
(AF_XDP): New macro.
(SOL_XDP): New macro.

5 years agoUpdate netinet/tcp.h from Linux 4.18.
Joseph Myers [Tue, 21 Aug 2018 15:57:22 +0000 (15:57 +0000)] 
Update netinet/tcp.h from Linux 4.18.

This patch adds constants from netinet/tcp.h in Linux 4.18, and an
associated struct tcp_zerocopy_receive, to sysdeps/gnu/netinet/tcp.h.
The new TCP_REPAIR_* constants seemed sufficiently related to those
already present to include them.

Note that this patch does not include additions to struct tcp_info;
there are many other elements in this structure in the Linux kernel
that are not included in the glibc version (which was last extended in
2007, it seems).  Such additions to the end of the structure may be OK
with the expected way it is used (size passed explicitly to the kernel
with getsockopt), but in principle any change to the size of a type
provided by glibc is an ABI change for external applications /
libraries using that type in their ABIs, and has the associated risks
of such a change.

Tested for x86_64.

* sysdeps/gnu/netinet/tcp.h (TCP_ZEROCOPY_RECEIVE): New macro.
(TCP_INQ): Likewise.
(TCP_CM_INQ): Likewise.
(TCP_REPAIR_ON): Likewise.
(TCP_REPAIR_OFF): Likewise.
(TCP_REPAIR_OFF_NO_WP): Likewise.
(struct tcp_zerocopy_receive): New type.

5 years agoAvoid running some tests if the file system does not support holes
Florian Weimer [Tue, 21 Aug 2018 10:56:53 +0000 (12:56 +0200)] 
Avoid running some tests if the file system does not support holes

Otherwise, these tests fills up the entire disk (or just run very
slowly and eventually time out).

5 years agoMakeconfig: Do not sort and deduplicate +cflags [BZ # 17248]
Florian Weimer [Tue, 21 Aug 2018 09:43:35 +0000 (11:43 +0200)] 
Makeconfig: Do not sort and deduplicate +cflags [BZ # 17248]

The original intent behind this is unclear.  It interferes with flags
that has to be ordered in a particular way.

5 years ago__readlink_chk: Remove micro-optimization
Florian Weimer [Tue, 21 Aug 2018 09:24:12 +0000 (11:24 +0200)] 
__readlink_chk: Remove micro-optimization

5 years ago__readlink_chk: Assume HAVE_INLINED_SYSCALLS
Florian Weimer [Mon, 20 Aug 2018 16:23:28 +0000 (18:23 +0200)] 
__readlink_chk: Assume HAVE_INLINED_SYSCALLS

HAVE_INLINED_SYSCALLS is always defined on Linux.
Switch to INLINE_SYSCALL_CALL as well.

5 years agoUpdate struct signalfd_siginfo from Linux 4.18.
Joseph Myers [Mon, 20 Aug 2018 15:48:16 +0000 (15:48 +0000)] 
Update struct signalfd_siginfo from Linux 4.18.

This patch updates struct signalfd_siginfo in sys/signalfd.h with new
members from Linux 4.18 (plus ssi_addr_lsb, added to the kernel in
2.6.37 without being added to sys/signalfd.h at that time).  The
__pad2 member name follows the kernel and the existing __pad name.

Tested for x86_64.

* sysdeps/unix/sysv/linux/sys/signalfd.h (struct
signalfd_siginfo): Add ssi_addr_lsb, ssi_syscall, ssi_call_addr
and ssi_arch members.

5 years agoAdd NT_VMCOREDD, AT_MINSIGSTKSZ from Linux 4.18 to elf.h.
Joseph Myers [Mon, 20 Aug 2018 15:46:26 +0000 (15:46 +0000)] 
Add NT_VMCOREDD, AT_MINSIGSTKSZ from Linux 4.18 to elf.h.

This patch adds two new constants from Linux 4.18 to elf.h,
NT_VMCOREDD and AT_MINSIGSTKSZ.

Tested for x86_64.

* elf/elf.c (NT_VMCOREDD): New macro.
(AT_MINSIGSTKSZ): Likewise.

5 years agomalloc: Add ChangeLog for accidentally committed change
Florian Weimer [Mon, 20 Aug 2018 12:57:13 +0000 (14:57 +0200)] 
malloc: Add ChangeLog for accidentally committed change

Commit b90ddd08f6dd688e651df9ee89ca3a69ff88cd0c ("malloc: Additional
checks for unsorted bin integrity I.") was committed without a
whitespace fix, so it is adjusted here as well.

5 years agopowerpc: Remove powerpc specific sinf and cosf optimization
Rajalakshmi Srinivasaraghavan [Mon, 20 Aug 2018 03:17:43 +0000 (08:47 +0530)] 
powerpc: Remove powerpc specific sinf and cosf optimization

New generic optimization of sinf and cosf introduced by commit
599cf3976679e1b345307d9c02057f02aa95528f shows improvement
compared to powerpc specific assembly version.  Hence removing
the powerpc assembly versions to make use of generic code.

5 years agomath: Regenerate s390 ulps
Florian Weimer [Fri, 17 Aug 2018 14:39:13 +0000 (16:39 +0200)] 
math: Regenerate s390 ulps

Based on results on a s390x 2964 machine, with -march=z196 and
-mtune=zEC12, and separately with -march=z13 and -mtune=z14.

5 years agomalloc: Additional checks for unsorted bin integrity I.
Istvan Kurucsai [Tue, 16 Jan 2018 13:54:32 +0000 (14:54 +0100)] 
malloc: Additional checks for unsorted bin integrity I.

On Thu, Jan 11, 2018 at 3:50 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/07/2017 04:27 PM, Istvan Kurucsai wrote:
>>
>> +          next = chunk_at_offset (victim, size);
>
>
> For new code, we prefer declarations with initializers.

Noted.

>> +          if (__glibc_unlikely (chunksize_nomask (victim) <= 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (victim) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid size (unsorted)");
>> +          if (__glibc_unlikely (chunksize_nomask (next) < 2 * SIZE_SZ)
>> +              || __glibc_unlikely (chunksize_nomask (next) >
>> av->system_mem))
>> +            malloc_printerr("malloc(): invalid next size (unsorted)");
>> +          if (__glibc_unlikely ((prev_size (next) & ~(SIZE_BITS)) !=
>> size))
>> +            malloc_printerr("malloc(): mismatching next->prev_size
>> (unsorted)");
>
>
> I think this check is redundant because prev_size (next) and chunksize
> (victim) are loaded from the same memory location.

I'm fairly certain that it compares mchunk_size of victim against
mchunk_prev_size of the next chunk, i.e. the size of victim in its
header and footer.

>> +          if (__glibc_unlikely (bck->fd != victim)
>> +              || __glibc_unlikely (victim->fd != unsorted_chunks (av)))
>> +            malloc_printerr("malloc(): unsorted double linked list
>> corrupted");
>> +          if (__glibc_unlikely (prev_inuse(next)))
>> +            malloc_printerr("malloc(): invalid next->prev_inuse
>> (unsorted)");
>
>
> There's a missing space after malloc_printerr.

Noted.

> Why do you keep using chunksize_nomask?  We never investigated why the
> original code uses it.  It may have been an accident.

You are right, I don't think it makes a difference in these checks. So
the size local can be reused for the checks against victim. For next,
leaving it as such avoids the masking operation.

> Again, for non-main arenas, the checks against av->system_mem could be made
> tighter (against the heap size).  Maybe you could put the condition into a
> separate inline function?

We could also do a chunk boundary check similar to what I proposed in
the thread for the first patch in the series to be even more strict.
I'll gladly try to implement either but believe that refining these
checks would bring less benefits than in the case of the top chunk.
Intra-arena or intra-heap overlaps would still be doable here with
unsorted chunks and I don't see any way to counter that besides more
generic measures like randomizing allocations and your metadata
encoding patches.

I've attached a revised version with the above comments incorporated
but without the refined checks.

Thanks,
Istvan

From a12d5d40fd7aed5fa10fc444dcb819947b72b315 Mon Sep 17 00:00:00 2001
From: Istvan Kurucsai <pistukem@gmail.com>
Date: Tue, 16 Jan 2018 14:48:16 +0100
Subject: [PATCH v2 1/1] malloc: Additional checks for unsorted bin integrity
 I.

Ensure the following properties of chunks encountered during binning:
- victim chunk has reasonable size
- next chunk has reasonable size
- next->prev_size == victim->size
- valid double linked list
- PREV_INUSE of next chunk is unset

    * malloc/malloc.c (_int_malloc): Additional binning code checks.

5 years agoAdd --with-nonshared-cflags option to configure
Florian Weimer [Fri, 17 Aug 2018 09:44:39 +0000 (11:44 +0200)] 
Add --with-nonshared-cflags option to configure

5 years agoMakeconfig (ASFLAGS): Always append required assembler flags
Florian Weimer [Fri, 17 Aug 2018 09:35:42 +0000 (11:35 +0200)] 
Makeconfig (ASFLAGS): Always append required assembler flags

Otherwise, it is impossible to set ASFLAGS differently from CFLAGS
without also overriding essential flags such as -Wa,--noexecstack.

5 years agoFix attribution of previous change in ChangeLog
Florian Weimer [Fri, 17 Aug 2018 09:33:29 +0000 (11:33 +0200)] 
Fix attribution of previous change in ChangeLog

5 years agomalloc: Mitigate null-byte overflow attacks
Moritz Eckert [Fri, 17 Aug 2018 01:08:36 +0000 (21:08 -0400)] 
malloc: Mitigate null-byte overflow attacks

* malloc/malloc.c (_int_free): Check for corrupt prev_size vs size.
(malloc_consolidate): Likewise.

5 years agomalloc: Verify size of top chunk.
Pochang Chen [Thu, 16 Aug 2018 19:24:24 +0000 (15:24 -0400)] 
malloc: Verify size of top chunk.

The House of Force is a well-known technique to exploit heap
overflow. In essence, this exploit takes three steps:
1. Overwrite the size of top chunk with very large value (e.g. -1).
2. Request x bytes from top chunk. As the size of top chunk
   is corrupted, x can be arbitrarily large and top chunk will
   still be offset by x.
3. The next allocation from top chunk will thus be controllable.

If we verify the size of top chunk at step 2, we can stop such attack.

5 years agoReallocate buffers for every run in strlen
Siddhesh Poyarekar [Thu, 16 Aug 2018 08:39:56 +0000 (14:09 +0530)] 
Reallocate buffers for every run in strlen

Try and avoid influencing performance of neighbouring functions.

5 years agoPrint strlen benchmark output in json
Siddhesh Poyarekar [Thu, 16 Aug 2018 08:29:13 +0000 (13:59 +0530)] 
Print strlen benchmark output in json

Allow reading the benchmark using the compare_strings.py script.

5 years agopowerpc: Rearrange little endian specific files
Rajalakshmi Srinivasaraghavan [Thu, 16 Aug 2018 06:42:02 +0000 (12:12 +0530)] 
powerpc: Rearrange little endian specific files

This patch moves little endian specific POWER9 optimization files to
sysdeps/powerpc/powerpc64/le and creates POWER9 ifunc functions
only for little endian.

5 years ago[aarch64] Add an ASIMD variant of strlen for falkor
Siddhesh Poyarekar [Wed, 15 Aug 2018 17:31:33 +0000 (23:01 +0530)] 
[aarch64] Add an ASIMD variant of strlen for falkor

This variant of strlen uses vector loads and operations to reduce the
size of the code and also eliminate the non-ascii fallback.  This
works very well for falkor because of its two vector units and
efficient vector ops.  In the best case it reduces latency of cases in
bench-strlen by 48%, with gains throughout the benchmark.
strlen-walk also sees uniform gains in the 5%-15% range.

Overall the routine appears to work better than the stock one for falkor
regardless of the benchmark, length of string or cache state.

The same cannot be said of a53 and a72 though.  a53 performance was
greatly reduced and for a72 it was a bit of a mixed bag, slightly on the
negative side but I reckon it might be fast in some situations.

* sysdeps/aarch64/strlen.S (__strlen): Rename to STRLEN.
[!STRLEN](STRLEN): Set to __strlen.
* sysdeps/aarch64/multiarch/strlen.c: New file.
* sysdeps/aarch64/multiarch/strlen_generic.S: Likewise.
* sysdeps/aarch64/multiarch/strlen_asimd.S: Likewise.
* sysdeps/aarch64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add strlen.
* sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add
strlen_generic and strlen_asimd.

Reviewed-By: szabolcs.nagy@arm.com
CC: pinskia@gmail.com
5 years agoUse generic sinf/cosf in lgammaf_r
Wilco Dijkstra [Wed, 15 Aug 2018 15:01:21 +0000 (16:01 +0100)] 
Use generic sinf/cosf in lgammaf_r

The internal functions __kernel_sinf and __kernel_cosf are used only by
lgammaf_r.  Removing the internal functions and using the generic sinf
and cosf is better overall.  Benchmarking on Cortex-A72 shows the generic
sinf and cosf are 1.4x and 2.3x faster in the range |x| < PI/4, and 0.66x
and 1.1x for |x| < PI/2, so it should make lgammaf_r faster on average.

GLIBC regression tests pass on AArch64.

* sysdeps/ieee754/flt-32/e_lgammaf_r.c (sin_pif): Use __sinf/__cosf.
* sysdeps/ieee754/flt-32/k_cosf.c (__kernel_cosf): Remove all code.
* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.

5 years agoFix spaces in x86_64 ULP file
Wilco Dijkstra [Wed, 15 Aug 2018 11:56:22 +0000 (12:56 +0100)] 
Fix spaces in x86_64 ULP file

Fix a few missing spaces, it's now identical to the regenerated version.

Passes GLIBC tests on x64.

* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate to fix spaces.

5 years agoerror, warn, warnx: Use __fxprintf for wide printing [BZ #23519]
Florian Weimer [Tue, 14 Aug 2018 11:36:10 +0000 (13:36 +0200)] 
error, warn, warnx: Use __fxprintf for wide printing [BZ #23519]

Also introduce the __vfxprintf function.

5 years agoImprove performance of sinf and cosf
Wilco Dijkstra [Tue, 14 Aug 2018 09:45:59 +0000 (10:45 +0100)] 
Improve performance of sinf and cosf

The second patch improves performance of sinf and cosf using the same
algorithms and polynomials.  The returned values are identical to sincosf
for the same input.  ULP definitions for AArch64 and x64 are updated.

sinf/cosf througput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.2x
* |x| < M_PI_4  : 1.8x
* |x| < 2 * M_PI: 1.7x
* |x| < 120.0   : 2.3x
* |x| < Inf     : 3.0x

* NEWS: Mention sinf, cosf, sincosf.
* sysdeps/aarch64/libm-test-ulps: Update ULP for sinf, cosf, sincosf.
* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sinf and cosf.
* sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c: Add definitions of
constants rather than including generic sincosf.h.
* sysdeps/x86_64/fpu/s_sincosf_data.c: Remove.
* sysdeps/ieee754/flt-32/s_cosf.c (cosf): Rewrite.
* sysdeps/ieee754/flt-32/s_sincosf.h (reduced_sin): Remove.
(reduced_cos): Remove.
(sinf_poly): New function.
* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Rewrite.

5 years agonss_files: Fix file stream leak in aliases lookup [BZ #23521]
Florian Weimer [Tue, 14 Aug 2018 08:52:06 +0000 (10:52 +0200)] 
nss_files: Fix file stream leak in aliases lookup [BZ #23521]

In order to get a clean test case, it was necessary to fix partially
fixed bug 23522 as well.

5 years agonscd: Deallocate existing user names in file parser
Florian Weimer [Tue, 14 Aug 2018 08:51:07 +0000 (10:51 +0200)] 
nscd: Deallocate existing user names in file parser

This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).

5 years agoUpdate syscall-names.list for Linux 4.18.
Joseph Myers [Mon, 13 Aug 2018 21:35:27 +0000 (21:35 +0000)] 
Update syscall-names.list for Linux 4.18.

This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.18.  The io_pgetevents and rseq syscalls are added to the
kernel on various architectures, so need to be mentioned in this file.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.18.
(io_pgetevents): New syscall.
(rseq): Likewise.

5 years agoUpdate install.texi documentation of uses of Perl and Python.
Joseph Myers [Mon, 13 Aug 2018 17:20:46 +0000 (17:20 +0000)] 
Update install.texi documentation of uses of Perl and Python.

The install.texi documentation of uses of Perl and Python is
substantially out of date.

The description of Perl is "to test the installation" (which I
interpret as referring to test-installation.pl), but it's used for
more tests than that, and to build the manual, and to regenerate one
file in the source tree.

The description of Python is only for pretty-printer tests, but it's
used for other tests / benchmarks as well (and for other internal uses
such as updating Unicode data, for which we already require Python 3,
but I think install.texi only needs to describe uses from the main
glibc Makefiles).

This patch updates the descriptions of what those tools are used for.
The Python information (and information about other tools for testing
pretty printers) was awkwardly in the middle of the general
description of building and testing glibc, rather than with the rest
of information about tools used in glibc build and test; this patch
moves the information about those tools into the main list.

Tested with regeneration of INSTALL as well as "make info" and "make
pdf".

* manual/install.texi (Configuring and compiling): Do not list
tools used for testing pretty printers here.
(Tools for Compilation): List Python, PExpect and GDB here.
Update descriptions of uses of Perl and Python.
* INSTALL: Regenerate.

5 years agoUse Linux 4.18 in build-many-glibcs.py.
Joseph Myers [Mon, 13 Aug 2018 16:46:13 +0000 (16:46 +0000)] 
Use Linux 4.18 in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Context.checkout): Default Linux
version to 4.18.

5 years agoerror, error_at_line: Add missing va_end calls
Florian Weimer [Mon, 13 Aug 2018 12:28:07 +0000 (14:28 +0200)] 
error, error_at_line: Add missing va_end calls

5 years agombstowcs: Remove outdated comment
Florian Weimer [Mon, 13 Aug 2018 12:05:00 +0000 (14:05 +0200)] 
mbstowcs: Remove outdated comment

ISO C requires that there is no effect on any global conversion state,
so the change in commit 9f097308c7465443765d1e25699a4cf33eff5455 was
correct in princple.

5 years ago[benchtests] Add workload test properties to schema
Siddhesh Poyarekar [Sat, 11 Aug 2018 13:24:46 +0000 (18:54 +0530)] 
[benchtests] Add workload test properties to schema

Add the workload test properties (max-throughput, latency, etc.) to
the schema to prevent benchmark output validation from failing.

* benchtests/scripts/benchout.schema.json (properties): Add
new properties.

5 years ago[benchtests] Add mandatory attributes to workload tests
Siddhesh Poyarekar [Sat, 11 Aug 2018 13:15:03 +0000 (18:45 +0530)] 
[benchtests] Add mandatory attributes to workload tests

Add the duration and iterations attributes to the workloads tests to
make the json schema parser happy

* benchtests/bench-skeleton.c (main): Add duration and
iterations attributes.

5 years agoChangeLog: Fix an obvious typo.
Rafal Luzynski [Fri, 10 Aug 2018 21:57:35 +0000 (23:57 +0200)] 
ChangeLog: Fix an obvious typo.

The typo has been introduced in commit
08a5ee14c6fcd87caa4f6f5c442be2fc345211f0.

5 years agoregex: Gnulib unibyte RRI uses bytes not chars
Paul Eggert [Fri, 10 Aug 2018 21:19:05 +0000 (14:19 -0700)] 
regex: Gnulib unibyte RRI uses bytes not chars

Adjust the non-glibc code to agree with what Gawk needs for
rational range interpretation (RRI) for regular expression ranges.
In unibyte locales, Gawk wants ranges to use the underlying byte
rather than the character code point.  This change does not affect
glibc proper.
* posix/regcomp.c (parse_byte) [!LIBC && RE_ENABLE_I18N]:
In unibyte locales, use the byte value rather than
running it through btowc.

5 years agoMove SNAN_TESTS_* out of math-tests.h.
Joseph Myers [Fri, 10 Aug 2018 19:22:01 +0000 (19:22 +0000)] 
Move SNAN_TESTS_* out of math-tests.h.

Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the SNAN_TESTS_* macros for individual types out to their own
sysdeps header (while the type-generic SNAN_TESTS wrapper for those
macros remains in math-tests.h).

Tested for x86_64 and x86, and with build-many-glibcs.py.

* sysdeps/generic/math-tests-snan.h: New file.
* sysdeps/generic/math-tests.h: Include <math-tests-snan.h>.
(SNAN_TESTS_float): Do not define here.
(SNAN_TESTS_double): Likewise.
(SNAN_TESTS_long_double): Likewise.
(SNAN_TESTS_float128): Likewise.
* sysdeps/i386/fpu/math-tests-snan.h: New file.
* sysdeps/i386/fpu/math-tests.h: Remove file.
* sysdeps/ia64/math-tests-snan.h: New file.
* sysdeps/ia64/math-tests.h: Remove file.
* sysdeps/x86/math-tests.h: Likewise.
* sysdeps/x86_64/fpu/math-tests-snan.h: New file.

5 years agoImprove performance of sincosf
Wilco Dijkstra [Fri, 10 Aug 2018 16:31:30 +0000 (17:31 +0100)] 
Improve performance of sincosf

This patch is a complete rewrite of sincosf.  The new version is
significantly faster, as well as simple and accurate.
The worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23 over
all 4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases.

The small range reducer uses a single reduction step to handle values up to
120.0.  It is fastest on targets which support inlined round instructions.

The large range reducer uses integer arithmetic for simplicity.  It does a
32x96 bit multiply to compute a 64-bit modulo result.  This is more than
accurate enough to handle the worst-case cancellation for values close to
an integer multiple of PI/4.  It could be further optimized, however it is
already much faster than necessary.

sincosf throughput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.6x
* |x| < M_PI_4  : 1.7x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.8x
* |x| < Inf     : 2.3x

* math/Makefile: Add s_sincosf_data.c.
* sysdeps/ia64/fpu/s_sincosf_data.c: New file.
* sysdeps/ieee754/flt-32/s_sincosf.h (abstop12): Add new function.
(sincosf_poly): Likewise.
(reduce_small): Likewise.
(reduce_large): Likewise.
* sysdeps/ieee754/flt-32/s_sincosf.c (sincosf): Rewrite.
* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file with sincosf data.
* sysdeps/m68k/m680x0/fpu/s_sincosf_data.c: New file.
* sysdeps/x86_64/fpu/s_sincosf_data.c: New file.

5 years agoClean up converttoint handling and document the semantics
Szabolcs Nagy [Wed, 4 Jul 2018 11:29:29 +0000 (12:29 +0100)] 
Clean up converttoint handling and document the semantics

This patch currently only affects aarch64.

The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int
conversion so the return type is changed to int32_t.

The original idea was to help the compiler keeping the result in uint64_t,
then it's clear that no sign extension is needed and there is no accidental
undefined or implementation defined signed int arithmetics.

But it turns out gcc does a good job with inlining so changing the type has
no overhead and the semantics of the conversion is less surprising this way.
Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top
bits were never usable and the existing code ensures that only the bottom
32 bits of the conversion result are used.

On aarch64 the neon intrinsics (which round ties to even) are changed to
round and lround (which round ties away from zero) this does not affect the
results in a significant way, but more portable (relies on round and lround
being inlined which works with -fno-math-errno).

The TOINT_SHIFT and TOINT_RINT macros were removed, only keep separate code
paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.

* sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round.
(converttoint): Use lround.
* sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and
document the semantics when TOINT_INTRINSICS is set.
(converttoint): Likewise.
(TOINT_RINT): Remove.
(TOINT_SHIFT): Remove.
* sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code
path.

5 years agoLinux: Rewrite __old_getdents64 [BZ #23497]
Florian Weimer [Fri, 10 Aug 2018 08:20:13 +0000 (10:20 +0200)] 
Linux: Rewrite __old_getdents64 [BZ #23497]

Commit 298d0e3129c0b5137f4989275b13fe30d0733c4d ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.

The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.

5 years agoS390: Fix unwind in 32-bit _mcount
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)] 
S390: Fix unwind in 32-bit _mcount

* Fix CFI offset for %r14.
* Fix unwound value of %r15 being off by 128 bytes.

ChangeLog:

* sysdeps/s390/s390-32/s390-mcount.S (_mcount):
Fix unwind.

5 years agoS390: Implement 64-bit __fentry__
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)] 
S390: Implement 64-bit __fentry__

* Since __fentry__ is almost the same as _mcount, reuse the code by
  #including it twice with different #defines around.
* Remove LA usages - they are needed in 31-bit mode to clear the top
  bit, but in 64-bit they appear to do nothing.
* Add CFI rule for the nonstandard return register. This rule applies
  to the current function (binutils generates a new CIE - see
  gas/dw2gencfi.c:select_cie_for_fde()), so it is not necessary to put
  __fentry__ into a new file.
* Fix CFI offset for %r14.
* Add CFI rule for %r0.
* Fix unwound value of %r15 being off by 244 bytes.
* Unwinding in __fentry__@plt does not work, no plan to fix it - it
  would require asking linker to generate CFI for return address in
  %r0.  From functional perspective keeping it broken is fine, since
  the callee did not have a chance to do anything yet.  From
  convenience perspective it would be possible to enhance GDB in the
  future to treat __fentry__@plt in a special way.
* Fix whitespace.
* Fix offsets in comments, which were copied from 32-bit code.
* 32-bit version will not be implemented, since it's not compatible
  with the corresponding PLT stubs: they assume %r12 points to GOT,
  which is not the case for gcc-emitted __fentry__ stub, which runs
  before the prolog.

This patch adds the runtime support in glibc for the -mfentry
gcc feature introduced in [1] and [2].

[1] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00784.html
[2] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00912.html

ChangeLog:

* sysdeps/s390/s390-64/Versions (__fentry__): Add.
* sysdeps/s390/s390-64/s390x-mcount.S: Move the common
code to s390x-mcount.h and #include it.
* sysdeps/s390/s390-64/s390x-mcount.h: New file.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
(__fentry__): Add.

5 years agoMove __fentry__ version definition to sysdeps/{i386,x86_64}
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:44 +0000 (09:07 +0200)] 
Move __fentry__ version definition to sysdeps/{i386,x86_64}

__fentry__ symbol is currently not defined for other architectures.
Attempts to introduce it cause abicheck to fail, because it will be
available since 2.29 earliest, and not 2.13, which is the case for
Intel.  With the new code, abicheck passes for i686-linux-gnu,
x86_64-linux-gnu and x86_64-linux-gnu32 triples.

ChangeLog:

* stdlib/Versions: Remove __fentry__.
* sysdeps/i386/Versions: Add __fentry__.
* sysdeps/x86_64/Versions: Add __fentry__.

5 years agoS390: Test that lazy binding does not clobber R0
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)] 
S390: Test that lazy binding does not clobber R0

The following combinations need to be tested:
* 32- (g5, esa and zarch) and 64-bit
  * linux32 glibc/configure CC='gcc -m31 -march=g5'
  * linux32 glibc/configure CC='gcc -m31'
  * linux32 glibc/configure CC='gcc -m31 -mzarch'
* With and without VX:
  * glibc/configure libc_cv_asm_s390_vx=no
* With and without profiling (using LD_PROFILE)
* With and without pltexit (using LD_AUDIT)

ChangeLog:

* sysdeps/s390/Makefile: Register the new tests.
* sysdeps/s390/tst-dl-runtime-mod.S: New file.
* sysdeps/s390/tst-dl-runtime-profile-audit.c: New file.
* sysdeps/s390/tst-dl-runtime-profile-noaudit.c: New file.
* sysdeps/s390/tst-dl-runtime-resolve-audit.c: New file.
* sysdeps/s390/tst-dl-runtime-resolve-noaudit.c: New file.
* sysdeps/s390/tst-dl-runtime.c: New file.

5 years agoS390: Do not clobber R0 in 64-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)] 
S390: Do not clobber R0 in 64-bit _dl_runtime_profile

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 64-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)] 
S390: Do not clobber R0 in 64-bit _dl_runtime_resolve

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 32-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:43 +0000 (09:07 +0200)] 
S390: Do not clobber R0 in 32-bit _dl_runtime_profile

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
Do not clobber R0.

5 years agoS390: Do not clobber R0 in 32-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)] 
S390: Do not clobber R0 in 32-bit _dl_runtime_resolve

Preparation for the usage of R0 by __fentry__.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
Do not clobber R0.

5 years agoS390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)] 
S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
Use symbolic offsets for stack variables.

5 years agoS390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:42 +0000 (09:07 +0200)] 
S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
Use symbolic offsets for stack variables.

5 years agoS390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile
Ilya Leoshkevich [Fri, 10 Aug 2018 07:07:41 +0000 (09:07 +0200)] 
S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile

Maintainability improvement.

ChangeLog:

* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
Use symbolic offsets for stack variables.