Commit Graph

10138 Commits

Author SHA1 Message Date
Joseph Myers 8a9fa0086d Fix ldbl-128ibm ceill for non-default rounding modes (bug 19592).
The ldbl-128ibm implementation of ceill is only correct in
round-to-nearest mode (in other modes, there are incorrect results and
overflow exceptions in some cases).  It is also unnecessarily
complicated, rounding both high and low parts to the nearest integer
and then adjusting for the semantics of ceil, when it seems more
natural to take the ceiling of the high part (__ceil optimized inline
versions can be used), and that of the low part if the high part is an
integer, as was done for floorl.  This patch makes it use that simpler
approach.

Tested for powerpc.

	[BZ #19592]
	* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Use __ceil on
	high and low parts then use ldbl_canonicalize_int if needed.
2016-02-18 21:40:39 +00:00
Joseph Myers 1833769e19 Fix ldbl-128ibm floorl for non-default rounding modes (bug 17899).
The ldbl-128ibm implementation of floorl is only correct in
round-to-nearest mode (in other modes, there are incorrect results and
overflow exceptions in some cases going beyond the incorrect signs of
zero results noted in bug 17899).  It is also unnecessarily
complicated, rounding both high and low parts to the nearest integer
and then adjusting for the semantics of floor, when it seems more
natural to take the floor of the high part (__floor optimized inline
versions can be used), and that of the low part if the high part is an
integer.  This patch makes it use that simpler approach, with a
canonicalization that works in all rounding modes (given that the only
way the result can be noncanonical is if taking the floor of a
negative noninteger low part increased its exponent).

Tested for powerpc, where over a thousand failures are removed from
test-ldouble.out (floorl problems affect many powl tests).

	[BZ #17899]
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h (ldbl_canonicalize_int):
	New function.
	* sysdeps/ieee754/ldbl-128ibm/s_floorl.c (__floorl): Use __floor
	on high and low parts then use ldbl_canonicalize_int if needed.
2016-02-18 21:31:10 +00:00
H.J. Lu 16396c41de Add _STRING_INLINE_unaligned and string_private.h
As discussed in

https://sourceware.org/ml/libc-alpha/2015-10/msg00403.html

the setting of _STRING_ARCH_unaligned currently controls the external
GLIBC ABI as well as selecting the use of unaligned accesses withing
GLIBC.

Since _STRING_ARCH_unaligned was recently changed for AArch64, this
would potentially break the ABI in GLIBC 2.23, so split the uses and add
_STRING_INLINE_unaligned to select the string ABI. This setting must be
fixed for each target, while _STRING_ARCH_unaligned may be changed from
release to release.  _STRING_ARCH_unaligned is used unconditionally in
glibc.  But <bits/string.h>, which defines _STRING_ARCH_unaligned, isn't
included with -Os.  Since _STRING_ARCH_unaligned is internal to glibc and
may change between glibc releases, it should be made private to glibc.
_STRING_ARCH_unaligned should defined in the new string_private.h heade
file which is included unconditionally from internal <string.h> for glibc
build.

	[BZ #19462]
	* bits/string.h (_STRING_ARCH_unaligned): Renamed to ...
	(_STRING_INLINE_unaligned): This.
	* include/string.h: Include <string_private.h>.
	* string/bits/string2.h: Replace _STRING_ARCH_unaligned with
	_STRING_INLINE_unaligned.
	* sysdeps/aarch64/bits/string.h (_STRING_ARCH_unaligned): Removed.
	(_STRING_INLINE_unaligned): New.
	* sysdeps/aarch64/string_private.h: New file.
	* sysdeps/generic/string_private.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/string_private.h: Likewise.
	* sysdeps/s390/string_private.h: Likewise.
	* sysdeps/x86/string_private.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/bits/string.h
	(_STRING_ARCH_unaligned): Renamed to ...
	(_STRING_INLINE_unaligned): This.
	* sysdeps/s390/bits/string.h (_STRING_ARCH_unaligned): Renamed
	to ...
	(_STRING_INLINE_unaligned): This.
	* sysdeps/sparc/bits/string.h (_STRING_ARCH_unaligned): Renamed
	to ...
	(_STRING_INLINE_unaligned): This.
	* sysdeps/x86/bits/string.h (_STRING_ARCH_unaligned): Renamed
	to ...
	(_STRING_INLINE_unaligned): This.
2016-02-18 14:55:29 -02:00
Andrew Senkevich a5df3210a6 Use PIC relocation in ALIAS_IMPL
Since libmvec_nonshared.a may be linked into shared objects, ALIAS_IMPL
should use PIC relocation.

	[BZ #19590]
	* sysdeps/x86_64/fpu/svml_finite_alias.S (ALIAS_IMPL): Use PIC
	relocation.
2016-02-17 14:23:32 -08:00
Rajalakshmi Srinivasaraghavan ebf1264f61 powerpc: Regenerate libm-test-ulps 2016-02-04 16:40:54 -02:00
Joseph Myers 5163b4b76f Fix MIPS mmap negative offset handling for consistency (bug 19550).
The handling of negative offsets in MIPS mmap is inconsistent with
other architectures, as shown by failure of the test
posix/tst-mmap-offset for o32 and n32.  The MIPS mmap syscall uses a
signed argument and does a signed arithmetic shift on it, whereas the
glibc semantics expected by that test are for the offset to be
considered as a large positive offset.  This patch makes MIPS
consistent with other architectures as far as possible by using the
mmap2 syscall on o32 (#including the generic implementation), and
making mmap not an alias for mmap64 for n32, with a custom
implementation for n32 that zero-extends the offset argument to 64-bit
before calling the mmap syscall.

Tested for MIPS64 (o32, n32, n64).

	[BZ #19550]
	* sysdeps/unix/sysv/linux/mips/mips32/mmap.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips64/mmap64.c: Move to ....
	* sysdeps/unix/sysv/linux/mips/mips64/n64/mmap64.c: ... here.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/mmap.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (mmap64):
	New syscall entry.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list (mmap):
	New syscall entry.
	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (mmap): Remove
	syscall entry.
2016-02-01 18:20:21 +00:00
Steve Ellcey 8a71d2e27f Fix MIPS64 memcpy regression.
The MIPS memcpy optimizations at
<https://sourceware.org/ml/libc-alpha/2015-10/msg00597.html>
introduced a bug causing many string function tests to fail with
segfaults for n32 and n64:

FAIL: string/stratcliff
FAIL: string/test-bcopy
FAIL: string/test-memccpy
FAIL: string/test-memcmp
FAIL: string/test-memcpy
FAIL: string/test-memmove
FAIL: string/test-mempcpy
FAIL: string/test-stpncpy
FAIL: string/test-strncmp
FAIL: string/test-strncpy

(Some failures in other directories could also be caused by this bug.)

The problem is that after the check for whether a word of input is
left that can be copied as a word before moving to byte copies, a load
can occur in the branch delay slot, resulting in a segfault if we are
at the end of a page and the following page is unmapped.  I don't see
how this would have passed the tests as reported in the original patch
posting (different kernel configurations affecting the code setting up
unmapped pages, maybe?), since the tests in question don't appear to
have changed recently.

This patch moves a later instruction into the delay slot, as suggested
at <https://sourceware.org/ml/libc-alpha/2016-01/msg00584.html>.

Tested for n32 and n64.

2016-01-28  Steve Ellcey  <sellcey@imgtec.com>
            Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/mips/memcpy.S (MEMCPY_NAME) [USE_DOUBLE]: Avoid word
	load in branch delay slot when less than a word of input left.
2016-01-28 01:52:05 +00:00
Andreas Schwab 4fb66fac3a Remove unused variables
They are flagged by -Wunused-const-variable.
2016-01-27 09:30:16 +01:00
David S. Miller 6ef1cb957e Update localplt.data for 32-bit sparc.
* sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data: Add _Q_cmp.
2016-01-26 16:16:38 -08:00
David S. Miller 82e5836613 Define __sqrtl_finite on sparc 32-bit with correct symbol version.
* sysdeps/sparc/sparc32/Versions (GLIBC_2.23): Add entry for __sqrtl_finite.
	* sysdeps/sparc/sparc32/fpu/e_sqrtl.c (__sqrtl_finite): Define instead using
	versioned_symbol.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Fix ordering of entries.
2016-01-25 16:07:15 -08:00
David S. Miller 7a18c2a0c1 Adjust sparc 32-bit __sqrtl_finite version tag.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Move
	__sqrtl_finite to GLIBC_2.23
2016-01-25 10:42:17 -08:00
Richard Henderson 89cfb554b8 Update Alpha libm-test-ulps 2016-01-25 10:43:41 -08:00
Paul E. Murphy 9200e581e5 Cleanup ppc bits/ipc.h
Ages ago (commit e9dcb08) the ipc syscalls were inlined and
eventually abstracted away any need for direct __ipc calls.
2016-01-25 10:35:21 -02:00
David S. Miller c34ae92056 Fix missing __sqrtl_finite symbol in libm on sparc 32-bit.
* sysdeps/sparc/sparc32/fpu/e_sqrtl.c: New file.
	* sysdeps/sparc/sparc32/soft-fp/q_sqrt.c (__ieee754_sqrtl): Remove alias.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Add __sqrtl_finite.
2016-01-24 21:14:12 -08:00
David S. Miller a9d460a977 Update sparc ULPS.
* sysdeps/sparc/fpu/libm-test-ulps: Update.
2016-01-24 21:12:58 -08:00
Maciej W. Rozycki d5f2798a0a MIPS: Set the required Linux kernel version to 4.5.0 for 2008 NaN
Complement the addition of the required kernel support, present upstream
as from commit 2b5e869ecfcb3112f7e1267cb0328f3ff6d49b18 ("MIPS: ELF:
Interpret the NAN2008 file header flag") and released with Linux 4.5-rc1
on Jan 24th, 2016.

	* sysdeps/unix/sysv/linux/mips/configure.ac: Set
	`arch_minimum_kernel' to 4.5.0 if 2008 NaN encoding is used.
	* sysdeps/unix/sysv/linux/mips/configure: Regenerate.
2016-01-25 00:19:27 +00:00
Paul E. Murphy af8ea0f449 powerpc: Fix macro usage of htm builtins
Some extraneous semicolons were included in a
recent patch which causes a build failure with
newer compilers.
2016-01-22 14:13:08 -02:00
Chung-Lin Tang fba91f1232 Maintainence patch for nios2: update ULPS file and localplt.data changes. 2016-01-21 22:58:03 -08:00
Roland McGrath a3140836c8 NaCl: Fix unused variable errors in lowlevellock-futex.h macros. 2016-01-20 13:57:14 -08:00
Paul Pluzhnikov b274130206 2016-01-20 Paul Pluzhnikov <ppluzhnikov@google.com>
[BZ #19490]
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S (pthread_cond_broadcast): Use ENTRY/END
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S (pthread_cond_signal): Likewise
* sysdeps/x86_64/nptl/pthread_spin_lock.S (pthread_spin_lock): Likewise
* sysdeps/x86_64/nptl/pthread_spin_trylock.S (pthread_spin_trylock): Likewise
* sysdeps/x86_64/nptl/pthread_spin_unlock.S (pthread_spin_unlock): Likewise
2016-01-20 13:39:20 -08:00
Joseph Myers dcb133b7a4 Fix __finitel libm compat symbol version.
The changes to restrict implementation-namespace symbol aliases such
as __finitel to compat symbols used code for __finitel in libm
analogous to that for __finitel in libc.  However, the versions for
the two symbols are actually different, GLIBC_2.0 in libc and
GLIBC_2.1 in libm.  This patch fixes the handling of the libm compat
symbol.

Tested for mips (o32), where it fixes an ABI test failure.

	* sysdeps/ieee754/dbl-64/s_finite.c
	[NO_LONG_DOUBLE && LDBL_CLASSIFY_COMPAT] (__finitel): Define
	compat symbol at version GLIBC_2_1 and use GLIBC_2_1 in
	SHLIB_COMPAT condition for libm, not GLIBC_2_0.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
	[NO_LONG_DOUBLE && LDBL_CLASSIFY_COMPAT] (__finitel): Likewise.
2016-01-20 19:04:43 +00:00
Joseph Myers 00b85374a9 Update localplt.data for powerpc-nofpu.
Testing for powerpc-nofpu showed that localplt.data was out of date.
Two new soft-fp functions showed up in the list: __gtsf2 and
__unordsf2; this patch adds these as optional.  __signbit and
__signbitl no longer appear as local PLT entries; given the move to
__builtin_signbit* for all GCC versions supported for building glibc
(and given the use of the type-generic signbit macro within glibc),
those can safely be removed from the list, which this patch does.

Tested for powerpc-nofpu.

	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/localplt.data
	(__gtsf2): Add as optional for libc.so.
	(__unordsf2): Likewise.
	(__signbit): Remove for libc.so.
	(__signbitl): Likewise.
2016-01-20 18:19:10 +00:00
Joseph Myers 2e3d0de31f Fix ulps regeneration for *-finite tests.
On running tests after from-scratch ulps regeneration, I found that
some libm tests failed with ulps in excess of those recorded in the
from-scratch regeneration, which should never happen unless those ulps
exceed the limit on ulps that can go in libm-test-ulps files.

Failure: Test: atan2_upward (inf, -inf)
Result:
 is:          2.35619498e+00   0x1.2d97ccp+1
 should be:   2.35619450e+00   0x1.2d97c8p+1
 difference:  4.76837159e-07   0x1.000000p-21
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of `atan2_upward'
 is      : 2 ulp
 accepted: 1 ulp
Failure: Test: carg_upward (-inf + inf i)
Result:
 is:          2.35619498e+00   0x1.2d97ccp+1
 should be:   2.35619450e+00   0x1.2d97c8p+1
 difference:  4.76837159e-07   0x1.000000p-21
 ulp       :  2.0000
 max.ulp   :  1.0000
Maximal error of `carg_upward'
 is      : 2 ulp
 accepted: 1 ulp

The problem comes from the addition of tests for the finite-math-only
versions of libm functions.  Those tests share ulps with the default
function variants.  make regen-ulps runs the default tests before the
finite-math-only tests, concatenating the resulting ulps before
feeding them to gen-libm-test.pl to generate a new libm-test-ulps
file.  But gen-libm-test.pl always takes the last ulps value given for
any (function, type) pair.  So, if the largest ulps for a function
come from non-finite inputs, a from-scratch regeneration loses those
ulps.

This patch fixes gen-libm-test.pl, in the case where there are
multiple ulps values for a (function, type) pair - which can only
happen as part of a regeneration - to take the largest ulps value
rather than the last one.

Tested for ARM / MIPS / powerpc-nofpu.

	* math/gen-libm-test.pl (parse_ulps): Do not reduce
	already-recorded ulps.
	* sysdeps/arm/libm-test-ulps: Regenerated.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
2016-01-19 21:42:58 +00:00
Andrew Senkevich df782dc690 Fixed build with assembler w/o AVX-512 support.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c: Fixed build with
    assembler not supporting AVX-512.
2016-01-19 14:34:53 +03:00
Stefan Liebler 415031f734 S390: Regenerate ULPs
I've regenerated ulps from scratch for s390/s390x.
All math testcases are passing afterwards.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2016-01-19 10:02:44 +01:00
Joseph Myers 204a038e57 Regenerate MIPS libm-test-ulps.
* sysdeps/mips/mips32/libm-test-ulps: Regenerated.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
2016-01-18 23:32:40 +00:00
Joseph Myers 844c75aa06 Regenerate powerpc-nofpu libm-test-ulps.
* sysdeps/powerpc/nofpu/libm-test-ulps: Regenerated.
2016-01-18 23:02:03 +00:00
Joseph Myers a99236df89 Regenerate ARM libm-test-ulps.
* sysdeps/arm/libm-test-ulps: Regenerated.
2016-01-18 22:55:47 +00:00
Stefan Liebler c4d17461e0 S/390: Do not raise inexact exception in lrint/lround. [BZ #19486]
I get some math test-failures on s390 for float/double/ldouble for
various lrint/lround functions like:
lrint (0x1p64): Exception "Inexact" set
lrint (-0x1p64): Exception "Inexact" set
lround (0x1p64): Exception "Inexact" set
lround (-0x1p64): Exception "Inexact" set
...

GCC emits "convert to fixed" instructions for casting floating point
values to integer values. These instructions raise invalid and inexact
exceptions if the floating point value exceeds the integer type ranges.

This patch enables the various FIX_DBL_LONG_CONVERT_OVERFLOW macros in
order to avoid a cast from floating point to integer type and raise the
invalid exception with feraiseexcept.
The ldbl-128 rint/round functions are now using the same logic.

ChangeLog:

	[BZ #19486]
	* sysdeps/s390/fix-fp-int-convert-overflow.h: New File.
	* sysdeps/generic/fix-fp-int-convert-overflow.h
	(FIX_LDBL_LONG_CONVERT_OVERFLOW,
	FIX_LDBL_LLONG_CONVERT_OVERFLOW): New define.
	* sysdeps/arm/fix-fp-int-convert-overflow.h: Likewise.
	* sysdeps/mips/mips32/fpu/fix-fp-int-convert-overflow.h:
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl):
	Avoid conversions to long int where inexact exceptions
	could be raised.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl):
	Avoid conversions to long long int where inexact exceptions
	could be raised.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c (__llroundl):
	Likewise.
2016-01-18 12:48:06 +01:00
Andrew Senkevich 214a44f394 Fixed typos in __memcpy_chk.
* sysdeps/x86_64/multiarch/memcpy_chk.S: Fixed typos.
2016-01-16 14:42:26 +03:00
Mike Frysinger 3f2c97261b sparc: mman.h: fix bad comment insertion
The MCL_ONFAULT define was inserted into the middle of a comment which
breaks the build.
2016-01-16 02:34:15 -05:00
Andrew Senkevich 72276d6e88 Added memcpy/memmove family optimized with AVX512 for KNL hardware.
Added AVX512 implementations of memcpy, mempcpy, memmove, memcpy_chk,
mempcpy_chk, memmove_chk.
It shows average improvement more than 30% over AVX versions on KNL
hardware (performance results in the thread
<https://sourceware.org/ml/libc-alpha/2016-01/msg00258.html>).

    * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Added new files.
    * sysdeps/x86_64/multiarch/ifunc-impl-list.c: Added new tests.
    * sysdeps/x86_64/multiarch/memcpy-avx512-no-vzeroupper.S: New file.
    * sysdeps/x86_64/multiarch/mempcpy-avx512-no-vzeroupper.S: Likewise.
    * sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S: Likewise.
    * sysdeps/x86_64/multiarch/memcpy.S: Added new IFUNC branch.
    * sysdeps/x86_64/multiarch/memcpy_chk.S: Likewise.
    * sysdeps/x86_64/multiarch/memmove.c: Likewise.
    * sysdeps/x86_64/multiarch/memmove_chk.c: Likewise.
    * sysdeps/x86_64/multiarch/mempcpy.S: Likewise.
    * sysdeps/x86_64/multiarch/mempcpy_chk.S: Likewise.
2016-01-16 00:49:45 +03:00
Torvald Riegel b02840bacd New pthread_barrier algorithm to fulfill barrier destruction requirements.
The previous barrier implementation did not fulfill the POSIX requirements
for when a barrier can be destroyed.  Specifically, it was possible that
threads that haven't noticed yet that their round is complete still access
the barrier's memory, and that those accesses can happen after the barrier
has been legally destroyed.
The new algorithm does not have this issue, and it avoids using a lock
internally.
2016-01-15 21:20:34 +01:00
Martin Sebor ad37480c4b Fix build errors with -DNDEBUG.
[BZ #18755]
        * iconv/skeleton.c (FUNCTION_NAME): Suppress -Wunused-but-set-variable
        warnings.
        * sysdeps/nptl/gai_misc.h (__gai_start_notify_thread): Same.
        (__gai_create_helper_thread): Same.
        * nscd/nscd.c (do_exit): Suppress -Wunused-variable.
        * iconvdata/iso-2022-cn-ext.c (BODY): Initialize local variable
        to suppress -Wmaybe-uninitialized warnings.
2016-01-15 10:44:07 -07:00
H.J. Lu 09245377da Call math_opt_barrier inside if
Since floating-point operation may trigger floating-point exceptions,
we call math_opt_barrier inside if to prevent code motion.

	[BZ #19465]
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Call math_opt_barrier
	inside if.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fma.c (__fma): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Likewise.
2016-01-15 05:23:20 -08:00
Amit Pawar d7890e6947 Set index_Fast_Unaligned_Load for Excavator family CPUs
GLIBC benchtest testcases shows SSE2_Unaligned based implementations
are performing faster compare to SSE2 based implementations for
routines: strcmp, strcat, strncat, stpcpy, stpncpy, strcpy, strncpy
and strstr. Flag index_Fast_Unaligned_Load is set for Excavator family
0x15h CPU's. This makes SSE2_Unaligned based implementations as
default for these routines.

	[BZ #19467]
	* sysdeps/x86/cpu-features.c (init_cpu_features): Set
	index_Fast_Unaligned_Load flag for Excavator family CPUs.
2016-01-14 08:14:31 -08:00
Marcin Kościelnicki a4b5177ca8 Add __private_ss to s390 struct tcbhead.
Preparation for gcc -fsplit-stack support (gcc bug #68191).  The new
field is basically identical to the one on x86.  Its TCB offset needs
to be constant, as it'll be hardcoded in gcc.

ChangeLog:

	* sysdeps/s390/nptl/tls.h (struct tcbhead_t): Add __private_ss field.
2016-01-14 16:48:55 +01:00
Joseph Myers fb53a27c57 Add new header definitions from Linux 4.4 (plus older ptrace definitions).
This patch adds some new header definitions from Linux 4.4:

* MCL_ONFAULT is added to bits/mman.h / bits/mman-linux.h (this was
  already done for hppa).

* PTRACE_SECCOMP_GET_FILTER is added to sys/ptrace.h.  Along with it,
  the older PTRACE_GETSIGMASK and PTRACE_SETSIGMASK, added in Linux
  3.11 but missed at the time, are also added.

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

	* bits/mman-linux.h [!MCL_CURRENT] (MCL_ONFAULT): New macro.
	* sysdeps/unix/sysv/linux/alpha/bits/mman.h (MCL_ONFAULT):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/mman.h (MCL_ONFAULT):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/mman.h (MCL_ONFAULT):
	Likewise.
	* sysdeps/unix/sysv/linux/sys/ptrace.h (PTRACE_GETSIGMASK): New
	enum constant and macro.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
	(PTRACE_GETSIGMASK): Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h (PTRACE_GETSIGMASK):
	Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
	(PTRACE_GETSIGMASK): Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h (PTRACE_GETSIGMASK):
	Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h (PTRACE_GETSIGMASK):
	Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h (PTRACE_GETSIGMASK):
	Likewise.
	(PTRACE_SETSIGMASK): Likewise.
	(PTRACE_SECCOMP_GET_FILTER): Likewise.
2016-01-12 12:42:55 +00:00
Tulio Magno Quites Machado Filho 42bf1c8971 powerpc: Enforce compiler barriers on hardware transactions
Work around a GCC behavior with hardware transactional memory built-ins.
GCC doesn't treat the PowerPC transactional built-ins as compiler
barriers, moving instructions past the transaction boundaries and
altering their atomicity.
2016-01-08 17:47:33 -02:00
Carlos Eduardo Seo d2de9ef7ad powerpc: Add hwcap2 bits for POWER9.
Added hwcap2 bit masks for Power ISA 3.0 and VSX IEEE binary float 128-bit
features.
2016-01-08 11:19:40 -02:00
John David Anglin 48025aa9ed hppa: fix dladdr [BZ #19415]
The attached patch fixes dladdr on hppa.

Instead of using the generic version of _dl_lookup_address, we use an
implementation more or less modeled after __canonicalize_funcptr_for_compare()
in gcc.  The function pointer is analyzed and if it points to the
trampoline used to call _dl_runtime_resolve just before the global
offset table, then we call _dl_fixup to resolve the function pointer.
Then, we return the instruction pointer from the first word of the
descriptor.

The change fixes the testcase provided in [BZ #19415] and the Debian
nss package now builds successfully.
2016-01-08 02:19:26 -05:00
Mike Frysinger 1f89b8d881 xstat: only check to see if __ASSUME_ST_INO_64_BIT is defined
We define __ASSUME_ST_INO_64_BIT by default for Linux targets, and then
undef it for alpha/sh targets.  But the code that uses it looks at its
value (as 0/1) rather than whether it's defined (like all other assume
knobs).  Change the code to see if it's defined to fix build Wundef build
errors for alpha/sh.
2016-01-07 14:37:09 -05:00
Marko Myllynen 48d0341cdd Make shebang interpreter directives consistent 2016-01-07 04:03:21 -05:00
John David Anglin d7f914848b hppa: fix pthread spinlock
URL: https://bugs.debian.org/725508
2016-01-06 17:26:04 -05:00
H.J. Lu db2f6f4794 Update copyright dates committed in 2016 2016-01-06 14:03:10 -08:00
H.J. Lu 730bbab2c3 Mark internal unistd functions hidden in ld.so
Since internal unistd functions are only used internally in ld.so and
libc.so, they can be made hidden.  __close, __getcwd, __getpid,
__libc_read and __libc_write can't be hidden in ld.so on Hurd since they
will be preempted by the ones in libc.so after bootstrap.

	[BZ #19122]
	* include/unistd.h [IS_IN (rtld)]: Include <dl-unistd.h>.
	* sysdeps/generic/dl-unistd.h: New file.
	* sysdeps/mach/hurd/dl-unistd.h: Likewise.
2016-01-06 12:54:10 -08:00
H.J. Lu 38acf35697 Mark ld.so internal mmap functions hidden in ld.so
Since ld.so internal mmap functions are only used internally in ld.so,
they can be made hidden.  Don't hide __mmap on Hurd, since __mmap in
ld.so will be preempted by the one in libc.so after bootstrap.

	 [BZ #19122]
	 * include/sys/mman.h [IS_IN (rtld)]: Include <dl-mman.h>.
	 * sysdeps/generic/dl-mman.h: New file.
	 * sysdeps/mach/hurd/dl-mman.h: Likewise.
2016-01-06 11:28:56 -08:00
Anton Blanchard 0a1f1e78fb Eliminate redundant sign extensions in pow()
When looking at the code generated for pow() on ppc64 I noticed quite
a few sign extensions. Making the array indices unsigned reduces the
number of sign extensions from 24 to 7.

Tested for powerpc64le and x86_64.
2016-01-04 14:55:38 -02:00
Joseph Myers 1979f3c1ad Update copyright dates not handled by scripts/update-copyrights.
I've updated copyright dates in glibc for 2016.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

	* NEWS: Update copyright dates.
	* catgets/gencat.c (print_version): Likewise.
	* csu/version.c (banner): Likewise.
	* debug/catchsegv.sh: Likewise.
	* debug/pcprofiledump.c (print_version): Likewise.
	* debug/xtrace.sh (do_version): Likewise.
	* elf/ldconfig.c (print_version): Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/pldd.c (print_version): Likewise.
	* elf/sotruss.sh: Likewise.
	* elf/sprof.c (print_version): Likewise.
	* iconv/iconv_prog.c (print_version): Likewise.
	* iconv/iconvconfig.c (print_version): Likewise.
	* locale/programs/locale.c (print_version): Likewise.
	* locale/programs/localedef.c (print_version): Likewise.
	* login/programs/pt_chown.c (print_version): Likewise.
	* malloc/memusage.sh (do_version): Likewise.
	* malloc/memusagestat.c (print_version): Likewise.
	* malloc/mtrace.pl: Likewise.
	* manual/libc.texinfo: Likewise.
	* nptl/version.c (banner): Likewise.
	* nscd/nscd.c (print_version): Likewise.
	* nss/getent.c (print_version): Likewise.
	* nss/makedb.c (print_version): Likewise.
	* posix/getconf.c (main): Likewise.
	* scripts/test-installation.pl: Likewise.
	* sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
2016-01-04 16:26:30 +00:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Helge Deller d4eed61f85 hppa: Add MAP_HUGETLB and MAP_STACK defines [BZ #19285]
The attached patch adds some upstream defines like MAP_HUGETLB and MAP_STACK
in mman.h for the hppa architecture.

The existing MADV_xxK_PAGES defines were dropped upstream, because they were
originally added many years ago based on a proposed patch for the Linux kernel
which was never applied. So, this patch drops those unneeded defines.
2016-01-02 23:39:49 -05:00
Mike Frysinger 19e0751014 ia64: fpu: fix gamma definition handling [BZ #15421]
The rework in commit d709042a6e broke
buiding on ia64 due to compat_symbol expanding into ... in some cases.
The common files were wrapped in a BUILD_LGAMMA check, but the ia64
ones were not.  Add that logic to the ia64 files too.
2016-01-01 22:17:07 -05:00
Dmitry V. Levin e0043e17df Fix linux personality syscall wrapper
The personality system call, starting with linux kernel commit
v2.6.29-6609-g11d06b2a1e5658f448a308aa3beb97bacd64a940, always
successfully changes the personality if requested.  The syscall
wrapper, however, still can return an error in the following cases:
- the value returned by the system call looks like an error
due to architecture limitations of 32-bit kernels;
- a personality greater than 0xffffffff is passed to the system call,
and the 64-bit kernel does not have commit
v2.6.35-rc1-372-g485d527686850d68a0e9006dd9904f19f122485e
that would truncate this value to unsigned int;
- on sparc64, the value returned by the system call looks like an error
due to sparc64 kernel sign extension bug.

The solution is three-fold:
- move generic syscalls.list personality entry to generic 64-bit
syscalls.list file;
- for each 32-bit architecture that use negated errno semantics,
add a NOERRNO personality entry to their syscalls.list file;
- for sparc64 and 32-bit architectures that use dedicated registers
to flag syscall errors, add a wrapper around personality syscall;
if the system call return value is flagged as an error, this wrapper
returns the negated "would be errno" value, otherwise it returns
the system call return value; on sparc64, it also truncates the
personality argument to unsigned int before passing it to the kernel.

[BZ #19408]
* sysdeps/unix/sysv/linux/personality.c: New file.
* sysdeps/unix/sysv/linux/sparc/sparc64/personality.c: Likewise.
* sysdeps/unix/sysv/linux/tst-personality.c: Likewise.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) == misc]
(sysdep_routines): Add personality.
(tests): Add tst-personality.
* sysdeps/unix/sysv/linux/syscalls.list (personality): Move ...
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: ... here.
* sysdeps/unix/sysv/linux/arm/syscalls.list (personality): New entry.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (personality): Likewise.
* sysdeps/unix/sysv/linux/i386/syscalls.list (personality): Likewise.
* sysdeps/unix/sysv/linux/m68k/syscalls.list (personality): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (personality):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (personality):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list (personality):
Likewise.
* sysdeps/unix/sysv/linux/sh/syscalls.list (personality): Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (personality):
Likewise.
2015-12-31 00:17:48 +00:00
Aurelien Jarno cc42170ef6 Cleanup ARM ioperm implementation (step 2)
Since GLIBC requires a minimum 2.6.32 kernel, the sysctl (CTL_BUS,
CTL_BUS_ISA, ISA_*) is always available.  We can therefore remove the
fallback code reading /etc/arm_systype or parsing /proc/cpuinfo.

Remove fscanf from localplt.data as it is no longer called from within
GLIBC.

	* sysdeps/unix/sysv/linux/arm/ioperm.c: Do not include <string.h>.
	(PATH_ARM_SYSTYPE): Remove.
	(PATH_CPUINFO): Likewise.
	(IO_BASE_FOOTBRIDGE): Likewise.
	(IO_SHIFT_FOOTBRIDGE): Likewise.
	(struct platform): Likewise.
	(init_iosys): Remove compatibility code for 2.4 kernels.
	* sysdeps/unix/sysv/linux/arm/localplt.data: Remove fscanf.
2015-12-30 23:31:18 +01:00
John David Anglin d51442aacd hppa: Define __NO_LONG_DOUBLE_MATH so headers are consistent with libm build [BZ #19270]
The attached patch fixes BZ #19270 and the Debian gmt package now builds
successfully.  Aside from the comment, the define of __NO_LONG_DOUBLE_MATH
is similar to that in the generic version of glibc.

Build tested on hppa-unknown-linux-gnu with no observed regressions.
2015-12-29 13:24:51 -05:00
Mike Frysinger d46256f440 ia64: fpu: fix gammaf typo [BZ #15421]
The lgamma rewrite in commit d709042a6e
used "gammaf" in this function when it should have used "gamma".
2015-12-28 22:20:03 -05:00
Torvald Riegel 389fdf78b2 Do not violate mutex destruction requirements.
POSIX and C++11 require that a thread can destroy a mutex if no other
thread owns the mutex, is blocked on the mutex, or will try to acquire
it in the future.  After destroying the mutex, it can reuse or unmap the
underlying memory.  Thus, we must not access a mutex' memory after
releasing it.  Currently, we can load the private flag after releasing
the mutex, which is fixed by this patch.
See https://sourceware.org/bugzilla/show_bug.cgi?id=13690 for more
background.

We need to call futex_wake on the lock after releasing it, however.  This
is by design, and can lead to spurious wake-ups on unrelated futex words
(e.g., when the mutex memory is reused for another mutex).  This behavior
is documented in the glibc-internal futex API and in recent drafts of the
Linux kernel's futex documentation (see the draft_futex branch of
git://git.kernel.org/pub/scm/docs/man-pages/man-pages.git).
2015-12-23 18:44:53 +01:00
Carlos Eduardo Seo c676e65939 powerpc: Export __parse_hwcap_and_convert_at_platform to libc.a.
Commit 67385a01d2 added a new feature for
powerpc, where we store HWCAP/Platform bits in the TCB.  In the dynamic
linking case, we use the versioned symbol
'__parse_hwcap_and_convert_at_platform' to verify if this feature is
available.  However, the same symbol was not exported to libc.a, making
it not possible for GCC to check for it prior to link time.
2015-12-22 15:41:19 -02:00
Carlos Eduardo Seo b1f19b8ef1 powerpc: Add basic support for POWER9 sans hwcap.
This patch adds the minimum changes for supporting the POWER9 processor.
2015-12-22 14:45:55 -02:00
Samuel Thibault 2cf3e1aa74 Harmonize generic stdio-lock support with nptl
This fixes build when _IO_funlockfile is a macro, fixes build where
	_IO_acquire_lock_clear_flags2 is used, and fixes unlocking on unexpected
	stack unwind.

	* sysdeps/generic/stdio-lock.h [__EXCEPTIONS] (_IO_acquire_lock,
	_IO_release_lock ): Use cleanup attribute on new
	_IO_acquire_lock_file variable instead of assuming that
	_IO_release_lock will be called.
	[!__EXCEPTIONS] (_IO_acquire_lock): Define to non-existing
	_IO_acquire_lock_needs_exceptions_enabled.
	(_IO_acquire_lock_clear_flags2): New macro.
2015-12-22 14:39:19 +01:00
Adhemerval Zanella 661a29a518 powerpc: Regenerate libm-test-ulps
* sysdeps/powerpc/fpu/libm-test-ulps: Regenerated.
2015-12-22 11:11:01 -02:00
Siddhesh Poyarekar b300455644 Consolidate sincos computation for 2.426265 < |x| < 105414350
Like the previous change, exploit the fact that computation for sin
and cos is identical except that it is apart by a quadrant.  Also
remove csloww, csloww1 and csloww2 since they can easily be expressed
in terms of sloww, sloww1 and sloww2.
2015-12-21 10:43:04 +05:30
Siddhesh Poyarekar f7953c44d5 Consolidate sin and cos code for 105414350 <|x|< 281474976710656
The sin and cos computation for this range of input is identical
except for a difference in quadrants by 1.  Exploit that fact and the
common argument reduction to reduce computations for sincos.
2015-12-21 10:41:46 +05:30
Siddhesh Poyarekar a045832deb Consolidate range reduction in sincos for x > 281474976710656
Range reduction needs to be done only once for sin and cos, so copy
over all of the relevant functions (__sin, __cos, reduce_and_compute)
and consolidate common code.
2015-12-21 10:40:32 +05:30
Aurelien Jarno 5537f466d6 i386: move ULPs to i686/multiarch and regenerate new ones for i386
The i386 ULPs are actually the i686/multiarch ones. The i686/multiarch
float ULPs are more precise as the SSE2 version (when available) uses
double for the cosf and sinf functions.

On the other hand the higher precision of the x86 FPU improves the
precision for a few other math functions.

	* sysdeps/i386/fpu/libm-test-ulps: Move to ....
	* sysdeps/i386/i686/multiarch/fpu/libm-test-ulps: ...here.
	* sysdeps/i386/fpu/libm-test-ulps: Regenerate.
2015-12-20 16:36:45 +01:00
Andrew Senkevich 83d776f979 Added memset optimized with AVX512 for KNL hardware.
It shows improvement up to 28% over AVX2 memset (performance results
attached at <https://sourceware.org/ml/libc-alpha/2015-12/msg00052.html>).

    * sysdeps/x86_64/multiarch/memset-avx512-no-vzeroupper.S: New file.
    * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Added new file.
    * sysdeps/x86_64/multiarch/ifunc-impl-list.c: Added new tests.
    * sysdeps/x86_64/multiarch/memset.S: Added new IFUNC branch.
    * sysdeps/x86_64/multiarch/memset_chk.S: Likewise.
    * sysdeps/x86/cpu-features.h (bit_Prefer_No_VZEROUPPER,
    index_Prefer_No_VZEROUPPER): New.
    * sysdeps/x86/cpu-features.c (init_cpu_features): Set the
    Prefer_No_VZEROUPPER for Knights Landing.
2015-12-19 02:47:28 +03:00
Adhemerval Zanella fc48bfbc79 Fix SYSCALL_CANCEL for empty argumetns
This patch fixes the SYSCALL_CANCEL macro for usage with zero argument
number (for instance SYSCALL_CANCEL (pause)) using a similar approach
used for SOCKETCALL_CANCEL.

GLIBC build still does not hit this issue still since SYSCALL_CANCEL
is not currently being used for zero arguments calls.

Tested on i386, x86_64, powerpc64le, aarch64.

	* sysdeps/unix/sysdep.h (SYSCALL_CANCEL): Fix macro for zero argument
	syscalls.
	(__SYSCALL0): New macro.
	(__SYSCALL1): Likewise.
	(__SYSCALL2): Likewise.
	(__SYSCALL3): Likewise.
	(__SYSCALL4): Likewise.
	(__SYSCALL5): Likewise.
	(__SYSCALL6): Likewise.
	(__SYSCALL7): Likewise.
	(__SYSCALL_CONCAT_X): Likewise.
	(__SYSCALL_CONCAT): Likewise.
	(__SYSCALL_DIST): Likewise.
	(__SYSCALL_CALL): Likewise.
2015-12-17 18:16:59 -02:00
H.J. Lu 8ead7a9b94 Provide x32 times
Since times returns 64-bit clock_t on x32, we need to provide x32 times
by redefining INTERNAL_SYSCALL_NCS and INTERNAL_SYSCALL_ERROR_P with
64-bit return type for syscall.  All system calls returning 64-bit
integer, which are lseek, time and times, must be handled specially for
x32.  lseek is handled by x32 lseek.S and time doesn't check syscall
return.  times is the only missed one.  Before this patch, there are

0000000 <__times>:
   0:	b8 64 00 00 40       	mov    $0x40000064,%eax
   5:	0f 05                	syscall
   7:	48 63 d0             	movslq %eax,%rdx
                                ^^^^^^^^^^ Incorrect signed extension
   a:	48 83 fa f2          	cmp    $0xfffffffffffffff2,%rdx
   e:	75 07                	jne    17 <__times+0x17>
  10:	3d 00 f0 ff ff       	cmp    $0xfffff000,%eax
                                ^^^^^^^^^^^^^^^^^^^^^ 32-bit compare
  15:	77 11                	ja     28 <__times+0x28>
  17:	48 83 fa ff          	cmp    $0xffffffffffffffff,%rdx
  1b:	b8 00 00 00 00       	mov    $0x0,%eax
  20:	48 0f 45 c2          	cmovne %rdx,%rax
  24:	c3                   	retq

After this patch, there are

00000000 <__times>:
   0:	b8 64 00 00 40       	mov    $0x40000064,%eax
   5:	0f 05                	syscall
   7:	48 83 f8 f2          	cmp    $0xfffffffffffffff2,%rax
   b:	75 08                	jne    15 <__times+0x15>
   d:	48 3d 00 f0 ff ff    	cmp    $0xfffffffffffff000,%rax
  13:	77 13                	ja     28 <__times+0x28>
  15:	48 83 f8 ff          	cmp    $0xffffffffffffffff,%rax
  19:	ba 00 00 00 00       	mov    $0x0,%edx
  1e:	48 0f 44 c2          	cmove  %rdx,%rax
  22:	c3                   	retq

The incorrect signed extension and 32-bit compare are gone.

	[BZ #19363]
	* sysdeps/unix/sysv/linux/x86_64/x32/times.c: New file.
2015-12-17 11:47:06 -08:00
Adhemerval Zanella 2094350c9c Fix POWER7 logb results for negative subnormals (bug 19375)
The optimized POWER7 logb implementation does not use the absolute
value of the word extracted from the input to apply the leading 0-bits
builtin (to ignore the float sign).  This patch fixes it by
clearing the signal bit in the resulting word.

It fixes the subnormal tests failures when running on POWER7 ou
newer chip.

Tested on powerpc64le (POWER8).

	[BZ# 19375]
	* sysdeps/powerpc/power7/fpu/s_logb.c (__logb): Fix return for
	negative subnormals.
2015-12-17 14:34:33 -02:00
H.J. Lu d29d57eed9 Add REGISTERS_CLOBBERED_BY_SYSCALL for x86-64
X86-64 system calls use a different calling convention, which clobbers
CC, %r11 an %rcx registers.  Define REGISTERS_CLOBBERED_BY_SYSCALL for
x86-64 inline asm statements.

	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(REGISTERS_CLOBBERED_BY_SYSCALL): New.
	(INTERNAL_SYSCALL_NCS): Use it.
	(INTERNAL_SYSCALL_NCS_TYPES): Likewise.
2015-12-16 05:20:15 -08:00
H.J. Lu b9eb92ab05 Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT
According to Silvermont software optimization guide, for 64-bit
applications, branch prediction performance can be negatively impacted
when the target of a branch is more than 4GB away from the branch.  Add
the Prefer_MAP_32BIT_EXEC bit so that mmap will try to map executable
pages with MAP_32BIT first.  NB: MAP_32BIT will map to lower 2GB, not
lower 4GB, address.  Prefer_MAP_32BIT_EXEC reduces bits available for
address space layout randomization (ASLR), which is always disabled for
SUID programs and can only be enabled by setting environment variable,
LD_PREFER_MAP_32BIT_EXEC.

On Fedora 23, this patch speeds up GCC 5 testsuite by 3% on Silvermont.

	[BZ #19367]
	* sysdeps/unix/sysv/linux/wordsize-64/mmap.c: New file.
	* sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/mmap.c: Likewise.
	* sysdeps/x86/cpu-features.h (bit_Prefer_MAP_32BIT_EXEC): New.
	(index_Prefer_MAP_32BIT_EXEC): Likewise.
2015-12-15 13:16:02 -08:00
H.J. Lu c9afcaaafa Enable Silvermont optimizations for Knights Landing
Knights Landing processor is based on Silvermont.  This patch enables
Silvermont optimizations for Knights Landing.

	* sysdeps/x86/cpu-features.c (init_cpu_features): Enable
	Silvermont optimizations for Knights Landing.
2015-12-15 11:46:54 -08:00
Joseph Myers eed3e1eb79 Make obsolete syscall wrappers into compat symbols (bug 18472).
Various Linux kernel syscalls have become obsolete over time.
Specifically, the following are obsolete in all kernel versions
supported by glibc, are not present for architectures more recently
added to the kernel, and as such, the wrapper functions for them
should be compat symbols, not in static libc and not available for new
links with shared libc.

* bdflush: in Linux 2.6, does nothing if present.

* create_module get_kernel_syms query_module: Linux 2.4 module
  interface, syscalls not present in Linux 2.6.

* uselib: part of the mechanism for loading a.out shared libraries,
  irrelevant with ELF.

This patch adds support for syscalls.list to list syscall aliases of
the form NAME@VERSION:OBSOLETED, with SHLIB_COMPAT conditionals being
generated for such aliases.  Those five syscalls are then made into
compat symbols (obsoleted in glibc 2.23, so future ports won't have
these symbols at all), with the header <sys/kdaemon.h> declaring
bdflush being removed.  When we move to 3.2 as minimum kernel version,
the same can be done for nfsservctl (removed in Linux 3.1) as well.

Tested for x86_64 and x86 (testsuite, as well as checking that the
symbols in question indeed become compat symbols, that they are indeed
omitted from static libc, and that the generated SHLIB_COMPAT
conditionals look right).

	[BZ #18472]
	* sysdeps/unix/Makefile ($(objpfx)stub-syscalls.c): Handle entries
	for the form NAME@VERSION:OBSOLETED and generate SHLIB_COMPAT
	conditionals for them.
	* sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Likewise.
	* sysdeps/unix/sysv/linux/sys/kdaemon.h: Remove file.
	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Remove
	sys/kdaemon.h.
	* sysdeps/unix/sysv/linux/syscalls.list (bdflush): Make into
	compat-only syscall, obsoleted in glibc 2.23.
	(create_module): Likewise.
	(get_kernel_syms): Likewise.
	(query_module): Likewise.
	(uselib): Likewise.
	* manual/sysinfo.texi (System Parameters): Do not mention bdflush.
2015-12-14 22:52:15 +00:00
Aurelien Jarno 5db0877750 Cleanup ARM ioperm implementation
Since GLIBC requires a minimum 2.6.32 kernel, the patch cleanups
the ARM ioperm by removing pre-2.4.23 kernel support.
2015-12-12 11:52:06 +01:00
Steve Ellcey 976ef87054 Fix indentation.
* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Fix indentation.
2015-12-11 09:19:37 -08:00
Aurelien Jarno 77356912e8 grantpt: trust the kernel about pty group and permission mode
According to POSIX the grantpt() function does the following:

  The grantpt() function shall change the mode and ownership of the
  slave pseudo-terminal device associated with its master
  pseudo-terminal counterpart. The fildes argument is a file descriptor
  that refers to a master pseudo-terminal device. The user ID of the
  slave shall be set to the real UID of the calling process and the
  group ID shall be set to an unspecified group ID. The permission
  mode of the slave pseudo-terminal shall be set to readable and
  writable by the owner, and writable by the group.

Historically the GNU libc has been responsible to setup the permission
mode to 0620 and the group to 'tty' usually number 5, using the pt_chown
helper, badly known for its security issues. With the creation of the
devpts filesytem in the Linux kernel, this responsibility has been moved
to the Linux kernel. The system is responsible to mount the devpts
filesystem in /dev/pts with the options gid=5 and mode=0620. In that
case the GNU libc has nothing to do and pt_chown is not need anymore. So
far so good.

The problem is that by default the devpts filesystem is shared between
all mounts, and that contrary to other filesystem, the mount options are
honored at the second mount, including for the default mount options.
Given it corresponds to mode=0600 without gid parameter (that is the
filesystem GID of the creating process), it's common to see systems
where the devpts filesystem is mounted using these options. It is enough
to run a "mount -t devpts devpts /mychroot/dev/pts" to come into this
situation, and it's unfortunately wrongly used in a lot of scripts
dealing with chroots, or for creating virtual machines images.

When this happens the GNU libc tries to fix the group and permission
mode of the pty nodes, and given it fails to do so for non-root users,
grantpt() almost always fail. It means users are not able to open new
terminals.

This patch changes grantpt() to not enforce this anymore, while still
enforcing minimum security measures to the permission mode. Therefore
the responsibility to follow POSIX is now shared at the system level,
i.e. kernel + system scripts + GNU libc. It stops trying to change the
group, and makes the pty node readable and writable by the owner, and
writable by the group only when originally writable and when the group
is the tty one.

As a result, on a system wrongly mounted with gid=0 and mode=0600, the
pty nodes won't be accessible by the tty group, but the grantpt()
function will succeed and users will have a working system. The system
is not fully POSIX compliant (which might be an admin choice to default
to "mesg n" mode), but the GNU libc is not to blame here, as without the
pt_chown helper it can't do anything.

With this patch there should not be any reason left to build the GNU
libc with the --enable-pt_chown configure option on a GNU/Linux system.
2015-12-10 22:33:10 +01:00
Joseph Myers e6a6b1c3de Fix ldbl-128ibm logl inaccuracy near 1 (bug 19351).
The ldbl-128ibm implementation of logl is inaccurate for arguments
near 1, because when deciding whether to bypass a series expansion for
log(1+z), where z = x-1, it compares the square of z rather than z
itself with an epsilon value.  This patch fixes that comparison, so
eliminating the test failures for inaccuracy of logl in such cases.

Tested for powerpc.

	[BZ #19351]
	* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): When
	expanding log(1+z), compare z rather than its square with epsilon
	to determine when to avoid evaluating the expansion.
2015-12-09 23:51:11 +00:00
Joseph Myers f517e06ab7 Fix ldbl-128ibm sinhl spurious overflows (bug 19350).
The ldbl-128ibm implementation of sinhl uses a slightly too small
overflow threshold (similar to bug 16407 for coshl).  This patch fixes
it to use a safe threshold (so that values whose high part is above
the value compared with definitely result in an overflow in all
rounding modes).

Tested for powerpc.

	[BZ #19350]
	* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl):
	Increase overflow threshold.
2015-12-09 22:37:08 +00:00
Joseph Myers ca2fcac629 Fix ldbl-128ibm tanhl inaccuracy for small arguments (bug 19349).
The ldbl-128ibm implementation of tanhl is inaccurate for small
arguments, because it returns x*(1+x) (maybe in an attempt to raise
"inexact") when x itself would be the accurate return value but
multiplying by 1+x introduces large errors.  This patch fixes it to
return x in that case (when the mathematical result is x plus a
negligible remainder on the order of x^3) to avoid those errors.

Tested for powerpc.

	[BZ #19349]
	* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Return argument
	when small.
2015-12-09 21:20:18 +00:00
Joseph Myers e5a5315e2d Use direct socket syscalls for new kernels on i386, m68k, microblaze, sh.
Now that we have __ASSUME_* macros for direct socket syscalls to use
them instead of socketcall when they can be assumed to be available on
socketcall architectures, this patch defines those macros when
appropriate for i386, m68k, microblaze and sh (for 4.3, 4.3, all
supported kernels and 2.6.37, respectively; the only use of socketcall
support on microblaze is it allows accept4 and sendmmsg to be
supported on a wider range of kernel versions).

David, it seems that 32-bit SPARC is the only architecture supported
by glibc that still lacks these direct syscalls.  It would be good to
get them added to the SPARC kernel so we can eventually eliminate
socketcall support in glibc (and thereby just use entries in
sysdeps/unix/syscalls.list for most of these functions) when we can
assume new-enough kernels.

Tested for i386 (testsuite, and that installed shared libraries are
unchanged by this patch - not using a new enough kernel, so this
doesn't actually test much, but the i386 and m68k code is essentially
the same as that already in use for s390).

	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
	New macro.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300]
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKET_SYSCALL): Likewise.
	(__ASSUME_BIND_SYSCALL): Likewise.
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	(__ASSUME_LISTEN_SYSCALL): Likewise.
	(__ASSUME_ACCEPT_SYSCALL): Likewise.
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	(__ASSUME_SEND_SYSCALL): Likewise.
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	(__ASSUME_RECV_SYSCALL): Likewise.
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	(__ASSUME_SHUTDOWN_SYSCALL): Likewise.
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	(__ASSUME_SENDMSG_SYSCALL): Likewise.
	(__ASSUME_RECVMSG_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SOCKET_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_BIND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_CONNECT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_LISTEN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_ACCEPT_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SEND_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDTO_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECV_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVFROM_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SHUTDOWN_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625]
	(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDMSG_SYSCALL):
	Likewise.
	[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVMSG_SYSCALL):
	Likewise.
2015-12-09 20:59:43 +00:00
Aurelien Jarno 578d080544 mips: fix testsuite build for O32 FPXX ABI on pre-R2 CPU
On MIPS when the toolchain is using the O32 FPXX ABI, the testsuite
fails to build for pre-R2 CPU.

It assumes that it is possible to use the -mfp64 option to build
tst-abi-fp64amod and tst-abi-fp64mod, while this requires a CPU which
supports the mfhc1 and mthc1 instructions, ie at least a R2 CPU:

  error: '-mgp32' and '-mfp64' can only be combined if the target
  supports the mfhc1 and mthc1 instructions

The same way it assumes that it is possible to use the -modd-spreg option
to build tst-abi-fpxxomod and tst-abi-fp64mod, while this requires at
least a R1 CPU:

  warning: the 'mips2' architecture does not support odd
  single-precision registers

This patches changes that by checking the usability of -mfp64 and
-modd-spreg options in configure, and disable those tests when they can
not be used.
2015-12-09 19:03:46 +01:00
Aurelien Jarno 3b51c390f7 Fix grantpt basename namespace bug
Commit cf06a4e3 removed test-xfail-POSIX2008/unistd.h/linknamespace, but
left one basename namespace issue in grantpt. However this issue is not
visible with the default configuration buy only when configure is passed
the --enable-pt_chown option.
2015-12-09 19:03:43 +01:00
Andrew Senkevich 377ed004f2 Utilize x86_64 vector math functions w/o -fopenmp.
This patch allows to use x86_64 vector math functions with GCC 6.*
without OpenMP SIMD constructs.  For additional details please visit
<https://sourceware.org/glibc/wiki/libmvec#Example_2>.

    * sysdeps/x86/fpu/bits/math-vector.h: W/o -fopenmp declare vector math
    functions with GCC 6.* __attribute__ ((__simd__)).
2015-12-07 21:58:26 +03:00
Chris Metcalf e59c94fa0e math: add LDBL_CLASSIFY_COMPAT support
If a platform does not define "long-double-fcts = yes" in its
Makefiles and it does define __NO_LONG_DOUBLE_MATH in its installed
headers, it will currently create exported symbols for __finitel,
__isinfl, and __isnanl that can't be reached from userspace by
correct use of the finite(), isinf(), or isnan() macros in <math.h>.

To avoid this situation, by default for such platforms we now no
longer export these symbols, thus causing appropriate link-time
errors.  However, for platforms that previously exported these
symbols, we continue to do so as compat symbols; this is enabled
by adding LDBL_CLASSIFY_COMPAT to math_private.h for the platform.

For tile, remove the now-unnecessary exports of those functions from
libc and libm.
2015-12-03 13:00:46 -05:00
Carlos Eduardo Seo 67385a01d2 powerpc: Add hwcap/hwcap2/platform data to TCB.
This patch adds a new feature for powerpc.  In order to get faster access to
the HWCAP/HWCAP2 bits and platform number (i.e. for implementing
__builtin_cpu_is () / __builtin_cpu_supports () in GCC) without the overhead of
reading from the auxiliary vector, we now reserve space for them in the TCB.
This is an ABI change for GLIBC 2.23.

A new versioned symbol '__parse_hwcap_and_convert_at_platform' is available to
get the data from the auxiliary vector and parse it, and store it for later use
in the TLS initialization code.  This function is called very early
(in _dl_sysdep_start () via DL_PLATFORM_INFO for the dynamic linking case, and
in __libc_start_main () for the static linking case) to make sure the data is
available at the time of TLS initialization.

	* sysdeps/powerpc/Makefile (sysdep-dl-routines): Add hwcapinfo.
	(sysdep_routines): Likewise.
	(sysdep-rtld-routines): Likewise.
	[$(subdir) = nptl](tests): Add test-get_hwcap and test-get_hwcap-static
	[$(subdir) = nptl](tests-static): test-get_hwcap-static
	* sysdeps/powerpc/Versions: Added new
	__parse_hwcap_and_convert_at_platform symbol to GLIBC-2.23.
	* sysdeps/powerpc/hwcapinfo.c: New file.
	(__tcb_parse_hwcap_and_convert_at_platform): New function to initialize
	and parse hwcap, hwcap2 and platform number information.
	* sysdeps/powerpc/hwcapinfo.h: New file.  Creates global variables
	to store HWCAP+HWCAP2 and platform number.
	* sysdeps/powerpc/nptl/tcb-offsets.sym: Added new offsets
	for HWCAP+HWCAP2 and platform number in the TCB.
	* sysdeps/powerpc/nptl/tls.h: New functionality.  Stores
	the HWCAP, HWCAP2 and platform number in the TCB.
	(dtv): Added new fields for HWCAP+HWCAP2 and platform number.
	(TLS_INIT_TP): Included calls to add the hwcap and
	at_platform values in the TCB in TP initialization.
	(TLS_DEFINE_INIT_TP): Likewise.
	(THREAD_GET_HWCAP): New macro.
	(THREAD_SET_HWCAP): Likewise.
	(THREAD_GET_AT_PLATFORM): Likewise.
	(THREAD_SET_AT_PLATFORM): Likewise.
	* sysdeps/powerpc/powerpc32/dl-machine.h:
	(dl_platform_init): New function that calls
	__parse_hwcap_and_convert_at_platform for the dymanic linking case for
	powerpc32.
	* sysdeps/powerpc/powerpc64/dl-machine.h: Likewise, for powerpc64.
	* sysdeps/powerpc/test-get_hwcap-static.c: New file.  Testcase for
	this functionality, static linking case.
	* sysdeps/powerpc/test-get_hwcap.c: New file.  Likewise, dynamic
	linking case.
	* sysdeps/unix/sysv/linux/powerpc/libc-start.c: Added call to
	__parse_hwcap_and_convert_at_platform for the static linking case.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/ld.abilist:
	Included the new __parse_hwcap_and_convert_at_platform symbol in the
	ABI list for GLIBC 2.23.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/ld.abilist:
	Likewise.
2015-12-03 13:56:13 -02:00
H.J. Lu 7635a88d32 Add __CPU_MASK_TYPE for __cpu_mask
Since x86-64 and x32 use the same set of sched_XXX system call interface:

[hjl@gnu-6 linux-stable]$ grep sched_
arch/x86/entry/syscalls/syscall_64.tbl
24	common	sched_yield		sys_sched_yield
142	common	sched_setparam		sys_sched_setparam
143	common	sched_getparam		sys_sched_getparam
144	common	sched_setscheduler	sys_sched_setscheduler
145	common	sched_getscheduler	sys_sched_getscheduler
146	common	sched_get_priority_max	sys_sched_get_priority_max
147	common	sched_get_priority_min	sys_sched_get_priority_min
148	common	sched_rr_get_interval	sys_sched_rr_get_interval
203	common	sched_setaffinity	sys_sched_setaffinity
204	common	sched_getaffinity	sys_sched_getaffinity
314	common	sched_setattr		sys_sched_setattr
315	common	sched_getattr		sys_sched_getattr
[hjl@gnu-6 linux-stable]$

__cpu_mask should be unsigned long long, instead of unsigned long, for
x32.  This patch adds __CPU_MASK_TYPE so that each architecture can
define the proper type for __cpu_mask.

	[BZ #19313]
	* bits/typesizes.h (__CPU_MASK_TYPE): New.
	* sysdeps/mach/hurd/bits/typesizes.h (__CPU_MASK_TYPE): Likewise.
	* sysdeps/nacl/bits/typesizes.h (__CPU_MASK_TYPE): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h (__CPU_MASK_TYPE):
	Likewise.
	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h (__CPU_MASK_TYPE):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h (__CPU_MASK_TYPE):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h (__CPU_MASK_TYPE):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h (__CPU_MASK_TYPE):
	* sysdeps/unix/sysv/linux/bits/sched.h (__cpu_mask): Replace
	unsigned long int with __CPU_MASK_TYPE.
2015-12-01 10:25:44 -08:00
Szabolcs Nagy c960ded0d5 [AArch64] Regenerate libm-test-ulps
* sysdeps/aarch64/libm-test-ulps: Regenerated.
2015-12-01 12:57:16 +00:00
Joseph Myers 60f435bb0c Use hex float constants in sysdeps/ieee754/dbl-64/e_sqrt.c.
Various sysdeps/ieee754/dbl-64 functions use double constants defined
using a union between a double and two ints, with separate big-endian
and little-endian definitions of the constants.

With modern C, this is unnecessary complication; hex float constants
(or __builtin_inf etc.) suffice to specify the exact value desired,
and so can avoid separate versions for each endianness.  Having this
complication also complicates cleanups such as removing slow paths
from these library functions, as they need to make sure to remove both
copies of variables that are no longer used after such a cleanup (and
in at least one case, proper removal of a slow path will also involve
removing slow-path-only values from the middle of an array - an array
with both big-endian and little-endian copies - and adjusting other
references to that array).

So it makes sense to clean up the code to define these constants using
hex floats and so eliminate the endianness conditional.  This patch
does so in the case of sqrt, where the two constants are such that it
makes sense just to put them directly in the code using them and
eliminate the names for them altogether.

Tested for arm (the code generated for sqrt does change, though not in
any significant way).

	* sysdeps/ieee754/dbl-64/e_sqrt.c: Do not include uroot.h.
	(__ieee754_sqrt): Use hex float constants instead of tm256.x and
	t512.x.
	* sysdeps/ieee754/dbl-64/uroot.h: Remove file.
2015-12-01 01:01:36 +00:00
H.J. Lu 9627da32ec Update family and model detection for AMD CPUs
AMD CPUs uses the similar encoding scheme for extended family and model
as Intel CPUs as shown in:

http://support.amd.com/TechDocs/25481.pdf

This patch updates get_common_indeces to get family and model for both
Intel and AMD CPUs when family == 0x0f.

	[BZ #19214]
	* sysdeps/x86/cpu-features.c (get_common_indeces): Add an
	argument to return extended model.  Update family and model
	with extended family and model when family == 0x0f.
	(init_cpu_features): Updated.
2015-11-30 09:01:31 -08:00
Samuel Thibault 5f75f6bdf8 hurd: Make mmap64 use vm_offset_t for overflow check
The RPC interface used by mmap uses the unsigned vm_offset_t, not the
	signed off_t, so 32bit bigger than 2GiB values are fine actually.

	* sysdeps/mach/hurd/mmap64.c: New file.
2015-11-29 17:26:50 +01:00
Thomas Schwinge 894f3e1311 hurd: install correct number of send rights on fork
* sysdeps/mach/hurd/fork.c (__fork): Install correct number of send
	rights for its main user thread in NEWTASK.
2015-11-29 16:41:00 +01:00
Maciej W. Rozycki db4855bf0c MIPS: Wire FCSR.ABS2008 to FCSR.NAN2008
Revision 3.50 of the MIPS architecture defined FCSR ABS2008 and NAN2008
bits as optionally read/write [1][2].  No hardware implementation has
ever made use of this feature though.  For example the first processor
to implement these bits, the MIPS32r3 proAptiv core, has both bits
read-only, hardwired to 1 [3].  And as from revision 5.03 of the MIPS
architecture the bits are required to be read-only, preset by hardware
[4][5].  Additionally all hardware implementations in existence have the
bits hardwired both to the same value, either of `0' and `1'.

These bits may still be read/write or hardwired to opposite values in
simulated hardware implementations such as QEMU or the FPU emulator
included with the Linux kernel.  However to match real hardware
implementations the Linux kernel will set FCSR ABS2008 and NAN2008 bits
both to the same value where possible, reflecting the setting of the
EF_MIPS_NAN2008 ELF file header bit.

Therefore update the bit patterns in macro definitions we use for the
control word, in the 2008-NaN encoding mode, so that both bits have the
same value in a given bit pattern.  Additionally mark the FCSR ABS2008
bit as reserved, so that high-level calls to change the control word do
not affect the bit.

This covers the regular FPU configurations, only leaving exotic corner
cases with the value of FCSR control word initially set by the kernel
different to what our code thinks it is.  To address the remaining cases
the AT_FPUCW auxiliary vector entry would have to be implemented in the
Linux kernel, which currently is not.

References:

[1] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
    MIPS32 Architecture", MIPS Technologies, Inc., Document Number:
    MD00082, Revision 3.50, September 20, 2012, Table 5.5 "FCSR Register
    Field Descriptions", p. 80

[2] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
    MIPS64 Architecture", MIPS Technologies, Inc., Document Number:
    MD00083, Revision 3.50, September 20, 2012, Table 5.5 "FCSR Register
    Field Descriptions", p. 82

[3] "MIPS32 proAptiv Multiprocessing System Software User's Manual",
    MIPS Technologies, Inc., Document Number: MD00878, Revision 01.22,
    May 14, 2013, Table 12.10 "FCSR Bit Field Descriptions", p. 570

[4] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
    MIPS32 Architecture", MIPS Technologies, Inc., Document Number:
    MD00082, Revision 5.03, Sept. 9, 2013, Table 5.7 "FCSR Register
    Field Descriptions", p. 82

[5] "MIPS Architecture For Programmers, Volume I-A: Introduction to the
    MIPS64 Architecture", MIPS Technologies, Inc., Document Number:
    MD00083, Revision 5.03, Sept. 9, 2013, Table 5.7 "FCSR Register
    Field Descriptions", p. 84

	* sysdeps/mips/fpu_control.h (_FPU_RESERVED): Include ABS2008.
	(_FPU_DEFAULT, _FPU_IEEE) [__mips_nan2008]: Set ABS2008.
2015-11-28 11:01:16 +00:00
Carlos O'Donell 90fe682d30 Rename localedir to complocaledir (bug 14259).
In preparation to fix the --localedir configure argument we must
move the existing conflicting definition of localedir to a more
appropriate name. Given that all current internal uses of localedir
relate to the compiled locales we rename to complocaledir.
2015-11-27 10:22:38 -05:00
Andrew Senkevich 977a30801f Better workaround for aliases of *_finite symbols in vector math library.
Old workaround based on assembly aliases can lead to link fail (bug 19058).
This patch makes workaround in another way to avoid it.

    [BZ #19058]
    * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a
    to AS_NEEDED.
    * sysdeps/x86/fpu/bits/math-vector.h: Removed code with old workaround.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support,
    libmvec-static-only-routines): Added new file.
    * sysdeps/x86_64/fpu/svml_finite_alias.S: New file.
2015-11-27 16:22:26 +03:00
Samuel Thibault 4d952856e3 hurd: Initialize __libc_stack_end for hidden support
* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Initialize to get
	into initialized data instead of common.
2015-11-25 17:48:51 +01:00
Samuel Thibault c679db4352 Do not add relro attribute to __libc_stack_end
It does not actually work yet

* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Remove relro attribute.
2015-11-25 17:05:53 +01:00
Samuel Thibault d1e815ed25 Revert not defining NO_HIDDEN on hurd
* sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Define.
       * sysdeps/mach/hurd/configure: Regenerate.
2015-11-25 02:48:22 +01:00
Samuel Thibault 6e45e6ef4d Fix hurd build with hidden support
* hurd/sigunwind.c (_hurdsig_longjmp_from_handler): Destroy reply port
	of interrupted RPC instead of restoring it.

	* sysdeps/i386/setjmp.S (__sigsetjmp): Add hidden_def.
	* sysdeps/mach/hurd/accept4.c (__libc_accept4): Remove
	libc_hidden_def.
	* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Add relro
	attribute, define rtld_hidden_data_def.
	* sysdeps/mach/hurd/fxstatat64.c (__fxstatat64): Add libc_hidden_def.
	* sysdeps/mach/hurd/if_index.c (__if_freenameindex): Add
	libc_hidden_def.
	(if_freenameindex): Add libc_hidden_weak.
	(if_nameindex): Add libc_hidden_weak.
	* sysdeps/mach/hurd/open.c (_open64): Rename libc_hidden_weak into
	__open64.
	* sysdeps/mach/hurd/sigwait.c (__sigwait): Add libc_hidden_def.
	* sysdeps/mach/hurd/xmknodat.c (__xmknodat): Add libc_hidden_def.
	* sysdeps/mach/nanosleep.c: Include <time.h>
	(__nanosleep): Rename to __libc_nanosleep.
	(__nanosleep): Add weak_alias.
	(nanosleep): Update alias.
	* sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Do not define.
	* sysdeps/mach/hurd/configure: Regenerate.
2015-11-25 02:35:18 +01:00
Joseph Myers e02cabecf0 Refactor strtod parsing of NaN payloads.
The nan* functions handle their string argument by constructing a
NAN(...) string on the stack as a VLA and passing it to strtod
functions.

This approach has problems discussed in bug 16961 and bug 16962: the
stack usage is unbounded, and it gives incorrect results in certain
cases where the argument is not a valid n-char-sequence.

The natural fix for both issues is to refactor the NaN payload parsing
out of strtod into a separate function that the nan* functions can
call directly, so that no temporary string needs constructing on the
stack at all.  This patch does that refactoring in preparation for
fixing those bugs (but without actually using the new functions from
nan* - which will also require exporting them from libc at version
GLIBC_PRIVATE).  This patch is not intended to change any user-visible
behavior, so no tests are added (fixes for the above bugs will of
course add tests for them).

This patch builds on my recent fixes for strtol and strtod issues in
Turkish locales.  Given those fixes, the parsing of NaN payloads is
locale-independent; thus, the new functions do not need to take a
locale_t argument.

Tested for x86_64, x86, mips64 and powerpc.

	* stdlib/strtod_nan.c: New file.
	* stdlib/strtod_nan_double.h: Likewise.
	* stdlib/strtod_nan_float.h: Likewise.
	* stdlib/strtod_nan_main.c: Likewise.
	* stdlib/strtod_nan_narrow.h: Likewise.
	* stdlib/strtod_nan_wide.h: Likewise.
	* stdlib/strtof_nan.c: Likewise.
	* stdlib/strtold_nan.c: Likewise.
	* sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h: Likewise.
	* sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h: Likewise.
	* wcsmbs/wcstod_nan.c: Likewise.
	* wcsmbs/wcstof_nan.c: Likewise.
	* wcsmbs/wcstold_nan.c: Likewise.
	* stdlib/Makefile (routines): Add strtof_nan, strtod_nan and
	strtold_nan.
	* wcsmbs/Makefile (routines): Add wcstod_nan, wcstold_nan and
	wcstof_nan.
	* include/stdlib.h (__strtof_nan): Declare and use
	libc_hidden_proto.
	(__strtod_nan): Likewise.
	(__strtold_nan): Likewise.
	(__wcstof_nan): Likewise.
	(__wcstod_nan): Likewise.
	(__wcstold_nan): Likewise.
	* include/wchar.h (____wcstoull_l_internal): Declare.
	* stdlib/strtod_l.c: Do not include <ieee754.h>.
	(____strtoull_l_internal): Remove declaration.
	(STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	(STRTOULL): Likewise.
	(____STRTOF_INTERNAL): Use STRTOF_NAN to parse NaN payload.
	* stdlib/strtof_l.c (____strtoull_l_internal): Remove declaration.
	(STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-128/strtold_l.c (STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c (STRTOF_NAN): Define
	macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c (STRTOF_NAN): Define
	macro.
	(SET_MANTISSA): Remove macro.
	* sysdeps/ieee754/ldbl-96/strtold_l.c (STRTOF_NAN): Define macro.
	(SET_MANTISSA): Remove macro.
	* wcsmbs/wcstod_l.c (____wcstoull_l_internal): Remove declaration.
	* wcsmbs/wcstof_l.c (____wcstoull_l_internal): Likewise.
	* wcsmbs/wcstold_l.c (____wcstoull_l_internal): Likewise.
2015-11-24 22:24:52 +00:00
Chris Metcalf 6a4448afe3 tile: define __NO_LONG_DOUBLE_MATH
This avoids build failures in the tests, and matches what is in
bits/mathdef.h.

Update the libc and libm abilist files to include __finitel,
__isinfl, and __isnanl.
2015-11-24 14:09:31 -05:00
Florian Weimer 2359035ac5 Remove CPU set size checking from affinity functions [BZ #19143]
With current kernel versions, the check does not reliably detect that
unavailable CPUs are requested, for these reasons:

(1) The kernel will silently ignore non-allowed CPUs, that is, CPUs
    which are physically present but disallowed for the thread
    based on system configuration.

(2) Similarly, CPU bits which lack an online CPU (possible CPUs)
    are ignored.

(3) The existing probing code assumes that the CPU mask size is a
    power of two and at least 1024.  Neither has it to be a power
    of two, nor is the minimum possible value 1024, so the value
    determined is often too large.  This means that the CPU set
    size check in glibc accepts CPU bits beyond the actual hard
    system limit.

(4) Future kernel versions may not even have a fixed CPU set size.

After the removal of the probing code, the kernel still returns
EINVAL if no CPU in the requested set remains which can run the
thread after the affinity change.

Applications which care about the exact affinity mask will have
to query it using sched_getaffinity after setting it.  Due to the
effects described above, this commit does not change this.

The new tests supersede tst-getcpu, which is removed.  This
addresses bug 19164 because the new tests allocate CPU sets
dynamically.

	* nptl/check-cpuset.h: Remove.
	* nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new):
	Remove CPU set size check.
	* nptl/pthread_setattr_default_np.c (pthread_setattr_default_np):
	Likewise.
	* sysdeps/unix/sysv/linux/check-cpuset.h: Remove.
	* sysdeps/unix/sysv/linux/pthread_setaffinity.c
	(__kernel_cpumask_size, __determine_cpumask_size): Remove.
	(__pthread_setaffinity_new): Remove CPU set size check.
	* sysdeps/unix/sysv/linux/sched_setaffinity.c
	(__kernel_cpumask_size): Remove.
	(__sched_setaffinity_new): Remove CPU set size check.
	* manual/threads.texi (Default Thread Attributes): Remove stale
	reference to check_cpuset_attr, determine_cpumask_size in comment.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) == posix] (tests):
	Remove tst-getcpu.  Add tst-affinity, tst-affinity-pid.
	[$(subdir) == nptl] (tests): Add tst-thread-affinity-pthread,
	tst-thread-affinity-pthread2, tst-thread-affinity-sched.
	* sysdeps/unix/sysv/linux/tst-affinity.c: New file.
	* sysdeps/unix/sysv/linux/tst-affinity-pid.c: New file.
	* sysdeps/unix/sysv/linux/tst-skeleton-affinity.c: New skeleton test file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c: New file.
	* sysdeps/unix/sysv/linux/tst-thread-skeleton-affinity.c: New
	skeleton test file.
	* sysdeps/unix/sysv/linux/tst-getcpu.c: Remove.  Superseded by
	tst-affinity-pid.
2015-11-24 17:21:01 +01:00
Florian Weimer 400e12265d Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code
* sysdeps/mach/hurd/libc-lock.h (_LIBC_LOCK_INITIALIZER): Define.
	(__libc_lock_define_initialized): Use it.
	* sysdeps/nptl/libc-lockP.h (_LIBC_LOCK_INITIALIZER): Define.
	* malloc/arena.c (list_lock): Use _LIBC_LOCK_INITIALIZER.
	* malloc/malloc.c (main_arena): Likewise.
	* sysdeps/generic/malloc-machine.h (MUTEX_INITIALIZER): Remove.
	* sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Remove.
2015-11-24 16:37:15 +01:00
Joseph Myers a61a1a2576 Update <sys/ptrace.h> for Linux 4.3.
This patch updates <sys/ptrace.h> for Linux 4.3, adding
PTRACE_O_SUSPEND_SECCOMP and updating the value of PTRACE_O_MASK.
Some architectures were missing the older PTRACE_O_EXITKILL, so that
was added to the files missing it as well.

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

	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
	(PTRACE_O_EXITKILL): New value in enum __ptrace_setoptions.
	(PTRACE_O_SUSPEND_SECCOMP): Likewise.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h (PTRACE_O_EXITKILL):
	New value in enum __ptrace_setoptions.
	(PTRACE_O_SUSPEND_SECCOMP): Likewise.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
	(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
	(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
	(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/sys/ptrace.h (PTRACE_O_SUSPEND_SECCOMP):
	New value in enum __ptrace_setoptions.
	(PTRACE_O_MASK): Update value.
	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h (PTRACE_O_EXITKILL):
	New value in enum __ptrace_setoptions.
	(PTRACE_O_SUSPEND_SECCOMP): Likewise.
	(PTRACE_O_MASK): Update value.
2015-11-23 17:53:08 +00:00
Joseph Myers dd17ede807 Update <netpacket/packet.h> for Linux 4.3.
In the course of reviewing Linux 4.3 changes for any glibc header
updates needed, I found that
sysdeps/unix/sysv/linux/netpacket/packet.h was extremely out of date
(last updated for Linux 2.3.15, it seems).  This patch updates the
sets of constants present in that header to include those added to
those sets in newer kernels (include/uapi/linux/if_packet.h).

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

	* sysdeps/unix/sysv/linux/netpacket/packet.h (PACKET_COPY_THRESH):
	New macro.
	(PACKET_AUXDATA): Likewise.
	(PACKET_ORIGDEV): Likewise.
	(PACKET_VERSION): Likewise.
	(PACKET_HDRLEN): Likewise.
	(PACKET_RESERVE): Likewise.
	(PACKET_TX_RING): Likewise.
	(PACKET_LOSS): Likewise.
	(PACKET_VNET_HDR): Likewise.
	(PACKET_TX_TIMESTAMP): Likewise.
	(PACKET_TIMESTAMP): Likewise.
	(PACKET_FANOUT): Likewise.
	(PACKET_TX_HAS_OFF): Likewise.
	(PACKET_QDISC_BYPASS): Likewise.
	(PACKET_ROLLOVER_STATS): Likewise.
	(PACKET_FANOUT_DATA): Likewise.
	(PACKET_MR_UNICAST): Likewise.
2015-11-23 17:52:08 +00:00
Roland McGrath f549f0bcba NaCl: Use allocate_code_data after dyncode_create 2015-11-20 16:16:35 -08:00
Joseph Myers 2d2c271aea Fix math_private.h multiple include guards.
Various math_private.h headers are guarded by "#ifndef
_MATH_PRIVATE_H", but never define the macro.  Nothing else defines
the macro either (the generic math_private.h that they include defines
a different macro, _MATH_PRIVATE_H_), so those guards are ineffective.

With the recent inclusion of s_sin.c in s_sincos.c, this breaks the
build for MIPS, since the build of s_sincos.c ends up including
<math_private.h> twice and the MIPS version defines inline functions
such as libc_feholdexcept_mips, without a separate fenv_private.h
header with its own guards such as some architectures have.

This patch fixes all the problem headers to use architecture-specific
guard macro names, and to define those macros in the headers they
guard, just as some architectures already do.

Tested for x86 (testsuite, and that installed shared libraries are
unchanged by the patch), and for mips64 (that it fixes the build).

	* sysdeps/arm/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!ARM_MATH_PRIVATE_H].
	[!ARM_MATH_PRIVATE_H] (ARM_MATH_PRIVATE_H): Define macro.
	* sysdeps/hppa/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!HPPA_MATH_PRIVATE_H].
	[!HPPA_MATH_PRIVATE_H] (HPPA_MATH_PRIVATE_H): Define macro.
	* sysdeps/i386/fpu/math_private.h [!_MATH_PRIVATE_H]: Change guard
	to [!I386_MATH_PRIVATE_H].
	[!I386_MATH_PRIVATE_H] (I386_MATH_PRIVATE_H): Define macro.
	* sysdeps/m68k/m680x0/fpu/math_private.h [!_MATH_PRIVATE_H]:
	Change guard to [!M68K_MATH_PRIVATE_H].
	[!M68K_MATH_PRIVATE_H] (M68K_MATH_PRIVATE_H): Define macro.
	* sysdeps/microblaze/math_private.h [!_MATH_PRIVATE_H]: Change
	guard to [!MICROBLAZE_MATH_PRIVATE_H].
	[!MICROBLAZE_MATH_PRIVATE_H] (MICROBLAZE_MATH_PRIVATE_H): Define
	macro.
	* sysdeps/mips/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!MIPS_MATH_PRIVATE_H].
	[!MIPS_MATH_PRIVATE_H] (MIPS_MATH_PRIVATE_H): Define macro.
	* sysdeps/nios2/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!NIO2_MATH_PRIVATE_H].
	[!NIO2_MATH_PRIVATE_H] (NIO2_MATH_PRIVATE_H): Define macro.
	* sysdeps/tile/math_private.h [!_MATH_PRIVATE_H]: Change guard to
	[!TILE_MATH_PRIVATE_H].
	[!TILE_MATH_PRIVATE_H] (TILE_MATH_PRIVATE_H): Define macro.
2015-11-20 23:46:23 +00:00
Joseph Myers d709042a6e Fix lgamma setting signgam for ISO C (bug 15421).
The lgamma (and likewise lgammaf, lgammal) function wrongly sets the
signgam variable even when building for strict ISO C conformance
(-std=c99 / -std=c11), although the user may define such a variable
and it's only in the implementation namespace for POSIX with XSI
extensions enabled.

Following discussions starting at
<https://sourceware.org/ml/libc-alpha/2013-04/msg00767.html> and
<https://sourceware.org/ml/libc-alpha/2015-10/msg00844.html>, it seems
that the safest approach for fixing this particular issue is for
signgam to become a weak alias for a newly exported symbol __signgam,
with the library functions only setting __signgam, at which point
static linker magic will preserve the alias for newly linked binaries
that refer to the library's signgam rather than defining their own,
while breaking the alias for programs that define their own signgam,
with new symbol versions for lgamma functions and with compat symbols
for existing binaries that set both signgam and __signgam.

This patch implements that approach for the fix.  signgam is made into
a weak alias.  The four symbols __signgam, lgamma, lgammaf, lgammal
get new symbol versions at version GLIBC_2.23, with the existing
versions of lgamma, lgammaf and lgammal becoming compat symbols.

When the compat versions are built, gamma, gammaf and gammal are
aliases for the compat versions (i.e. always set signgam); this is OK
as they are not ISO C functions, and avoids adding new symbol versions
for them unnecessarily.  When the compat versions are not built
(i.e. for static linking and for future glibc ports), gamma, gammaf
and gammal are aliases for the new versions that set __signgam.  The
ldbl-opt versions are updated accordingly.

The lgamma wrappers are adjusted so that the same source files,
included from different files with different definitions of
USE_AS_COMPAT, can build either the new versions or the compat
versions.  Similar changes are made to the ia64 versions (untested).

Tests are added that the lgamma functions do not interfere with a user
variable called signgam for ISO C, with various choices for the size
of that variable, whether it is initialized, and for static and
dynamic linking.  The conformtest whitelist entry is removed as well.

Tested for x86_64, x86, mips64 and powerpc, including looking at
objdump --dynamic-syms output to make sure the expected sets of
symbols were aliases.  Also spot-tested that a binary built with old
glibc works properly (i.e. gets signgam set) when run with new glibc.

	[BZ #15421]
	* sysdeps/ieee754/s_signgam.c (signgam): Rename to __signgam,
	initialize with 0 and define as weak alias of __signgam.
	* include/math.h [!_ISOMAC] (__signgam): Declare.
	* math/Makefile (libm-calls): Add w_lgamma_compat.
	(tests): Add test-signgam-uchar, test-signgam-uchar-init,
	test-signgam-uint, test-signgam-uint-init, test-signgam-ullong and
	test-signgam-ullong-init.
	(tests-static): Add test-signgam-uchar-static,
	test-signgam-uchar-init-static, test-signgam-uint-static,
	test-signgam-uint-init-static, test-signgam-ullong-static and
	test-signgam-ullong-init-static.
	(CFLAGS-test-signgam-uchar.c): New variable.
	(CFLAGS-test-signgam-uchar-init.c): Likewise.
	(CFLAGS-test-signgam-uchar-static.c): Likewise.
	(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
	(CFLAGS-test-signgam-uint.c): Likewise.
	(CFLAGS-test-signgam-uint-init.c): Likewise.
	(CFLAGS-test-signgam-uint-static.c): Likewise.
	(CFLAGS-test-signgam-uint-init-static.c): Likewise.
	(CFLAGS-test-signgam-ullong.c): Likewise.
	(CFLAGS-test-signgam-ullong-init.c): Likewise.
	(CFLAGS-test-signgam-ullong-static.c): Likewise.
	(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
	* math/Versions (libm): Add GLIBC_2.23.
	* math/lgamma-compat.h: New file.
	* math/test-signgam-main.c: Likewise.
	* math/test-signgam-uchar-init-static.c: Likewise.
	* math/test-signgam-uchar-init.c: Likewise.
	* math/test-signgam-uchar-static.c: Likewise.
	* math/test-signgam-uchar.c: Likewise.
	* math/test-signgam-uint-init-static.c: Likewise.
	* math/test-signgam-uint-init.c: Likewise.
	* math/test-signgam-uint-static.c: Likewise.
	* math/test-signgam-uint.c: Likewise.
	* math/test-signgam-ullong-init-static.c: Likewise.
	* math/test-signgam-ullong-init.c: Likewise.
	* math/test-signgam-ullong-static.c: Likewise.
	* math/test-signgam-ullong.c: Likewise.
	* math/w_lgamma.c: Rename to w_lgamma_main.c and replace by
	wrapper of w_lgamma_main.c.
	* math/w_lgamma_compat.c: New file.
	* math/w_lgamma_compatf.c: Likewise.
	* math/w_lgamma_compatl.c: Likewise.
	* math/w_lgamma_main.c: New file.  Based on w_lgamma.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgamma): Change to LGFUNC (__lgamma).  Use CALL_LGAMMA.
	* math/w_lgammaf.c: Rename to w_lgammaf_main.c and replace by
	wrapper of w_lgammaf_main.c.
	* math/w_lgammaf_main.c: New file.  Based on w_lgammaf.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgammaf): Change to LGFUNC (__lgammaf).  Use CALL_LGAMMA.
	* math/w_lgammal.c: Rename to w_lgammal_main.c and replace by
	wrapper of w_lgammal_main.c.
	* math/w_lgammal_main.c: New file.  Based on w_lgammal.c.  Include
	<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
	defining compatibility symbols.
	(__lgammal): Change to LGFUNC (__lgammal).  Use CALL_LGAMMA.
	* sysdeps/ia64/fpu/lgamma-compat.h: New file.
	* sysdeps/ia64/fpu/w_lgamma.c: Move to ....
	* sysdeps/ia64/fpu/w_lgamma_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgamma): Change to LGFUNC (lgamma).  Use CALL_LGAMMA.
	(__ieee754_gamma): Define as alias.
	* sysdeps/ia64/fpu/w_lgammaf.c: Move to ....
	* sysdeps/ia64/fpu/w_lgammaf_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgammaf): Change to LGFUNC (lgammaf).  Use CALL_LGAMMA.
	(__ieee754_gammaf): Define as alias.
	* sysdeps/ia64/fpu/w_lgammal.c: Move to ....
	* sysdeps/ia64/fpu/w_lgammal_main.c: ...here.  Include
	<lgamma-compat.h>.
	(__ieee754_lgammal): Change to LGFUNC (lgammal).  Use CALL_LGAMMA.
	(__ieee754_gammal): Define as alias.
	* sysdeps/ieee754/ldbl-opt/w_lgamma.c: Move to ....
	* sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c: ...here.  Include
	<math/w_lgamma_compat.c>.
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (__lgammal_dbl_compat):
	Define as alias of __lgamma_compat and use in defining lgammal.
	* sysdeps/ieee754/ldbl-opt/w_lgammal.c: Move to ....
	* sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c: ...here.  Include
	<math/lgamma-compat.h> and <math/w_lgamma_compatl.c>.
	(USE_AS_COMPAT): New macro.
	(LGAMMA_OLD_VER): Undefine and redefine.
	(lgammal): Do not define here.
	(gammal): Only define here if [GAMMA_ALIAS].
	* conform/linknamespace.pl (@whitelist): Remove signgam.
	* 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.
2015-11-20 22:49:59 +00:00
Adhemerval Zanella 8c873bf019 Remove signal handling for nanosleep (bug 16364)
Linux 2.6.32 and forward do not show the issue regarding SysV SIGCHLD
vs. SIG_IGN for nanosleep which make it feasible to use it for sleep
implementation without requiring any hacking to handle the spurious
wake up.  The issue is likely being fixed before 2.6 and git
history [1] [2].

This patch simplifies the sleep code to call nanosleep directly by
using the posix default version.  It also removes the early cancellation
tests for zero argument, since nanosleep will handle cancellation
in this case.

[1] https://lkml.org/lkml/2004/11/25/5
[2] https://lkml.org/lkml/2003/11/8/50

Checked on x86_64, ppc64le, and aarch64.

	[BZ #16364]
	* sysdeps/unix/sysv/linux/sleep.c: Remove file
	* sysdeps/posix/sleep.c (__sleep): Simplify cancellation handling.
2015-11-20 11:16:07 -02:00
Stefan Liebler 31cf39421b S390: Use __asm__ instead of asm.
* sysdeps/s390/fpu/bits/mathinline.h:
	Use __asm__ [__volatile__] instead of asm [volatile].
	* sysdeps/s390/abort-instr.h: Likewise.
	* sysdeps/s390/atomic-machine.h: Likewise.
	* sysdeps/s390/bits/string.h: Likewise.
	* sysdeps/s390/dl-tls.h: Likewise.
	* sysdeps/s390/fpu/e_sqrt.c: Likewise.
	* sysdeps/s390/fpu/e_sqrtf.c: Likewise.
	* sysdeps/s390/fpu/e_sqrtl.c: Likewise.
	* sysdeps/s390/fpu/fesetround.c: Likewise.
	* sysdeps/s390/fpu/fpu_control.h: Likewise.
	* sysdeps/s390/fpu/s_fma.c: Likewise.
	* sysdeps/s390/fpu/s_fmaf.c: Likewise.
	* sysdeps/s390/memusage.h: Likewise.
	* sysdeps/s390/multiarch/ifunc-resolve.h: Likewise.
	* sysdeps/s390/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/s390/nptl/pthread_spin_trylock.c: Likewise.
	* sysdeps/s390/nptl/pthread_spin_unlock.c: Likewise.
	* sysdeps/s390/nptl/tls.h: Likewise.
	* sysdeps/s390/s390-32/__longjmp.c: Likewise.
	* sysdeps/s390/s390-32/backtrace.c: Likewise.
	* sysdeps/s390/s390-32/dl-machine.h: Likewise.
	* sysdeps/s390/s390-32/multiarch/memcmp.c: Likewise.
	* sysdeps/s390/s390-32/stackguard-macros.h: Likewise.
	* sysdeps/s390/s390-32/tls-macros.h: Likewise.
	* sysdeps/s390/s390-64/__longjmp.c: Likewise.
	* sysdeps/s390/s390-64/backtrace.c: Likewise.
	* sysdeps/s390/s390-64/dl-machine.h: Likewise.
	* sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c: Likewise.
	* sysdeps/s390/s390-64/multiarch/memcmp.c: Likewise.
	* sysdeps/s390/s390-64/stackguard-macros.h: Likewise.
	* sysdeps/s390/s390-64/tls-macros.h: Likewise.
	* sysdeps/s390/s390-64/utf16-utf32-z9.c: Likewise.
	* sysdeps/s390/s390-64/utf8-utf16-z9.c: Likewise.
	* sysdeps/s390/s390-64/utf8-utf32-z9.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/brk.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/elision-trylock.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sysconf.c: Likewise.
2015-11-20 08:56:40 +01:00
Paul Murphy 9695cb3e65 powerpc: Spinlock optimization and cleanup
This patch optimizes powerpc spinlock implementation by:

* Use the correct EH hint bit on the larx for supported ISA.  For lock
  acquisition, the thread that acquired the lock with a successful stcx
  does not want to give away the write ownership on the cacheline.  The
  idea is to make the load reservation "sticky" about retaining write
  authority to the line.  That way, the store that must inevitably come
  to release the lock can succeed quickly and not contend with other
  threads issuing lwarx.  If another thread does a store to the line
  (false sharing), the winning thread must give up write authority to
  the proper value of EH for the larx for a lock acquisition is 1.

* Increase contented lock performance by up to 40%, and no measurable
  impact on uncontended locks on P8.

Thanks to Adhemerval Zanella who did most of the work.  I've run some
tests, and addressed some minor feedback.

	* sysdeps/powerpc/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Add lwarx hint, and use macro for acquire instruction.
	* sysdeps/powerpc/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* sysdep/unix/sysv/linux/powerpc/pthread_spin_unlock.c: Move to ...
	* sysdeps/powerpc/nptl/pthread_spin_unlock.c: ... here, and
	update to use new atomic macros.
2015-11-19 18:04:30 -02:00
Paul Murphy 86b4939846 powerpc: More elision improvements
__lll_trylock_elision sets the adapt_count variable too
aggressively, and incorrectly on persistent aborts.  Taking
a cue from s390, adapt_count is only updated if the lock
is locked, or a persistent failure occurs.

In addition, the abort codes have been renumbered and
refactored for clarity.  As it stands, glibc only cares
if the abort is persistent or not.

All aborts are now persistent, excepting a busy lock.  This
includes changing _ABORT_NESTED_TRYLOCK into a persistent
abort.

	* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
	(__lll_trylock_elision): Fix setting of adapt_count.
	* sysdeps/unix/sysv/linux/powerpc/htm.h
	(_ABORT_PERSISTENT): Define to clarify persistent aborts.
	(_ABORT_NESTED_TRYLOCK): Renumber, and make persistent.
	(_ABORT_SYSCALL): Renumber, and clarify definition.
	(_ABORT_LOCK_BUSY): Renumber, make non-persistent.
2015-11-19 16:15:42 -02:00
Paul Murphy 79adcb58f6 Shuffle includes in ldbl-128ibm/mpn2ldl.c
Kind of hokey, but errno.h drags in misc/sys/param.h which
defines MIN/MAX causing an error.  Include system headers
first to grab MIN/MAX definition in param.h, and define
HAVE_ALLOCA to preserve existing behavior.

	* sysdeps/ieee754/ldbl-128ibm/mpn2ldl.c: Include gmp headers
	after system headers to prevent MIN/MAX redefinition.  Define
	HAVE_ALLOCA to preserve builtin alloca usage.
2015-11-19 15:52:43 -02:00
Siddhesh Poyarekar 463ac90dab Include s_sin.c in s_sincos.c
Include the __sin and __cos functions as local static copies to allow
deper optimization of the functions.  This change shows an improvement
of about 17% in the min case and 12.5% in the mean case for the sincos
microbenchmark on x86_64.

	* sysdeps/ieee754/dbl-64/s_sin.c (__sin)[IN_SINCOS]: Mark function
	static and don't set or restore rounding.
	(__cos)[IN_SINCOS]: Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c: Include s_sin.c.
	(__sincos): Set and restore rounding mode.  Remove check for infinite
	or NaN input.
2015-11-17 21:11:31 +05:30
Siddhesh Poyarekar b7665e5163 Remove redundant else clauses in s_sin.c
Makes the code easier to read due to the reduced nesting.  The
generated binary is unchanged.
2015-11-17 16:03:11 +05:30
H.J. Lu 89569c8bb6 Run tst-prelink test for GLOB_DAT reloc
Run tst-prelink test on targets with GLOB_DAT relocaton.

	* config.make.in (have-glob-dat-reloc): New.
	* configure.ac (libc_cv_has_glob_dat): New.  Set to yes if
	target supports GLOB_DAT relocaton. AC_SUBST.
	* configure: Regenerated.
	* elf/Makefile (tests): Add tst-prelink.
	(tests-special): Add $(objpfx)tst-prelink-cmp.out.
	(tst-prelink-ENV): New.
	($(objpfx)tst-prelink-conflict.out): Likewise.
	($(objpfx)tst-prelink-cmp.out): Likewise.
	* sysdeps/x86/tst-prelink.c: Moved to ...
	* elf/tst-prelink.c: Here.
	* sysdeps/x86/tst-prelink.exp: Moved to ...
	* elf/tst-prelink.exp: Here.
	* sysdeps/x86/Makefile (tests): Don't add tst-prelink.
	(tst-prelink-ENV): Removed.
	($(objpfx)tst-prelink-conflict.out): Likewise.
	($(objpfx)tst-prelink-cmp.out): Likewise.
	(tests-special): Don't add $(objpfx)tst-prelink-cmp.out.
2015-11-14 12:00:38 -08:00
Joseph Myers 909f8e14db Fix ldbl-128ibm strtold overflow handling (bug 14551).
For ldbl-128ibm, if the result of strtold overflows in the final
conversion from MPN to IBM long double (because the exponent for a
106-bit IEEE result is 1023 but the high part would end up as
0x1p1024, which overflows), that conversion code fails to handle this
and produces an invalid long double value (high part infinite, low
part not zero) without raising exceptions or setting errno.  This
patch adds an explicit check for this case to ensure an appropriate
result is returned in a way that ensures the right exceptions are
raised, with errno set.

Tested for powerpc.

	[BZ #14551]
	* sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c: Include <errno.h>.
	(__mpn_construct_long_double): If high part overflows to infinity,
	set errno and recompute overflowed result of the correct sign.
	* sysdeps/ieee754/ldbl-128ibm/Makefile
	[$(subdir) = stdlib] (tests): Add tst-strtold-ldbl-128ibm.
	[$(subdir) = stdlib] ($(objpfx)tst-strtold-ldbl-128ibm): Depend on
	$(libm).
	* sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c: New file.
2015-11-13 12:03:46 +00:00
Joseph Myers 21378ae0d3 Fix powerpc round, roundf spurious "inexact" (bug 19238).
The powerpc hard-float round and roundf functions, both 32-bit and
64-bit, raise spurious "inexact" exceptions for integer arguments from
adding 0.5 and rounding to integer toward zero.

Since these functions already save and restore the rounding mode, it's
natural to make them restore the full floating-point state instead to
fix this bug, which this patch does.  The save of the state is moved
after the first floating-point operation on the input so that any
"invalid" exceptions from signaling NaN inputs are properly
preserved.  As a consequence of this approach to the fix, "inexact"
for noninteger arguments (disallowed by TS 18661-1 but not by C99/C11,
see bug 15479) is also avoided for these implementations; this is
*not* a general fix for bug 15479 since plenty of other
implementations of various functions still raise spurious "inexact"
for noninteger arguments.

This issue and fix do not apply to builds using power5+ versions of
round and roundf, which use the frin instruction and avoid "inexact"
exceptions that way.

This patch should get hard-float powerpc32 and powerpc64 (default
function implementations) back to a state where test-float and
test-double will pass after ulps regeneration.

Tested for powerpc32 and powerpc64.

	[BZ #15479]
	[BZ #19238]
	* sysdeps/powerpc/powerpc32/fpu/s_round.S (__round): Save
	floating-point state after first operation on input.  Restore full
	state rather than just rounding mode.
	* sysdeps/powerpc/powerpc32/fpu/s_roundf.S (__roundf): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_round.S (__round): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_roundf.S (__roundf): Likewise.
2015-11-12 19:00:06 +00:00
Joseph Myers 32b71ad358 Fix powerpc64 lround, lroundf, llround, llroundf spurious "inexact" exceptions (bug 19235).
Similar to bug 19134 for powerpc32, the powerpc64 implementations of
lround, lroundf, llround, llroundf can raise spurious "inexact"
exceptions for integer arguments from adding 0.5 then converting to
integer (this does not apply to the power5+ version for double, which
uses the frin instruction which is defined never to raise "inexact"; I
don't know why power5+ doesn't use that version for float as well).

This patch fixes the bug in a similar way to the powerpc32 bug, by
testing for integers (adding and subtracting 2^52 and comparing with
the value before that addition and subtraction) and not adding 0.5 in
that case.

The powerpc maintainers may wish to look at making power5+ / power6x /
power8 use frin for float lround / llround as well as for double,
unless there's some reason I've missed that this isn't beneficial.

Tested for powerpc64.

	[BZ #19235]
	* sysdeps/powerpc/powerpc64/fpu/s_llround.S (__llround): Do not
	add 0.5 to integer arguments.
	* sysdeps/powerpc/powerpc64/fpu/s_llroundf.S (__llroundf):
	Likewise.
	(.LC2): New object.
2015-11-12 16:24:00 +00:00
Roland McGrath c0d6f2a33e NaCl: Use open_resource API for shared objects 2015-11-10 19:44:48 -08:00
Joseph Myers 71d1b0166b Fix powerpc nearbyint wrongly clearing "inexact" and leaving traps disabled (bug 19228).
Similar to bug 15491 recently fixed for x86_64 / x86, the powerpc
(both powerpc32 and powerpc64) hard-float implementations of
nearbyintf and nearbyint wrongly clear an "inexact" exception that was
raised before the function was called; this shows up as failure of the
test math/test-nearbyint-except added when that bug was fixed.  They
also wrongly leave traps on "inexact" disabled if they were enabled
before the function was called.

This patch fixes the bugs similar to how the x86 bug was fixed: saving
and restoring the whole floating-point state, both to restore the
original "inexact" flag state and to restore the original state of
whether traps on "inexact" were enabled.  Because there's a convenient
point in the powerpc implementations to save state after any sNaN
arguments will have raised "invalid" but before "inexact" traps need
to be disabled, no special handling for "invalid" is needed as in the
x86 version.

Tested for powerpc64 and powerpc32, where it fixes the
math/test-nearbyint-except failure as well as fixing the new test
math/test-nearbyint-except-2 added by this patch.  Also tested for
x86_64 and x86 that the new test passes.

If powerpc experts see a more efficient way of doing this
(e.g. instruction positioning that's better for pipelines on typical
processors) then of course followups optimizing the fix are welcome.

	[BZ #19228]
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S (__nearbyint): Save
	and restore full floating-point state.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S (__nearbyintf):
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S (__nearbyint):
	Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S (__nearbyintf):
	Likewise.
	* math/test-nearbyint-except-2.c: New file.
	* math/Makefile (tests): Add test-nearbyint-except-2.
2015-11-11 00:06:09 +00:00
H.J. Lu fe534fe898 Add a test for prelink output
This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.

	[BZ #19178]
	* sysdeps/x86/Makefile (tests): Add tst-prelink.
	(tst-prelink-ENV): New.
	($(objpfx)tst-prelink-conflict.out): Likewise.
	($(objpfx)tst-prelink-cmp.out): Likewise.
	(tests-special): Add $(objpfx)tst-prelink-cmp.out.
	* sysdeps/x86/tst-prelink.c: New file.
	* sysdeps/x86/tst-prelink.exp: Likewise.
2015-11-10 12:27:24 -08:00
Adhemerval Zanella 71bbdde7f5 Fix nearbyintl linkage for ia64 (bug 19219)
GLIBC fails to build for ia64 since commit d0d286d32d.
It is because this commit uses the internal definition for nearbyintl,
but ia64 specialized implementation (sysdeps/ia64/fpu/s_nearbyintl.S)
does not define it.

Tested with a ia64 build.

        [BZ #19219]
        * sysdeps/ia64/fpu/s_nearbyintl.S (__nearbyint): Define and
        weak_alias to nearbyintl.
2015-11-10 10:56:24 -02:00
Wilco Dijkstra 2fee269248 Enable _STRING_ARCH_unaligned on AArch64.
* sysdeps/aarch64/bits/string.h: New file.
        (_STRING_ARCH_unaligned): Define.
2015-11-10 11:15:59 +00:00
Wilco Dijkstra 755f6e0ad5 Remove __signbit* from localplt.data as they are no longer called from within GLIBC.
* sysdeps/unix/sysv/linux/aarch64/localplt.data: Remove __signbit*.
	* sysdeps/unix/sysv/linux/arm/localplt.data: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/localplt.data: Likewise.
	* sysdeps/unix/sysv/linux/nios2/localplt.data: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/localplt.data: Likewise.
2015-11-10 11:15:43 +00:00
Florian Weimer a1b85ae88b ld.so: Add original DSO name if overridden by audit module [BZ #18251]
* elf/dl-load.c (_dl_map_object_from_fd): Add additional parameter
	for original name of the DSO.  Add it to the name list of the DSO
	if it is actually given.
	(_dl_map_object): Keep track of whether an audit module rewrote
	the file name.  If yes, pass the original name to
	_dl_map_object_from_fd in a new parameter, otherwise NULL.  When
	debugging is enabled, log the change of the file name.
	* sysdeps/mach/hur/dl-sysdep.c: Adjust commented-out call to
	_dl_map_object_from_fd.
	* elf/Makefile: Build and run tst-audit11 and tst-audit12.
	* elf/tst-audit11.c: New file
	* elf/tst-auditmod11.c: New file.
	* elf/tst-audit11mod1.c: New file.
	* elf/tst-audit11mod2.c: New file.
	* elf/tst-audit11mod2.map: New file.
	* elf/tst-audit12.c: New file
	* elf/tst-auditmod12.c: New file.
	* elf/tst-audit12mod1.c: New file.
	* elf/tst-audit12mod2.c: New file.
	* elf/tst-audit12mod2.map: New file.
	* elf/tst-audit12mod3.c: New file.
2015-11-09 17:01:46 +01:00
Stefan Liebler 37d13b179c S390: Clean setjmp, longjmp, getcontext symbols.
For each function setjmp, longjmp, getcontext, there exist a symbol
<func> and a default/versioned symbol <func>@@GLIBC_2.x in the build
obj-files.
This is wrong because it should only exist an unversioned or a
default-versioned symbol with the same name in an obj-file.
Glibc can't be build with recent binutils. See the already fixed linker
bug https://sourceware.org/bugzilla/show_bug.cgi?id=19073.
Nevertheless, this patch cleans this up.

Furthermore the BSD entry points setjmp, _setjmp were marked as weak,
but should be strong as on other architectures.
(see https://sourceware.org/ml/libc-alpha/2014-07/msg00568.html for an
older discussion with Andreas Schwab)

Some whitespace issues are corrected in sysdeps/s390/s390-64/setjmp.S,
too. But there is no change in the assembler code.

ChangeLog:

	* sysdeps/s390/longjmp.c (longjmp, _longjmp, siglongjmp):
	Don't create weak aliases,
	because versioned symbols are created later.
	* sysdeps/s390/s390-32/setjmp.S
	(setjmp, _setjmp): Remove weak and rename to an unique name
	in SHARED case due to existing versioned symbols.
	* sysdeps/s390/s390-64/setjmp.S: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S
	(getcontext): Create weak alias only in non SHARED case.
	* sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S: Likewise.
2015-11-09 16:14:49 +01:00
Stefan Liebler 016495b818 S390: Call direct system calls for socket operations.
this patch calls direct system calls for socket operations in the same way as power does. The system calls were introduced in kernel commit https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=977108f89c989b1eeb5c8d938e1e71913391eb5f.
There are no direct recv, send, accept syscalls available on s390. Thus
recvfrom, sendto, accept4 are called instead of the socketcall by defining __ASSUME_*_FOR_*_SYSCALL macros. See recv.c, send.c, accept.c in sysdeps/unix/sysv/linux/ folder.

The socketcalls in syscalls.list for s390-64 are removed. They were never used on s390x.

ChangeLog:

	* sysdeps/unix/sysv/linux/s390/kernel-features.h:
	(__ASSUME_*_SYSCALL) Define new macros.
	* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
	Remove socketcall syscalls.
	* sysdeps/unix/sysv/linux/accept.c (__libc_accept):
	Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
	* sysdeps/unix/sysv/linux/recv.c (__libc_recv):
	Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
	* sysdeps/unix/sysv/linux/send.c (__libc_send):
	Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.
2015-11-09 16:14:49 +01:00
Florian Weimer 2eecc8afd0 Terminate process on invalid netlink response from kernel [BZ #12926]
The recvmsg system calls for netlink sockets have been particularly
prone to picking up unrelated data after a file descriptor race
(where the descriptor is closed and reopened concurrently in a
multi-threaded process, as the result of a file descriptor
management issue elsewhere).  This commit adds additional error
checking and aborts the process if a datagram of unexpected length
(without the netlink header) is received, or an error code which
cannot happen due to the way the netlink socket is used.

	[BZ #12926]
	Terminate process on invalid netlink response.
	* sysdeps/unix/sysv/linux/netlinkaccess.h
	(__netlink_assert_response): Declare.
	* sysdeps/unix/sysv/linux/netlink_assert_response.c: New file.
	* sysdeps/unix/sysv/linux/Makefile [$(subdir) == inet]
	(sysdep_routines): Add netlink_assert_response.
	* sysdeps/unix/sysv/linux/check_native.c (__check_native): Call
	__netlink_assert_response.
	* sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise.
	* sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise.
	* sysdeps/unix/sysv/linux/Versions (GLIBC_PRIVATE): Add
	__netlink_assert_response.
2015-11-09 12:48:41 +01:00
Florian Weimer 8c77b6ad40 Simplify the abilist format
The new format lists the version on each line, as in:

	VERSION SYMBOL TYPE [VALUE]

This makes it easier to process the files with line-oriented tools.

The abilist files were converted with this awk script:

/^[^ ]/ { version = $1 }
/^ / { print version, substr($0, 2) }

And sorted under the "C" locale with sort.
2015-11-06 13:58:53 +01:00
Mark Wielaard 8b7b7f75d9 Add LFS support for fts functions (bug 11460)
fts didn't have large-file support yet and fts.h had an #error preventing
usage when _FILE_OFFSET_BITS was set. This required nasty workarounds for
programs using fts with LFS. This patch implements LFS support for fts by
adding FTS64 and FTENT64 variants plus fts64 functions. Which are simple
aliases for 64bit off_t arches.

Also includes a simple testcase for some of the fts functions with or
without LFS enabled.

	[BZ #11460]
	* io/Makefile (routines): Add fts64.
	(tests): Add tst-fts and tst-fts-lfs.
	(CFLAGS-fts64.c): New.
	* io/Versions (GLIBC_2.23): New.
	* io/fts.c: Replace FTS with FTSOBJ, FTSENT with FTSENTRY. Use
	function defines FTS_OPEN, FTS_CLOSE, FTS_READ, FTS_SET and
	FTS_CHILDREN. Define FTSOBJ, FTSENTRY, FTS_OPEN, FTS_CLOSE,
	FTS_READ, FTS_SET, FTS_CHILDREN, INO_T, STAT and LSTAT if necessary.
	* io/fts.h (FTS64): New if _USE_LARGEFILE64.
	(FTSENT64): Likewise.
	(fts64_children): Likewise.
	(fts64_close): Likewise.
	(fts64_open): Likewise.
	(fts64_read): Likewise.
	(fts64_set): Likewise.
	* io/fts64.c: New file.
	* io/tst-fts.c: New test.
	* io/tst-fts-lfs.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.23): Add
	GLIBC_2.23, fts64_children, fts64_close, fts64_open, fts64_read and
	fts64_set.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/wordsize-64/fts.c: New file.
	* sysdeps/wordsize-64/fts64.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/fts.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/fts64.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/fts.c: likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/fts64.c: likewise.
2015-11-06 11:24:16 +01:00
Joseph Myers 01189b083b Fix i386/x86_64 log* (1) zero sign for -ffinite-math-only (bug 19213).
For the -ffinite-math-only versions of various x86_64 and x86 log*
functions, a zero result from log* (1) is returned with incorrect sign
in round-downward mode.  This patch fixes this in a similar way to the
previous fixes for the non-*_finite versions of the functions.

Tested for x86_64 and x86 (including an i586 build), together with a
patch that will be applied separately to enable the main libm-test.inc
tests for the finite-math-only functions.

	[BZ #19213]
	* sysdeps/i386/fpu/e_log.S (__log_finite): Ensure +0 is always
	returned for argument 1.
	* sysdeps/i386/fpu/e_logf.S (__logf_finite): Likewise.
	* sysdeps/i386/fpu/e_logl.S (__logl_finite): Likewise.
	* sysdeps/i386/i686/fpu/e_logl.S (__logl_finite): Likewise.
	* sysdeps/x86_64/fpu/e_log10l.S (__log10l_finite): Likewise.
	* sysdeps/x86_64/fpu/e_log2l.S (__log2l_finite): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S (__logl_finite): Likewise.
2015-11-05 21:56:31 +00:00
Joseph Myers 9f9f27248b Remove miscellaneous GCC >= 4.7 version conditionals.
This patch removes miscellaneous __GNUC_PREREQ (4, 7) conditionals
that are now dead.

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

	* sysdeps/arm/atomic-machine.h
	[__GNUC_PREREQ (4, 7) && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4]:
	Change conditional to [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4].
	[__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 && !__GNUC_PREREQ (4, 7)]:
	Remove conditional code.
	[!__GNUC_PREREQ (4, 7) || !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4]:
	Change conditional to [!__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4].
	* sysdeps/i386/sysdep.h [__ASSEMBLER__ && __GNUC_PREREQ (4, 7)]:
	Change conditional to [__ASSEMBLER__].
	[__ASSEMBLER__ && !__GNUC_PREREQ (4, 7)]: Remove conditional code.
	[!__ASSEMBLER__ && __GNUC_PREREQ (4, 7)]: Change conditional to
	[!__ASSEMBLER__].
	[!__ASSEMBLER__ && !__GNUC_PREREQ (4, 7)]: Remove conditional
	code.
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h (rNOSP): Remove
	conditional macro definitions.
	(__arch_compare_and_exchange_val_8_acq): Use "u" instead of rNOSP.
	(__arch_compare_and_exchange_val_16_acq): Likewise.
	(__arch_compare_and_exchange_val_32_acq): Likewise.
	(atomic_exchange_and_add): Likewise.
	(atomic_add): Likewise.
	(atomic_add_negative): Likewise.
	(atomic_add_zero): Likewise.
	(atomic_bit_set): Likewise.
	(atomic_bit_test_set): Likewise.
	* sysdeps/x86_64/atomic-machine.h [__GNUC_PREREQ (4, 7)]: Make
	code unconditional.
	[!__GNUC_PREREQ (4, 7)]: Remove conditional code.
2015-11-04 21:34:36 +00:00
Joseph Myers 199a338654 Add more libm tests (scalb*, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, y0, y1, yn, significand).
This patch improves the libm test coverage for a few more functions.

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Add more tests of sin, sincos, sinh,
	sqrt, tan, tanh, y0, y1 and yn.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (scalb_test_data): Add more tests.
	(scalbn_test_data): Likewise.
	(scalbln_test_data): Likewise.
	(signbit_test_data): Likewise.
	(sin_test_data): Likewise.
	(sincos_test_data): Likewise.
	(sinh_test_data): Likewise.
	(sqrt_test_data): Likewise.
	(tan_test_data): Likewise.
	(tanh_test_data): Likewise.
	(tgamma_test_data): Likewise.
	(y0_test_data): Likewise.
	(y1_test_data): Likewise.
	(yn_test_data): Likewise.
	(significand_test_data): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-11-04 00:45:23 +00:00
Joseph Myers 444ec6b8d8 Fix dbl-64 remainder sign of zero result (bug 19201).
For some large arguments, the dbl-64 implementation of remainder gives
zero results with the wrong sign, resulting from a subtraction that is
mathematically correct but does not guarantee that a zero result has
the sign of the first argument to remainder.  This patch adds an
appropriate check for this case, similar to other implementations of
remainder in the case of equality, and adds tests of remainder on
inputs already used to test remquo.

Tested for x86_64 and x86.

	[BZ #19201]
	* sysdeps/ieee754/dbl-64/e_remainder.c (__ieee754_remainder):
	Check for zero remainder in case of large exponents and ensure
	correct sign of result in that case.
	* math/libm-test.inc (remainder_test_data): Add more tests.
2015-11-03 00:11:49 +00:00
Joseph Myers 85422c2acb Make nextafter, nexttoward set errno (bug 6799).
nextafter and nexttoward fail to set errno on overflow and underflow.
This patch makes them do so in cases that should include all the cases
where such errno setting is required by glibc's goals for when to set
errno (but not all cases of underflow where the result is nonzero and
so glibc's goals do not require errno setting).

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #6799]
	* math/s_nextafter.c: Include <errno.h>.
	(__nextafter): Set errno on overflow and underflow.
	* math/s_nexttowardf.c: Include <errno.h>.
	(__nexttowardf): Set errno on overflow and underflow.
	* sysdeps/i386/fpu/s_nextafterl.c: Include <errno.h>.
	(__nextafterl): Set errno on overflow and underflow.
	* sysdeps/i386/fpu/s_nexttoward.c: Include <errno.h>.
	(__nexttoward): Set errno on overflow and underflow.
	* sysdeps/i386/fpu/s_nexttowardf.c: Include <errno.h>.
	(__nexttowardf): Set errno on overflow and underflow.
	* sysdeps/ieee754/flt-32/s_nextafterf.c: Include <errno.h>.
	(__nextafterf): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c: Include <errno.h>.
	(__nextafterl): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128/s_nexttoward.c: Include <errno.h>.
	(__nexttoward): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128/s_nexttowardf.c: Include <errno.h>.
	(__nexttowardf): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c: Include <errno.h>.
	(__nextafterl): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c: Include <errno.h>.
	(__nexttoward): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c: Include <errno.h>.
	(__nexttowardf): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-96/s_nexttoward.c: Include <errno.h>.
	(__nexttoward): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-96/s_nexttowardf.c: Include <errno.h>.
	(__nexttowardf): Set errno on overflow and underflow.
	* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c: Include <errno.h>.
	(__nldbl_nexttowardf): Set errno on overflow and underflow.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c: Include <errno.h>.
	(__nextafterl): Set errno on overflow and underflow.
	* math/libm-test.inc (nextafter_test_data): Do not allow errno
	setting to be missing on overflow.  Add more tests.
	(nexttoward_test_data): Likewise.
2015-11-02 18:54:19 +00:00
Joseph Myers af1b2fd083 Fix ldbl-128 log1pl (-qNaN) spurious "invalid" exception (bug 19189).
The ldbl-128 version of log1pl raises a spurious "invalid" exception
for a -qNaN argument.  This patch fixes this by making the initial
check for infinities and NaNs handle arguments of both signs in such a
way that NaNs result in a NaN being returned (quietly if the input NaN
was quiet) while +Inf results in +Inf being returned and -Inf results
in a qNaN being returned with "invalid" exception raised.

Tested for mips64.

	[BZ #19189]
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Make check for
	non-finite argument handle arguments with negative sign.
2015-10-29 23:09:51 +00:00
Joseph Myers 5ce8f12506 Make drem an alias of remainder (bug 16171).
The libm drem functions just call the corresponding __remainder
functions.  This patch removes the unnecessary wrappers by making them
into weak aliases at the ELF level.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16171]
	* math/w_remainder.c (drem): Define as weak alias of __remainder.
	[NO_LONG_DOUBLE] (dreml): Define as weak alias of __remainder.
	* math/w_remainderf.c (dremf): Define as weak alias of
	__remainderf.
	* math/w_remainderl.c (dreml): Define as weak alias of
	__remainderl.
	* sysdeps/ia64/fpu/e_remainder.S (drem): Define as weak alias of
	__remainder.
	* sysdeps/ia64/fpu/e_remainderf.S (dremf): Define as weak alias of
	__remainderf.
	* sysdeps/ia64/fpu/e_remainderl.S (dreml): Define as weak alias of
	__remainderl.
	* sysdeps/ieee754/ldbl-opt/nldbl-remainder.c (dreml): Define as
	weak alias of remainderl.
	* sysdeps/ieee754/ldbl-opt/w_remainder.c
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (__drem): Define as strong
	alias of __remainder.
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (dreml): Use compat_symbol.
	* sysdeps/ieee754/ldbl-opt/w_remainderl.c (__dreml): Define as
	strong alias of __remainderl.
	(dreml): Use long_double_symbol.
	* math/Makefile (libm-calls): Remove w_drem.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Remove drem.
	(CFLAGS-nldbl-drem.c): Remove variable.
	(CFLAGS-nldbl-remainder.c): Add -fno-builtin-dreml.
	* math/w_drem.c: Remove file.
	* math/w_dremf.c: Likewise.
	* math/w_dreml.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/nldbl-drem.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_drem.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/w_dreml.c: Likewise.
2015-10-29 22:29:21 +00:00
Joseph Myers 91bcb95ad4 Remove cpuid.h configure tests.
There are configure tests for the cpuid.h header for x86 / x86_64.
GCC 4.3 and later install this header, so those tests are obsolete.
This patch removes them.

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

	* sysdeps/i386/configure.ac (cpuid.h): Do not test for header.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/x86_64/configure.ac (cpuid.h): Do not test for header.
	* sysdeps/x86_64/configure: Regenerated.
2015-10-29 14:43:46 +00:00
Joseph Myers 2145f97cee Handle more state in i386/x86_64 fesetenv (bug 16068).
fenv_t should include architecture-specific floating-point modes and
status flags.  i386 and x86_64 fesetenv limit which bits they use from
the x87 status and control words, when using saved state, and limit
which parts of the state they set to fixed values, when using
FE_DFL_ENV / FE_NOMASK_ENV.  The following should be included but are
excluded in at least some cases: status and masking for the "denormal
operand" exception (which isn't part of FE_ALL_EXCEPT); precision
control (explicitly mentioned in Annex F as something that counts as
part of the floating-point environment); MXCSR FZ and DAZ bits (for
FE_DFL_ENV and FE_NOMASK_ENV).  This patch arranges for this extra
state to be handled by fesetenv (and thereby by feupdateenv, which
calls fesetenv).

(Note that glibc functions using floating point are not generally
expected to work correctly with non-default values of this state,
especially precision control, but it is still logically part of the
floating-point environment and should be handled as such by fesetenv.
Changes to the state relating to subnormals ought generally to work
with libm functions when the arguments aren't subnormal and neither
are the expected results; that's a consequence of functions avoiding
spurious internal underflows.)

A question arising from this is whether FE_NOMASK_ENV should or should
not mask the "denormal operand" exception.  I decided it should mask
that exception.  This is the status quo - previously that exception
could only be unmasked by direct manipulation of control registers
(possibly via <fpu_control.h>).  In addition, it means that use of
FE_NOMASK_ENV leaves a floating-point environment the same as could be
obtained by fesetenv (FE_DFL_ENV); feenableexcept (FE_ALL_EXCEPT);,
rather than an environment in which an exception is unmasked that
could only be masked again by using fesetenv with FE_DFL_ENV (or a
previously saved environment) - this exception not being usable with
other <fenv.h> functions because it's outside FE_ALL_EXCEPT.

Tested for x86_64 and x86.

	[BZ #16068]
	* sysdeps/i386/fpu/fesetenv.c: Include <fpu_control.h>.
	(FE_ALL_EXCEPT_X86): New macro.
	(__fesetenv): Use FE_ALL_EXCEPT_X86 in most places instead of
	FE_ALL_EXCEPT.  Ensure precision control is included in
	floating-point state.  Ensure that FE_DFL_ENV and FE_NOMASK_ENV
	handle "denormal operand exception" and clear FZ and DAZ bits.
	* sysdeps/x86_64/fpu/fesetenv.c: Include <fpu_control.h>.
	(FE_ALL_EXCEPT_X86): New macro.
	(__fesetenv): Use FE_ALL_EXCEPT_X86 in most places instead of
	FE_ALL_EXCEPT.  Ensure precision control is included in
	floating-point state.  Ensure that FE_DFL_ENV and FE_NOMASK_ENV
	handle "denormal operand exception" and clear FZ and DAZ bits.
	* sysdeps/x86/fpu/test-fenv-sse-2.c: New file.
	* sysdeps/x86/fpu/test-fenv-x87.c: Likewise.
	* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
	test-fenv-x87 and test-fenv-sse-2.
	[$(subdir) = math] (CFLAGS-test-fenv-sse-2.c): New variable.
2015-10-28 22:58:29 +00:00
Joseph Myers 1f4dafa3ea Use C11 *_TRUE_MIN macros where applicable.
C11 defines standard <float.h> macros *_TRUE_MIN for the least
positive subnormal value of a type.  Now that we build with
-std=gnu11, we can use these macros in glibc.  This patch replaces
previous uses of the GCC predefines __*_DENORM_MIN__ (used in
<float.h> to define *_TRUE_MIN), as well as *_DENORM_MIN references in
comments.

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

	* math/libm-test.inc (min_subnorm_value): Use LDBL_TRUE_MIN,
	DBL_TRUE_MIN and FLT_TRUE_MIN instead of __LDBL_DENORM_MIN__,
	__DBL_DENORM_MIN__ and __FLT_DENORM_MIN__.
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Refer to DBL_TRUE_MIN
	instead of DBL_DENORM_MIN in comment.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Refer to
	LDBL_TRUE_MIN instead of LDBL_DENORM_MIN in comment.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c: Include <float.h>.
	(__nextafterl): Use LDBL_TRUE_MIN instead of __LDBL_DENORM_MIN__.
	* sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Refer to
	LDBL_TRUE_MIN instead of LDBL_DENORM_MIN in comment.
2015-10-28 21:42:52 +00:00
Joseph Myers 0b9af583a5 Fix i386/x86_64 fesetenv SSE exception clearing (bug 19181).
The i386 and x86_64 versions of fesetenv, when called with FE_DFL_ENV
or FE_NOMASK_ENV as argument, do not clear SSE exceptions raised in
MXCSR.  These arguments should, like other fenv_t values, represent
the whole of the floating-point state, so such exceptions should be
cleared; this patch adds the required clearing.  (Discovered while
working on bug 16068.)

Tested for x86_64 and x86.

	[BZ #19181]
	* sysdeps/i386/fpu/fesetenv.c (__fesetenv): Clear already-raised
	SSE exceptions when argument is FE_DFL_ENV or FE_NOMASK_ENV.
	* sysdeps/x86_64/fpu/fesetenv.c (__fesetenv): Likewise.
	* math/test-fenv-clear-main.c: New file.
	* math/test-fenv-clear.c: Likewise.
	* math/Makefile (tests): Add test-fenv-clear.
	* sysdeps/x86/fpu/test-fenv-clear-sse.c: New file.
	* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
	test-fenv-clear-sse.
	[$(subdir) = math] (CFLAGS-test-fenv-clear-sse.c): New variable.
2015-10-28 18:50:20 +00:00
Carlos Eduardo Seo 352988a4a6 powerpc: Provide __tls_get_addr () in static libc
Since '--no-tls-optimize' is available for Power in ld, we need to provide
__tls_get_addr () in static libc in order to avoid undefined references to this
symbol when that flag is used.

	* sysdeps/powerpc/libc-tls.c: New file. Provides __tls_get_addr () in
	static libc.
2015-10-28 11:42:23 -02:00
Joseph Myers c871b9b096 Remove -mavx2 configure tests.
There are configure tests for the -mavx2 compiler option.  AVX2
support was added in GCC 4.7, so these tests are now obsolete; this
patch removes them.

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

	* sysdeps/i386/configure.ac (libc_cv_cc_avx2): Remove configure
	test.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/x86_64/configure.ac (libc_cv_cc_avx2): Remove configure
	test.
	* sysdeps/x86_64/configure: Regenerated.
	* config.h.in (HAVE_AVX2_SUPPORT): Remove #undef.
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	memset-avx2 unconditionally instead of conditionally on
	[$(config-cflags-avx2) = yes].
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list) [HAVE_AVX2_SUPPORT]: Make code
	unconditional.
	* sysdeps/x86_64/multiarch/memset.S [HAVE_AVX2_SUPPORT]: Likewise.
	* sysdeps/x86_64/multiarch/memset_chk.S
	[IS_IN (libc) && SHARED && HAVE_AVX2_SUPPORT]: Change conditional
	to [IS_IN (libc) && SHARED].
2015-10-28 13:29:03 +00:00
Joseph Myers 56583289b1 Remove configure test for ARM TLS descriptors support.
GCC 4.7 added support for ARM TLS descriptors.  The binutils support
is present in binutils 2.22.  Thus, this patch removes the associated
configure test as obsolete (leaving Makefile conditionals, as NaCl
sets have-arm-tls-desc = no in its sysdeps fragment).

Tested for ARM that installed shared libraries are unchanged by the
patch.

	* sysdeps/arm/configure.ac (libc_cv_arm_tls_desc): Remove
	configure test.
	* sysdeps/arm/configure: Regenerated.
	* sysdeps/arm/Makefile [!have-arm-tls-desc] (have-arm-tls-desc):
	Define variable if not already defined.
2015-10-27 23:56:50 +00:00
Joseph Myers 8f82f28bba Remove MIPS16 atomics using __sync_* (bug 17404).
MIPS16 atomics used __sync_* with GCC before 4.7, which as noted in
bug 17404 is missing the required barrier semantics for
atomic_exchange_rel.  This patch removes the code in question as dead
now GCC before 4.7 is no longer supported for building glibc.

Sanity tested with builds for MIPS.

	[BZ #17404]
	* sysdeps/mips/atomic-machine.h
	[__GNUC_PREREQ (4, 8) || (__mips16 && __GNUC_PREREQ (4, 7))]:
	Change conditional to [__GNUC_PREREQ (4, 8) || __mips16].
	[__mips16 && !__GNUC_PREREQ (4, 7)]: Remove conditional code.
2015-10-27 23:47:56 +00:00
Joseph Myers f1d237df1e Remove GCC version conditionals on -Wmaybe-uninitialized pragmas.
One common case of __GNUC_PREREQ (4, 7) conditionals is use of
diagnostic control pragmas for -Wmaybe-uninitialized, an option
introduced in GCC 4.7 where older GCC needed -Wuninitialized to be
controlled instead if the warning appeared with older GCC.  This patch
removes such conditionals.

(There remain several older uses of -Wno-uninitialized in makefiles
that still need to be converted to diagnostic control pragmas if the
issue is still present with current sources and supported GCC
versions, and it's likely that in most cases those pragmas also will
end up controlling -Wmaybe-uninitialized.)

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch, except for libresolv
since res_send.c contains assertions whose line numbers are changed by
the patch).

	* resolv/res_send.c (send_vc) [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	* soft-fp/fmadf4.c [__GNUC_PREREQ (4, 7)]: Likewise.
	[!__GNUC_PREREQ (4, 7)]: Remove conditional code.
	* soft-fp/fmasf4.c [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	[!__GNUC_PREREQ (4, 7)]: Remove conditional code.
	* soft-fp/fmatf4.c [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	[!__GNUC_PREREQ (4, 7)]: Remove conditional code.
	* stdlib/setenv.c
	[((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7)]: Make
	code unconditional.
	[!(((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7))]:
	Remove conditional code.
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c
	(__ieee754_lgamma_r) [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	(__ieee754_lgamma_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional
	code.
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c
	(__ieee754_lgammaf_r) [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	(__ieee754_lgammaf_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional
	code.
	* sysdeps/ieee754/ldbl-128/k_tanl.c
	(__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional.
	(__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code.
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c
	(__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional.
	(__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code.
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c
	(__ieee754_lgammal_r) [__GNUC_PREREQ (4, 7)]: Make code
	unconditional.
	(__ieee754_lgammal_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional
	code.
	* sysdeps/ieee754/ldbl-96/k_tanl.c
	(__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional.
	(__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code.
2015-10-27 23:42:20 +00:00
Joseph Myers 3e2ee6f0e3 Remove sysdeps/nptl/configure.ac.
sysdeps/nptl/configure.ac tests for forced unwind support and the C
cleanup attribute, giving errors if either is unsupported.  It does
nothing beyond running those two tests.

Both the attribute, and _Unwind_GetCFA which is used in the forced
unwind test, were added in GCC 3.3.  Thus these tests are long
obsolete, and this patch removes the configure fragment running them,
along with associated conditionals.

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

	* sysdeps/nptl/configure.ac: Remove file.
	* sysdeps/nptl/configure: Remove generated file.
	* configure.ac (libc_cv_forced_unwind): Do not substitute.
	* configure: Regenerated.
	* config.h.in (HAVE_FORCED_UNWIND): Remove #undef.
	* config.make.in (have-forced-unwind): Remove variable.
	* nptl/Makefile [$(have-forced-unwind) = yes]: Make code
	unconditional.
	* nptl/descr.h [HAVE_FORCED_UNWIND]: Likewise.
	* nptl/unwind.c [HAVE_FORCED_UNWIND]: Likewise.
	(__pthread_unwind) [!HAVE_FORCED_UNWIND]: Remove conditional code.
	* nptl/version.c [HAVE_FORCED_UNWIND]: Make code unconditional.
	* sysdeps/nptl/Makefile [$(have-forced-unwind) = yes]: Make code
	unconditional.
2015-10-27 21:46:03 +00:00
Paul Murphy 72f1463df8 powerpc: Fix usage of elision transient failure adapt param
The skip_lock_out_of_tbegin_retries adaptive parameter was
not being used correctly, nor as described.  This prevents
a fallback for all users of the lock if a transient abort
occurs within the accepted number of retries.

	[BZ #19174]
	* sysdeps/powerpc/nptl/elide.h (__elide_lock): Fix usage of
	.skip_lock_out_of_tbegin_retries.
	* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
	(__lll_lock_elision): Likewise, and respect a value of
	try_tbegin <= 0.
2015-10-27 17:27:41 -02:00
Florian Weimer e39edb0552 x86_64: Regenerate ulps [BZ #19168]
This comes from running “make regen-ulps” on AMD Opteron 6272 CPUs.
2015-10-26 13:15:48 +01:00
Joseph Myers 9d1687b2df Add more libm tests (ilogb, is*, j0, j1, jn, lgamma, log*).
This patch improves the libm test coverage for a few more functions.

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Add more tests of log, log10, log1p and
	log2.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (MAX_EXP): New macro.
	(ilogb_test_data): Add more tests.
	(isfinite_test_data): Likewise.
	(isgreater_test_data): Likewise.
	(isgreaterequal_test_data): Likewise.
	(isinf_test_data): Likewise.
	(isless_test_data): Likewise.
	(islessequal_test_data): Likewise.
	(islessgreater_test_data): Likewise.
	(isnan_test_data): Likewise.
	(isnormal_test_data): Likewise.
	(issignaling_test_data): Likewise.
	(isunordered_test_data): Likewise.
	(j0_test_data): Likewise.
	(j1_test_data): Likewise.
	(jn_test_data): Likewise.
	(lgamma_test_data): Likewise.
	(log_test_data): Likewise.
	(log10_test_data): Likewise.
	(log1p_test_data): Likewise.
	(log2_test_data): Likewise.
	(logb_test_data): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-10-23 22:46:05 +00:00