]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years agoAdd framework for tunables
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:02:17 +0000 (23:32 +0530)] 
Add framework for tunables

The tunables framework allows us to uniformly manage and expose global
variables inside glibc as switches to users.  tunables/README has
instructions for glibc developers to add new tunables.

Tunables support can be enabled by passing the --enable-tunables
configure flag to the configure script.  This patch only adds a
framework and does not pose any limitations on how tunable values are
read from the user.  It also adds environment variables used in malloc
behaviour tweaking to the tunables framework as a PoC of the
compatibility interface.

* manual/install.texi: Add --enable-tunables option.
* INSTALL: Regenerate.
* README.tunables: New file.
* Makeconfig (CPPFLAGS): Define TOP_NAMESPACE.
(before-compile): Generate dl-tunable-list.h early.
* config.h.in: Add HAVE_TUNABLES.
* config.make.in: Add have-tunables.
* configure.ac: Add --enable-tunables option.
* configure: Regenerate.
* csu/init-first.c (__libc_init_first): Move
__libc_init_secure earlier...
* csu/init-first.c (LIBC_START_MAIN):... to here.
Include dl-tunables.h, libc-internal.h.
(LIBC_START_MAIN) [!SHARED]: Initialize tunables for static
binaries.
* elf/Makefile (dl-routines): Add dl-tunables.
* elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE
namespace.
* elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_
only when !HAVE_TUNABLES.
* elf/rtld.c (process_envvars): Likewise.
* elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h
(_dl_sysdep_start): Call __tunables_init.
* elf/dl-tunable-types.h: New file.
* elf/dl-tunables.c: New file.
* elf/dl-tunables.h: New file.
* elf/dl-tunables.list: New file.
* malloc/tst-malloc-usable-static.c: New test case.
* malloc/Makefile (tests-static): Add it.
* malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h.
Define TUNABLE_NAMESPACE.
(DL_TUNABLE_CALLBACK (set_mallopt_check)): New function.
(DL_TUNABLE_CALLBACK_FNDECL): New macro.  Use it to define
callback functions.
(ptmalloc_init): Set tunable values.
* scripts/gen-tunables.awk: New file.
* sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h.
(_dl_sysdep_start): Call __tunables_init.

7 years agoresolv: Deprecate RES_BLAST
Florian Weimer [Sat, 31 Dec 2016 18:08:39 +0000 (19:08 +0100)] 
resolv: Deprecate RES_BLAST

7 years agoresolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]
Florian Weimer [Tue, 4 Oct 2016 09:52:10 +0000 (11:52 +0200)] 
resolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]

7 years agoresolv: Add beginnings of a libresolv test suite
Florian Weimer [Sat, 31 Dec 2016 13:06:16 +0000 (14:06 +0100)] 
resolv: Add beginnings of a libresolv test suite

7 years agosupport: Implement --verbose option for test programs
Florian Weimer [Sat, 31 Dec 2016 10:01:40 +0000 (11:01 +0100)] 
support: Implement --verbose option for test programs

Some tests can produce rather verbose tracing information,
and the --verbose option provides a standardized way to enable
such logging output.

7 years agosupport: Use support_record_failure consistently
Florian Weimer [Sat, 31 Dec 2016 11:20:49 +0000 (12:20 +0100)] 
support: Use support_record_failure consistently

This causes more test programs to link in the support_record_failure
function, which triggers an early call to mmap from an ELF
constructor, but this should not have side effects intefering
with the functionality actually under test (unlike, say, a call
to malloc).

7 years agosupport: Helper functions for entering namespaces
Florian Weimer [Sat, 31 Dec 2016 17:51:07 +0000 (18:51 +0100)] 
support: Helper functions for entering namespaces

7 years agogetentropy: Declare it in <unistd.h> for __USE_MISC [BZ #17252]
Florian Weimer [Sat, 31 Dec 2016 14:11:29 +0000 (15:11 +0100)] 
getentropy: Declare it in <unistd.h> for __USE_MISC [BZ #17252]

7 years agoNew condvar implementation that provides stronger ordering guarantees.
Torvald Riegel [Wed, 25 May 2016 21:43:36 +0000 (23:43 +0200)] 
New condvar implementation that provides stronger ordering guarantees.

This is a new implementation for condition variables, required
after http://austingroupbugs.net/view.php?id=609 to fix bug 13165.  In
essence, we need to be stricter in which waiters a signal or broadcast
is required to wake up; this couldn't be solved using the old algorithm.
ISO C++ made a similar clarification, so this also fixes a bug in
current libstdc++, for example.

We can't use the old algorithm anymore because futexes do not guarantee
to wake in FIFO order.  Thus, when we wake, we can't simply let any
waiter grab a signal, but we need to ensure that one of the waiters
happening before the signal is woken up.  This is something the previous
algorithm violated (see bug 13165).

There's another issue specific to condvars: ABA issues on the underlying
futexes.  Unlike mutexes that have just three states, or semaphores that
have no tokens or a limited number of them, the state of a condvar is
the *order* of the waiters.  A waiter on a semaphore can grab a token
whenever one is available; a condvar waiter must only consume a signal
if it is eligible to do so as determined by the relative order of the
waiter and the signal.
Therefore, this new algorithm maintains two groups of waiters: Those
eligible to consume signals (G1), and those that have to wait until
previous waiters have consumed signals (G2).  Once G1 is empty, G2
becomes the new G1.  64b counters are used to avoid ABA issues.

This condvar doesn't yet use a requeue optimization (ie, on a broadcast,
waking just one thread and requeueing all others on the futex of the
mutex supplied by the program).  I don't think doing the requeue is
necessarily the right approach (but I haven't done real measurements
yet):
* If a program expects to wake many threads at the same time and make
that scalable, a condvar isn't great anyway because of how it requires
waiters to operate mutually exclusive (due to the mutex usage).  Thus, a
thundering herd problem is a scalability problem with or without the
optimization.  Using something like a semaphore might be more
appropriate in such a case.
* The scalability problem is actually at the mutex side; the condvar
could help (and it tries to with the requeue optimization), but it
should be the mutex who decides how that is done, and whether it is done
at all.
* Forcing all but one waiter into the kernel-side wait queue of the
mutex prevents/avoids the use of lock elision on the mutex.  Thus, it
prevents the only cure against the underlying scalability problem
inherent to condvars.
* If condvars use short critical sections (ie, hold the mutex just to
check a binary flag or such), which they should do ideally, then forcing
all those waiter to proceed serially with kernel-based hand-off (ie,
futex ops in the mutex' contended state, via the futex wait queues) will
be less efficient than just letting a scalable mutex implementation take
care of it.  Our current mutex impl doesn't employ spinning at all, but
if critical sections are short, spinning can be much better.
* Doing the requeue stuff requires all waiters to always drive the mutex
into the contended state.  This leads to each waiter having to call
futex_wake after lock release, even if this wouldn't be necessary.

[BZ #13165]
* nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to
use new algorithm.
* nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
* nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise.
* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
(__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c.
(__condvar_confirm_wakeup, __condvar_cancel_waiting,
__condvar_cleanup_waiting, __condvar_dec_grefs,
__pthread_cond_wait_common): New.
(__condvar_cleanup): Remove.
* npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt.
* npt/pthread_condattr_setclock.c (pthread_condattr_setclock):
Likewise.
* npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared):
Likewise.
* npt/pthread_condattr_init.c (pthread_condattr_init): Likewise.
* nptl/tst-cond1.c: Add comment.
* nptl/tst-cond20.c (do_test): Adapt.
* nptl/tst-cond22.c (do_test): Likewise.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt
structure.
* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove.
(COND_CLOCK_BITS): Adapt.
* sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt.
* nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK,
__PTHREAD_COND_SHARED_MASK): New.
* nptl/nptl-printers.py (CLOCK_IDS): Remove.
(ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt.
* nptl/nptl_lock_constants.pysym: Adapt.
* nptl/test-cond-printers.py: Adapt.
* sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear,
cond_compat_check_and_clear): Adapt.
* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ...
* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
(__pthread_cond_timedwait): ... and move here.
* nptl/DESIGN-condvar.txt: Remove file.
* nptl/lowlevelcond.sym: Likewise.
* nptl/pthread_cond_timedwait.c: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.

7 years agoRevert "Fix ChangeLog typo"
Andreas Schwab [Sat, 31 Dec 2016 07:53:22 +0000 (08:53 +0100)] 
Revert "Fix ChangeLog typo"

This reverts commit d2d43afa113eb143303a3d4c1e31194648077642.

7 years agoAdd fromfp functions.
Joseph Myers [Sat, 31 Dec 2016 00:40:59 +0000 (00:40 +0000)] 
Add fromfp functions.

TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp,
ufromfpx, and float and long double variants) to convert from
floating-point to an integer type with any signedness and any given
width up to that of intmax_t, in any of the five IEEE rounding modes
(the usual four for binary floating point, plus rounding to nearest
with ties rounding away from zero), with control of whether in-range
non-integer values should result in the "inexact" exception being
raised.  This patch implements these functions for glibc.

These implementations are (apart from raising exceptions) pure integer
implementations; it's entirely possible optimized versions could be
devised for some architectures.  A common math/fromfp.h header
provides various common helper code that can readily be shared between
the implementations for different types.  For each type, the bulk of
the implementation is also shared between the four functions, with
wrappers that define UNSIGNED and INEXACT macros appropriately before
including the main implementation.

As the functions return intmax_t and uintmax_t without math.h being
allowed to expose those typedef names, they are declared using
__intmax_t and __uintmax_t as obtained from <bits/types.h>.

The FP_INT_* rounding direction macros are defined as ascending
integers in the order the names are listed in the TS; I see no
significant value in allowing architectures to vary the values of
them.

The libm-test machinery is duly adapted to handle unsigned int
arguments, and intmax_t and uintmax_t results.  Because each test
input is generally tested for four functions, five rounding modes and
several different widths, the libm-test.inc additions are very large.
Thus, the diffs in the body of this message exclude the libm-test.inc
changes, with the full patch being attached gzipped.  The bulk of the
new tests were generated (expanded from a test input plus rounding
results and information about where it lies in the relevant interval
between integers, to libm-test tests for all relevant combinations of
function, rounding direction and width) by a script that's included in
the patch as math/gen-fromfp-tests.py (input data
math/gen-fromfp-tests-inputs); as an ad hoc script that's not really
expected to be rerun, it's not very polished, but it's at least
plausibly useful for adding any further tests for these functions in
future.  I may split the libm-test tests up by function in future (so
both libm-test.inc and auto-libm-test-out are split into separate
files, and the tests for each function are also built and run
separately), but not for 2.25.

For no obvious reason, adding tgmath tests for the new functions
resulted in -Wuninitialized errors from test-tgmath.c about the
variable i being used uninitialized.  Those errors were correct - the
variable is read by the frexp version in test-tgmath.c (where real
frexp would write through that pointer instead of reading it) - but I
don't know why this patch would result in the pre-existing issue being
newly detected.  The patch initializes the variable to avoid those
errors.

With these changes, glibc 2.25 should have all the library features
from TS 18661-1 other than the functions that round result to narrower
type (and constant rounding directions, but I'm considering those
mainly a compiler feature not a library one).

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(fromfp): New declaration.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/math.h: Include <bits/types.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum
constant and macro.
(FP_INT_DOWNWARD): Likewise.
(FP_INT_TOWARDZERO): Likewise.
(FP_INT_TONEARESTFROMZERO): Likewise.
(FP_INT_TONEAREST): Likewise.
* math/Versions (fromfp): New libm symbol at version GLIBC_2.25.
(fromfpf): Likewise.
(fromfpl): Likewise.
(ufromfp): Likewise.
(ufromfpf): Likewise.
(ufromfpl): Likewise.
(fromfpx): Likewise.
(fromfpxf): Likewise.
(fromfpxl): Likewise.
(ufromfpx): Likewise.
(ufromfpxf): Likewise.
(ufromfpxl): Likewise.
* math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF,
s_fromfpxF and s_ufromfpxF.
* math/gen-fromfp-tests.py: New file.
* math/gen-fromfp-tests-inputs: Likewise.
* math/libm-test.inc: Include <stdint.h>
(check_intmax_t): New function.
(check_uintmax_t): Likewise.
(struct test_fiu_M_data): New type.
(struct test_fiu_U_data): Likewise.
(RUN_TEST_fiu_M): New macro.
(RUN_TEST_LOOP_fiu_M): Likewise.
(RUN_TEST_fiu_U): Likewise.
(RUN_TEST_LOOP_fiu_U): Likewise.
(fromfp_test_data): New array.
(fromfp_test): New function.
(fromfpx_test_data): New array.
(fromfpx_test): New function.
(ufromfp_test_data): New array.
(ufromfp_test): New function.
(ufromfpx_test_data): New array.
(ufromfpx_test): New function.
(main): Call fromfp_test, fromfpx_test, ufromfp_test and
ufromfpx_test.
* math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor
characters.
* math/test-tgmath-ret.c: Include <stdint.h>.
(rm): New variable.
(width): Likewise.
(CHECK_RET_CONST_TYPE): Take extra arguments and pass them to
called function.
(CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to
CHECK_RET_CONST_TYPE.
(CHECK_RET_CONST_DOUBLE): Likewise.
(CHECK_RET_CONST_LDOUBLE): Likewise.
(CHECK_RET_CONST): Take extra arguments and pass them to calls
macros.
(fromfp): New CHECK_RET_CONST call.
(ufromfp): Likewise.
(fromfpx): Likewise.
(ufromfpx): Likewise.
(do_test): Call check_return_fromfp, check_return_ufromfp,
check_return_fromfpx and check_return_ufromfpx.
* math/test-tgmath.c: Include <stdint.h>
(NCALLS): Increase to 138.
(F(compile_test)): Initialize i.  Call fromfp functions.
(F(fromfp)): New function.
(F(fromfpx)): Likewise.
(F(ufromfp)): Likewise.
(F(ufromfpx)): Likewise.
* manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD,
FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO,
FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf,
ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and
ufromfpxl.
* manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx,
ufromfp and ufromfpx.
* math/fromfp.h: New file.
* sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp,
ufromfp, fromfpx and ufromfpx.
(CFLAGS-nldbl-fromfp.c): New variable.
(CFLAGS-nldbl-fromfpx.c): Likewise.
(CFLAGS-nldbl-ufromfp.c): Likewise.
(CFLAGS-nldbl-ufromfpx.c): Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.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 agoresolv: Turn historic name lookup functions into compat symbols
Florian Weimer [Fri, 30 Dec 2016 17:43:04 +0000 (18:43 +0100)] 
resolv: Turn historic name lookup functions into compat symbols

This change also removes the preprocessor-based function renaming.
It also applied to tests in resolv/, which ended up running against
the historic functions.

_endhtent was not part of the ABI because it is not listed in the
resolv/Versions file.

7 years agoDefine __intmax_t, __uintmax_t in bits/types.h.
Joseph Myers [Fri, 30 Dec 2016 13:41:40 +0000 (13:41 +0000)] 
Define __intmax_t, __uintmax_t in bits/types.h.

TS 18661-1 defines *fromfp* functions, which are declared in math.h
and whose return types are intmax_t and uintmax_t, without allowing
math.h to define those typedefs.  (This is similar to e.g. ISO C
declaring vprintf in stdio.h without allowing that header to define
va_list.)  Thus, math.h needs to access those typedefs under internal
names.

This patch accordingly arranges for bits/types.h (which defines only
internal names, not public *_t typedefs) to define __intmax_t and
__uintmax_t.  stdint.h is made to use bits/types.h and define intmax_t
and uintmax_t using __intmax_t and __uintmax_t, to avoid duplication
of information.  (It would be reasonable to define more of the types
in stdint.h - and in sys/types.h, where it duplicates such types -
using information already available in bits/types.h.)  The idea is
that the subsequent addition of fromfp functions would then make
math.h include bits/types.h and use __intmax_t and __uintmax_t as the
return types of those functions.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

* bits/types.h (__intmax_t): New typedef.
(__uintmax_t): Likewise.
* sysdeps/generic/stdint.h: Include <bits/types.h>.
(intmax_t): Define using __intmax_t.
(uintmax_t): Define using __uintmax_t.

7 years agoFix tst-support_record_failure-2 for run-built-tests = no.
Joseph Myers [Fri, 30 Dec 2016 13:01:44 +0000 (13:01 +0000)] 
Fix tst-support_record_failure-2 for run-built-tests = no.

The support/tst-support_record_failure-2.out test attempts to run
built code even if run-built-tests = no, so failing with
build-many-glibcs.py for all architectures whose code cannot be run on
the system running the script.  This patch disables the test in that
case.

Tested for x86_64 (native), and for aarch64 with build-many-glibcs.py.

* support/Makefile (tests-special): Make definition conditional on
[$(run-built-tests) = yes].
($(objpfx)tst-support_record_failure-2.out): Make rule conditional
on [$(run-built-tests) = yes].

7 years agoFix ChangeLog typo
Andreas Schwab [Fri, 30 Dec 2016 09:34:14 +0000 (10:34 +0100)] 
Fix ChangeLog typo

7 years agolocaledata: bs_BA: fix yesexpr/noexpr [BZ #20974]
Mike Frysinger [Thu, 15 Dec 2016 23:34:05 +0000 (18:34 -0500)] 
localedata: bs_BA: fix yesexpr/noexpr [BZ #20974]

Both regexes end with a "*." which means the previous match can be
omitted, and then the . allows them to match any input at all.

This means tools like coreutils' `rm -i` will always delete things
when prompted because the yesexpr regex matches all inputs (even
the negative ones).

7 years agoFix pretty printer tests for run-built-tests == no
Siddhesh Poyarekar [Fri, 30 Dec 2016 04:12:38 +0000 (09:42 +0530)] 
Fix pretty printer tests for run-built-tests == no

In my change to add configure tests for python I had a brainfart where
I tried to filter out unsupported tests from tests-printers-programs
instead of tests-printers to select tests to build.  I realize now
that all of that is completely unnecessary and it would be safe to
just build the tests as long as we don't try to run it.

This patch reverts that bit of the change.  Tested with
run-built-tests = no in config.make.

* Rules (tests): Add tests-printers-programs to tests to be
built.

7 years agoAdd SYSV shared memory test
Adhemerval Zanella [Mon, 31 Oct 2016 13:22:43 +0000 (11:22 -0200)] 
Add SYSV shared memory test

This patch adds a simple SYSV shared memory test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvshm.
* sysvipc/test-sysvshm.c: New file.

7 years agoUse shmget syscall for linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:24:53 +0000 (18:24 -0200)] 
Use shmget syscall for linux implementation

this patch add a direct call to shmget syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/shmget.c (shmget): Use shmget syscall if it
is defined.

7 years agoUse shmdt syscall for linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:23:11 +0000 (18:23 -0200)] 
Use shmdt syscall for linux implementation

this patch add a direct call to shmdt syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmdt): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmdt):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmdt):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Use shmdt syscall if it is
defined.

7 years agoConsolidate Linux shmctl implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:20:36 +0000 (18:20 -0200)] 
Consolidate Linux shmctl implementation

This patch consolidates the shmctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/shmctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldshmctl.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmctl): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmctl):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/alpha/shmctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/shmctl.c: Use default
implementation.
* sysdeps/unix/sysv/linux/shmctl.c (__new_shmctl): Use shmctl syscall
if it is defined.

7 years agoUse shmat syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:04:48 +0000 (18:04 -0200)] 
Use shmat syscall for Linux implementation

This patch add a direct call to shmat syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmat): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmat):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmat):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat):
Define to __NR_osf_shmat.
* sysdeps/unix/sysv/linux/shmat.c (shmat): Use shmat syscall if it is
defined.

7 years agoAdd SYSV semaphore test
Adhemerval Zanella [Mon, 31 Oct 2016 13:03:07 +0000 (11:03 -0200)] 
Add SYSV semaphore test

This patch adds a simple SYSV semaphore test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvsem.
* sysvipc/test-sysvsem.c: New file.

7 years agoConsolidate Linux semtimedop implementation
Adhemerval Zanella [Wed, 26 Oct 2016 19:51:37 +0000 (17:51 -0200)] 
Consolidate Linux semtimedop implementation

This patch consolidates the semtimedop Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semtimedop.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semtimedop): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/m68k/semtimedop.S: Remove file.
* sysdeps/unix/sysv/linux/s390/semtimedop.c: Reorganize headers and
add a comment about s390 syscall difference from default one.
* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use semtimedop
syscall if it is defined.

7 years agoUse semop syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 19:01:43 +0000 (17:01 -0200)] 
Use semop syscall for Linux implementation

This patch add a direct call to semop syscall if it is supported by
kernel headers.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semop): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semop):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semop):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/semop.c (semop): Use semop syscall if it is
defined.

7 years agoUse semget syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 18:59:55 +0000 (16:59 -0200)] 
Use semget syscall for Linux implementation

This patch add a direct call to semget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/semget.c (semget): Use semget syscall
if it is defined.

7 years agoConsolidate Linux semctl implementation
Adhemerval Zanella [Wed, 26 Oct 2016 18:55:39 +0000 (16:55 -0200)] 
Consolidate Linux semctl implementation

This patch consolidates the semctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldsemctl.
* sysdeps/unix/sysv/linux/alpha/semctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/semctl.c: Use defaulf
implementation.
* sysdeps/unix/sysv/linux/semctl.c (__new_semctl): Use semctl
syscall if it is defined.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semctl): Remove.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semctl): Likewise.

7 years agoAdd SYSV message queue test
Adhemerval Zanella [Fri, 28 Oct 2016 20:35:03 +0000 (18:35 -0200)] 
Add SYSV message queue test

This patch adds a simple SYSV message queue test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvmsg.
* sysvipc/test-sysvmsg.c: New file.
* test-skeleton.c (FAIL_UNSUPPORTED): New define.

7 years agoUse msgget syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 13:00:24 +0000 (11:00 -0200)] 
Use msgget syscall for Linux implementation

This patch add a direct call to msgget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/msgget.c (msgget): Use msgget syscall if
define.

7 years agoUse msgsnd syscall for Linux implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:57:55 +0000 (20:57 -0200)] 
Use msgsnd syscall for Linux implementation

This patch add a direct call to msgsnd syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgsnd): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgsnd):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgsnd):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/msgsnd.c (__libc_msgsnd): Use msgsnd syscall
if defined.

7 years agoConsolidate Linux msgrcv implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:55:09 +0000 (20:55 -0200)] 
Consolidate Linux msgrcv implementation

This patch consolidates the msgrcv Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgrcv.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgctl): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise,
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/msgrcv.c (__libc_msgrcv): Use msgrcv syscall
if defined.
* sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c: Remove file.

7 years agoConsolidate Linux msgctl implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:38:37 +0000 (20:38 -0200)] 
Consolidate Linux msgctl implementation

This patch consolidates the msgctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldmsgctl.
* sysdeps/unix/sysv/linux/alpha/msgctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/msgctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/msgctl.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (oldmsgctl): Remove.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/msgctl.c: Use default
implementation.
* sysdeps/unix/sysv/linux/msgctl.c (__new_msgctl): Use msgctl syscall
if defined.

7 years agoRefactor Linux ipc_priv header
Adhemerval Zanella [Mon, 7 Nov 2016 19:29:30 +0000 (17:29 -0200)] 
Refactor Linux ipc_priv header

Some architectures support the old-style IPC and require IPC_64 equal to
0x100 to be passed along SysV IPC syscalls, while new architectures should
default to new IPC version (without the flags being set).

This patch refactor current ipc_priv.h Linux headers in two directions:

- Remove cross platform references (for instance alpha including powerpc
  definition) and add required definition for each required port.  The
  idea is to avoid tie one architecture definition with another and make
  platform change independent.

- Move all common definitions (the ipc syscall commands) on a common
  header, ipc_ops.h.

* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h: New file.
* sysdeps/unix/sysv/linux/alpha/ipc_priv.h: Avoid included other arch
definition and define its own.
* sysdeps/unix/sysv/linux/ipc_ops.h: New file.
* sysdeps/unix/sysv/linux/x86_64/ipc_priv.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h: Likewise.
* sysdeps/unix/sysv/linux/mips/ipc_priv.h: Remove file.
* sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h: New file.
* sysdeps/unix/sysv/linux/ipc_priv.h: Move ipc syscall operation
definitions to common header.
* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h: Use common syscall
operation from ipc_ops.h.

7 years agoAdd __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux
Adhemerval Zanella [Wed, 2 Nov 2016 17:41:15 +0000 (15:41 -0200)] 
Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux

On current minimum supported kernels, the SysV IPC on Linux is provided
by either the ipc syscalls or correspondent wire syscalls.  Also, for
architectures that supports wire syscalls all syscalls are supported
in a set (msgct, msgrcv, msgsnd, msgget, semctl, semget, semop, semtimedop,
shmctl, shmat, shmget, shmdt).

The architectures that only supports ipc syscall are:

  - i386, m68k, microblaze, mips32, powerpc (powerpc32, powerpc64, and
    powerpc64le), s390 (32 and 64 bits), sh, sparc32, and sparc64.

And the architectures that only supports wired syscalls are:

  - aarch64, alpha, hppa, ia64, mips64, mips64n32, nios2, tile
    (tilepro, tilegx, and tilegx64), and x86_64

Also arm is the only one that supports both wire syscalls and the
ipc, although the ipc one is deprecated.

This patch adds a new define, __ASSUME_DIRECT_SYSVIPC_SYSCALL, that wired
syscalls are supported on the system and the general idea is to use
it where possible.

I also checked the syscall table for all architectures on Linux 4.9
and there is no change on described support for Linux 2.6.32/3.2.

* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): New define.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Undef.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.

7 years agopowerpc: Fix powerpc32/power7 memchr for large input sizes
Tulio Magno Quites Machado Filho [Wed, 28 Dec 2016 13:38:56 +0000 (11:38 -0200)] 
powerpc: Fix powerpc32/power7 memchr for large input sizes

The same error fixed in commit b224637928e9fc04e3cef3e10d02ccf042d01584
happens in the 32-bit implementation of memchr for power7.

This patch adopts the same solution, with a minimal change: it
implements a saturated addition where overflows sets the maximum pointer
size to UINTPTR_MAX.

7 years agopowerpc64: strchr/strchrnul optimization for power8
Rajalakshmi Srinivasaraghavan [Tue, 27 Dec 2016 19:48:37 +0000 (17:48 -0200)] 
powerpc64: strchr/strchrnul optimization for power8

The P7 code is used for <=32B strings and for > 32B vectorized loops are used.
This shows as an average 25% improvement depending on the position of search
character.  The performance is same for shorter strings.
Tested on ppc64 and ppc64le.

7 years agoFix various typos in the ChangeLog
Florian Weimer [Wed, 28 Dec 2016 12:49:06 +0000 (13:49 +0100)] 
Fix various typos in the ChangeLog

7 years agoAdd file missing from ChangeLog in previous commit
Florian Weimer [Wed, 28 Dec 2016 12:43:49 +0000 (13:43 +0100)] 
Add file missing from ChangeLog in previous commit

7 years agosupport: Add support for delayed test failure reporting
Florian Weimer [Wed, 28 Dec 2016 12:37:18 +0000 (13:37 +0100)] 
support: Add support for delayed test failure reporting

The new functions support_record_failure records a test failure,
but does not terminate the process.  The macros TEST_VERIFY
and TEST_VERIFY_EXIT check that a condition is true.

7 years agoAdd comments to check-c++-types.sh.
Steve Ellcey [Tue, 27 Dec 2016 22:26:05 +0000 (14:26 -0800)] 
Add comments to check-c++-types.sh.

* scripts/check-c++-types.sh: Add comments.

7 years agoFix typos in the spelling of "implementation"
Dmitry V. Levin [Tue, 27 Dec 2016 20:13:35 +0000 (20:13 +0000)] 
Fix typos in the spelling of "implementation"

Apply the following spelling fix:
$ git grep -El 'implemetn?ation' |
  xargs sed -ri 's/implemetn?ation/implementation/g'

[BZ #19514]
* resolv/res_send.c: Fix typo in comment.
* sysdeps/i386/i386-mcount.S: Likewise.
* sysdeps/s390/s390-32/s390-mcount.S: Likewise.
* sysdeps/s390/s390-64/s390x-mcount.S: Likewise.
* sysdeps/sparc/sparc-mcount.S: Likewise.

7 years agopowerpc: Remove f{max,min}{f} assembly implementations
Adhemerval Zanella [Fri, 16 Dec 2016 19:13:14 +0000 (19:13 +0000)] 
powerpc: Remove f{max,min}{f} assembly implementations

This patch removes the powerpc assembly implementation of fmax/fmin.
Based on benchtests, the assembly ones shows:

$ ./testrun.sh benchtests/bench-fmax
  "fmax": {
   "": {
    "duration": 5.07586e+09,
    "iterations": 2.01676e+09,
    "max": 1350.39,
    "min": 2.073,
    "mean": 2.51684
   },
   "qNaN": {
    "duration": 5.09315e+09,
    "iterations": 8.4568e+08,
    "max": 2788,
    "min": 5.806,
    "mean": 6.02255
   },
   "sNaN": {
    "duration": 5.09073e+09,
    "iterations": 8.42316e+08,
    "max": 4215.84,
    "min": 5.737,
    "mean": 6.04373
   }

And

$ ./testrun.sh benchtests/bench-fmin
  "fmin": {
   "": {
    "duration": 5.07711e+09,
    "iterations": 2.02982e+09,
    "max": 497.094,
    "min": 2.073,
    "mean": 2.50126
   },
   "qNaN": {
    "duration": 5.09134e+09,
    "iterations": 8.46968e+08,
    "max": 2255.14,
    "min": 5.807,
    "mean": 6.01125
   },
   "sNaN": {
    "duration": 5.09122e+09,
    "iterations": 8.4746e+08,
    "max": 1969.38,
    "min": 5.729,
    "mean": 6.00763
   }
  }

The default implementation (math/s_f{max.min}_template.c) shows slight better
latency for all cases:

$ ./testrun.sh benchtests/bench-fmax
  "fmax": {
   "": {
    "duration": 5.07044e+09,
    "iterations": 2.38695e+09,
    "max": 2048.58,
    "min": 2.073,
    "mean": 2.12423
   },
   "qNaN": {
    "duration": 5.09004e+09,
    "iterations": 9.45428e+08,
    "max": 3306.93,
    "min": 5.138,
    "mean": 5.38385
   },
   "sNaN": {
    "duration": 5.08458e+09,
    "iterations": 1.15959e+09,
    "max": 972.008,
    "min": 3.321,
    "mean": 4.3848
   }
  }

And:

$ ./testrun.sh benchtests/bench-fmin
  "fmin": {
   "": {
    "duration": 5.06817e+09,
    "iterations": 2.3913e+09,
    "max": 1177.9,
    "min": 2.073,
    "mean": 2.11942
   },
   "qNaN": {
    "duration": 5.08857e+09,
    "iterations": 9.45656e+08,
    "max": 2658.83,
    "min": 5.09,
    "mean": 5.38099
   },
   "sNaN": {
    "duration": 5.08093e+09,
    "iterations": 1.16725e+09,
    "max": 1030.74,
    "min": 3.323,
    "mean": 4.3529
   }
  }

Both were run with GCC 5.4 (ubuntu 16 default installation) using default
compiler flags on POWER8E 3.4GHz (powerpc64le-linux-gnu).

7 years agoFix typo in manual for iseqsig
Gabriel F. T. Gomes [Tue, 29 Nov 2016 15:48:24 +0000 (13:48 -0200)] 
Fix typo in manual for iseqsig

7 years agoDeclare getentropy in <unistd.h> [BZ #17252]
Florian Weimer [Tue, 27 Dec 2016 16:13:21 +0000 (17:13 +0100)] 
Declare getentropy in <unistd.h> [BZ #17252]

7 years agoresolv: Remove processing of unimplemented "spoof" host.conf options
Florian Weimer [Tue, 27 Dec 2016 15:01:06 +0000 (16:01 +0100)] 
resolv: Remove processing of unimplemented "spoof" host.conf options

7 years agosunrpc: Always obtain AF_INET addresses from NSS [BZ #20964]
Florian Weimer [Tue, 27 Dec 2016 15:44:15 +0000 (16:44 +0100)] 
sunrpc: Always obtain AF_INET addresses from NSS [BZ #20964]

The new __libc_rpc_gethostbyname function calls gethostbyname2_r
with an AF_INET argument and is therefore not affected by the
RES_USE_INET6 flag.

Validated with the following test program, with and without
RES_OPTIONS=inet6, against a NFS server.  (Link with -lrpcsvc.)

#include <rpc/clnt.h>
#include <rpcsvc/mount.h>
#include <stdio.h>
#include <string.h>

static void
usage (char **argv)
{
  printf ("usage:\n"
          "  %1$s HOST getrpcport\n"
          "  %1$s HOST callrpc\n"
          "  %1$s HOST clnt_create\n",
          argv[0]);
}

static void
dump_exports (struct exportnode *exports)
{
  while (exports != NULL)
    {
      printf ("%s\n", exports->ex_dir);
      exports = exports->ex_next;
    }
}

int
main (int argc, char **argv)
{
  if (argc != 3)
    {
      usage (argv);
      return 1;
    }

  const char *host = argv[1];
  const char *command = argv[2];

  if (strcmp (command, "getrpcport") == 0)
    {
      int port = getrpcport (host, MOUNTPROG, MOUNTVERS, IPPROTO_UDP);
      printf ("getrpcport: %d\n", port);
    }
  else if (strcmp (command, "callrpc") == 0)
    {
      struct exportnode *exports = NULL;
      int ret = callrpc (host, MOUNTPROG, MOUNTVERS, MOUNTPROC_EXPORT,
                         (xdrproc_t) xdr_void, NULL,
                         (xdrproc_t) xdr_exports, (char *)&exports);
      if (ret != 0)
        {
          clnt_perrno (ret);
          puts ("");
          return 1;
        }
      dump_exports (exports);
    }
  else if (strcmp (command, "clnt_create") == 0)
    {
      CLIENT *client = clnt_create
        (host, MOUNTPROG, MOUNTVERS, "udp");
      if (client == NULL)
        {
          printf ("error: clnt_create failed\n");
          return 1;
        }
      struct exportnode *exports = NULL;
      int ret = CLNT_CALL (client, MOUNTPROC_EXPORT,
                           (xdrproc_t) xdr_void, NULL,
                           (xdrproc_t) xdr_exports, (char *)&exports,
                           ((struct timeval) {15, 0}));
      if (ret != 0)
        {
          clnt_perrno (ret);
          puts ("");
          return 1;
        }
      dump_exports (exports);
    }
  else
    {
      usage (argv);
      return 1;
    }

  return 0;
}

7 years agorpcinfo: Remove traces of unbuilt helper program
Florian Weimer [Tue, 27 Dec 2016 13:56:32 +0000 (14:56 +0100)] 
rpcinfo: Remove traces of unbuilt helper program

7 years agoFix x86_64 memchr for large input sizes
Adhemerval Zanella [Thu, 15 Dec 2016 20:17:09 +0000 (18:17 -0200)] 
Fix x86_64 memchr for large input sizes

Current optimized memchr for x86_64 does for input arguments pointers
module 64 in range of [49,63] if there is no searchr char in the rest
of 64-byte block a pointer addition which might overflow:

* sysdeps/x86_64/memchr.S

    77          .p2align 4
    78  L(unaligned_no_match):
    79          add     %rcx, %rdx

Add (uintptr_t)s % 16 to n in %rdx.

    80          sub     $16, %rdx
    81          jbe     L(return_null)

This patch fixes by adding a saturated math that sets a maximum pointer
value if it overflows (UINTPTR_MAX).

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

[BZ# 19387]
* sysdeps/x86_64/memchr.S (memchr): Avoid overflow in pointer
addition.
* string/test-memchr.c (do_test): Remove alignment limitation.
(test_main): Add test that trigger BZ# 19387.

7 years agoEnable -fstack-protector=* when requested by configure [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:10 +0000 (10:09 +0100)] 
Enable -fstack-protector=* when requested by configure [BZ #7065]

7 years agoDo not stack-protect sigreturn stubs [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:06 +0000 (10:09 +0100)] 
Do not stack-protect sigreturn stubs [BZ #7065]

These are called from the kernel with the stack at a carefully-
chosen location so that the stack frame can be restored: they must not
move the stack pointer lest garbage be restored into the registers.

We explicitly inhibit protection for SPARC and for signal/sigreturn.c:
other arches either define their sigreturn stubs in .S files, or (i386,
x86_64, mips) use macros expanding to top-level asm blocks and explicit
labels in the text section to mock up a "function" without telling the
compiler that one is there at all.

7 years agoDrop explicit stack-protection of pieces of the system [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:03 +0000 (10:09 +0100)] 
Drop explicit stack-protection of pieces of the system [BZ #7065]

7 years agoLink a non-libc-using test with -fno-stack-protector [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:00 +0000 (10:09 +0100)] 
Link a non-libc-using test with -fno-stack-protector [BZ #7065]

This test cannot reference __stack_chk_fail because it is not linked
with libc at all.

7 years agoPLT avoidance for __stack_chk_fail [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:57 +0000 (10:08 +0100)] 
PLT avoidance for __stack_chk_fail [BZ #7065]

Add a hidden __stack_chk_fail_local alias to libc.so,
and make sure that on targets which use __stack_chk_fail,
this does not introduce a local PLT reference into libc.so.

7 years agoWork even with compilers which enable -fstack-protector by default [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:54 +0000 (10:08 +0100)] 
Work even with compilers which enable -fstack-protector by default [BZ #7065]

With all the machinery we just added, we can easily arrange to work even
when the compiler passes in -fstack-protector automatically: all the
necessary bits of glibc are always compiled with -fno-stack-protector
now.

So tear out the check in configure, and add appropriate calls to
-fno-stack-protector in tests that need them (largely those that use
-nostdlib), since we don't yet have a __stack_chk_fail that those
tests can rely upon.  (GCC often provides one, but we cannot rely on
this, especially not when bootstrapping.)

When stack protection is disabled, explicitly pass -fno-stack-protector
to everything, to stop a compiler hacked to enable it from inserting
calls to __stack_chk_fail via the PLT in every object file.

7 years agoIgnore __stack_chk_fail* in the rtld mapfile computation [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:51 +0000 (10:08 +0100)] 
Ignore __stack_chk_fail* in the rtld mapfile computation [BZ #7065]

The previous commit prevented rtld itself from being built with
-fstack-protector, but this is not quite enough.  We identify which
objects belong in rtld via a test link and analysis of the resulting
mapfile.  That link is necessarily done against objects that are
stack-protected, so drags in __stack_chk_fail_local, __stack_chk_fail,
and all the libc and libio code they use.

To stop this happening, use --defsym in the test librtld.map-production
link to force the linker to predefine these two symbols (to 0, but it
could be to anything).  (In a real link, this would of course be
catastrophic, but these object files are never used for anything else.)

7 years agoCompile the dynamic linker without stack protection [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:48 +0000 (10:08 +0100)] 
Compile the dynamic linker without stack protection [BZ #7065]

Also compile corresponding routines in the static libc.a with the same
flag.

7 years agoDisable stack protector in early static initialization [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:45 +0000 (10:08 +0100)] 
Disable stack protector in early static initialization [BZ #7065]

The startup code in csu/, and the brk and sbrk functions are
needed very early in initialization of a statically-linked program,
before the stack guard is initialized; TLS initialization also uses
memcpy, which cannot overrun its own stack.  Mark all of these as
-fno-stack-protector.

We also finally introduce @libc_cv_ssp@ and @no_stack_protector@, both
substituted by the configury changes made earlier, to detect the case
when -fno-stack-protector is supported by the compiler, and
unconditionally pass it in when this is the case, whether or not
--enable-stack-protector is passed to configure.  (This means that
it'll even work when the compiler's been hacked to pass
-fstack-protector by default, unless the hackage is so broken that
it does so in a way that is impossible to override.)

7 years agoDo not stack-protect ifunc resolvers [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:41 +0000 (10:08 +0100)] 
Do not stack-protect ifunc resolvers [BZ #7065]

When dynamically linking, ifunc resolvers are called before TLS is
initialized, so they cannot be safely stack-protected.

We avoid disabling stack-protection on large numbers of files by
using __attribute__ ((__optimize__ ("-fno-stack-protector")))
to turn it off just for the resolvers themselves.  (We provide
the attribute even when statically linking, because we will later
use it elsewhere too.)

7 years agoInitialize the stack guard earlier when linking statically [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:34 +0000 (10:08 +0100)] 
Initialize the stack guard earlier when linking statically [BZ #7065]

The address of the stack canary is stored in a per-thread variable,
which means that we must ensure that the TLS area is intialized before
calling any -fstack-protector'ed functions.  For dynamically linked
applications, we ensure this (in a later patch) by disabling
-fstack-protector for the whole dynamic linker, but for static
applications, the AT_ENTRY address is called directly by the kernel, so
we must deal with the problem differently.

In static appliations, __libc_setup_tls performs the TCB setup and TLS
initialization, so this commit arranges for it to be called early and
unconditionally.  The call (and the stack guard initialization) is
before the DL_SYSDEP_OSCHECK hook, which if set will probably call
functions which are stack-protected (it does on Linux and NaCL too).  We
also move apply_irel up, so that we can still safely call functions that
require ifuncs while in __libc_setup_tls (though if stack-protection is
enabled we still have to avoid calling functions that are not
stack-protected at this stage).

7 years agoConfigure support for --enable-stack-protector [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:18 +0000 (10:08 +0100)] 
Configure support for --enable-stack-protector [BZ #7065]

This adds =all and =strong, with obvious semantics, defaulting to off.

We don't validate the value of the option yet: that's in a later patch.
Nor do we use it for anything at this stage.

We differentiate between 'the compiler understands -fstack-protector'
and 'the user wanted -fstack-protector' so that we can pass
-fno-stack-protector in appropriate places even if the user didn't want
to turn on -fstack-protector for other parts.  (This helps us overcome
another existing limitation, that glibc doesn't work with GCCs hacked
to pass in -fstack-protector by default.)

We also arrange to set the STACK_PROTECTOR_LEVEL #define to a value
appropriate for the stack-protection level in use for each file in
particular.

7 years agoFix failing pretty printer tests when CPPFLAGS has optimizations.
Carlos O'Donell [Fri, 23 Dec 2016 18:46:56 +0000 (13:46 -0500)] 
Fix failing pretty printer tests when CPPFLAGS has optimizations.

The value of CPPFLAGS provided by the environment may have optimizations
that interfere with the pretty printer test requirements. To override
such optimizations the pretty printer tests must also specify CPPFLAGS.
The existing pretty printer tests are fixed and the
README.pretty-printers is updated with the new requirement.

7 years agoAdd deferred cancellation regression test for getpwuid_r.
Carlos O'Donell [Fri, 23 Dec 2016 18:39:23 +0000 (13:39 -0500)] 
Add deferred cancellation regression test for getpwuid_r.

The fix in commit 312be3f9f5eab1643d7dcc7728c76d413d4f2640 resolved
several cancellation issues in several APIs.  This regression test is
designed to double check that at least getpwuid_r remainds correctly
implemented and does not provide additional unintended cancellation
points that may leave locks in an inconsistent state.

7 years agoBug 11941: ld.so: Improper assert map->l_init_called in dlclose
Carlos O'Donell [Fri, 23 Dec 2016 18:30:22 +0000 (13:30 -0500)] 
Bug 11941: ld.so: Improper assert map->l_init_called in dlclose

There is at least one use case where during exit a library destructor
might call dlclose() on a valid handle and have it fail with an
assertion. We must allow this case, it is a valid handle, and dlclose()
should not fail with an assert. In the future we might be able to return
an error that the dlclose() could not be completed because the opened
library has already been unloaded and destructors have run as part of
exit processing.

For more details see:
https://www.sourceware.org/ml/libc-alpha/2016-12/msg00859.html

7 years agoscripts/test_printers_common.py: Log GDB error message
Florian Weimer [Fri, 23 Dec 2016 14:13:28 +0000 (15:13 +0100)] 
scripts/test_printers_common.py: Log GDB error message

If GDB prints an error message for a "python" command, include
that error message in the test log output, to simplify diagnosing
GDB/Python detection issues.

7 years agoAdd configure check for python program
Siddhesh Poyarekar [Thu, 22 Dec 2016 17:37:52 +0000 (23:07 +0530)] 
Add configure check for python program

Add a configure check that looks for python3 and python in that order
since we had agreed in the past to prefer python3 over python in all
our code.  The patch also adjusts invocations through the various
Makefiles to use the set variable.

* configure.ac: Check for python3 or python.
* configure: Regenerated.
* config.make.in (PYTHON): New variable.
* benchtests/Makefile: Don't define PYTHON.
(bench): Define target only if PYTHON was defined.
* Rules: Don't define PYTHON.
Define pretty printer targets only if PYTHON was defined.
(tests-printers): Add to tests-unsupported if PYTHON is not
found.
(python-flags, python-invoke): Remove.
(tests-printers-out): Use PYTHON instead of python-invoke.

7 years agoUpdate NEWS feature test macro description of TS 18661-1 support.
Joseph Myers [Thu, 22 Dec 2016 00:04:58 +0000 (00:04 +0000)] 
Update NEWS feature test macro description of TS 18661-1 support.

The NEWS entry for the feature test macro
__STDC_WANT_IEC_60559_BFP_EXT__ describes the state of support for
that TS as "most features from that TS are not supported by the GNU C
Library".  This patch updates it to say "not all features from that TS
are supported by the GNU C Library".

(The functions not yet supported are the fromfp functions - I'm
working on them, but they may not be done before the freeze - and the
functions round result to narrower type - which definitely won't be
started for 2.25, since they require significant infrastructure work.
That's 30 functions, which is less than half the number of functions
in the TS, so saying "most" now seems inaccurate.)

7 years agoFix nss_nisplus build with mainline GCC (bug 20978).
Joseph Myers [Wed, 21 Dec 2016 23:44:01 +0000 (23:44 +0000)] 
Fix nss_nisplus build with mainline GCC (bug 20978).

glibc build with current mainline GCC fails because
nis/nss_nisplus/nisplus-alias.c contains code

  if (name != NULL)
    {
      *errnop = EINVAL;
      return NSS_STATUS_UNAVAIL;
    }

  char buf[strlen (name) + 9 + tablename_len];

producing an error about strlen being called on a pointer that is
always NULL (and a subsequent use of that pointer with a %s format in
snprintf).

As Andreas noted, the bogus conditional comes from a 1997 change:

-  if (name == NULL || strlen(name) > 8)
-    return NSS_STATUS_NOTFOUND;
-  else
+  if (name != NULL || strlen(name) <= 8)

So the intention is clearly to return an error for NULL name.

This patch duly inverts the sense of the conditional.  It fixes the
build with GCC mainline, and passes usual glibc testsuite testing for
x86_64.  However, I have not tried any actual substantive nisplus
testing, do not have an environment for such testing, and do not know
whether it is possible that strlen (name) or tablename_len might be
large so that the VLA for buf is actually a security issue.  However,
if it is a security issue, there are plenty of other similar instances
in the nisplus code (that haven't been hidden by a bogus comparison
with NULL) - and nis_table.c:__create_ib_request uses strdupa on the
string passed to nis_list, so a local fix in the caller wouldn't
suffice anyway (see bug 20987).  (Calls to strdupa and other such
macros that use alloca must be considered equally questionable
regarding stack overflow issues as direct calls to alloca and VLA
declarations.)

[BZ #20978]
* nis/nss_nisplus/nisplus-alias.c (_nss_nisplus_getaliasbyname_r):
Compare name == NULL, not name != NULL.

7 years agoUpdate miscellaneous files from upstream sources.
Joseph Myers [Wed, 21 Dec 2016 16:05:55 +0000 (16:05 +0000)] 
Update miscellaneous files from upstream sources.

This patch updates texinfo.tex and various miscellaneous scripts to
their latest upstream versions.  (There may be another update in early
January to bring in 2017 copyright dates, if the upstream versions get
updated with such dates promptly.)

Tested for x86_64.

* manual/texinfo.tex: Update to version 2016-09-18.18 with
trailing whitespace removed.
* scripts/config.guess: Update to version 2016-10-02.
* scripts/config.sub: Update to version 2016-11-19.
* scripts/install-sh: Update to version 2016-01-11.22.
* scripts/mkinstalldirs: Update to version 2016-01-11.22.
* scripts/move-if-change: Update to version 2016-01-11 22:04.

7 years agoThis patch cleans up the strsep implementation and improves performance.
Wilco Dijkstra [Wed, 21 Dec 2016 15:16:29 +0000 (15:16 +0000)] 
This patch cleans up the strsep implementation and improves performance.
Currently strsep calls strpbrk is is now a veneer to strcspn.  Calling
strcspn directly is faster.  Since it handles a delimiter string of size
1 as a special case, this is not needed in strsep itself.  Although this
means there is a slightly higher overhead if the delimiter size is 1,
all other cases are slightly faster.  The overall performance gain is 5-10%
on AArch64.

The string/bits/string2.h header contains optimizations for constant
delimiters of size 1-3.  Benchmarking these showed similar performance for
size 1 (since in all cases strchr/strchrnul is used), while size 2 and 3
can give up to 2x speedup for small input strings.  However if these cases
are common it seems much better to add this optimization to strcspn.
So move these header optimizations to string-inlines.c.

Improve the strsep benchmark so that it actually benchmarks something.
The current version contains a delimiter character at every position in the
input string, so there is very little work to do, and the extremely inefficent
simple_strsep implementation appears fastest in every case.  The new version
has either no match in the input for the fail case and a match halfway in the
input for the success case.  The input is then restored so that each iteration
does exactly the same amount of work.  Reduce the number of testcases since
simple_strsep takes a lot of time now.

* benchtests/bench-strsep.c (oldstrsep): Add old implementation.
(do_one_test) Restore original string so iteration works.
* string/string-inlines.c (do_test): Create better input strings.
(test_main) Reduce number of testruns.
* string/string-inlines.c (__old_strsep_1c): New function.
(__old_strsep_2c): Likewise.
(__old_strsep_3c): Likewise.
* string/strsep.c (__strsep): Remove case of small delim string.
Call strcspn directly rather than strpbrk.
* string/bits/string2.h (__strsep): Remove define.
(__strsep_1c): Remove.
(__strsep_2c): Remove.
(__strsep_3c): Remove.
(strsep): Remove.
* sysdeps/unix/sysv/linux/internal_statvfs.c
(__statvfs_getflags): Rename to __strsep.

7 years agoRemove unused function _dl_tls_setup
Florian Weimer [Wed, 21 Dec 2016 13:30:56 +0000 (14:30 +0100)] 
Remove unused function _dl_tls_setup

Commit 7a5e3d9d633c828d84a9535f26b202a6179978e7 (elf: Assume TLS is
initialized in _dl_map_object_from_fd) removed the last call of
_dl_tls_setup, but did not remove the function itself.

7 years agox86_64: tst-quad1pie, tst-quad2pie: compile with -fPIE [BZ #7065]
Nick Alcock [Wed, 21 Dec 2016 11:04:12 +0000 (12:04 +0100)] 
x86_64: tst-quad1pie, tst-quad2pie: compile with -fPIE [BZ #7065]

With stack protection enabled, these files have external symbol
references for the first time, so the fact that they are not compiled
with -fPIE and are then linked into a -pie binary starts to hurt.

7 years agoMove all tests out of the csu subdirectory
Nick Alcock [Wed, 21 Dec 2016 10:52:19 +0000 (11:52 +0100)] 
Move all tests out of the csu subdirectory

Stack-protection on .o files in csu/ must be suppressed for the sake of
library startup code.  This also suppresses stack-protection in tests
(which are also covered by CFLAGS-.o), though this is neither necessary
nor desirable.

So impose the rule that .o files in csu/ are necessarily C startup code,
and move the few tests in there into misc/ instead.

7 years agomanual: Convert @tables of variables to @vtables.
Rical Jasan [Wed, 21 Dec 2016 09:36:58 +0000 (01:36 -0800)] 
manual: Convert @tables of variables to @vtables.

Texinfo @vindex commands add entries to the Variable and Constant
Macro Index.  Similarly, @items in @vtables are automatically indexed.
A number of @tables exist where all @items are @vindexed or all @items
are variables, but not indexed, suggesting an optimization by
converting such @tables to @vtables and dropping the @vindex.

Using a @vtable provides a context for processing @items whereby it
can be known the @items should have header and standards annotations.
This commit converts @tables of such @items to @vtables in order to
establish a framework for automated processing.

A pleasant consequence of these changes is that @items previously
lacking a @vindex are present in the Variable and Constant Macro Index
now.  @vindex entries previously detected by summary.awk will still be
detected as @items with appropriate annotations.

The @vtable of the NSS databases is converted to a @table because 1)
those @items are not variables (and will no longer appear in the
Variable and Constant Macro Index) and 2) they do not need header and
standards annotations, so the incorrect context is fixed.

* manual/nss.texi: Change incorrect @vtable to @table.
* manual/arith.texi: Convert @tables of variables to @vtables
and remove unnecessary indexing.
* manual/filesys.texi: Likewise.
* manual/llio.texi: Likewise.
* manual/memory.texi: Likewise.
* manual/process.texi: Likewise.
* manual/resource.texi: Likewise.
* manual/search.texi: Likewise.
* manual/signal.texi: Likewise.
* manual/socket.texi: Likewise.
* manual/stdio.texi: Likewise.
* manual/sysinfo.texi: Likewise.
* manual/syslog.texi: Likewise.
* manual/terminal.texi: Likewise.
* manual/time.texi: Likewise.
* manual/users.texi: Likewise.

7 years agoAdd roundeven, roundevenf, roundevenl.
Joseph Myers [Wed, 21 Dec 2016 01:48:27 +0000 (01:48 +0000)] 
Add roundeven, roundevenf, roundevenl.

TS 18661-1 defines roundeven functions that round a floating-point
number to the nearest integer, in that floating-point type, with ties
rounding to even (whereas the round functions round ties away from
zero).  As with other such functions, they raise no exceptions apart
from "invalid" for signaling NaNs.  There was a previous user request
for this functionality in glibc in
<https://sourceware.org/ml/libc-help/2015-02/msg00005.html>.

This patch implements these functions for glibc.  The implementations
use integer bit-manipulation (or roundeven on the high and low parts,
in the IBM long double case).  It's possible that there may be faster
approaches on some architectures (in particular, on AArch64 the frintn
instruction should do exactly what's required); I'll leave it to
architecture maintainers or others interested to implement such
architecture-specific versions if desired.  (Where architectures have
instructions to round to nearest integer in the current rounding mode,
implementations saving and restoring the rounding mode - and dealing
with exceptions if those instructions generate "inexact" - are also
possible, though their performance depends on the cost of manipulating
exceptions / rounding mode state.)

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(roundeven): New declaration.
* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (roundeven): New
macro.
* math/Versions (roundeven): New libm symbol at version
GLIBC_2.25.
(roundevenf): Likewise.
(roundevenl): Likewise.
* math/Makefile (libm-calls): Add s_roundevenF.
* math/libm-test.inc (roundeven_test_data): New array.
(roundeven_test): New function.
(main): Call roundeven_test.
* math/test-tgmath.c (NCALLS): Increase to 134.
(F(compile_test)): Call roundeven.
(F(roundeven)): New function.
* manual/arith.texi (Rounding Functions): Document roundeven,
roundevenf and roundevenl.
* manual/libm-err-tab.pl (@all_functions): Add roundeven.
* include/math.h (roundeven): Use libm_hidden_proto.
* sysdeps/ieee754/dbl-64/s_roundeven.c: New file.
* sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c: Likewise.
* sysdeps/ieee754/flt-32/s_roundevenf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_roundevenl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_roundevenl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_roundevenl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
roundeven.
(CFLAGS-nldbl-roundeven.c): New variable.
* sysdeps/ieee754/ldbl-opt/nldbl-roundeven.c: New file.
* 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 agoAdd preprocessor indentation for llogb macro in tgmath.h.
Joseph Myers [Tue, 20 Dec 2016 21:23:04 +0000 (21:23 +0000)] 
Add preprocessor indentation for llogb macro in tgmath.h.

* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (llogb): Add
preprocessor indentation inside #if.

7 years agoReplace use of snprintf with strfrom in libm tests
Gabriel F. T. Gomes [Tue, 27 Sep 2016 18:28:49 +0000 (15:28 -0300)] 
Replace use of snprintf with strfrom in libm tests

In order to support float128 tests, the calls to snprintf, which does
not support the type __float128, are replaced with calls to
strfrom{f,d,l}.

Tested for powerpc64le, s390, and x64_64.

7 years agoS390: Optimize lock-elision by decrementing adapt_count at unlock.
Stefan Liebler [Tue, 20 Dec 2016 14:12:48 +0000 (15:12 +0100)] 
S390: Optimize lock-elision by decrementing adapt_count at unlock.

This patch decrements the adapt_count while unlocking the futex
instead of before aquiring the futex as it is done on power, too.
Furthermore a transaction is only started if the futex is currently free.
This check is done after starting the transaction, too.
If the futex is not free and the transaction nesting depth is one,
we can simply end the started transaction instead of aborting it.
The implementation of this check was faulty as it always ended the
started transaction.  By using the fallback path, the the outermost
transaction was aborted.  Now the outermost transaction is aborted
directly.

This patch also adds some commentary and aligns the code in
elision-trylock.c to the code in elision-lock.c as possible.

ChangeLog:

* sysdeps/unix/sysv/linux/s390/lowlevellock.h
(__lll_unlock_elision, lll_unlock_elision): Add adapt_count argument.
* sysdeps/unix/sysv/linux/s390/elision-lock.c:
(__lll_lock_elision): Decrement adapt_count while unlocking
instead of before locking.
* sysdeps/unix/sysv/linux/s390/elision-trylock.c
(__lll_trylock_elision): Likewise.
* sysdeps/unix/sysv/linux/s390/elision-unlock.c:
(__lll_unlock_elision): Likewise.

7 years agoS390: Use new __libc_tbegin_retry macro in elision-lock.c.
Stefan Liebler [Tue, 20 Dec 2016 14:12:48 +0000 (15:12 +0100)] 
S390: Use new __libc_tbegin_retry macro in elision-lock.c.

This patch implements __libc_tbegin_retry macro which is equivalent to
gcc builtin __builtin_tbegin_retry, except the changes which were applied
to __libc_tbegin in the previous patch.

If tbegin aborts with _HTM_TBEGIN_TRANSIENT.  Then this macros restores
the fpc, fprs and automatically retries up to retry_cnt tbegins.
Further saving of the state is omitted as it is already saved in the
first round.  Before retrying a further transaction, the
transaction-abort-assist instruction is used to support the cpu.

This macro is now used in function __lll_lock_elision.

ChangeLog:

* sysdeps/unix/sysv/linux/s390/htm.h(__libc_tbegin_retry): New macro.
* sysdeps/unix/sysv/linux/s390/elision-lock.c (__lll_lock_elision):
Use __libc_tbegin_retry macro.

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.