]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years agoS390: Use own tbegin macro instead of __builtin_tbegin.
Stefan Liebler [Tue, 20 Dec 2016 14:12:48 +0000 (15:12 +0100)] 
S390: Use own tbegin macro instead of __builtin_tbegin.

This patch defines __libc_tbegin, __libc_tend, __libc_tabort and
__libc_tx_nesting_depth in htm.h which replaces the direct usage of
equivalent gcc builtins.

We have to use an own inline assembly instead of __builtin_tbegin,
as tbegin has to filter program interruptions which can't be done with
the builtin.  Before this change, e.g. a segmentation fault within a
transaction, leads to a coredump where the instruction pointer points
behind the tbegin instruction instead of real failing one.
Now the transaction aborts and the code should be reexecuted by the
fallback path without transactions.  The segmentation fault will
produce a coredump with the real failing instruction.

The fpc is not saved before starting the transaction.  If e.g. the
rounging mode is changed and the transaction is aborting afterwards,
the builtin will not restore the fpc.  This is now done with the
__libc_tbegin macro.

Now the call saved fprs have to be saved / restored in the
__libc_tbegin macro.  Using the gcc builtin had forced the saving /
restoring of fprs at begin / end of e.g. __lll_lock_elision function.
The new macro saves these fprs before tbegin instruction and only
restores them on a transaction abort.  Restoring is not needed on
a successfully started transaction.

The used inline assembly does not clobber the fprs / vrs!
Clobbering the latter ones would force the compiler to save / restore
the call saved fprs as those overlap with the vrs, but they only
need to be restored if the transaction fails.  Thus the user of the
tbegin macros has to compile the file / function with -msoft-float.
It prevents gcc from using fprs / vrs.

ChangeLog:

* sysdeps/unix/sysv/linux/s390/Makefile (elision-CFLAGS):
Add -msoft-float.
* sysdeps/unix/sysv/linux/s390/htm.h: New File.
* sysdeps/unix/sysv/linux/s390/elision-lock.c:
Use __libc_t* transaction macros instead of __builtin_t*.
* sysdeps/unix/sysv/linux/s390/elision-trylock.c: Likewise.
* sysdeps/unix/sysv/linux/s390/elision-unlock.c: Likewise.

7 years agoS390: Use C11-like atomics instead of plain memory accesses in lock elision code.
Stefan Liebler [Tue, 20 Dec 2016 14:12:48 +0000 (15:12 +0100)] 
S390: Use C11-like atomics instead of plain memory accesses in lock elision code.

This uses atomic operations to access lock elision metadata that is accessed
concurrently (ie, adapt_count fields).  The size of the data is less than a
word but accessed only with atomic loads and stores.

See also x86 commit ca6e601a9d4a72b3699cca15bad12ac1716bf49a:
"Use C11-like atomics instead of plain memory accesses in x86 lock elision."

ChangeLog:

* sysdeps/unix/sysv/linux/s390/elision-lock.c
(__lll_lock_elision): Use atomics to load / store adapt_count.
* sysdeps/unix/sysv/linux/s390/elision-trylock.c
(__lll_trylock_elision): Likewise.

7 years agoDo not require memset elimination in explicit_bzero test
Florian Weimer [Tue, 20 Dec 2016 10:01:05 +0000 (11:01 +0100)] 
Do not require memset elimination in explicit_bzero test

Some targets fail to apply dead store elimination to the
memset call in setup_ordinary_clear.  Before this commit,
this causes the test case to fail.  Instead, the test case
now logs lack of memset elimination as an informational
message.

7 years agoAdd fmaxmag, fminmag functions.
Joseph Myers [Tue, 20 Dec 2016 00:46:53 +0000 (00:46 +0000)] 
Add fmaxmag, fminmag functions.

TS 18661-1 defines fmaxmag and fminmag functions that return the
argument with maximum / minimum magnitude (acting like fmax / fmin if
the arguments have the same magnitude or either argument is a NaN).
These correspond to the IEEE 754-2008 operations maxNumMag and
minNumMag.  This patch implements these functions for glibc.  They are
implemented with type-generic templates.  Tests are based on those for
fmax and fmin.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(fmaxmag): New declaration.
(fminmag): Likewise.
* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (fmaxmag): New
macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fminmag): Likewise.
* math/Versions (fmaxmag): New libm symbol at version GLIBC_2.25.
(fmaxmagf): Likewise.
(fmaxmagl): Likewise.
(fminmag): Likewise.
(fminmagf): Likewise.
(fminmagl): Likewise.
* math/Makefile (gen-libm-calls): Add s_fmaxmagF and s_fminmagF.
* math/s_fmaxmag_template.c: New file.
* math/s_fminmag_template.c: Likewise.
* math/libm-test.inc (fmaxmag_test_data): New array.
(fmaxmag_test): New function.
(fminmag_test_data): New array.
(fminmag_test): New function.
(main): Call fmaxmag_test and fminmag_test.
* math/test-tgmath.c (NCALLS): Increase to 132.
(F(compile_test)): Call fmaxmag and fminmag.
(F(fminmag)): New function.
(F(fmaxmag)): Likewise.
* manual/arith.texi (Misc FP Arithmetic): Document fminmag,
fminmagf, fminmagl, fmaxmag, fmaxmagf and fmaxmagl.
* manual/libm-err-tab.pl (@all_functions): Add fmaxmag and
fminmag.
* sysdeps/ieee754/ldbl-opt/nldbl-fmaxmag.c: New file.
* sysdeps/ieee754/ldbl-opt/nldbl-fminmag.c: Likewise.
* sysdeps/ieee754/ldbl-opt/s_fmaxmagl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/s_fminmagl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fmaxmag
and fminmag.
(CFLAGS-nldbl-fmaxmag.c): New variable.
(CFLAGS-nldbl-fminmag.c): Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoRobust mutexes: Fix lost wake-up.
Torvald Riegel [Thu, 15 Dec 2016 15:06:28 +0000 (16:06 +0100)] 
Robust mutexes: Fix lost wake-up.

Assume that Thread 1 waits to acquire a robust mutex using futexes to
block (and thus sets the FUTEX_WAITERS flag), and is unblocked when this
mutex is released.  If Thread 2 concurrently acquires the lock and is
killed, Thread 1 can recover from the died owner but fail to restore the
FUTEX_WAITERS flag.  This can lead to a Thread 3 that also blocked using
futexes at the same time as Thread 1 to not get woken up because
FUTEX_WAITERS is not set anymore.

The fix for this is to ensure that we continue to preserve the
FUTEX_WAITERS flag whenever we may have set it or shared it with another
thread.  This is the same requirement as in the algorithm for normal
mutexes, only that the robust mutexes need additional handling for died
owners and thus preserving the FUTEX_WAITERS flag cannot be done just in
the futex slowpath code.

[BZ #20973]
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Fix lost
wake-up in robust mutexes.
* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.

7 years agobenchtests: Add fmaxf/fminf benchmarks
Adhemerval Zanella [Mon, 19 Dec 2016 13:00:45 +0000 (11:00 -0200)] 
benchtests: Add fmaxf/fminf benchmarks

This patch adds fmaxf and fminf benchtests.  It is based on
math/s_fmax_template.c implementation which checks for basically four
different classes:

  1. if x is greater or equal than y.
  2. if x is less than y.
  3. if x or y is signaling.
  4. if y is nan.

Cases 1 and 2 are used for default input number (by mixing normal double
numbers and infinity), while case 3 and 4 are used each for on for a
benchmark class.

Checked on x86_64-linux-gnu and powerpc64-linux-gnu.

* benchtests/Makefile (bench-math): Add fminf and fmaxf.
(CFLAGS-bench-fmaxf.c): New rule.
(CFLAGS-bench-fminf.c): Likewise.
        * benchtests/fmaxf-inputs: New file.
        * benchtests/fminf-inputs: Likewise.

7 years agobenchtests: Add fmax/fmin benchmarks
Adhemerval Zanella [Fri, 16 Dec 2016 19:10:58 +0000 (19:10 +0000)] 
benchtests: Add fmax/fmin benchmarks

This patch adds fmax and fmin benchtests.  It is based math/s_fmax_template.c
implementation which checks for basically four different classes:

  1. if x is greater or equal than y.
  2. if x is less than y.
  3. if x or y is signaling.
  4. if y is nan.

Cases 1 and 2 are used for default input number (by mixing normal double
numbers and infinity), while case 3 and 4 are used each for on for a
benchmark class.

Checked on x86_64-linux-gnu and powerpc64-linux-gnu.

* benchtests/Makefile (bench-math): Add fmin and fmax.
(CFLAGS-bench-fmax.c): New rule.
(CFLAGS-bench-fmin.c): New rule.
* benchtests/fmax-inputs: New file.
* benchtests/fmin-inputs: Likewise.

7 years agoAdjust benchtests to new support library.
Adhemerval Zanella [Fri, 16 Dec 2016 17:35:06 +0000 (17:35 +0000)] 
Adjust benchtests to new support library.

This patch basically replaces the test-skeleton.c inclusion by
support/test-driver.c and also minor adjustments in bench-string.h.

Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.

* benchtests/bench-string.h (TEST_FUNCTION): Use name without
parenthesis.
(CMDLINE_PROCESS): Define using function instead of macro.
* benchtests/bench-memccpy.c: Include <support/test-driver.c> instead
of test-skeleton.
* benchtests/bench-memchr.c: Likewise.
* benchtests/bench-memcmp.c: Likewise.
* benchtests/bench-memcpy-large.c: Likewise.
* benchtests/bench-memcpy.c: Likewise.
* benchtests/bench-memmem.c: Likewise.
* benchtests/bench-memmove-large.c: Likewise.
* benchtests/bench-memmove.c: Likewise.
* benchtests/bench-memset-large.c: Likewise.
* benchtests/bench-memset.c: Likewise.
* benchtests/bench-rawmemchr.c: Likewise.
* benchtests/bench-strcasecmp.c: Likewise.
* benchtests/bench-strcasestr.c: Likewise.
* benchtests/bench-strcat.c: Likewise.
* benchtests/bench-strchr.c: Likewise.
* benchtests/bench-strcmp.c: Likewise.
* benchtests/bench-strcpy.c: Likewise.
* benchtests/bench-strcpy_chk.c: Likewise.
* benchtests/bench-strlen.c: Likewise.
* benchtests/bench-strncasecmp.c: Likewise.
* benchtests/bench-strncmp.c: Likewise.
* benchtests/bench-strncpy.c: Likewise.
* benchtests/bench-strnlen.c: Likewise.
* benchtests/bench-strpbrk.c: Likewise.
* benchtests/bench-strrchr.c: Likewise.
* benchtests/bench-strsep.c: Likewise.
* benchtests/bench-strspn.c: Likewise.
* benchtests/bench-strstr.c: Likewise.
* benchtests/bench-strtok.c: Likewise.

7 years agoDisable TSX on some Haswell processors.
Andrew Senkevich [Mon, 19 Dec 2016 10:20:31 +0000 (13:20 +0300)] 
Disable TSX on some Haswell processors.

Patch disables Intel TSX on some Haswell processors to avoid TSX
on kernels that weren't updated with the latest microcode package
(which disables broken feature by default).

    * sysdeps/x86/cpu-features.c (get_common_indeces): Add
    stepping identification.
    (init_cpu_features): Add handle of Haswell.

7 years agoAdd missing bug number to ChangeLog
Florian Weimer [Sun, 18 Dec 2016 14:44:48 +0000 (15:44 +0100)] 
Add missing bug number to ChangeLog

7 years agoassert.h: allow gcc to detect assert(a = 1) errors
Jim Meyering [Thu, 5 Jun 2014 17:42:05 +0000 (10:42 -0700)] 
assert.h: allow gcc to detect assert(a = 1) errors

* assert/assert.h (assert): Rewrite assert's definition so that
a s/==/=/ typo, e.g., assert(errno = ENOENT) is not hidden from
gcc's -Wparentheses by assert-added parentheses.  The new definition
uses "if (expr) /* empty */; else __assert_fail...", so
gcc -Wall will now detect that type of error in an assert, too.
The __STRICT_ANSI__ disjunct is to make this work also with both
-ansi and  -pedantic, which would reject the use of ({...}).
I would have preferred to use __extension__ to mark that, but
doing so would mistakenly suppress warnings about any extension
in the user-supplied "expr".
E.g., "assert ( ({1;}) )" must continue to evoke a warning.

7 years agoLink benchset tests against libsupport
Siddhesh Poyarekar [Sat, 17 Dec 2016 19:52:29 +0000 (01:22 +0530)] 
Link benchset tests against libsupport

Benchsets in benchtests use test-skeleton, so they too need to be
linked against the new libsupport DSO.

       * benchtests/Makefile (binaries-benchset): Depend on libsupport
       DSO.

7 years agoAdd ChangeLog for previous commit
Siddhesh Poyarekar [Sat, 17 Dec 2016 19:12:59 +0000 (00:42 +0530)] 
Add ChangeLog for previous commit

Oops.

7 years agoAdd -B to python invocation to avoid generating pyc files
Martin Galvan [Sat, 17 Dec 2016 19:03:43 +0000 (00:33 +0530)] 
Add -B to python invocation to avoid generating pyc files

Without -B, python invocations may result in generation of pyc files
for modules within the source tree, which does not work well when the
source tree is read-only.

2016-12-17  Martin Galvan  <martingalvan@sourceware.org>

* Rules (python-flags, python-invoke): New.
($(test-printers-out)): Use $(python-flags).

7 years agoDocument sNaN argument error handling.
Joseph Myers [Fri, 16 Dec 2016 23:41:00 +0000 (23:41 +0000)] 
Document sNaN argument error handling.

TS 18661-1 says that "Whether a signaling NaN input causes a domain
error is implementation-defined.".  Considering it a domain error
would (given glibc's math_errhandling definition) mean setting errno
to EDOM.  glibc consistently does not set errno for sNaN inputs
(unless it does so for qNaN as well, i.e. iseqsig), so this patch adds
documentation of the implementation-defined choice not to treat this
case as a domain error.

* manual/arith.texi (Math Error Reporting): Document that sNaN
arguments are not considered domain errors.

7 years agoNew string function explicit_bzero (from OpenBSD).
Zack Weinberg [Thu, 15 Sep 2016 11:29:44 +0000 (07:29 -0400)] 
New string function explicit_bzero (from OpenBSD).

explicit_bzero(s, n) is the same as memset(s, 0, n), except that the
compiler is not allowed to delete a call to explicit_bzero even if the
memory pointed to by 's' is dead after the call.  Right now, this effect
is achieved externally by having explicit_bzero be a function whose
semantics are unknown to the compiler, and internally, with a no-op
asm statement that clobbers memory.  This does mean that small
explicit_bzero operations cannot be expanded inline as small memset
operations can, but on the other hand, small memset operations do get
deleted by the compiler.  Hopefully full compiler support for
explicit_bzero will happen relatively soon.

There are two new tests: test-explicit_bzero.c verifies the
visible semantics in the same way as the existing test-bzero.c,
and tst-xbzero-opt.c verifies the not-being-optimized-out property.
The latter is conceptually based on a test written by Matthew Dempsky
for the OpenBSD regression suite.

The crypt() implementation has an immediate use for this new feature.
We avoid having to add a GLIBC_PRIVATE alias for explicit_bzero
by running all of libcrypt's calls through the fortified variant,
__explicit_bzero_chk, which is in the impl namespace anyway.  Currently
I'm not aware of anything in libc proper that needs this, but the
glue is all in place if it does become necessary.  The legacy DES
implementation wasn't bothering to clear its buffers, so I added that,
mostly for consistency's sake.

* string/explicit_bzero.c: New routine.
* string/test-explicit_bzero.c, string/tst-xbzero-opt.c: New tests.
* string/Makefile (routines, strop-tests, tests): Add them.
* string/test-memset.c: Add ifdeffage for testing explicit_bzero.
* string/string.h [__USE_MISC]: Declare explicit_bzero.

* debug/explicit_bzero_chk.c: New routine.
* debug/Makefile (routines): Add it.
* debug/tst-chk1.c: Test fortification of explicit_bzero.
* string/bits/string3.h: Fortify explicit_bzero.

* manual/string.texi: Document explicit_bzero.
* NEWS: Mention addition of explicit_bzero.

* crypt/crypt-entry.c (__crypt_r): Clear key-dependent intermediate
data before returning, using explicit_bzero.
* crypt/md5-crypt.c (__md5_crypt_r): Likewise.
* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.

* include/string.h: Redirect internal uses of explicit_bzero
to __explicit_bzero_chk[_internal].
* string/Versions [GLIBC_2.25]: Add explicit_bzero.
* debug/Versions [GLIBC_2.25]: Add __explicit_bzero_chk.
* sysdeps/arm/nacl/libc.abilist
* sysdeps/unix/sysv/linux/aarch64/libc.abilist
* sysdeps/unix/sysv/linux/alpha/libc.abilist
* sysdeps/unix/sysv/linux/arm/libc.abilist
* sysdeps/unix/sysv/linux/hppa/libc.abilist
* sysdeps/unix/sysv/linux/i386/libc.abilist
* sysdeps/unix/sysv/linux/ia64/libc.abilist
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
* sysdeps/unix/sysv/linux/microblaze/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
* sysdeps/unix/sysv/linux/nios2/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
* sysdeps/unix/sysv/linux/sh/libc.abilist
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist:
Add entries for explicit_bzero and __explicit_bzero_chk.

7 years agoDefine FE_SNANS_ALWAYS_SIGNAL.
Joseph Myers [Fri, 16 Dec 2016 18:03:25 +0000 (18:03 +0000)] 
Define FE_SNANS_ALWAYS_SIGNAL.

TS 18661-1 defines a macro FE_SNANS_ALWAYS_SIGNAL in <fenv.h>, to
indicate that the recommended practice regarding sNaNs (that
operations always produce a qNaN output with "invalid" exception, even
in the fmax / fmin / hypot / pow cases where a qNaN input would not
result in qNaN output) is followed.

Now that those functions with C99 special cases for NaNs have been
fixed not to apply those special cases to sNaN, only to qNaN, glibc
follows that recommended practice.  This patch makes it define the
corresponding macro.

Since compiler optimizations may affect whether sNaNs behave as
expected and the macro relates to both language and library features,
it is only defined if __SUPPORT_SNAN__ is defined (which GCC defines
for -fsignaling-nans).  It is also not defined if FE_INVALID is
undefined, since the recommended practice specifically refers to
raising the "invalid" exception, so it seems inappropriate to define
the macro for soft-float cases without support for exceptions.
(Further refinement would be possible in cases where bits/fenv.h is
shared by configurations both with and without exceptions support.)

Tested for x86_64 and x86, and also did compile-only testing for nios2
to cover the no-exceptions case.

* math/fenv.h
[__GLIBC_USE (IEC_60559_BFP_EXT) && FE_INVALID && __SUPPORT_SNAN__]
(FE_SNANS_ALWAYS_SIGNAL): New macro.
* math/test-fe-snans-always-signal.c: New file.
* math/Makefile (tests): Add test-fe-snans-always-signal.
(CFLAGS-test-fe-snans-always-signal.c): New variable.
* manual/arith.texi (Infinity and NaN): Document
FE_SNANS_ALWAYS_SIGNAL.

7 years agoFix typos and missing closing bracket in test-memchr.c
Adhemerval Zanella [Fri, 16 Dec 2016 16:37:39 +0000 (14:37 -0200)] 
Fix typos and missing closing bracket in test-memchr.c

* string/test-memchr.c (do_test): Typo on ‘byte’ and missing closing
bracket.

7 years agoMake build-many-glibcs.py flush stdout before execv.
Joseph Myers [Fri, 16 Dec 2016 16:17:13 +0000 (16:17 +0000)] 
Make build-many-glibcs.py flush stdout before execv.

When build-many-glibcs.py re-execs itself with execv, any buffered
output on stdout may be lost (in particular, messages intended to go
to a bot's log about the re-exec taking place).  This patch makes it
flush stdout before execv, similar to the flush before running a
subprocess from the bot that is done to ensure output appears in the
right order.

* scripts/build-many-glibcs.py (Context.exec_self): Flush stdout
before calling execv.

7 years agoFix powerpc64/power7 memchr for large input sizes
Adhemerval Zanella [Thu, 15 Dec 2016 18:27:10 +0000 (18:27 +0000)] 
Fix powerpc64/power7 memchr for large input sizes

Current optimized powercp64/power7 memchr uses a strategy to check for
p versus align(p+n) (where 'p' is the input char pointer and n the
maximum size to check for the byte) without taking care for possible
overflow on the pointer addition in case of large 'n'.

It was triggered by 3038145ca23 where default rawmemchr (used to
created ppc64 rawmemchr in ifunc selection) now uses memchr (p, c, (size_t)-1)
on its implementation.

This patch fixes it by implement a satured addition where overflows
sets the maximum pointer size to UINTPTR_MAX.

Checked on powerpc64le-linux-gnu.

[BZ# 20971]
* sysdeps/powerpc/powerpc64/power7/memchr.S (__memchr): Avoid
overflow in pointer addition.
* string/test-memchr.c (do_test): Add an argument to pass as
the size on memchr.
(test_main): Add check for SIZE_MAX.

7 years agoMake w_scalbln type-generic
Gabriel F. T. Gomes [Fri, 9 Dec 2016 19:08:14 +0000 (17:08 -0200)] 
Make w_scalbln type-generic

This patch converts the wrapper scalbln (which set errno directly
rather than doing anything with __kernel_standard) to use the
type-generic template machinery, in the same way that has been done
for ldexp.

Tested for powerpc64le, s390, and x86_64.

7 years agoFix x86, x86_64 fmax, fmin sNaN handling, add tests (bug 20947).
Joseph Myers [Thu, 15 Dec 2016 23:52:18 +0000 (23:52 +0000)] 
Fix x86, x86_64 fmax, fmin sNaN handling, add tests (bug 20947).

Various fmax and fmin function implementations mishandle sNaN
arguments:

(a) When both arguments are NaNs, the return value should be a qNaN,
but sometimes it is an sNaN if at least one argument is an sNaN.

(b) Under TS 18661-1 semantics, if either argument is an sNaN then the
result should be a qNaN (whereas if one argument is a qNaN and the
other is not a NaN, the result should be the non-NaN argument).
Various implementations treat sNaNs like qNaNs here.

This patch fixes the x86 and x86_64 versions (ignoring float and
double for 32-bit x86 given the inability to reliably avoid the sNaN
turning into a qNaN before it gets to the called function).  Tests of
sNaN inputs to these functions are added.

Note on architecture versions I haven't changed for this issue:
AArch64 already gets this right (it uses a hardware instruction with
the correct semantics for both quiet and signaling NaNs) and does not
need changes.  It's possible Alpha, IA64, SPARC might need changes
(this would be shown by the testsuite if so).

Tested for x86_64 and x86 (both i686 and i586 builds, to cover the
different x86 implementations).

[BZ #20947]
* sysdeps/i386/fpu/s_fmaxl.S (__fmaxl): Add the arguments when
either is a signaling NaN.
* sysdeps/i386/fpu/s_fminl.S (__fminl): Likewise.  Make code
follow fmaxl more closely.
* sysdeps/i386/i686/fpu/s_fmaxl.S (__fmaxl): Add the arguments
when either is a signaling NaN.
* sysdeps/i386/i686/fpu/s_fminl.S (__fminl): Likewise.
* sysdeps/x86_64/fpu/s_fmax.S (__fmax): Likewise.
* sysdeps/x86_64/fpu/s_fmaxf.S (__fmaxf): Likewise.
* sysdeps/x86_64/fpu/s_fmaxl.S (__fmaxl): Likewise.
* sysdeps/x86_64/fpu/s_fmin.S (__fmin): Likewise.
* sysdeps/x86_64/fpu/s_fminf.S (__fminf): Likewise.
* sysdeps/x86_64/fpu/s_fminl.S (__fminl): Likewise.
* math/libm-test.inc (fmax_test_data): Add tests of sNaN inputs.
(fmin_test_data): Likewise.

7 years agoFix assertion failure on test timeout
Andreas Schwab [Thu, 15 Dec 2016 15:41:04 +0000 (16:41 +0100)] 
Fix assertion failure on test timeout

7 years agoFix powerpc fmax, fmin sNaN handling (bug 20947).
Joseph Myers [Thu, 15 Dec 2016 00:43:16 +0000 (00:43 +0000)] 
Fix powerpc fmax, fmin sNaN handling (bug 20947).

Various fmax and fmin function implementations mishandle sNaN
arguments:

(a) When both arguments are NaNs, the return value should be a qNaN,
but sometimes it is an sNaN if at least one argument is an sNaN.

(b) Under TS 18661-1 semantics, if either argument is an sNaN then the
result should be a qNaN (whereas if one argument is a qNaN and the
other is not a NaN, the result should be the non-NaN argument).
Various implementations treat sNaNs like qNaNs here.

This patch fixes the powerpc versions of these functions (shared by
float and double, 32-bit and 64-bit).  The structure of those versions
is that all ordered cases are already handled before anything dealing
with the case where the arguments are unordered; thus, this patch
causes no change to the code executed in the common case (neither
argument a NaN).

Tested for powerpc (32-bit and 64-bit), together with tests to be
added along with the x86_64 / x86 fixes.

[BZ #20947]
* sysdeps/powerpc/fpu/s_fmax.S (__fmax): Add the arguments when
either is a signaling NaN.
* sysdeps/powerpc/fpu/s_fmin.S (__fmin): Likewise.

7 years agoFix generic fmax, fmin sNaN handling (bug 20947).
Joseph Myers [Wed, 14 Dec 2016 22:41:26 +0000 (22:41 +0000)] 
Fix generic fmax, fmin sNaN handling (bug 20947).

Various fmax and fmin function implementations mishandle sNaN
arguments:

(a) When both arguments are NaNs, the return value should be a qNaN,
but sometimes it is an sNaN if at least one argument is an sNaN.

(b) Under TS 18661-1 semantics, if either argument is an sNaN then the
result should be a qNaN (whereas if one argument is a qNaN and the
other is not a NaN, the result should be the non-NaN argument).
Various implementations treat sNaNs like qNaNs here.

This patch fixes the generic implementations used in the absence of
architecture-specific versions.

Tested for mips64 and powerpc (together with testcases that I'll add
along with the x86_64 / x86 fixes).

[BZ #20947]
* math/s_fmax_template.c (M_DECL_FUNC (__fmax)): Add the arguments
when either is a signaling NaN.
* math/s_fmin_template.c (M_DECL_FUNC (__fmin)): Likewise.

7 years agoRefactor long double information into bits/long-double.h.
Joseph Myers [Wed, 14 Dec 2016 18:27:56 +0000 (18:27 +0000)] 
Refactor long double information into bits/long-double.h.

Information about whether the ABI of long double is the same as that
of double is split between bits/mathdef.h and bits/wordsize.h.

When the ABIs are the same, bits/mathdef.h defines
__NO_LONG_DOUBLE_MATH.  In addition, in the case where the same glibc
binary supports both -mlong-double-64 and -mlong-double-128,
bits/wordsize.h defines __LONG_DOUBLE_MATH_OPTIONAL, along with
__NO_LONG_DOUBLE_MATH if this particular compilation is with
-mlong-double-64.

As part of the refactoring I proposed in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>, this
patch puts all that information in a single header,
bits/long-double.h.  It is included from sys/cdefs.h alongside the
include of bits/wordsize.h, so other headers generally do not need to
include bits/long-double.h directly.

Previously, various bits/mathdef.h headers and bits/wordsize.h headers
had this long double information (including implicitly in some
bits/mathdef.h headers through not having the defines present in the
default version).  After the patch, it's all in six bits/long-double.h
headers.  Furthermore, most of those new headers are not
architecture-specific.  Architectures with optional long double all
use the ldbl-opt sysdeps directory, either in the order (ldbl-64-128,
ldbl-opt, ldbl-128) or (ldbl-128ibm, ldbl-opt).  Thus a generic header
for the case where long double = double, and headers in ldbl-128,
ldbl-96 and ldbl-opt, suffices to cover every architecture except for
cases where long double properties vary between different ABIs sharing
a set of installed headers; fortunately all the ldbl-opt cases share a
single compiler-predefined macro __LONG_DOUBLE_128__ that can be used
to tell whether this compilation is -mlong-double-64 or
-mlong-double-128.

The two cases where a set of headers is shared between ABIs with
different long double properties, MIPS (o32 has long double = double,
other ABIs use ldbl-128) and SPARC (32-bit has optional long double,
64-bit has required long double), need their own bits/long-double.h
headers.

As with bits/wordsize.h, multiple-include protection for this header
is generally implicit through the include guards on sys/cdefs.h, and
multiple inclusion is harmless in any case.  There is one subtlety:
the header must not define __LONG_DOUBLE_MATH_OPTIONAL if
__NO_LONG_DOUBLE_MATH was defined before its inclusion, because doing
so breaks how sysdeps/ieee754/ldbl-opt/nldbl-compat.h defines
__NO_LONG_DOUBLE_MATH itself before including system headers.  Subject
to keeping that working, it would be reasonable to move these macros
from defined/undefined #ifdef to always-defined 1/0 #if semantics, but
this patch does not attempt to do so, just rearranges where the macros
are defined.

After this patch, the only use of bits/mathdef.h is the alpha one for
modifying complex function ABIs for old GCC.  Thus, all versions of
the header other than the default and alpha versions are removed, as
is the include from math.h.

Tested for x86_64 and x86.  Also did compilation-only testing with
build-many-glibcs.py.

* bits/long-double.h: New file.
* sysdeps/ieee754/ldbl-128/bits/long-double.h: Likewise.
* sysdeps/ieee754/ldbl-96/bits/long-double.h: Likewise.
* sysdeps/ieee754/ldbl-opt/bits/long-double.h: Likewise.
* sysdeps/mips/bits/long-double.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/long-double.h: Likewise.
* math/Makefile (headers): Add bits/long-double.h.
* misc/sys/cdefs.h: Include <bits/long-double.h>.
* stdlib/strtold.c: Include <bits/long-double.h> instead of
<bits/wordsize.h>.
* bits/mathdef.h [!_COMPLEX_H]: Do not allow inclusion.
[!__NO_LONG_DOUBLE_MATH]: Remove conditional code.
* math/math.h: Do not include <bits/mathdef.h>.
* sysdeps/aarch64/bits/mathdef.h: Remove file.
* sysdeps/alpha/bits/mathdef.h [!_COMPLEX_H]: Do not allow
inclusion.
* sysdeps/ia64/bits/mathdef.h: Remove file.
* sysdeps/m68k/m680x0/bits/mathdef.h: Likewise.
* sysdeps/mips/bits/mathdef.h: Likewise.
* sysdeps/powerpc/bits/mathdef.h: Likewise.
* sysdeps/s390/bits/mathdef.h: Likewise.
* sysdeps/sparc/bits/mathdef.h: Likewise.
* sysdeps/x86/bits/mathdef.h: Likewise.
* sysdeps/s390/s390-32/bits/wordsize.h
[!__NO_LONG_DOUBLE_MATH && !__LONG_DOUBLE_MATH_OPTIONAL]: Remove
conditional code.
* sysdeps/s390/s390-64/bits/wordsize.h
[!__NO_LONG_DOUBLE_MATH && !__LONG_DOUBLE_MATH_OPTIONAL]:
Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/wordsize.h
[!__NO_LONG_DOUBLE_MATH && !__LONG_DOUBLE_MATH_OPTIONAL]:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h
[!__NO_LONG_DOUBLE_MATH && !__LONG_DOUBLE_MATH_OPTIONAL]:
Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/wordsize.h
[!__NO_LONG_DOUBLE_MATH && !__LONG_DOUBLE_MATH_OPTIONAL]:
Likewise.

7 years agoInclude <linux/falloc.h> in bits/fcntl-linux.h.
Joseph Myers [Wed, 14 Dec 2016 18:23:15 +0000 (18:23 +0000)] 
Include <linux/falloc.h> in bits/fcntl-linux.h.

This patch makes bits/fcntl-linux.h include <linux/falloc.h> to define
the FALLOC_* flags under __USE_GNU (linux/falloc.h defines only those
bits, nothing else).

Tested for x86_64 and x86.

* sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_GNU]: Include
<linux/falloc.h>.
(FALLOC_FL_KEEP_SIZE): Remove.
(FALLOC_FL_PUNCH_HOLE): Likewise.
(FALLOC_FL_COLLAPSE_RANGE): Likewise.
(FALLOC_FL_ZERO_RANGE): Likewise.

7 years agoFix arg used as litteral suffix in tst-strfrom.h
Gabriel F. T. Gomes [Fri, 28 Oct 2016 19:24:17 +0000 (17:24 -0200)] 
Fix arg used as litteral suffix in tst-strfrom.h

The macro ENTRY in tst-strfrom.h is used to generate the input values for
each floating-point type (float, double, long double).  It should append
the parameter LSUF (Literal suffix) to the floating-point number, but is
using CSUF (C function suffix).  This patch fixes it.

Tested for powerpc64le and x86_64.

7 years agoConsolidate renameat Linux implementation
Adhemerval Zanella [Tue, 13 Dec 2016 18:50:06 +0000 (16:50 -0200)] 
Consolidate renameat Linux implementation

This patch consolidates the Linux renameat implementation on
sysdeps/unix/sysv/linux/renameat.c.  The renameat syscall was
deprecated at b0da6d44 for newer architectures, so using the
auto-generation list may generate wrappers that returns ENOSYS.

Current code try to use __NR_renameat and if it is not define
it uses __NR_renameat2.

Checked on x86_64 and aarch64.

* sysdeps/unix/sysv/linux/renameat.c: New file.
* sysdeps/unix/sysv/linux/syscalls.list: Remove renameat.

7 years agoConsolidate rename Linux implementation
Adhemerval Zanella [Fri, 11 Nov 2016 11:02:46 +0000 (09:02 -0200)] 
Consolidate rename Linux implementation

This patch consolidates the Linux rename implementation on
sysdeps/unix/sysv/linux/rename.c.  Current code try to use
__NR_rename if is defined and apply the same strategy for
__NR_renameat and __NR_renameat2.

Check on x86_64 and aarch64.

* sysdeps/unix/sysv/linux/rename.c: New file.
* sysdeps/unix/sysv/linux/generic/rename.c: Remove file.

7 years agoAdd [BZ #19398] marker to ChangeLog entry.
Joseph Myers [Wed, 14 Dec 2016 17:30:06 +0000 (17:30 +0000)] 
Add [BZ #19398] marker to ChangeLog entry.

7 years agoImprove strtok and strtok_r performance. Instead of calling strpbrk which
Wilco Dijkstra [Wed, 14 Dec 2016 15:12:18 +0000 (15:12 +0000)] 
Improve strtok and strtok_r performance.  Instead of calling strpbrk which
calls strcspn, call strcspn directly so we get the end of the token without
an extra call to rawmemchr.  Also avoid an unnecessary call to strcspn after
the last token by adding an early exit for an empty string.  Change strtok
to tailcall strtok_r to avoid unnecessary code duplication.

Remove the special header optimization for strtok_r of a 1-character
constant string - both strspn and strcspn contain optimizations for this
case.  Benchmarking this showed similar performance in the worst case,
but up to 5.5x better performance in the "found" case for large inputs.

* benchtests/bench-strtok.c (oldstrtok): Add old implementation.
* string/strtok.c (strtok): Change to tailcall __strtok_r.
* string/strtok_r.c (__strtok_r): Optimize for performance.
* string/string-inlines.c (__old_strtok_r_1c): New function.
* string/bits/string2.h (__strtok_r): Move to string-inlines.c.

7 years agoMake w_log1p type-generic
Gabriel F. T. Gomes [Wed, 7 Dec 2016 18:19:11 +0000 (16:19 -0200)] 
Make w_log1p type-generic

This patch converts the wrapper log1p (which set errno directly rather
than doing anything with __kernel_standard) to use the type-generic
template machinery, in the same way that has been done for ilogb.

Tested for powerpc64le, s390, and x86_64.

7 years agoImprove generic rawmemchr for targets that don't have an
Wilco Dijkstra [Wed, 14 Dec 2016 13:16:13 +0000 (13:16 +0000)] 
Improve generic rawmemchr for targets that don't have an
assembler version by tailcalling memchr with the maximum size.
If a target has an optimized memchr this is significantly faster,
if not, then this makes little difference.
Also optimize the special case of zero to use strlen as this is
typically faster than memchr.

* string/rawmemchr.c (RAWMEMCHR): Use faster memchr/strlen.

7 years agoUse Linux 4.9 (headers) in build-many-glibcs.py.
Joseph Myers [Wed, 14 Dec 2016 02:11:37 +0000 (02:11 +0000)] 
Use Linux 4.9 (headers) in build-many-glibcs.py.

This patch updates build-many-glibcs.py to use Linux 4.9 for kernel
headers unless another version is explicitly specified.  Note that
when a version changes like this you'll need to use --replace-sources
when updating an existing checkout to tell build-many-glibcs.py it's
OK to delete and replace the sources of a component for which the
version used has changed.

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

7 years agoBetter design of libm.a installation rule.
Andrew Senkevich [Tue, 13 Dec 2016 14:40:08 +0000 (17:40 +0300)] 
Better design of libm.a installation rule.

    * math/Makefile ($(inst_libdir)/libm-$(version).a): New target.
    * ($(inst_libdir)/libm.a): Fix rule to create the target only.

7 years agopowerpc: remove _dl_platform_string and _dl_powerpc_platforms
Andreas Schwab [Mon, 21 Nov 2016 16:40:01 +0000 (17:40 +0100)] 
powerpc: remove _dl_platform_string and _dl_powerpc_platforms

7 years agonptl/tst-cancel7: Add missing case label
Florian Weimer [Tue, 13 Dec 2016 08:26:20 +0000 (09:26 +0100)] 
nptl/tst-cancel7: Add missing case label

The label was lost during the conversion to the new test framework
in commit c23de0aacbeaa7a091609b35764bed931475a16d, and the --command
option is currently unused.

7 years agoExpose linking against libsupport as make dependency
Florian Weimer [Tue, 13 Dec 2016 06:58:26 +0000 (07:58 +0100)] 
Expose linking against libsupport as make dependency

This ensures that tests are rebuilt when libsupport changes.

7 years agopowerpc: strncmp optimization for power9
Rajalakshmi Srinivasaraghavan [Tue, 13 Dec 2016 05:23:42 +0000 (10:53 +0530)] 
powerpc: strncmp optimization for power9

Vectorized loops are used for strings > 32B when compared
to power8 optimization.

Tested on power9 ppc64le simulator.

7 years agoAdd getentropy, getrandom, <sys/random.h> [BZ #17252]
Florian Weimer [Mon, 12 Dec 2016 16:28:03 +0000 (17:28 +0100)] 
Add getentropy, getrandom, <sys/random.h> [BZ #17252]

7 years agodebug: Additional compiler barriers for backtrace tests [BZ #20956]
Florian Weimer [Sat, 10 Dec 2016 20:16:57 +0000 (21:16 +0100)] 
debug: Additional compiler barriers for backtrace tests [BZ #20956]

The new test framework changed the call stacks.  The weak attribute
acts as a strong compiler barrier.  Some static functions had to be
declared extern as a consequence.

7 years agoFix testsuite timeout handling
Andreas Schwab [Sat, 10 Dec 2016 15:10:53 +0000 (16:10 +0100)] 
Fix testsuite timeout handling

7 years agoinet: Make IN6_IS_ADDR_UNSPECIFIED etc. usable with POSIX [BZ #16421]
Florian Weimer [Fri, 9 Dec 2016 10:27:44 +0000 (11:27 +0100)] 
inet: Make IN6_IS_ADDR_UNSPECIFIED etc. usable with POSIX [BZ #16421]

Previously, under some feature test macros and compilers, the
macros were defined, but references undefined struct members
in their implementation.

7 years agosupport: Introduce new subdirectory for test infrastructure
Florian Weimer [Fri, 9 Dec 2016 07:18:27 +0000 (08:18 +0100)] 
support: Introduce new subdirectory for test infrastructure

The new test driver in <support/test-driver.c> has feature parity with
the old one.  The main difference is that its hooking mechanism is
based on functions and function pointers instead of macros.  This
commit also implements a new environment variable, TEST_COREDUMPS,
which disables the code which disables coredumps (that is, it enables
them if the invocation environment has not disabled them).

<test-skeleton.c> defines wrapper functions so that it is possible to
use existing macros with the new-style hook functionality.

This commit changes only a few test cases to the new test driver, to
make sure that it works as expected.

7 years agoMake _REENTRANT and _THREAD_SAFE aliases for _POSIX_C_SOURCE=199506L.
Zack Weinberg [Tue, 6 Dec 2016 15:14:42 +0000 (10:14 -0500)] 
Make _REENTRANT and _THREAD_SAFE aliases for _POSIX_C_SOURCE=199506L.

For many years, the only effect of these macros has been to make
unistd.h declare getlogin_r.  _POSIX_C_SOURCE >= 199506L also causes
this function to be declared.  However, people who don't carefully
read all the headers might be confused into thinking they need to
define _REENTRANT for any threaded code (as was indeed the case a long
time ago).

Therefore, remove __USE_REENTRANT, and make _REENTRANT and _THREAD_SAFE
into synonyms for _POSIX_C_SOURCE=199506L.  This will only affect
programs that don't select a higher conformance level some other way.
For instance, -std=c89 -D_REENTRANT will see a change in visible
declarations, but -std=c99 -D_POSIX_C_SOURCE=200809L -D_REENTRANT won't,
and -D_REENTRANT all by itself also won't, because _DEFAULT_SOURCE
implies _POSIX_C_SOURCE > 199506.

* include/features.h: Remove __USE_REENTRANT.  Treat _REENTRANT
and _THREAD_SAFE the same as _POSIX_C_SOURCE=199506L, if a higher
POSIX conformance level has not been selected by other macros.
* NEWS, manual/creature.texi: Document this change.

* posix/unistd.h, posix/bits/unistd.h: Don't check __USE_REENTRANT.
* include/libc-symbols.h: Don't define _REENTRANT.
* scripts/check-installed-headers.sh: Don't undefine _REENTRANT.

7 years agoFix tests-printers handling for cross compiling.
Joseph Myers [Thu, 8 Dec 2016 18:54:13 +0000 (18:54 +0000)] 
Fix tests-printers handling for cross compiling.

The pretty-printers changes resulted in the new tests showing as
UNRESOLVED (missing .out files) when run-built-tests = no, so
resulting in "make check" exiting with error status.

https://sourceware.org/ml/libc-testresults/2016-q4/msg00014.html

This patch moves the use of $(tests-printers) when generating the
summary of results into the setting of tests-expected, which is
appropriately conditional, matching the conditional for when tests
depends on $(tests-printers-out).

Tested with cross to aarch64 with build-many-glibcs.py, and natively
on x86_64.

* Rules [$(run-built-tests) != no] (tests-expected): Add
$(tests-printers).
(tests): Do not pass $(tests-printers) to merge-test-results.sh.

7 years agoInstall libm.a as linker script (bug 20539).
Andrew Senkevich [Thu, 8 Dec 2016 14:25:59 +0000 (17:25 +0300)] 
Install libm.a as linker script (bug 20539).

Install libm.a as linker script to avoid static link fail w/o passing
additional -lmvec option while building with GCC >= 6.1.

    [BZ #20539]
    * math/Makefile (install-lib-ldscripts): Add libm.a.
    (install_subdir): Remove.
    (install-others): Add.
    ($(inst_libdir)/libm.a): Add rule for installation as
    linker script.
    * Makerules (install-lib.a): Filter out install-lib-ldscripts.

7 years agoAdd pretty printers for the NPTL lock types
Martin Galvan [Thu, 8 Dec 2016 13:29:02 +0000 (18:59 +0530)] 
Add pretty printers for the NPTL lock types

This patch adds pretty printers for the following NPTL types:

- pthread_mutex_t
- pthread_mutexattr_t
- pthread_cond_t
- pthread_condattr_t
- pthread_rwlock_t
- pthread_rwlockattr_t

To load the pretty printers into your gdb session, do the following:

python
import sys
sys.path.insert(0, '/path/to/glibc/build/nptl/pretty-printers')
end

source /path/to/glibc/source/pretty-printers/nptl-printers.py

You can check which printers are registered and enabled by issuing the
'info pretty-printer' gdb command. Printers should trigger automatically when
trying to print a variable of one of the types mentioned above.

The printers are architecture-independent, and were tested on an AMD64 running
Ubuntu 14.04 and an x86 VM running Fedora 24.

In order to work, the printers need to know the values of various flags that
are scattered throughout pthread.h and pthreadP.h as enums and #defines. Since
replicating these constants in the printers file itself would create a
maintenance burden, I wrote a script called gen-py-const.awk that Makerules uses
to extract the constants. This script is pretty much the same as gen-as-const.awk,
except it doesn't cast the constant values to 'long' and is thorougly documented.
The constants need only to be enumerated in a .pysym file, which is then referenced
by a Make variable called gen-py-const-headers.

As for the install directory, I discussed this with Mike Frysinger and Siddhesh
Poyarekar, and we agreed that it can be handled in a separate patch, and shouldn't
block merging of this one.

In addition, I've written a series of test cases for the pretty printers.
Each lock type (mutex, condvar and rwlock) has two test programs, one for itself
and other for its related 'attributes' object. Each test program in turn has a
PExpect-based Python script that drives gdb and compares its output to the
expected printer's. The tests run on the glibc host, which is assumed to have
both gdb and PExpect; if either is absent the tests will fail with code 77
(UNSUPPORTED). For cross-testing you should use cross-test-ssh.sh as test-wrapper.
I've tested the printers on both native builds and a cross build using a Beaglebone
Black running Debian, with the build system's filesystem shared with the board
through NFS.

Finally, I've written a README that explains all this and more.

* INSTALL: Regenerated.
* Makeconfig: Add comments and whitespace to make the control flow
clearer.
(+link-printers-tests, +link-pie-printers-tests, CFLAGS-printers-tests,
installed-rtld-LDFLAGS, built-rtld-LDFLAGS, link-libc-rpath,
link-libc-tests-after-rpath-link, link-libc-printers-tests): New.
(rtld-LDFLAGS, rtld-tests-LDFLAGS, link-libc-tests-rpath-link,
link-libc-tests): Use the new variables as required.
* Makerules ($(py-const)): New rule.
generated: Add $(py-const).
* README.pretty-printers: New file.
* Rules (tests-printers-programs, tests-printers-out, py-env): New.
(others): Depend on $(py-const).
(tests): Depend on $(tests-printers-programs) or $(tests-printers-out),
as required.  Pass $(tests-printers) to merge-test-results.sh.
* manual/install.texi: Add requirements for testing the pretty printers.
* nptl/Makefile (gen-py-const-headers, pretty-printers, tests-printers,
CFLAGS-test-mutexattr-printers.c CFLAGS-test-mutex-printers.c,
CFLAGS-test-condattr-printers.c, CFLAGS-test-cond-printers.c,
CFLAGS-test-rwlockattr-printers.c CFLAGS-test-rwlock-printers.c,
tests-printers-libs): Define.
* nptl/nptl-printers.py: New file.
* nptl/nptl_lock_constants.pysym: Likewise.
* nptl/test-cond-printers.c: Likewise.
* nptl/test-cond-printers.py: Likewise.
* nptl/test-condattr-printers.c: Likewise.
* nptl/test-condattr-printers.py: Likewise.
* nptl/test-mutex-printers.c: Likewise.
* nptl/test-mutex-printers.py: Likewise.
* nptl/test-mutexattr-printers.c: Likewise.
* nptl/test-mutexattr-printers.py: Likewise.
* nptl/test-rwlock-printers.c: Likewise.
* nptl/test-rwlock-printers.py: Likewise.
* nptl/test-rwlockattr-printers.c: Likewise.
* nptl/test-rwlockattr-printers.py: Likewise.
* scripts/gen-py-const.awk: Likewise.
* scripts/test_printers_common.py: Likewise.
* scripts/test_printers_exceptions.py: Likewise.

7 years agoAdd build-many-glibcs.py option to strip installed shared libraries.
Joseph Myers [Wed, 7 Dec 2016 21:29:24 +0000 (21:29 +0000)] 
Add build-many-glibcs.py option to strip installed shared libraries.

This patch adds a --strip option to build-many-glibcs.py, to make it
strip the installed shared libraries after installation.  This is for
convenience if you want to compare installed stripped shared libraries
before and after a patch that was not meant to result in any code
changes: you can run with this option, copy the install/glibcs
directory, run again with the patch and compare the */lib*
subdirectory contents.

(It might make sense for the option to strip libraries in other
directories, including stripping debug information from static
libraries, with a view to making it possible for a
no-generated-code-changes patch to result in completely identical
install/glibcs directories, so simplifying comparison, though that may
need other build determinism changes, e.g. to build deterministic .a
files.)

* scripts/build-many-glibcs.py (Context.__init__): Take strip
argument.
(Glibc.build_glibc): Strip installed shared libraries if
requested.
(get_parser): Add --strip option.
(main): Update Context call.

7 years agoFix writes past the allocated array bounds in execvpe (BZ#20847)
Adhemerval Zanella [Tue, 22 Nov 2016 18:23:28 +0000 (16:23 -0200)] 
Fix writes past the allocated array bounds in execvpe (BZ#20847)

Commit 6c9e1be87a37bf wrongly fixes BZ#20847 by lefting the else branch
on maybe_script_execute to still being able to invalid write on stack
allocated buffer.  It happens if execvp{e} is executed with an empty
arguments list ({ NULL }) and although manual states first argument
should be the script name itself, by convention, old and current
implementation allows it.

This patch fixes the issue by just account for arguments and not the
final 'NULL' (since the 'argv + 1' will indeed ignored the script name).
The empty argument list is handled in a special case with a minimum
allocated size.  The patch also adds extra tests for such case in
tst-vfork3.

Tested on x86_64.

[BZ #20847]
* posix/execvpe.c (maybe_script_execute): Remove write past allocated
array bounds for else branch.
(__execvpe): Style fixes.
* posix/tst-vfork3.c (run_script): New function.
(create_script): Likewise.
(do_test): Use run_script internal function.
(do_prepare): Use create_script internal function.

7 years agoGet rid of __elision_available
Andreas Schwab [Mon, 5 Dec 2016 11:06:46 +0000 (12:06 +0100)] 
Get rid of __elision_available

7 years agoFix typo in last ChangeLog message.
Joseph Myers [Wed, 7 Dec 2016 01:17:58 +0000 (01:17 +0000)] 
Fix typo in last ChangeLog message.

7 years agoFix hypot sNaN handling (bug 20940).
Joseph Myers [Wed, 7 Dec 2016 01:16:36 +0000 (01:16 +0000)] 
Fix hypot sNaN handling (bug 20940).

TS 18661-1 generally defines libm functions taking sNaN arguments to
return qNaN and raise "invalid", even for the cases where a
corresponding qNaN argument would not result in a qNaN return.  This
includes hypot with one argument being an infinity and the other being
an sNaN.  This patch duly fixes hypot implementatations in glibc
(generic and powerpc) to ensure qNaN, computed by arithmetic on the
arguments, is returned in that case.

Various implementations do their checks for infinities and NaNs inline
by manipulating the representations of the arguments.  For simplicity,
this patch just uses issignaling to check for sNaN arguments.  This
could be inlined like the existing code (with due care about reversed
quiet NaN conventions, for implementations where that is relevant),
but given that all these checks are in cases where it's already known
at least one argument is not finite, which should be the uncommon
case, that doesn't seem worthwhile unless performance issues are
observed in practice.

Tested for x86_64, x86, mips64 and powerpc.

[BZ #20940]
* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Do not
return Inf for arguments Inf and sNaN.
* sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Likewise.
* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl):
Likewise.
* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise.
* sysdeps/powerpc/fpu/e_hypot.c (TEST_INF_NAN): Do not return Inf
for arguments Inf and sNaN.  When returning a NaN, compute it by
arithmetic on the arguments.
* sysdeps/powerpc/fpu/e_hypotf.c (TEST_INF_NAN): Likewise.
* math/libm-test.inc (pow_test_data): Add tests of sNaN arguments.

7 years agoFix x86_64/x86 powl handling of sNaN arguments (bug 20916).
Joseph Myers [Tue, 6 Dec 2016 00:33:19 +0000 (00:33 +0000)] 
Fix x86_64/x86 powl handling of sNaN arguments (bug 20916).

The x86_64/x86 powl implementations mishandle sNaN arguments, both by
returning sNaN in some cases (instead of doing arithmetic on the
arguments to produce the result when NaN arguments result in NaN
results) and by treating sNaN the same as qNaN for arguments (1, sNaN)
and (sNaN, 0), contrary to TS 18661-1 which requires those cases to
return qNaN instead of 1.

This patch makes the x86_64/x86 powl implementations follow TS 18661-1
semantics for sNaN arguments; sNaN tests are also added for pow.
Given the problems with testing float and double sNaN arguments on
32-bit x86 (sNaN tests disabled because the compiler may convert
unnecessarily to a qNaN when passing arguments), no changes are made
to the powf and pow implementations there.

Tested for x86_64 and x86.

[BZ #20916]
* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Do not return 1 for
arguments (sNaN, 0) or (1, sNaN).  Do arithmetic on NaN arguments
to compute result.
* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Likewise.
* math/libm-test.inc (pow_test_data): Add tests of sNaN arguments.

7 years agoUse C11-like atomics instead of plain memory accesses in x86 lock elision.
Torvald Riegel [Wed, 30 Nov 2016 16:53:11 +0000 (17:53 +0100)] 
Use C11-like atomics instead of plain memory accesses in x86 lock elision.

This uses atomic operations to access lock elision metadata that is accessed
concurrently (ie, adapt_count fields).  The size of the data is less than a
word but accessed only with atomic loads and stores; therefore, we add
support for shorter-size atomic load and stores too.

* include/atomic.h (__atomic_check_size_ls): New.
(atomic_load_relaxed, atomic_load_acquire, atomic_store_relaxed,
atomic_store_release): Use it.
* sysdeps/x86/elide.h (ACCESS_ONCE): Remove.
(elision_adapt, ELIDE_LOCK): Use atomics.
* sysdeps/unix/sysv/linux/x86/elision-lock.c (__lll_lock_elision): Use
atomics and improve code comments.
* sysdeps/unix/sysv/linux/x86/elision-trylock.c
(__lll_trylock_elision): Likewise.

7 years agohurd: fix using hurd.h in C++ programs
Samuel Thibault [Sun, 4 Dec 2016 22:18:32 +0000 (23:18 +0100)] 
hurd: fix using hurd.h in C++ programs

* hurd/hurd.h: Cast errno constants to error_t to fix usage in C++
programs.

7 years agoFix sysdeps/ieee754 pow handling of sNaN arguments (bug 20916).
Joseph Myers [Fri, 2 Dec 2016 23:21:15 +0000 (23:21 +0000)] 
Fix sysdeps/ieee754 pow handling of sNaN arguments (bug 20916).

Various pow function implementations mishandle sNaN arguments in
various ways.  This includes returning sNaN instead of qNaN for sNaN
arguments.  For arguments (1, sNaN) and (sNaN, 0), TS 18661-1
semantics are also that the result should be qNaN, whereas with a qNaN
argument there the result should be 1, but for the dbl-64
implementation of pow there are issues with sNaN arguments beyond not
implementing the TS 18661-1 semantics in those special cases.

This patch makes the implementations in sysdeps/ieee754 follow the TS
18661-1 semantics consistently.  Because x86 / x86_64 implementations
still need fixing, testcases are not included with this patch; they
will be included with the fix for the x86 / x86_64 versions.

Tested for x86_64, x86, mips64 and powerpc (with such testcases, which
pass in the mips64 and powerpc cases).

[BZ #20916]
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Do not return 1
for arguments (sNaN, 0) or (1, sNaN).  Do arithmetic on NaN
arguments to compute result.
* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Do not return
1 for arguments (sNaN, 0) or (1, sNaN).
* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise.

7 years agoFix pow (qNaN, 0) result with -lieee (bug 20919), remove dead parts of wrappers.
Joseph Myers [Fri, 2 Dec 2016 22:50:46 +0000 (22:50 +0000)] 
Fix pow (qNaN, 0) result with -lieee (bug 20919), remove dead parts of wrappers.

The dbl-64 implementation of __ieee754_pow returns a NaN for pow
(qNaN, 0) when it should return 1.  Normally this is covered up by the
wrappers ending up calling __kernel_standard which fixes up the result
for this case, but for -lieee the wrappers are bypassed and the bad
result gets through as a return value.

Now, the wrappers fixing this are dealing with variant error handling
that wants a result of NaN for pow (qNaN, 0), and only ever call
__kernel_standard for this case if NaN resulted from __ieee754_pow.
This leads to a question of whether the dbl-64 code might be
deliberately returning NaN in order to use those code paths.  However,
I can find no sign that this is deliberate.  If it were deliberate one
would expect other implementations to do the same, and would expect
the return of NaN to be very old, but it appears it came in by
accident when the present e_pow.c implementation replaced an fdlibm
implementation in 2001.  So it appears to be unintended that this path
through the pow wrapper could be used at all.

So this patch fixes the implementation to return 1 in this case as
expected.  This is consistent with all the other implementations.  The
relevant path through the wrappers is now unreachable, so is removed
(which is the main motivation of this patch: to avoid that path
becoming accidentally reachable when implementing TS 18661-1 semantics
that pow (sNaN, 0) should return qNaN with "invalid" raised).  Another
path that would require __ieee754_pow (0, 0) to return 0 is also
unreachable (as all implementations return 1, in accordance with C99
semantics), so is removed as well.

Note: we don't have anything set up to test -lieee, which in any case
is obsolescent (at some point we should remove the ability for new
programs to access _LIB_VERSION or define matherr and have it called
by glibc).  So testing will be implicit through sNaN tests added when
making sNaN inputs work correctly for pow functions.

Tested for x86_64 and x86.

[BZ #20919]
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Do not return
NaN first argument when raised to power 0.
* math/w_pow.c (__pow): Do not check for NaN or zero results from
raising to power zero.
* math/w_powf.c (__powf): Likewise.
* math/w_powl.c (__powl): Likewise.
* sysdeps/ieee754/k_standard.c (__kernel_standard): Do not handle
pow (0, 0) or pow (NaN, 0).

7 years agoBug 20918 - Building with --enable-nss-crypt fails tst-linkall-static
Carlos O'Donell [Fri, 2 Dec 2016 20:39:09 +0000 (15:39 -0500)] 
Bug 20918 - Building with --enable-nss-crypt fails tst-linkall-static

Some configurations may use NSS cryptographic routines but have no
static library for those routines. The following changes allow glibc to
be built and tested with --enable-nss-crypt, but without having a static
NSS library. At a high level the change does two things:

(1) Detect at configure time if static NSS crypto libraries are
    available.  Assumes libfreebl3.a (instead of the existing Fedora
    libfreebl.a which is incomplete) which matches libfreebl3.so.

(2) If static NSS crypto libraries are _not_ available then adjust the
    way in which we build tst-linkall-static. This includes excluding a
    reference to crypt and not linking against libcrypt.a, all of which
    will fail otherwise.

Testing assumptions:
* Static library is named libfreebl3.a (not libfreebl.a as is currently
  provided in Fedora), matching libfreebl3.so shared link name.

Tested on x86_64 on Fedora with:

(a) --enable-nss-crypt, with no static NSS library support: PASS
    (previous FAIL)

(b) --enable-nss-crypt, with faked static NSS library support: PASS
    (unsupported)
* Requires changing elf/Makefile to include a stub
  /lib64/libfreebl3.a for testing purposes.

(c) --disable-nss-crypt: PASS
    (default)

No regressions on x86_64.

For details see:
https://www.sourceware.org/ml/libc-alpha/2016-11/msg00647.html

7 years agoelf/tst-tls-manydynamic: New test
Florian Weimer [Fri, 2 Dec 2016 16:09:19 +0000 (17:09 +0100)] 
elf/tst-tls-manydynamic: New test

This test adds coverage for creating many dynamic TLS variables
which exhaust the static TLS allocation.

7 years agoaarch64: Use explicit offsets in _dl_tlsdesc_dynamic
Florian Weimer [Fri, 2 Dec 2016 15:52:57 +0000 (16:52 +0100)] 
aarch64: Use explicit offsets in _dl_tlsdesc_dynamic

Commit 389d1f1b232b3d6b9d73ee2c50e543ace6675621 (“Partial ILP32
support for aarch64”) broke dynamic TLS support because a load
offset changed:

 0000000000000030 <_dl_tlsdesc_dynamic>:
   30:  a9bc7bfd        stp     x29, x30, [sp,#-64]!
   34:  910003fd        mov     x29, sp
   38:  a9020be1        stp     x1, x2, [sp,#32]
   3c:  a90313e3        stp     x3, x4, [sp,#48]
   40:  d53bd044        mrs     x4, tpidr_el0
   44:  c8dffc1f        ldar    xzr, [x0]
   48:  f9400401        ldr     x1, [x0,#8]
   4c:  f9400080        ldr     x0, [x4]
   50:  f9400823        ldr     x3, [x1,#16]
   54:  f9400002        ldr     x2, [x0]
   58:  eb02007f        cmp     x3, x2
   5c:  540001a8        b.hi    90 <_dl_tlsdesc_dynamic+0x60>
   60:  f9400022        ldr     x2, [x1]
   64:  8b021000        add     x0, x0, x2, lsl #4
   68:  f9400000        ldr     x0, [x0]
   6c:  b100041f        cmn     x0, #0x1
   70:  54000100        b.eq    90 <_dl_tlsdesc_dynamic+0x60>
-  74:  f9400421        ldr     x1, [x1,#8]
+  74:  f9400821        ldr     x1, [x1,#16]
   78:  8b010000        add     x0, x0, x1


This commit introduces explicit struct offsets, generated
from the C headers, fixing the regression.

7 years agoS390: Regenerate ULPs.
Stefan Liebler [Fri, 2 Dec 2016 11:52:36 +0000 (12:52 +0100)] 
S390: Regenerate ULPs.

Updated ulps file.

ChangeLog:

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

7 years agoFix new testcase elf/tst-latepthread on s390x.
Stefan Liebler [Fri, 2 Dec 2016 08:09:55 +0000 (09:09 +0100)] 
Fix new testcase elf/tst-latepthread on s390x.

The first dlopen ("tst-latepthreadmod.so", RTLD_LOCAL | RTLD_LAZY) call
in elf/tst-latepthread.c fails on s390x with "error: dlopen failed:
.../build-s390x/elf/tst-latepthreadmod.so:
undefined symbol: this_function_is_not_defined".

In elf/tst-latepthreadmod.c, this_function_is_not_defined is a sibling
call which leads to a R_390_GLOB_DAT relocation in .rela.dyn instead of
a R_390_JMP_SLOT in .rela.plt.

As RTLD_LAZY skips the JMP_SLOT relocations, but not GLOB_DAT ones,
the dlopen call fails. If elf/tst-latepthreadmod.c is build with
-fno-optimize-sibling-calls, a JMP_SLOT relocation is generated for
this_function_is_not_defined and the test passes.

ChangeLog:

* elf/Makefile (CFLAGS-tst-latepthreadmod.c):
Add -fno-optimize-sibling-calls.

7 years agoAdd llogb, llogbf, llogbl.
Joseph Myers [Fri, 2 Dec 2016 01:42:49 +0000 (01:42 +0000)] 
Add llogb, llogbf, llogbl.

TS 18661-1 defines llogb functions that are like ilogb except that
they return long int instead of int.  Corresponding FP_LLOGB* macros
are defined, whose values are required to have the obvious
correspondence to those of the FP_ILOGB* macros.

This patch implements these functions and macros for glibc.  llogb
uses the type-generic infrastructure, with an implementation similar
to the wrapper for ilogb but with additional conversion from FP_ILOGB*
to FP_LLOGB*; this approach avoids needing to modify or duplicate any
of the architecture-specific ilogb implementations.  Tests are also
based on those for ilogb.

Ideally the llogb functions would alias the ilogb ones when long is
32-bit, but such aliasing requires the associated header declarations
of the different-type alias to be hidden, typically by defining macros
before including the header (see e.g. how
sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c defines lround to
__hidden_lround before including <math.h>).  The infrastructure for
type-generic function implementations does not support defining such
macros at present (since C code can't define a macro whose name is
determined by other macros).  So this patch leaves them as separate
functions (similar to e.g. scalbln and scalbn being separate in such a
case as well), but with the remapping of FP_ILOGB* to FP_LLOGB*
conditioned out in the case where it would be the identity map.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (llogb):
New declaration.
* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (llogb): New
macro.
* math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (__FP_LONG_MAX):
New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_LLOGB0): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_LLOGBNAN): Likewise.
* math/Versions (llogb): New libm symbol at version GLIBC_2.25.
(llogbf): Likewise.
(llogbl): Likewise.
* math/Makefile (gen-libm-calls): Add w_llogbF.
(tests): Add test-fp-llogb-constants.
* math/w_llogb_template.c: New file.  Based on
math/w_ilogb_template.c.
* math/libm-test.inc (llogb_test_data): New array.
(llogb_test): New function.
(main): Call llogb_test.
* math/test-fp-llogb-constants.c: New file.  Based on
math/test-fp-ilogb-constants.c.
* math/test-tgmath-ret.c (llogb): New CHECK_RET_CONST call.
(do_test): Call check_return_llogb.
* math/test-tgmath.c (NCALLS): Increase to 126.
(F(compile_test)): Call llogb.
(F(llogb)): New function.
* manual/math.texi (Exponents and Logarithms): Document llogb,
llogbf, llogbl, FP_LLOGB0 and FP_LLOGBNAN.
* manual/libm-err-tab.pl (@all_functions): Add llogb.
* sysdeps/ieee754/ldbl-opt/nldbl-llogb.c: New file.
* sysdeps/ieee754/ldbl-opt/w_llogbl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add llogb.
(CFLAGS-nldbl-llogb.c): New variable.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoMake ldbl-128 getpayload, setpayload functions use _Float128.
Joseph Myers [Thu, 1 Dec 2016 23:23:51 +0000 (23:23 +0000)] 
Make ldbl-128 getpayload, setpayload functions use _Float128.

When I added the getpayload and setpayload functions I failed to make
the ldbl-128 functions use the _Float128 type name like most other
ldbl-128 functions do in preparation for being used to implement *f128
functions.  This patch fixes them to use that name.

Tested for mips64.

* sysdeps/ieee754/ldbl-128/s_getpayloadl.c (getpayloadl): Use
_Float128 instead of long double.
* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c (FUNC): Likewise.

7 years agoAdd missing hidden_def (__sigsetjmp).
Joseph Myers [Thu, 1 Dec 2016 20:49:25 +0000 (20:49 +0000)] 
Add missing hidden_def (__sigsetjmp).

This patch adds the missing hidden_def (__sigsetjmp) on various
architectures that were failing to build (as noted in
<https://sourceware.org/ml/libc-alpha/2016-11/msg01124.html>).

Tested (compilation only) with build-many-glibcs.py.

* sysdeps/alpha/setjmp.S (__sigsetjmp): Use hidden_def.
* sysdeps/hppa/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/mips/mips64/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/mips/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/sh/sh3/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/sh/sh4/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/sparc/sparc32/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/tile/setjmp.S (__sigsetjmp): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/setjmp.S (__sigsetjmp):
Likewise.

7 years agopowerpc: Remove stpcpy internal clash with IFUNC
Adhemerval Zanella [Thu, 1 Dec 2016 17:53:16 +0000 (15:53 -0200)] 
powerpc: Remove stpcpy internal clash with IFUNC

Commit c7debbdfacb redirected the internal strrch to default powerpc64
implementation by redefining the weak_alias at
sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.c:

  #undef weak_alias
  #define weak_alias(name, aliasname) \
    extern __typeof (__strrchr_ppc) aliasname \
      __attribute__ ((weak, alias ("__strrchr_ppc")));

This creates a __GI_strchr alias that clashes with the IFUNC symbol in
stprchr.os.  There is not need to define the default version for internal
version, since ifunc should work internally for powerpc64.  This patch
removes the weak_alias indirection.

Checked on powerpc64le.

* sysdeps/powerpc/powerpc64/multiarch/strrchr-ppc64.c (weak_alias):
Remove redirection to __strrchr_ppc.

7 years agopowerpc: strcmp optimization for power9
Rajalakshmi Srinivasaraghavan [Thu, 1 Dec 2016 06:05:43 +0000 (11:35 +0530)] 
powerpc: strcmp optimization for power9

Vectorized loops are used for strings > 32B when compared
to power8 optimization.

Tested on power9 ppc64le simulator.

7 years agoRefactor FP_ILOGB* out of bits/mathdef.h.
Joseph Myers [Thu, 1 Dec 2016 02:56:55 +0000 (02:56 +0000)] 
Refactor FP_ILOGB* out of bits/mathdef.h.

Continuing the refactoring of bits/mathdef.h, this patch stops it
defining FP_ILOGB0 and FP_ILOGBNAN, moving the required information to
a new header bits/fp-logb.h.

There are only two possible values of each of those macros permitted
by ISO C.  TS 18661-1 adds corresponding macros for llogb, and their
values are required to correspond to those of the ilogb macros in the
obvious way.  Thus two boolean values - for which the same choices are
correct for most architectures - suffice to determine the value of all
these macros, and by defining macros for those boolean values in
bits/fp-logb.h we can then define the public FP_* macros in math.h and
avoid the present duplication of the associated feature test macro
logic.

This patch duly moves to bits/fp-logb.h defining __FP_LOGB0_IS_MIN and
__FP_LOGBNAN_IS_MIN.  Default definitions of those to 0 are correct
for both architectures, while ia64, m68k and x86 get their own
versions of bits/fp-logb.h to reflect their use of values different
from the defaults.

The patch renders many copies of bits/mathdef.h trivial (needed only
to avoid the default __NO_LONG_DOUBLE_MATH).  I'll revise
<https://sourceware.org/ml/libc-alpha/2016-11/msg00865.html>
accordingly so that it removes all bits/mathdef.h headers except the
default one and the alpha one, and arranges for the header to be
included only by complex.h as the only remaining use at that point
will be for the alpha ABI issues there.

Tested for x86_64 and x86.  Also did compile-only testing with
build-many-glibcs.py (using glibc sources from before the commit that
introduced many build failures with undefined __GI___sigsetjmp).

* bits/fp-logb.h: New file.
* sysdeps/ia64/bits/fp-logb.h: Likewise.
* sysdeps/m68k/m680x0/bits/fp-logb.h: Likewise.
* sysdeps/x86/bits/fp-logb.h: Likewise.
* math/Makefile (headers): Add bits/fp-logb.h.
* math/math.h: Include <bits/fp-logb.h>.
[__USE_ISOC99] (FP_ILOGB0): Define based on __FP_LOGB0_IS_MIN.
[__USE_ISOC99] (FP_ILOGBNAN): Define based on __FP_LOGBNAN_IS_MIN.
* bits/mathdef.h (FP_ILOGB0): Remove.
(FP_ILOGBNAN): Likewise.
* sysdeps/aarch64/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/alpha/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/ia64/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/m68k/m680x0/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/mips/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/powerpc/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/s390/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/sparc/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.
* sysdeps/x86/bits/mathdef.h (FP_ILOGB0): Likewise.
(FP_ILOGBNAN): Likewise.

7 years agoMake build-many-glibcs.py support running as a bot.
Joseph Myers [Thu, 1 Dec 2016 00:09:25 +0000 (00:09 +0000)] 
Make build-many-glibcs.py support running as a bot.

This patch makes build-many-glibcs.py support a "bot" action, for
repeatedly running a checkout and build cycle.

Two new configuration variables are used in bot-config.json.  "delay"
indicates the time to sleep after each bot-cycle round (regardless of
whether that round actually ran any builds); "run" is a boolean, which
is false if the bot should just exit (the point of this is that you
can edit bot-config.json to set this to false to cause a running bot
to exit cleanly between builds) and true if the bot should run.  The
bot does not exit if the bot-cycle process exits with error status
(that can occur when sourceware's load limiting means anonymous
version control access fails, for example), just sleeps until it's
time to try again.

The script is changed to flush stdout before running a subprocess in
bot-cycle, so that when output is redirected (as expected for a bot)
the status messages from bot-cycle appear in their proper position in
its redirected output relative to the output from the subprocesses
run, and to copy the logs directory before running builds in bot-cycle
so that the logs from at least one complete build are always available
for looking at how something failed, even while the next build is
running.

* scripts/build-many-glibcs.py: Add bot to usage message.  Import
time module.
(Context.__init__): Initialize self.logsdir_old.
(Context.run_builds): Handle bot action.
(Context.bot_cycle): Copy logs directory before running builds.
(Context.bot_run_self): Take argument for whether to check
subprocess result.  Flush stdout before running subprocess.
(Context.bot): New function.
(get_parser): Allow bot action.

7 years agoAdd build-many-glibcs.py bot-cycle action.
Joseph Myers [Wed, 30 Nov 2016 18:56:37 +0000 (18:56 +0000)] 
Add build-many-glibcs.py bot-cycle action.

This patch continues the process of setting up build-many-glibcs.py to
run as a bot monitoring for and reporting on build issues by adding a
bot-cycle action to the script.  When this action is used, it will run
the checkout action (re-execing itself if it was changed by that
action), then rebuild whichever of host-libraries, compilers, glibcs
should be rebuilt based on changed versions, time elapsed and state of
previous builds.  Email is sent with the results of the build (for
each build action done).

The rebuild logic is: if previous build time or versions aren't
recorded, rebuild that component.  If the script has changed, rebuild
everything.  If any relevant component version has changed, rebuild,
except for not rebuilding compilers if the time indicated in the bot
configuration has not passed since the last build of the compilers.
If one piece is rebuilt then rebuild subsequent pieces as well.

Using bot-cycle requires a configuration file bot-config.json in the
toplevel directory used by build-many-glibcs.py.  It might contain
e.g.

{
  "compilers-rebuild-delay": 604800,
  "email-from": "Example Name <user@example.org>",
  "email-server": "localhost",
  "email-subject": "GCC 6 %(action)s %(build-time)s build results",
  "email-to": "libc-testresults@sourceware.org"
}

My next intended step is adding a further action "bot" which loops
running bot-cycle then sleeping for an amount of time given in
bot-config.json.  Then I'll set up a bot using that action (building
with GCC 6 branch; a bot using GCC mainline may wait until the SH
out-of-memory issues
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78460> are fixed; I
expect the bot to mail to me until it seems ready to switch to mailing
to gcc-testresults).

* scripts/build-many-glibcs.py: Add bot-cycle to usage message.
Import email.mime.text, email.utils and smtplib modules.
(Context.__init__): Initialize self.bot_config_json.
(Context.run_builds): Handle bot-cycle action.
(Context.load_bot_config_json): New function.
(Context.part_build_old): Likewise.
(Context.bot_cycle): Likewise.
(Context.bot_build_mail): Likewise.
(Context.bot_run_self): Likewise.
(get_parser): Allow bot-cycle action.

7 years agopowerpc: Remove stpcpy internal clash with IFUNC
Adhemerval Zanella [Wed, 30 Nov 2016 13:31:41 +0000 (11:31 -0200)] 
powerpc: Remove stpcpy internal clash with IFUNC

Commit 142e0a99530 redirected the internal stpcpy to default powerpc64
implementation by redefining the weak_alias at
sysdeps/powerpc/powerpc64/multiarch/stpcpy-ppc64.c:

  #undef weak_alias
  #define weak_alias(name, aliasname) \
    extern __typeof (__stpcpy_ppc) aliasname \
      __attribute__ ((weak, alias ("__stpcpy_ppc")));

This creates a __GI_stpcpy alias that clashes with the IFUNC symbol in
stpcpy.os.  There is not need to define the default version for internal
version, since ifunc should work internally for powerpc64.  This patch
removes the weak_alias indirection.

Checked on powerpc64le.

* sysdeps/powerpc/powerpc64/multiarch/stpcpy-ppc64.c (weak_alias):
Remove redirection to __stpcpy_ppc.

7 years agold.so: Remove __libc_memalign
Florian Weimer [Wed, 30 Nov 2016 15:23:58 +0000 (16:23 +0100)] 
ld.so: Remove __libc_memalign

It is no longer needed since commit 6c444ad6e953dbdf9c7be065308a0a777
(elf: Do not use memalign for TCB/TLS blocks allocation [BZ #17730]).
Applications do not link against ld.so and will use the definition in
libc.so, so there is no ABI impact.

7 years agoImplement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]
Florian Weimer [Wed, 30 Nov 2016 14:59:57 +0000 (15:59 +0100)] 
Implement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]

This change moves the main implementation of _dl_catch_error,
_dl_signal_error to libc.so, where TLS variables can be used
directly.  This removes a writable function pointer from the
rtld_global variable.

For use during initial relocation, minimal implementations of these
functions are provided in ld.so.  These are eventually interposed
by the libc.so implementations.  This is implemented by compiling
elf/dl-error-skeleton.c twice, via elf/dl-error.c and
elf/dl-error-minimal.c.

As a side effect of this change, the static version of dl-error.c
no longer includes support for the
_dl_signal_cerror/_dl_receive_error mechanism because it is only
used in ld.so.

7 years agolibio: Limit buffer size to 8192 bytes [BZ #4099]
Florian Weimer [Wed, 30 Nov 2016 13:59:27 +0000 (14:59 +0100)] 
libio: Limit buffer size to 8192 bytes [BZ #4099]

This avoids overly large buffers with network file systems which report
very large block sizes.

7 years agoRemove out of date PROJECTS file.
Carlos O'Donell [Wed, 30 Nov 2016 13:07:24 +0000 (08:07 -0500)] 
Remove out of date PROJECTS file.

Developers should use:
https://sourceware.org/glibc/wiki/Development_Todo/Master

7 years agogconv: Adjust GBK to support the Euro sign
Florian Weimer [Tue, 29 Nov 2016 17:35:12 +0000 (18:35 +0100)] 
gconv: Adjust GBK to support the Euro sign

Commit aa4d00ca39e604ac4e9fead401ccd4483e11a281 only updated the
data used by locales.

7 years agoUse XSTAT_IS_XSTAT64 in generic xstat functions
Steve Ellcey [Tue, 29 Nov 2016 16:06:47 +0000 (08:06 -0800)] 
Use XSTAT_IS_XSTAT64 in generic xstat functions

* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c: Do not define
fxstat if XSTAT_IS_XSTAT64 is set to non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c: Ditto for
fxstatat.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat.c: Ditto for
lxstat.
* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat.c: Ditto for xstat.

* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c: New file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c: New file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lxstat64.c: Make __lxstat
an alias of __lxstat64 if XSTAT_IS_XSTAT64 is set to non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/xstat64.c: Ditto for
__xstat.

7 years agopowerpc: Add hidden definition for __sigsetjmp
Florian Weimer [Tue, 29 Nov 2016 09:16:35 +0000 (10:16 +0100)] 
powerpc: Add hidden definition for __sigsetjmp

There already is a hidden prototype for __sigsetjmp, but the
architecture-specific definition was missing.

7 years agopowerpc: Remove unintended __longjmp symbol from ABI
Florian Weimer [Tue, 29 Nov 2016 09:08:06 +0000 (10:08 +0100)] 
powerpc: Remove unintended __longjmp symbol from ABI

The __longjmp symbol was left in accidentally.  It is not exported
through a Versions file, but through a .symver assembler directive.

The corresponding exported symbol was removed from the non-fpu
powerpc64 targets in commit 9b9ef823581ecee546653d6ac3fd335f7b79faca.

7 years agoRefactor FP_FAST_* into bits/fp-fast.h.
Joseph Myers [Tue, 29 Nov 2016 01:45:00 +0000 (01:45 +0000)] 
Refactor FP_FAST_* into bits/fp-fast.h.

Continuing the refactoring of bits/mathdef.h, this patch moves the
FP_FAST_* definitions into a new bits/fp-fast.h header.  Currently
this is only for FP_FAST_FMA*, but in future it would be the
appropriate place for the FP_FAST_* macros from TS 18661-1 as well.

The generic bits/mathdef.h header defines these macros based on
whether the compiler defines __FP_FAST_*.  Most architecture-specific
headers, however, fail to do so, meaning that if the architecture (or
some particular processors) does in fact have fused operations, and
GCC knows to use them inline, the FP_FAST_* macros will still not be
defined.

By refactoring, this patch causes the generic version (based on
__FP_FAST_*) to be used in more cases, and so the macro definitions to
be more accurate.  Architectures that already defined some or all of
these macros other than based on the predefines have their own
versions of fp-fast.h, which are arranged so they define FP_FAST_* if
either the architecture-specific conditions are true or __FP_FAST_*
are defined.

After this refactoring, various bits/mathdef.h headers for
architectures with long double = double are semantically identical to
the generic version.  The patch removes those headers that are
redundant.  (In fact two of the four removed were already redundant
before this patch because they did use __FP_FAST_*.)

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

* bits/fp-fast.h: New file.
* sysdeps/aarch64/bits/fp-fast.h: Likewise.
* sysdeps/powerpc/bits/fp-fast.h: Likewise.
* math/Makefile (headers): Add bits/fp-fast.h.
* math/math.h: Include <bits/fp-fast.h>.
* bits/mathdef.h (FP_FAST_FMA): Remove.
(FP_FAST_FMAF): Likewise.
(FP_FAST_FMAL): Likewise.
* sysdeps/aarch64/bits/mathdef.h (FP_FAST_FMA): Likewise.
(FP_FAST_FMAF): Likewise.
* sysdeps/powerpc/bits/mathdef.h (FP_FAST_FMA): Likewise.
(FP_FAST_FMAF): Likewise.
* sysdeps/x86/bits/mathdef.h (FP_FAST_FMA): Likewise.
(FP_FAST_FMAF): Likewise.
(FP_FAST_FMAL): Likewise.
* sysdeps/arm/bits/mathdef.h: Remove file.
* sysdeps/hppa/fpu/bits/mathdef.h: Likewise.
* sysdeps/sh/sh4/bits/mathdef.h: Likewise.
* sysdeps/tile/bits/mathdef.h: Likewise.

7 years agoMake ilogb wrappers type-generic.
Joseph Myers [Mon, 28 Nov 2016 23:27:23 +0000 (23:27 +0000)] 
Make ilogb wrappers type-generic.

This patch converts the ilogb wrappers (which set errno directly
rather than doing anything with __kernel_standard) to use the
type-generic template machinery.  This is intended as preparation for
adding llogb.

Tested for x86_64 and x86, and tested compile for other architectures
with build-many-glibcs.py.

* math/w_ilogb_template.c: New file.  Based on math/w_ilogb.c.
* math/w_ilogb.c: Remove.
* math/w_ilogbf.c: Likewise.
* math/w_ilogbl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_ilogb.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_ilogbl.c: Likewise.
* math/Makefile (gen-libm-calls): Add w_ilogbF.
(libm-calls): Remove w_ilogbF.
* sysdeps/ieee754/ldbl-opt/math-type-macros-double.h
(LDOUBLE_ilogbl_libm_version): New macro.

7 years agoWork around IA64 tst-setcontext2.c compile failure.
Joseph Myers [Mon, 28 Nov 2016 23:13:46 +0000 (23:13 +0000)] 
Work around IA64 tst-setcontext2.c compile failure.

Building tests for IA64 runs into a build failure compiling
stdlib/tst-setcontext2.c:

tst-setcontext2.c: In function 'do_test':
tst-setcontext2.c:210:20: error: passing argument 1 of 'sigismember' from incompatible pointer type [-Werror=incompatible-pointer-types]
   if (sigismember (&oldctx.uc_sigmask, SIGUSR2) != 1)
                    ^

Indeed, the IA64 uc_sigmask as unsigned long rather than the larger
userspace sigset_t.  Fixing this might be hard; this patch works
around the build failure by making IA64 wrap the test with a version
that #defines sigismember to add a cast (I'd welcome a better approach
for fixing this).

Tested (compilation only) for ia64.

* sysdeps/unix/sysv/linux/ia64/tst-setcontext2.c: New file.

7 years agoFix sysdeps/ia64/fpu/libm-symbols.h for inclusion in testcases.
Joseph Myers [Mon, 28 Nov 2016 23:12:49 +0000 (23:12 +0000)] 
Fix sysdeps/ia64/fpu/libm-symbols.h for inclusion in testcases.

IA64 builds in math/ use "-include libm-symbols.h".  This breaks the
signgam tests, which rely on undefining _LIBC and feature test macros
and defining _ISOMAC before including system headers to get them to
provide only ISO C declarations (libm-symbols.h ending up indirectly
including headers which result in this breaking); similarly, it breaks
C++ tests as some headers included from libm-symbols.h are not ready
for inclusion in C++ code.  This patch disables the contents of
libm-symbols.h if __STRICT_ANSI__ or __cplusplus are defined to avoid
this problem (this header can only test symbols defined before the
source file is processed, so can't test _ISOMAC because that's defined
within the source file, after this header is included).

Tested (compilation only) for ia64.

* sysdeps/ia64/fpu/libm-symbols.h: Make contents conditional on
[!__STRICT_ANSI__ && !__cplusplus].

7 years agoX86_64: Don't use PLT nor GOT in static archives [BZ #20750]
H.J. Lu [Mon, 28 Nov 2016 17:44:49 +0000 (09:44 -0800)] 
X86_64: Don't use PLT nor GOT in static archives [BZ #20750]

There is no need to use PLT nor GOT in static archives to branch to a
function, regardless whether static archives is compiled with PIC or
not.  When static archives are used to create dynamic executable,
PLT/GOT may be used.  The resulting executable still works correctly.

[BZ #20750]
* sysdeps/x86_64/sysdep.h (JUMPTARGET): Check SHARED instead
of PIC.

7 years agoPartial ILP32 support for aarch64.
Steve Ellcey [Mon, 28 Nov 2016 17:01:23 +0000 (09:01 -0800)] 
Partial ILP32 support for aarch64.

* sysdeps/aarch64/crti.S: Add include of sysdep.h.
(call_weak_fn): Use PTR_REG to get correct reg name in ILP32.
* sysdeps/aarch64/dl-irel.h: Add include of sysdep.h.
(elf_irela): Use AARCH64_R macro to get correct relocation in ILP32.
* sysdeps/aarch64/dl-machine.h: Add include of sysdep.h.
(elf_machine_load_address, RTLD_START, RTLD_START_1, RTLD_START,
elf_machine_type_class, ELF_MACHINE_JMP_SLOT, elf_machine_rela,
elf_machine_lazy_rel): Add ifdef's for ILP32 support.
* sysdeps/aarch64/dl-tlsdesc.S (_dl_tlsdesc_return,
_dl_tlsdesc_return_lazy, _dl_tlsdesc_dynamic,
_dl_tlsdesc_resolve_hold): Extend pointers in ILP32, use PTR_REG
to get correct reg name for ILP32.
* sysdeps/aarch64/dl-trampoline.S (ip01): New Macro.
(RELA_SIZE): New Macro.
(_dl_runtime_resolve, _dl_runtime_profile): Use new macros and PTR_REG
to support ILP32.
* sysdeps/aarch64/jmpbuf-unwind.h (_JMPBUF_CFA_UNWINDS_ADJ): Add
cast for ILP32 mode.
* sysdeps/aarch64/memcmp.S (memcmp): Extend arg pointers for ILP32 mode.
* sysdeps/aarch64/memcpy.S (memmove, memcpy): Ditto.
* sysdeps/aarch64/memset.S (__memset): Ditto.
* sysdeps/aarch64/strchr.S (strchr): Ditto.
* sysdeps/aarch64/strchrnul.S (__strchrnul): Ditto.
* sysdeps/aarch64/strcmp.S (strcmp): Ditto.
* sysdeps/aarch64/strcpy.S (strcpy): Ditto.
* sysdeps/aarch64/strlen.S (__strlen): Ditto.
* sysdeps/aarch64/strncmp.S (strncmp): Ditto.
* sysdeps/aarch64/strnlen.S (strnlen): Ditto.
* sysdeps/aarch64/strrchr.S (strrchr): Ditto.
* sysdeps/unix/sysv/linux/aarch64/clone.S: Ditto.
* sysdeps/unix/sysv/linux/aarch64/setcontext.S (__setcontext): Ditto.
* sysdeps/unix/sysv/linux/aarch64/swapcontext.S (__swapcontext): Ditto.
* sysdeps/aarch64/__longjmp.S (__longjmp): Extend pointers in ILP32,
change PTR_MANGLE call to use register numbers instead of names.
* sysdeps/unix/sysv/linux/aarch64/getcontext.S (__getcontext): Ditto.
* sysdeps/aarch64/setjmp.S (__sigsetjmp): Extend arg pointers for
ILP32 mode, change PTR_MANGLE calls to use register numbers.
* sysdeps/aarch64/start.S (_start): Ditto.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h
(__PTHREAD_RWLOCK_INT_FLAGS_SHARED): New define.
(__SIZEOF_PTHREAD_ATTR_T, __SIZEOF_PTHREAD_MUTEX_T,
__SIZEOF_PTHREAD_MUTEXATTR_T, __SIZEOF_PTHREAD_COND_T,
__SIZEOF_PTHREAD_COND_COMPAT_T, __SIZEOF_PTHREAD_CONDATTR_T,
__SIZEOF_PTHREAD_RWLOCK_T, __SIZEOF_PTHREAD_RWLOCKATTR_T,
__SIZEOF_PTHREAD_BARRIER_T, __SIZEOF_PTHREAD_BARRIERATTR_T):
Make defined values dependent on __ILP32__.
* sysdeps/aarch64/nptl/bits/semaphore.h (__SIZEOF_SEM_T): Change define.
(sem_t): Change __align type.
* sysdeps/aarch64/sysdep.h (AARCH64_R, PTR_REG, PTR_LOG_SIZE, DELOUSE,
PTR_SIZE): New Macros.
(LDST_PCREL, LDST_GLOBAL) Update to use PTR_REG.
* sysdeps/unix/sysv/linux/aarch64/bits/fcntl.h (O_LARGEFILE):
Set when in ILP32 mode.
(F_GETLK64, F_SETLK64, F_SETLKW64): Only set in LP64 mode.
* sysdeps/unix/sysv/linux/aarch64/dl-cache.h (DL_CACHE_DEFAULT_ID):
Set elf flags for ILP32.
(add_system_dir): Set ILP32 library directories.
* sysdeps/unix/sysv/linux/aarch64/init-first.c
(_libc_vdso_platform_setup): Set minimum kernel version for ILP32.
* sysdeps/unix/sysv/linux/aarch64/ldconfig.h
(SYSDEP_KNOWN_INTERPRETER_NAMES): Add ILP32 names.
* sysdeps/unix/sysv/linux/aarch64/sigcontextinfo.h (GET_PC, SET_PC):
New Macros.
* sysdeps/unix/sysv/linux/aarch64/sysdep.h: Handle ILP32 pointers.

7 years agoFix for [f]statfs64/[f]statfs aliasing patch
Steve Ellcey [Mon, 28 Nov 2016 16:51:01 +0000 (08:51 -0800)] 
Fix for [f]statfs64/[f]statfs aliasing patch

* sysdeps/unix/sysv/linux/fstatfs64.c: Reorder include files,
only alias fstatfs and __fstatfs if STATFS_IS_STATFS64 is non-zero.
* sysdeps/unix/sysv/linux/statfs64.c: Ditto for statfs and __statfs.

7 years agoDo not include asm/cachectl.h in nios2 sys/cachectl.h.
Joseph Myers [Mon, 28 Nov 2016 13:55:31 +0000 (13:55 +0000)] 
Do not include asm/cachectl.h in nios2 sys/cachectl.h.

The nios2 sys/cachectl.h includes a kernel header asm/cachectl.h,
which does not exist, so causing the check-installed-headers tests to
fail.  This patch removes the include of a nonexistent header.

Tested (compilation only) for nios2.

* sysdeps/unix/sysv/linux/nios2/sys/cachectl.h: Do not include
<asm/cachectl.h>.

7 years agoMinor problems exposed by compiling C++ tests under _ISOMAC.
Zack Weinberg [Sun, 27 Nov 2016 17:36:16 +0000 (12:36 -0500)] 
Minor problems exposed by compiling C++ tests under _ISOMAC.

* libio/libio.h: Use __USE_GNU, not _GNU_SOURCE, in a conditional.
* test-skeleton.c: Include stdint.h to ensure uintptr_t is available.

7 years agohurd: fix using hurd/signal.h in C++ programs
Samuel Thibault [Sun, 27 Nov 2016 16:22:22 +0000 (17:22 +0100)] 
hurd: fix using hurd/signal.h in C++ programs

* hurd/hurd/signal.h (HURD_MSGPORT_RPC): Cast expressions results to
error_t to fix usage in C++ programs.

7 years agolocaledata: GBK: add mapping for 0x80->Euro sign [BZ #20864]
Mike Frysinger [Fri, 25 Nov 2016 16:12:10 +0000 (11:12 -0500)] 
localedata: GBK: add mapping for 0x80->Euro sign [BZ #20864]

Microsoft long ago added a mapping for 0x80 to the Euro sign to their
CP936.  While GBK 1.0 doesn't include this mapping, it is compatible,
and Microsoft and glibc alias the two codepages.  We could split them
apart so GBK wouldn't include the mapping, but that seems like a lot
of work for little gain.

7 years agoMake build-many-glibcs.py store more information about builds.
Joseph Myers [Sat, 26 Nov 2016 00:10:24 +0000 (00:10 +0000)] 
Make build-many-glibcs.py store more information about builds.

This patch makes build-many-glibcs.py store information about builds
in JSON format.  This is part of preparing it for use in a bot
checking for regressions.

The information stored is: time of last build (of host-libraries,
compilers or glibcs); versions of components used in the last build
(for compilers, host library versions are properly copied from those
used for the previous host-libraries build, and for glibcs, component
versions other than that of glibc are similarly copied from the last
compilers build); PASS/FAIL/UNRESOLVED results of the individual build
steps; a list of changed results; a list of tests (that are still run
at all) that have ever been recorded to PASS.

The first pieces of information are intended to be used by a bot to
decide whether a rebuild is appropriate (based on some combination of
elapsed time and changes to versions; a bot might want to rebuild
glibcs if there had been any change but only rebuild compilers after
enough time had elapsed, for example).  All the information is
intended to be used in generating mails with results information.

This state is specifically for full builds (no individual configs for
building compilers or glibcs specified).  If individual configs are
specified, build-time and build-versions information is cleared (since
it will no longer accurately reflect the install directory contents),
while the other information is left unchanged.  This reflects the
motivation of providing information for a bot checking for
regressions; the contents of build-state.json in a tree used for
manual builds that may be only for some configurations are not
particularly important.

* scripts/build-many-glibcs.py: Import datetime module.
(Context.__init__): Load JSON build state.  Initialize list of
status logs.
(Context.run_builds): Update saved build state.
(Context.add_makefile_cmdlist): Update list of status logs.
(Context.load_build_state_json): New function.
(Context.store_build_state_json): Likewise.
(Context.clear_last_build_state): Likewise.
(Context.update_build_state): Likewise.
(CommandList.status_logs): Likewise.

7 years agoMake build-many-glibcs.py re-exec itself if changed by checkout.
Joseph Myers [Fri, 25 Nov 2016 00:58:22 +0000 (00:58 +0000)] 
Make build-many-glibcs.py re-exec itself if changed by checkout.

Updating build-many-glibcs.py may result in changes to the default
versions of components, or to the set of components (if e.g. Hurd
support is added and that requires a new component).

It's desirable for the checkout process to leave a source tree that is
ready to use.  If the checkout updated the script itself, that means
it needs to be rerun to cause any new versions or components
referenced by the new script version to be properly checked out.  This
patch makes the script check if it was modified by the checkout
process, and re-exec itself (with the same arguments) if so.

* scripts/build-many-glibcs.py (Context.__init__): Save text of
script being executed.
(Context.get_script_text): New function.
(Context.exec_self): Likewise.
(Context.checkout): Re-exec script if changed by checkout process.

7 years agoAdd setpayloadsig, setpayloadsigf, setpayloadsigl.
Joseph Myers [Thu, 24 Nov 2016 23:56:48 +0000 (23:56 +0000)] 
Add setpayloadsig, setpayloadsigf, setpayloadsigl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the setpayloadsig functions for glibc; these are
like the setpayload functions, but produce a signaling NaN instead of
a quiet NaN.

The substance of the implementation was included with the setpayload
implementation, so the new files here just need to wrap the main files
with different defines to build the new functions.

Because the functions store a signaling NaN via a pointer and the
libm-test macros choose a suitable initial value for the variable in
such a case by comparing with the expected value, the relevant macro
needs to clear exceptions after FE_INVALID may have been raised by
that comparison.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(setpayloadsig): New declaration.
* math/Versions (setpayloadsig): New libm symbol at version
GLIBC_2.25.
(setpayloadsigf): Likewise.
(setpayloadsigl): Likewise.
* math/Makefile (libm-calls): Add s_setpayloadsigF.
* math/libm-test.inc (RUN_TEST_Ff_b1): Call feclearexcept
(FE_ALL_EXCEPT) after initializing EXTRA_VAR.
(setpayloadsig_test_data): New array.
(setpayloadsig_test): New function.
(main): Call setpayloadsig_test.
* manual/arith.texi (FP Bit Twiddling): Document setpayloadsig,
setpayloadsigf and setpayloadsigl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_setpayloadsig.c: New file.
* sysdeps/ieee754/flt-32/s_setpayloadsigf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-setpayloadsig.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
setpayloadsig.
(CFLAGS-nldbl-setpayloadsig.c): New variable.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoMake build-many-glibcs.py track component versions requested and used.
Joseph Myers [Thu, 24 Nov 2016 22:25:58 +0000 (22:25 +0000)] 
Make build-many-glibcs.py track component versions requested and used.

This patch makes build-many-glibcs.py record the component versions
checked out, and whether those versions were explicitly requested or
defaults, in a file versions.json in the source directory.

The preferred version of a component is the first of: one explicitly
specified on the command line; one explicitly specified on the command
line in a previous run of build-many-glibcs.py; a default version for
that component.  Thus, once you've run build-many-glibcs.py checkout
once with the updated script (making sure to specify the right
versions of any components previously checked out with a non-default
version), in future you can just run it without version specifiers and
it will know when a default-version component has changed its default
version and so should be checked out again.

Because you might have local changes and not want a default-version
component checkout replaced, you need to pass the --replace-sources
option to allow the script to delete and replace a component source
directory automatically; otherwise, it will give an error if a version
has changed.  The script does not try to change branches of git or SVN
checkouts without checking out from scratch; if the version number
requested has changed and --replace-sources is used, the relevant
source directory will be removed completely and a new one checked out
from scratch.

Apart from allowing automatic updates of components with default
versions, this also facilitates bots reporting on the versions used in
a given build.  versions.json contains not just information on the
version number and whether that was requested explicitly, but also git
or SVN revision information intended to be used in email reports from
bots.

* scripts/build-many-glibcs.py: Import json module.
(Context.__init__): Take replace_sources argument.  Load
versions.json.
(Context.load_versions_json): New function.
(Context.store_json): Likewise.
(Context.store_versions_json): Likewise.
(Context.set_component_version): Likewise.
(Context.checkout): Update versions.json.  Check for and handle
changes of version.  Prefer previously explicitly specified
version to default version.
(Context.checkout_vcs): Return a revision identifier.
(Context.git_checkout): Likewise.
(Context.gcc_checkout): Likewise.
(get_parser): Add --replace-sources option.
(main): Pass replace_sources argument to Context call.

7 years agoRemove cached PID/TID in clone
Adhemerval Zanella [Mon, 10 Oct 2016 18:08:39 +0000 (15:08 -0300)] 
Remove cached PID/TID in clone

This patch remove the PID cache and usage in current GLIBC code.  Current
usage is mainly used a performance optimization to avoid the syscall,
however it adds some issues:

  - The exposed clone syscall will try to set pid/tid to make the new
    thread somewhat compatible with current GLIBC assumptions.  This cause
    a set of issue with new workloads and usecases (such as BZ#17214 and
    [1]) as well for new internal usage of clone to optimize other algorithms
    (such as clone plus CLONE_VM for posix_spawn, BZ#19957).

  - The caching complexity also added some bugs in the past [2] [3] and
    requires more effort of each port to handle such requirements (for
    both clone and vfork implementation).

  - Caching performance gain in mainly on getpid and some specific
    code paths.  The getpid performance leverage is questionable [4],
    either by the idea of getpid being a hotspot as for the getpid
    implementation itself (if it is indeed a justifiable hotspot a
    vDSO symbol could let to a much more simpler solution).

    Other usage is mainly for non usual code paths, such as pthread
    cancellation signal and handling.

For thread creation (on stack allocation) the code simplification in fact
adds some performance gain due the no need of transverse the stack cache
and invalidate each element pid.

Other thread usages will require a direct getpid syscall, such as
cancellation/setxid signal, thread cancellation, thread fail path (at
create_thread), and thread signal (pthread_kill and pthread_sigqueue).
However these are hardly usual hotspots and I think adding a syscall is
justifiable.

It also simplifies both the clone and vfork arch-specific implementation.
And by review each fork implementation there are some discrepancies that
this patch also solves:

  - microblaze clone/vfork does not set/reset the pid/tid field
  - hppa uses the default vfork implementation that fallback to fork.
    Since vfork is deprecated I do not think we should bother with it.

The patch also removes the TID caching in clone. My understanding for
such semantic is try provide some pthread usage after a user program
issue clone directly (as done by thread creation with CLONE_PARENT_SETTID
and pthread tid member).  However, as stated before in multiple discussions
threads, GLIBC provides clone syscalls without further supporting all this
semantics.

I ran a full make check on x86_64, x32, i686, armhf, aarch64, and powerpc64le.
For sparc32, sparc64, and mips I ran the basic fork and vfork tests from
posix/ folder (on a qemu system).  So it would require further testing
on alpha, hppa, ia64, m68k, nios2, s390, sh, and tile (I excluded microblaze
because it is already implementing the patch semantic regarding clone/vfork).

[1] https://codereview.chromium.org/800183004/
[2] https://sourceware.org/ml/libc-alpha/2006-07/msg00123.html
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=15368
[4] http://yarchive.net/comp/linux/getpid_caching.html

* sysdeps/nptl/fork.c (__libc_fork): Remove pid cache setting.
* nptl/allocatestack.c (allocate_stack): Likewise.
(__reclaim_stacks): Likewise.
(setxid_signal_thread): Obtain pid through syscall.
* nptl/nptl-init.c (sigcancel_handler): Likewise.
(sighandle_setxid): Likewise.
* nptl/pthread_cancel.c (pthread_cancel): Likewise.
* sysdeps/unix/sysv/linux/pthread_kill.c (__pthread_kill): Likewise.
* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
Likewise.
* sysdeps/unix/sysv/linux/createthread.c (create_thread): Likewise.
* sysdeps/unix/sysv/linux/getpid.c: Remove file.
* nptl/descr.h (struct pthread): Change comment about pid value.
* nptl/pthread_getattr_np.c (pthread_getattr_np): Remove thread
pid assert.
* sysdeps/unix/sysv/linux/pthread-pids.h (__pthread_initialize_pids):
Do not set pid value.
* nptl_db/td_ta_thr_iter.c (iterate_thread_list): Remove thread
pid cache check.
* nptl_db/td_thr_validate.c (td_thr_validate): Likewise.
* sysdeps/aarch64/nptl/tcb-offsets.sym: Remove pid offset.
* sysdeps/alpha/nptl/tcb-offsets.sym: Likewise.
* sysdeps/arm/nptl/tcb-offsets.sym: Likewise.
* sysdeps/hppa/nptl/tcb-offsets.sym: Likewise.
* sysdeps/i386/nptl/tcb-offsets.sym: Likewise.
* sysdeps/ia64/nptl/tcb-offsets.sym: Likewise.
* sysdeps/m68k/nptl/tcb-offsets.sym: Likewise.
* sysdeps/microblaze/nptl/tcb-offsets.sym: Likewise.
* sysdeps/mips/nptl/tcb-offsets.sym: Likewise.
* sysdeps/nios2/nptl/tcb-offsets.sym: Likewise.
* sysdeps/powerpc/nptl/tcb-offsets.sym: Likewise.
* sysdeps/s390/nptl/tcb-offsets.sym: Likewise.
* sysdeps/sh/nptl/tcb-offsets.sym: Likewise.
* sysdeps/sparc/nptl/tcb-offsets.sym: Likewise.
* sysdeps/tile/nptl/tcb-offsets.sym: Likewise.
* sysdeps/x86_64/nptl/tcb-offsets.sym: Likewise.
* sysdeps/unix/sysv/linux/aarch64/clone.S: Remove pid and tid caching.
* sysdeps/unix/sysv/linux/alpha/clone.S: Likewise.
* sysdeps/unix/sysv/linux/arm/clone.S: Likewise.
* sysdeps/unix/sysv/linux/hppa/clone.S: Likewise.
* sysdeps/unix/sysv/linux/i386/clone.S: Likewise.
* sysdeps/unix/sysv/linux/ia64/clone2.S: Likewise.
* sysdeps/unix/sysv/linux/mips/clone.S: Likewise.
* sysdeps/unix/sysv/linux/nios2/clone.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sh/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/tile/clone.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/clone.S: Likewise.
* sysdeps/unix/sysv/linux/aarch64/vfork.S: Remove pid set and reset.
* sysdeps/unix/sysv/linux/alpha/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/arm/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/i386/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/ia64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/m68k/clone.S: Likewise.
* sysdeps/unix/sysv/linux/m68k/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/mips/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/nios2/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sh/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/tile/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/tst-clone2.c (f): Remove direct pthread
struct access.
(clone_test): Remove function.
(do_test): Rewrite to take in consideration pid is not cached anymore.

7 years agoRefactor float_t, double_t information into bits/flt-eval-method.h.
Joseph Myers [Thu, 24 Nov 2016 18:44:50 +0000 (18:44 +0000)] 
Refactor float_t, double_t information into bits/flt-eval-method.h.

At present, definitions of float_t and double_t are split among many
bits/mathdef.h headers.

For all but three architectures, these types are float and double.
Furthermore, if you assume __FLT_EVAL_METHOD__ to be defined, that
provides a more generic way of determining the correct values of these
typedefs.  Defining these typedefs more generally based on
__FLT_EVAL_METHOD__ was previously proposed by Paul Eggert in
<https://sourceware.org/ml/libc-alpha/2012-02/msg00002.html>.

This patch refactors things in the way I proposed in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>.  A new
header bits/flt-eval-method.h defines a single macro,
__GLIBC_FLT_EVAL_METHOD, which is then used by math.h to define
float_t and double_t.  The default is based on __FLT_EVAL_METHOD__
(although actually a default to 0 would have the same effect for
current ports, because ports where values other than 0 or 16 are
possible all have their own headers).

To avoid changing the existing semantics in any case, including for
compilers not defining __FLT_EVAL_METHOD__, architecture-specific
files are then added for m68k, s390, x86 which replicate the existing
semantics.  At least with __FLT_EVAL_METHOD__ values possible with
GCC, there should be no change to the choices of float_t and double_t
for any supported configuration.

Architecture maintainer notes:

* m68k: sysdeps/m68k/m680x0/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 2 to replicate the existing logic.  But
  actually GCC defines __FLT_EVAL_METHOD__ to 0 if TARGET_68040.  It
  might make sense to make the header prefer to base things on
  __FLT_EVAL_METHOD__ if defined, like the x86 version, and so make
  the choices of these types more accurate (with a NEWS entry as for
  the other changes to these types on particular architectures).

* s390: sysdeps/s390/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 1 to replicate the existing logic.  As
  previously discussed, it might make sense in coordination with GCC
  to eliminate the historic mistake, avoid excess precision in the
  -fexcess-precision=standard case and make the typedefs match (with a
  NEWS entry, again).

Tested for x86-64 and x86.  Also did compilation-only testing with
build-many-glibcs.py.

* bits/flt-eval-method.h: New file.
* sysdeps/m68k/m680x0/bits/flt-eval-method.h: Likewise.
* sysdeps/s390/bits/flt-eval-method.h: Likewise.
* sysdeps/x86/bits/flt-eval-method.h: Likewise.
* math/Makefile (headers): Add bits/flt-eval-method.h.
* math/math.h: Include <bits/flt-eval-method.h>.
[__USE_ISOC99] (float_t): Define based on __GLIBC_FLT_EVAL_METHOD.
[__USE_ISOC99] (double_t): Likewise.
* bits/mathdef.h (float_t): Remove.
(double_t): Likewise.
* sysdeps/aarch64/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/alpha/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/arm/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/hppa/fpu/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/ia64/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/m68k/m680x0/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/mips/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/powerpc/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/s390/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/sh/sh4/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/sparc/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/tile/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/x86/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.

7 years agox86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE
Aurelien Jarno [Thu, 24 Nov 2016 11:10:13 +0000 (12:10 +0100)] 
x86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE

When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __memcpy_chk is not built,
as the test is done on PIC instead of SHARED. Fix the test to check for
SHARED, like it is done for similar functions like memmove_chk.

Changelog:
* sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
instead of PIC.

7 years agoMore NEWS entries / fixes for float_t / double_t changes.
Joseph Myers [Wed, 23 Nov 2016 21:30:04 +0000 (21:30 +0000)] 
More NEWS entries / fixes for float_t / double_t changes.

Document changes for x86_64 -mfpmath=sse and -mfpmath=sse+387.  Don't
put these NEWS entries in the middle of TS 18661-1 entries.