Commit Graph

10047 Commits

Author SHA1 Message Date
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
Joseph Myers
c643db8792 Fix j1, jn missing errno setting on underflow (bug 18611).
j1 and jn can underflow for small arguments, but fail to set errno
when underflowing to 0.  This patch fixes them to set errno in that
case.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18611]
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Set errno and
	avoid excess range and precision on underflow.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Set errno on
	underflow.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	* math/auto-libm-test-in: Do not allow missing errno setting for
	tests of j1 and jn.
	* math/auto-libm-test-out: Regenerated.
2015-10-23 21:37:33 +00:00
Joseph Myers
846d9a4a3a Fix i386 / x86_64 nearbyint exception clearing (bug 15491).
The implementations of nearbyint functions using x87 floating point
(i386 all versions, x86_64 long double only) use the fclex
instruction, which clears any exceptions that were raised before the
function was called.  These functions must not clear exceptions that
were raised before they were called.

This patch fixes these functions to save and restore the whole
floating-point environment (fnstenv / fldenv) as the way of avoiding
raising "inexact" (recall that there isn't an x87 instruction for
loading just the status word, so the whole environment has to be saved
and loaded instead - the code already saved and loaded the control
word, which is now obtained from the saved environment after this
patch, to disable traps on "inexact").  In the case of the long double
functions, any "invalid" exception from frndint (applied to a
signaling NaN) needs merging into the saved state; this issue doesn't
apply to the float and double functions because that exception would
have been raised when the argument is loaded, before the environment
is saved.

	[BZ #15491]
	* sysdeps/i386/fpu/s_nearbyint.S (__nearbyint): Save and restore
	floating-point environment instead of clearing all exceptions.
	* sysdeps/i386/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
	* sysdeps/i386/fpu/s_nearbyintl.S (__nearbyintl): Likewise,
	merging in "invalid" exceptions from frndint.
	* sysdeps/x86_64/fpu/s_nearbyintl.S (__nearbyintl): Likewise.
	* math/test-nearbyint-except.c: New file.
	* math/Makefile (tests): Add test-nearbyint-except.
2015-10-22 23:14:55 +00:00
Chris Metcalf
822095e8a4 tile: regenerate libm-test-ulps 2015-10-22 12:00:31 -04:00
Adhemerval Zanella
c2c904ffd3 Cleanup sync_file_range implementation
Since GLIBC requires a minimum 2.6.32 kernel, the patch cleanups
the mips code to assume __NR_sync_file_range and the powerpc one
to either assume __NR_sync_file_range2 or __NR_sync_file_range.

Checked on powerpc64le and build for mips (ABIO32, ABIN32, and ABI64).

	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sync_file_range.c
	(__NR_sync_file_range2): Assume it is always defined.
	* sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c
	(__NR_sync_file_range): Assume it is always defined.
2015-10-22 12:00:06 -02:00
Andreas Schwab
751709fec9 Always use INTERNAL_SYSCALL_ERRNO with INTERNAL_SYSCALL 2015-10-22 14:59:29 +02:00
H.J. Lu
95b097779a Build i386 __libc_do_syscall when PROF is defined
Need to provide i386 __libc_do_syscall when PROF is defined.
Define OPTIMIZE_FOR_GCC_5 for .S files so that it can be used
in libc-do-syscall.S.

	* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S: Replace
	__GNUC_PREREQ (5,0) with OPTIMIZE_FOR_GCC_5.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (OPTIMIZE_FOR_GCC_5):
	Moved before "#ifdef __ASSEMBLER__".
2015-10-21 10:14:08 -07:00
Joseph Myers
0a90a8f2b9 Fix ldbl-128 j0l spurious underflows (bug 19156).
My recent addition of more tests for j0 showed up that the ldbl-128
implementation of j0l produces spurious underflow exceptions for
arguments close to 0 (when the result is very close to 1).  This patch
fixes this by just returning the argument in that case.

Tested for mips64 (where it fixes the recently-added tests that were
previously failing).

	[BZ #19156]
	* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Return 1 for
	arguments very close to 0.
2015-10-21 16:40:20 +00:00
Chris Metcalf
1245e51596 tile: avoid preprocessor redefinition warnings
PSEUDO_END and PSEUDO_END_NOERRNO are being defined in
sysdeps/unix/sysdep.h and then redefined for tile.  Add an
undef before each define to silence the warnings.
2015-10-21 12:18:08 -04:00
H.J. Lu
23c4baa214 Disable GCC 5 optimization when PROF is defined
Since asm ("ebp") can't be used to put the 6th argument in %ebp for
syscall when compiling for profiling, we disable GCC 5 optimization
when PROF is defined.

	* sysdeps/unix/sysv/linux/i386/sysdep.h (OPTIMIZE_FOR_GCC_5):
	New.  Defined for GCC 5 and above when not compiling for
	profiling.
	Replace __GNUC_PREREQ (5,0) with OPTIMIZE_FOR_GCC_5.
2015-10-21 09:07:46 -07:00
H.J. Lu
d8f7fcacd7 Apply -fomit-frame-pointer only to .o/.os files
Since -fomit-frame-pointer is compatible with -pg, apply it only to
.o/.os files.

	* sysdeps/unix/sysv/linux/i386/Makefile (CFLAGS-epoll_pwait.c):
	Renamed to ...
	(CFLAGS-epoll_pwait.o): This.
	(CFLAGS-mmap.c): Renamed to ...
	(CFLAGS-mmap.o): This.
	(CFLAGS-mmap64.c): Renamed to ...
	(CFLAGS-mmap64.o): This.
	(CFLAGS-epoll_pwait.os): New.
	(CFLAGS-mmap.os): Likewise.
	(CFLAGS-mmap64.os): Likewise.
	(CFLAGS-semtimedop.os): Likewise.
	(CFLAGS-semtimedop.c): Renamed to ...
	(CFLAGS-semtimedop.o): This.
2015-10-21 09:05:01 -07:00
Joseph Myers
80d9be8122 Convert miscellaneous function definitions to prototype style.
This patch converts various miscellaneous functions definitions in
glibc, found with grep and not covered by my previous scripted
conversions, from old-style K&R to prototype-style.  These changes
were made manually.  This is not necessarily exhaustive as formatting
variants may have prevented my grep from finding some such
definitions.

Regarding the changes to files from GMP, they may originally have been
omitted when removing __STDC__ conditionals because of the files
coming from another package, but (a) GMP no longer has __STDC__
conditionals there anyway and (b) we don't try to keep these files
verbatim in sync with GMP (and there are licensing differences), so
making the change to them in glibc seems reasonable.

Tested for x86_64 and x86 (testsuite - this patch affects files
containing assertions).

	* debug/fortify_fail.c (__fortify_fail): Convert to
	prototype-style function definition.  Use internal_function.
	* libio/genops.c (save_for_backup): Convert to prototype-style
	function definition.
	* libio/wgenops.c (save_for_wbackup): Likewise.
	* login/grantpt.c (grantpt): Likewise.
	* login/ptsname.c (ptsname): Likewise.
	(__ptsname_r): Likewise.
	* login/unlockpt.c (unlockpt): Likewise.
	* mach/msgserver.c (__mach_msg_server): Likewise.
	* misc/efgcvt.c (__APPEND (FUNC_PREFIX, fcvt)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt)): Likewise.
	(__APPEND (FUNC_PREFIX, gcvt)): Likewise.
	* misc/efgcvt_r.c (__APPEND (FUNC_PREFIX, fcvt_r)): Likewise.
	(__APPEND (FUNC_PREFIX, ecvt_r)): Likewise.
	* nptl/cleanup_compat.c (_pthread_cleanup_push): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_push_defer):
	Likewise.
	* nptl/libc_pthread_init.c (__libc_pthread_init): Likewise.  Use
	internal_function.
	* nptl/pthread_atfork.c (__pthread_atfork): Convert to
	prototype-style function definition.
	* nptl/pthread_create.c (__pthread_create_2_1): Likewise.
	[SHLIB_COMPAT(libpthread, GLIBC_2_0, GLIBC_2_1)]
	(__pthread_create_2_0): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/register-atfork.c (__register_atfork): Likewise.
	* posix/glob.c (glob): Likewise.
	* posix/regcomp.c (re_comp): Likewise.
	* posix/regexec.c (re_exec): Likewise.
	* stdlib/add_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/cmp.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divmod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/divrem.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/lshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mod_1.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/mul_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/rshift.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* stdlib/strtod.c (INTERNAL (STRTOF)): Convert to prototype-style
	function definition.
	(STRTOF): Likewise.
	* stdlib/strtod_l.c (__STRTOF): Likewise.
	* stdlib/strtol.c (INTERNAL (strtol)): Likewise.
	* stdlib/strtol_l.c (INTERNAL (__strtol_l)): Likewise.
	(__strtol_l): Likewise.
	* stdlib/sub_n.c [__STDC__]: Make code unconditional.
	[!__STDC__]: Remove conditional code.
	* string/memrchr.c (MEMRCHR): Convert to prototype-style function
	definition.
	* string/strcasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strcasecmp): Convert to prototype-style function definition.
	* string/strncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__strncasecmp): Convert to prototype-style function definition.
	* sunrpc/pm_getport.c (__libc_rpc_getport): Likewise.
	* sunrpc/xdr.c (xdr_union): Likewise.
	* sunrpc/xdr_array.c (xdr_array): Likewise.
	* sunrpc/xdr_ref.c (xdr_reference): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_atan.c (__CONCATX(__,FUNC)): Likewise.
	* sysdeps/m68k/m680x0/fpu/s_isinf.c (__CONCATX(__,FUNC)):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(__scalbn,suffix):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_sincos.c (CONCATX(__,FUNC)): Likewise.
	* sysdeps/unix/sysv/linux/i386/scandir64.c (__old_scandir64):
	Likewise.
	* time/strftime_l.c (LOCALE_PARAM_DECL): Remove macro.
	(LOCALE_PARAM_PROTO): Likewise.
	[_LIBC && USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include
	argument type.
	(ut_argument_spec): Remove macro.
	(ut_argument_spec_iso): Rename to ut_argument_spec.
	(memcpy_lowcase): Use LOCALE_PARAM in declaration.  Convert to
	prototype-style function definition.
	(memcpy_uppcase): Likewise.
	(__strftime_internal): Likewise.
	(my_strftime): Likewise.
	* time/strptime_l.c (LOCALE_PARAM_PROTO): Remove macro.
	(LOCALE_PARAM_DECL): Likewise.
	[_LIBC] (LOCALE_PARAM): Include argument type.
	(__strptime_internal): Convert to prototype-style function
	definition.
	(strptime): Likewise.
	* wcsmbs/wcscasecmp.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcscasecmp): Convert to prototype-style function definition.
	* wcsmbs/wcsncase.c (LOCALE_PARAM_DECL): Remove macro.
	[USE_IN_EXTENDED_LOCALE_MODEL] (LOCALE_PARAM): Include argument
	type.
	(__wcsncasecmp): Convert to prototype-style function definition.
2015-10-20 21:27:22 +00:00
Joseph Myers
9dd346ff43 Convert 113 more function definitions to prototype style (files with assertions).
This mostly automatically-generated patch converts 113 function
definitions in glibc from old-style K&R to prototype-style.  Following
my other recent such patches, this one deals with the case of function
definitions in files that either contain assertions or where grep
suggested they might contain assertions - and thus where it isn't
possible to use a simple object code comparison as a sanity check on
the correctness of the patch, because line numbers are changed.

A few such automatically-generated changes needed to be supplemented
by manual changes for the result to compile.  openat64 had a prototype
declaration with "..." but an old-style definition in
sysdeps/unix/sysv/linux/dl-openat64.c, and "..." needed adding to the
generated prototype in the definition (I've filed
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68024> for diagnosing
such cases in GCC; the old state was undefined behavior not requiring
a diagnostic, but one seems a good idea).  In addition, as Florian has
noted regparm attribute mismatches between declaration and definition
are only diagnosed for prototype definitions, and five functions
needed internal_function added to their definitions (in the case of
__pthread_mutex_cond_lock, via the macro definition of
__pthread_mutex_lock) to compile on i386.

After this patch is in, remaining old-style definitions are probably
most readily fixed manually before we can turn on
-Wold-style-definition for all builds.

Tested for x86_64 and x86 (testsuite).

	* crypt/md5-crypt.c (__md5_crypt_r): Convert to prototype-style
	function definition.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.
	* debug/backtracesyms.c (__backtrace_symbols): Likewise.
	* elf/dl-minimal.c (_itoa): Likewise.
	* hurd/hurdmalloc.c (malloc): Likewise.
	(free): Likewise.
	(realloc): Likewise.
	* inet/inet6_option.c (inet6_option_space): Likewise.
	(inet6_option_init): Likewise.
	(inet6_option_append): Likewise.
	(inet6_option_alloc): Likewise.
	(inet6_option_next): Likewise.
	(inet6_option_find): Likewise.
	* io/ftw.c (FTW_NAME): Likewise.
	(NFTW_NAME): Likewise.
	(NFTW_NEW_NAME): Likewise.
	(NFTW_OLD_NAME): Likewise.
	* libio/iofwide.c (_IO_fwide): Likewise.
	* libio/strops.c (_IO_str_init_static_internal): Likewise.
	(_IO_str_init_static): Likewise.
	(_IO_str_init_readonly): Likewise.
	(_IO_str_overflow): Likewise.
	(_IO_str_underflow): Likewise.
	(_IO_str_count): Likewise.
	(_IO_str_seekoff): Likewise.
	(_IO_str_pbackfail): Likewise.
	(_IO_str_finish): Likewise.
	* libio/wstrops.c (_IO_wstr_init_static): Likewise.
	(_IO_wstr_overflow): Likewise.
	(_IO_wstr_underflow): Likewise.
	(_IO_wstr_count): Likewise.
	(_IO_wstr_seekoff): Likewise.
	(_IO_wstr_pbackfail): Likewise.
	(_IO_wstr_finish): Likewise.
	* locale/programs/localedef.c (normalize_codeset): Likewise.
	* locale/programs/locarchive.c (add_locale_to_archive): Likewise.
	(add_locales_to_archive): Likewise.
	(delete_locales_from_archive): Likewise.
	* malloc/malloc.c (__libc_mallinfo): Likewise.
	* math/gen-auto-libm-tests.c (init_fp_formats): Likewise.
	* misc/tsearch.c (__tfind): Likewise.
	* nptl/pthread_attr_destroy.c (__pthread_attr_destroy): Likewise.
	* nptl/pthread_attr_getdetachstate.c
	(__pthread_attr_getdetachstate): Likewise.
	* nptl/pthread_attr_getguardsize.c (pthread_attr_getguardsize):
	Likewise.
	* nptl/pthread_attr_getinheritsched.c
	(__pthread_attr_getinheritsched): Likewise.
	* nptl/pthread_attr_getschedparam.c
	(__pthread_attr_getschedparam): Likewise.
	* nptl/pthread_attr_getschedpolicy.c
	(__pthread_attr_getschedpolicy): Likewise.
	* nptl/pthread_attr_getscope.c (__pthread_attr_getscope):
	Likewise.
	* nptl/pthread_attr_getstack.c (__pthread_attr_getstack):
	Likewise.
	* nptl/pthread_attr_getstackaddr.c (__pthread_attr_getstackaddr):
	Likewise.
	* nptl/pthread_attr_getstacksize.c (__pthread_attr_getstacksize):
	Likewise.
	* nptl/pthread_attr_init.c (__pthread_attr_init_2_1): Likewise.
	(__pthread_attr_init_2_0): Likewise.
	* nptl/pthread_attr_setdetachstate.c
	(__pthread_attr_setdetachstate): Likewise.
	* nptl/pthread_attr_setguardsize.c (pthread_attr_setguardsize):
	Likewise.
	* nptl/pthread_attr_setinheritsched.c
	(__pthread_attr_setinheritsched): Likewise.
	* nptl/pthread_attr_setschedparam.c
	(__pthread_attr_setschedparam): Likewise.
	* nptl/pthread_attr_setschedpolicy.c
	(__pthread_attr_setschedpolicy): Likewise.
	* nptl/pthread_attr_setscope.c (__pthread_attr_setscope):
	Likewise.
	* nptl/pthread_attr_setstack.c (__pthread_attr_setstack):
	Likewise.
	* nptl/pthread_attr_setstackaddr.c (__pthread_attr_setstackaddr):
	Likewise.
	* nptl/pthread_attr_setstacksize.c (__pthread_attr_setstacksize):
	Likewise.
	* nptl/pthread_condattr_setclock.c (pthread_condattr_setclock):
	Likewise.
	* nptl/pthread_create.c (__find_in_stack_list): Likewise.
	* nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.
	* nptl/pthread_mutex_cond_lock.c (__pthread_mutex_lock): Define to
	use internal_function.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Convert to
	prototype-style function definition.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	(__pthread_mutex_cond_lock_adjust): Likewise.  Use
	internal_function.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock):
	Convert to prototype-style function definition.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock):
	Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_usercnt):
	Likewise.
	(__pthread_mutex_unlock): Likewise.
	* nptl_db/td_ta_clear_event.c (td_ta_clear_event): Likewise.
	* nptl_db/td_ta_set_event.c (td_ta_set_event): Likewise.
	* nptl_db/td_thr_clear_event.c (td_thr_clear_event): Likewise.
	* nptl_db/td_thr_event_enable.c (td_thr_event_enable): Likewise.
	* nptl_db/td_thr_set_event.c (td_thr_set_event): Likewise.
	* nss/makedb.c (process_input): Likewise.
	* posix/fnmatch.c (__strchrnul): Likewise.
	(__wcschrnul): Likewise.
	(fnmatch): Likewise.
	* posix/fnmatch_loop.c (FCT): Likewise.
	* posix/glob.c (globfree): Likewise.
	(__glob_pattern_type): Likewise.
	(__glob_pattern_p): Likewise.
	* posix/regcomp.c (re_compile_pattern): Likewise.
	(re_set_syntax): Likewise.
	(re_compile_fastmap): Likewise.
	(regcomp): Likewise.
	(regerror): Likewise.
	(regfree): Likewise.
	* posix/regexec.c (regexec): Likewise.
	(re_match): Likewise.
	(re_search): Likewise.
	(re_match_2): Likewise.
	(re_search_2): Likewise.
	(re_search_stub): Likewise.  Use internal_function
	(re_copy_regs): Likewise.
	(re_set_registers): Convert to prototype-style function
	definition.
	(prune_impossible_nodes): Likewise.  Use internal_function.
	* resolv/inet_net_pton.c (inet_net_pton): Convert to
	prototype-style function definition.
	(inet_net_pton_ipv4): Likewise.
	* stdlib/strtod_l.c (____STRTOF_INTERNAL): Likewise.
	* sysdeps/pthread/aio_cancel.c (aio_cancel): Likewise.
	* sysdeps/pthread/aio_suspend.c (aio_suspend): Likewise.
	* sysdeps/pthread/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	Make variadic.
	* time/strptime_l.c (localtime_r): Convert to prototype-style
	function definition.
	* wcsmbs/mbsnrtowcs.c (__mbsnrtowcs): Likewise.
	* wcsmbs/mbsrtowcs_l.c (__mbsrtowcs_l): Likewise.
	* wcsmbs/wcsnrtombs.c (__wcsnrtombs): Likewise.
	* wcsmbs/wcsrtombs.c (__wcsrtombs): Likewise.
2015-10-20 11:54:09 +00:00
Joseph Myers
a72ddc1424 Convert 24 more function definitions to prototype style (array parameters).
This automatically-generated patch converts 24 function definitions in
glibc from old-style K&R to prototype-style.  Following my other
recent such patches, this one deals with the case of functions with
array parameters.

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

	* crypt/cert.c (main): Convert to prototype-style function
	definition.
	* io/pipe.c (__pipe): Likewise.
	* io/pipe2.c (__pipe2): Likewise.
	* misc/futimesat.c (futimesat): Likewise.
	* misc/utimes.c (__utimes): Likewise.
	* posix/execve.c (__execve): Likewise.
	* posix/execvp.c (execvp): Likewise.
	* posix/execvpe.c (__execvpe): Likewise.
	* posix/fexecve.c (fexecve): Likewise.
	* socket/socketpair.c (socketpair): Likewise.
	* stdlib/drand48-iter.c (__drand48_iterate): Likewise.
	* stdlib/erand48.c (erand48): Likewise.
	* stdlib/erand48_r.c (__erand48_r): Likewise.
	* stdlib/jrand48.c (jrand48): Likewise.
	* stdlib/jrand48_r.c (__jrand48_r): Likewise.
	* stdlib/lcong48.c (lcong48): Likewise.
	* stdlib/lcong48_r.c (__lcong48_r): Likewise.
	* stdlib/nrand48.c (nrand48): Likewise.
	* stdlib/nrand48_r.c (__nrand48_r): Likewise.
	* stdlib/seed48.c (seed48): Likewise.
	* stdlib/seed48_r.c (__seed48_r): Likewise.
	* sysdeps/mach/hurd/execve.c (__execve): Likewise.
	* sysdeps/mach/hurd/utimes.c (__utimes): Likewise.
	* sysdeps/unix/sysv/linux/fexecve.c (fexecve): Likewise.
2015-10-20 11:51:03 +00:00
Joseph Myers
f63f2bfdfa Convert 69 more function definitions to prototype style (line wrap cases).
This automatically-generated patch converts 69 function definitions in
glibc from old-style K&R to prototype-style.

This patch, covering both sysdeps and non-sysdeps files, deals with
cases where the prototype needed to be wrapped over more than one
line.  Otherwise, exclusions and caveats are as for
<https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> and
<https://sourceware.org/ml/libc-alpha/2015-10/msg00599.html>.

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

	* crypt/crypt-entry.c (__crypt_r): Convert to prototype-style
	function definition.
	* crypt/crypt_util.c (__encrypt_r): Likewise.
	* libio/genops.c (_IO_no_init): Likewise.
	* libio/iofopncook.c (_IO_fopencookie): Likewise.
	(_IO_old_fopencookie): Likewise.
	* libio/iofwrite_u.c (fwrite_unlocked): Likewise.
	* libio/iogetline.c (_IO_getline): Likewise.
	(_IO_getline_info): Likewise.
	* libio/iogetwline.c (_IO_getwline): Likewise.
	(_IO_getwline_info): Likewise.
	* libio/vsnprintf.c (_IO_vsnprintf): Likewise.
	* libio/vswprintf.c (_IO_vswprintf): Likewise.
	* locale/programs/simple-hash.c (insert_entry_2): Likewise.
	(find_entry): Likewise.
	(iterate_table): Likewise.
	(lookup): Likewise.
	* login/forkpty.c (forkpty): Likewise.
	* misc/hsearch_r.c (__hsearch_r): Likewise.
	* misc/select.c (__select): Likewise.
	* nptl/cleanup_defer_compat.c (_pthread_cleanup_pop_restore):
	Likewise.
	* nptl/old_pthread_cond_init.c (__pthread_cond_init_2_0):
	Likewise.
	* nptl/old_pthread_cond_timedwait.c
	(__pthread_cond_timedwait_2_0): Likewise.
	* nptl/pthread_barrier_init.c (__pthread_barrier_init): Likewise.
	* nptl/pthread_barrierattr_getpshared.c
	(pthread_barrierattr_getpshared): Likewise.
	* nptl/pthread_getschedparam.c (__pthread_getschedparam):
	Likewise.
	* nptl/pthread_mutex_setprioceiling.c
	(pthread_mutex_setprioceiling): Likewise.
	* nptl/pthread_mutexattr_getprioceiling.c
	(pthread_mutexattr_getprioceiling): Likewise.
	* nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Likewise.
	* nptl/pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock):
	Likewise.
	* nptl/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock):
	Likewise.
	* nptl/pthread_setschedparam.c (__pthread_setschedparam):
	Likewise.
	* socket/recvfrom.c (__recvfrom): Likewise.
	* socket/sendto.c (__sendto): Likewise.
	* socket/setsockopt.c (__setsockopt): Likewise.
	* stdio-common/_itoa.c (_itoa): Likewise.
	* stdio-common/_itowa.c (_itowa): Likewise.
	* stdio-common/reg-printf.c (__register_printf_specifier):
	Likewise.
	(__register_printf_function): Likewise.
	* stdio-common/tempname.c (__path_search): Likewise.
	* stdlib/addmul_1.c (mpn_addmul_1): Likewise.
	* stdlib/mul_1.c (mpn_mul_1): Likewise.
	* stdlib/random_r.c (__initstate_r): Likewise.
	* stdlib/setenv.c (__add_to_environ): Likewise.
	* stdlib/submul_1.c (mpn_submul_1): Likewise.
	* streams/getpmsg.c (getpmsg): Likewise.
	* streams/putmsg.c (putmsg): Likewise.
	* streams/putpmsg.c (putpmsg): Likewise.
	* sunrpc/clnt_raw.c (clntraw_call): Likewise.
	* sunrpc/clnt_tcp.c (clnttcp_call): Likewise.
	* sunrpc/clnt_udp.c (clntudp_create): Likewise.
	* sunrpc/clnt_unix.c (clntunix_call): Likewise.
	* sunrpc/pm_getport.c (pmap_getport): Likewise.
	* sunrpc/svc_udp.c (cache_get): Likewise.
	* sunrpc/xdr_array.c (xdr_vector): Likewise.
	* sysdeps/mach/hurd/getcwd.c
	(__canonicalize_directory_name_internal): Likewise.
	* sysdeps/mach/hurd/pselect.c (__pselect): Likewise.
	* sysdeps/mach/hurd/recvfrom.c (__recvfrom): Likewise.
	* sysdeps/mach/hurd/select.c (__select): Likewise.
	* sysdeps/posix/ttyname_r.c (getttyname_r): Likewise.
	* sysdeps/pthread/timer_settime.c (timer_settime): Likewise.
	* sysdeps/sparc/nptl/pthread_barrier_init.c
	(__pthread_barrier_init): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c
	(__pthread_cond_timedwait): Likewise.
	* sysdeps/unix/sysv/linux/i386/putmsg.c (putmsg): Likewise.
	* sysdeps/unix/sysv/linux/s390/semtimedop.c (semtimedop):
	Likewise.
	* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Likewise.
	* sysdeps/unix/sysv/linux/timer_settime.c (timer_settime):
	Likewise.
	* sysvipc/semtimedop.c (semtimedop): Likewise.
	* time/setitimer.c (__setitimer): Likewise.
	* time/strftime_l.c (emacs_strftime): Likewise.
2015-10-19 21:23:47 +00:00
Tulio Magno Quites Machado Filho
6ec52bf634 PowerPC: Fix a race condition when eliding a lock
The previous code used to evaluate the preprocessor token is_lock_free to
a variable before starting a transaction.  This behavior can cause an
error if another thread got the lock (without using a transaction)
between the evaluation of the token and the beginning of the transaction.

This bug can be triggered with the following order of events:
1. The lock accessed by is_lock_free is free.
2. Thread T1 evaluates is_lock_free and stores into register R1 that the
   lock is free.
3. Thread T2 acquires the same lock used in is_lock_free.
4. T1 begins the transaction, creating a memory barrier where is_lock_free
   is false, but R1 is true.
5. T1 reads R1 and doesn't abort the transaction.
6. T1 calls ELIDE_UNLOCK, which reads false from is_lock_free and decides
   to unlock a lock acquired by T2, leading to undefined behavior.

This patch delays the evaluation of is_lock_free to inside a transaction
by moving this part of the code to the macro ELIDE_LOCK.

	[BZ #18743]
	* sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
	code to...
	(ELIDE_LOCK): ...here.
	(__get_new_count): New function with part of the code from
	__elide_lock that updates the value of adapt_count after a
	transaction abort.
	(__elided_trylock): Moved this code to...
	(ELIDE_TRYLOCK): ...here.
2015-10-19 16:58:03 -02:00
Joseph Myers
bd2260a206 Convert 231 sysdeps function definitions to prototype style.
This mostly automatically-generated patch converts 231 sysdeps
function definitions in glibc from old-style K&R to prototype-style.

For __aio_sigqueue and __gai_sigqueue I had to add internal_function
to the definitions as noted by Florian in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00595.html> to keep
the functions compiling on x86 after conversion to prototype
definitions.  Otherwise, the patch is automatically generated with all
the same exclusions and caveats as in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> except
that it's a patch for sysdeps files.

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

	* sysdeps/arm/backtrace.c (__backtrace): Convert to
	prototype-style function definition.
	* sysdeps/i386/backtrace.c (__backtrace): Likewise.
	* sysdeps/i386/ffs.c (__ffs): Likewise.
	* sysdeps/i386/i686/ffs.c (__ffs): Likewise.
	* sysdeps/ia64/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/ia64/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/m68k/ffs.c (__ffs): Likewise.
	* sysdeps/m68k/m680x0/fpu/e_acos.c (FUNC): Likewise.
	* sysdeps/m68k/m680x0/fpu/e_fmod.c (FUNC): Likewise.
	* sysdeps/mach/adjtime.c (__adjtime): Likewise.
	* sysdeps/mach/gettimeofday.c (__gettimeofday): Likewise.
	* sysdeps/mach/hurd/_exit.c (_exit): Likewise.
	* sysdeps/mach/hurd/access.c (__access): Likewise.
	* sysdeps/mach/hurd/adjtime.c (__adjtime): Likewise.
	* sysdeps/mach/hurd/chdir.c (__chdir): Likewise.
	* sysdeps/mach/hurd/chmod.c (__chmod): Likewise.
	* sysdeps/mach/hurd/chown.c (__chown): Likewise.
	* sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Likewise.
	(cthread_getspecific): Likewise.
	(cthread_setspecific): Likewise.
	(__libc_getspecific): Likewise.
	* sysdeps/mach/hurd/euidaccess.c (__euidaccess): Likewise.
	* sysdeps/mach/hurd/faccessat.c (faccessat): Likewise.
	* sysdeps/mach/hurd/fchdir.c (__fchdir): Likewise.
	* sysdeps/mach/hurd/fchmod.c (__fchmod): Likewise.
	* sysdeps/mach/hurd/fchmodat.c (fchmodat): Likewise.
	* sysdeps/mach/hurd/fchown.c (__fchown): Likewise.
	* sysdeps/mach/hurd/fchownat.c (fchownat): Likewise.
	* sysdeps/mach/hurd/flock.c (__flock): Likewise.
	* sysdeps/mach/hurd/fsync.c (fsync): Likewise.
	* sysdeps/mach/hurd/ftruncate.c (__ftruncate): Likewise.
	* sysdeps/mach/hurd/getgroups.c (__getgroups): Likewise.
	* sysdeps/mach/hurd/gethostname.c (__gethostname): Likewise.
	* sysdeps/mach/hurd/getitimer.c (__getitimer): Likewise.
	* sysdeps/mach/hurd/getlogin_r.c (__getlogin_r): Likewise.
	* sysdeps/mach/hurd/getpgid.c (__getpgid): Likewise.
	* sysdeps/mach/hurd/getrusage.c (__getrusage): Likewise.
	* sysdeps/mach/hurd/getsockname.c (__getsockname): Likewise.
	* sysdeps/mach/hurd/group_member.c (__group_member): Likewise.
	* sysdeps/mach/hurd/isatty.c (__isatty): Likewise.
	* sysdeps/mach/hurd/lchown.c (__lchown): Likewise.
	* sysdeps/mach/hurd/link.c (__link): Likewise.
	* sysdeps/mach/hurd/linkat.c (linkat): Likewise.
	* sysdeps/mach/hurd/listen.c (__listen): Likewise.
	* sysdeps/mach/hurd/mkdir.c (__mkdir): Likewise.
	* sysdeps/mach/hurd/mkdirat.c (mkdirat): Likewise.
	* sysdeps/mach/hurd/openat.c (__openat): Likewise.
	* sysdeps/mach/hurd/poll.c (__poll): Likewise.
	* sysdeps/mach/hurd/readlink.c (__readlink): Likewise.
	* sysdeps/mach/hurd/readlinkat.c (readlinkat): Likewise.
	* sysdeps/mach/hurd/recv.c (__recv): Likewise.
	* sysdeps/mach/hurd/rename.c (rename): Likewise.
	* sysdeps/mach/hurd/renameat.c (renameat): Likewise.
	* sysdeps/mach/hurd/revoke.c (revoke): Likewise.
	* sysdeps/mach/hurd/rewinddir.c (__rewinddir): Likewise.
	* sysdeps/mach/hurd/rmdir.c (__rmdir): Likewise.
	* sysdeps/mach/hurd/seekdir.c (seekdir): Likewise.
	* sysdeps/mach/hurd/send.c (__send): Likewise.
	* sysdeps/mach/hurd/setdomain.c (setdomainname): Likewise.
	* sysdeps/mach/hurd/setegid.c (setegid): Likewise.
	* sysdeps/mach/hurd/seteuid.c (seteuid): Likewise.
	* sysdeps/mach/hurd/setgid.c (__setgid): Likewise.
	* sysdeps/mach/hurd/setgroups.c (setgroups): Likewise.
	* sysdeps/mach/hurd/sethostid.c (sethostid): Likewise.
	* sysdeps/mach/hurd/sethostname.c (sethostname): Likewise.
	* sysdeps/mach/hurd/setlogin.c (setlogin): Likewise.
	* sysdeps/mach/hurd/setpgid.c (__setpgid): Likewise.
	* sysdeps/mach/hurd/setregid.c (__setregid): Likewise.
	* sysdeps/mach/hurd/setreuid.c (__setreuid): Likewise.
	* sysdeps/mach/hurd/settimeofday.c (__settimeofday): Likewise.
	* sysdeps/mach/hurd/setuid.c (__setuid): Likewise.
	* sysdeps/mach/hurd/shutdown.c (shutdown): Likewise.
	* sysdeps/mach/hurd/sigaction.c (__sigaction): Likewise.
	* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
	* sysdeps/mach/hurd/sigpending.c (sigpending): Likewise.
	* sysdeps/mach/hurd/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/mach/hurd/sigsuspend.c (__sigsuspend): Likewise.
	* sysdeps/mach/hurd/socket.c (__socket): Likewise.
	* sysdeps/mach/hurd/symlink.c (__symlink): Likewise.
	* sysdeps/mach/hurd/symlinkat.c (symlinkat): Likewise.
	* sysdeps/mach/hurd/telldir.c (telldir): Likewise.
	* sysdeps/mach/hurd/truncate.c (__truncate): Likewise.
	* sysdeps/mach/hurd/umask.c (__umask): Likewise.
	* sysdeps/mach/hurd/unlink.c (__unlink): Likewise.
	* sysdeps/mach/hurd/unlinkat.c (unlinkat): Likewise.
	* sysdeps/mips/mips64/__longjmp.c (__longjmp): Likewise.
	* sysdeps/posix/alarm.c (alarm): Likewise.
	* sysdeps/posix/cuserid.c (cuserid): Likewise.
	* sysdeps/posix/dirfd.c (dirfd): Likewise.
	* sysdeps/posix/dup.c (__dup): Likewise.
	* sysdeps/posix/dup2.c (__dup2): Likewise.
	* sysdeps/posix/euidaccess.c (euidaccess): Likewise.
	(main): Likewise.
	* sysdeps/posix/flock.c (__flock): Likewise.
	* sysdeps/posix/fpathconf.c (__fpathconf): Likewise.
	* sysdeps/posix/getcwd.c (__getcwd): Likewise.
	* sysdeps/posix/gethostname.c (__gethostname): Likewise.
	* sysdeps/posix/gettimeofday.c (__gettimeofday): Likewise.
	* sysdeps/posix/isatty.c (__isatty): Likewise.
	* sysdeps/posix/killpg.c (killpg): Likewise.
	* sysdeps/posix/libc_fatal.c (__libc_fatal): Likewise.
	* sysdeps/posix/mkfifoat.c (mkfifoat): Likewise.
	* sysdeps/posix/raise.c (raise): Likewise.
	* sysdeps/posix/remove.c (remove): Likewise.
	* sysdeps/posix/rename.c (rename): Likewise.
	* sysdeps/posix/rewinddir.c (__rewinddir): Likewise.
	* sysdeps/posix/seekdir.c (seekdir): Likewise.
	* sysdeps/posix/sigblock.c (__sigblock): Likewise.
	* sysdeps/posix/sigignore.c (sigignore): Likewise.
	* sysdeps/posix/sigintr.c (siginterrupt): Likewise.
	* sysdeps/posix/signal.c (__bsd_signal): Likewise.
	* sysdeps/posix/sigset.c (sigset): Likewise.
	* sysdeps/posix/sigsuspend.c (__sigsuspend): Likewise.
	* sysdeps/posix/sysconf.c (__sysconf): Likewise.
	* sysdeps/posix/sysv_signal.c (__sysv_signal): Likewise.
	* sysdeps/posix/time.c (time): Likewise.
	* sysdeps/posix/ttyname.c (getttyname): Likewise.
	(ttyname): Likewise.
	* sysdeps/posix/ttyname_r.c (__ttyname_r): Likewise.
	* sysdeps/posix/utime.c (utime): Likewise.
	* sysdeps/powerpc/fpu/s_isnan.c (__isnan): Likewise.
	* sysdeps/powerpc/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/powerpc/nptl/pthread_spin_trylock.c
	(pthread_spin_trylock): Likewise.
	* sysdeps/pthread/aio_error.c (aio_error): Likewise.
	* sysdeps/pthread/aio_read.c (aio_read): Likewise.
	* sysdeps/pthread/aio_read64.c (aio_read64): Likewise.
	* sysdeps/pthread/aio_write.c (aio_write): Likewise.
	* sysdeps/pthread/aio_write64.c (aio_write64): Likewise.
	* sysdeps/pthread/flockfile.c (__flockfile): Likewise.
	* sysdeps/pthread/ftrylockfile.c (__ftrylockfile): Likewise.
	* sysdeps/pthread/funlockfile.c (__funlockfile): Likewise.
	* sysdeps/pthread/timer_create.c (timer_create): Likewise.
	* sysdeps/pthread/timer_getoverr.c (timer_getoverrun): Likewise.
	* sysdeps/pthread/timer_gettime.c (timer_gettime): Likewise.
	* sysdeps/s390/ffs.c (__ffs): Likewise.
	* sysdeps/s390/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/s390/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* sysdeps/sh/nptl/pthread_spin_lock.c (pthread_spin_lock):
	Likewise.
	* sysdeps/sparc/nptl/pthread_barrier_destroy.c
	(pthread_barrier_destroy): Likewise.
	* sysdeps/sparc/nptl/pthread_barrier_wait.c
	(__pthread_barrier_wait): Likewise.
	* sysdeps/sparc/sparc32/e_sqrt.c (__ieee754_sqrt): Likewise.
	* sysdeps/sparc/sparc32/pthread_barrier_wait.c
	(__pthread_barrier_wait): Likewise.
	* sysdeps/sparc/sparc32/sem_init.c (__old_sem_init): Likewise.
	* sysdeps/tile/memcmp.c (memcmp_common_alignment): Likewise.
	(memcmp_not_common_alignment): Likewise.
	(MEMCMP): Likewise.
	* sysdeps/tile/wordcopy.c (_wordcopy_fwd_aligned): Likewise.
	(_wordcopy_fwd_dest_aligned): Likewise.
	(_wordcopy_bwd_aligned): Likewise.
	(_wordcopy_bwd_dest_aligned): Likewise.
	* sysdeps/unix/bsd/ftime.c (ftime): Likewise.
	* sysdeps/unix/bsd/gtty.c (gtty): Likewise.
	* sysdeps/unix/bsd/stty.c (stty): Likewise.
	* sysdeps/unix/bsd/tcflow.c (tcflow): Likewise.
	* sysdeps/unix/bsd/tcflush.c (tcflush): Likewise.
	* sysdeps/unix/bsd/tcgetattr.c (__tcgetattr): Likewise.
	* sysdeps/unix/bsd/tcgetpgrp.c (tcgetpgrp): Likewise.
	* sysdeps/unix/bsd/tcsendbrk.c (tcsendbreak): Likewise.
	* sysdeps/unix/bsd/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/bsd/tcsetpgrp.c (tcsetpgrp): Likewise.
	* sysdeps/unix/bsd/ualarm.c (ualarm): Likewise.
	* sysdeps/unix/bsd/wait3.c (__wait3): Likewise.
	* sysdeps/unix/getlogin_r.c (__getlogin_r): Likewise.
	* sysdeps/unix/sockatmark.c (sockatmark): Likewise.
	* sysdeps/unix/stime.c (stime): Likewise.
	* sysdeps/unix/sysv/linux/_exit.c (_exit): Likewise.
	* sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue):
	Likewise.  Use internal_function.
	* sysdeps/unix/sysv/linux/arm/sigaction.c (__libc_sigaction):
	Convert to prototype-style function definition.
	* sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
	* sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
	* sysdeps/unix/sysv/linux/fpathconf.c (__fpathconf): Likewise.
	* sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue):
	Likewise.  Use internal_function.
	* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Convert to
	prototype-style function definition
	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
	Likewise.
	(__getlogin_r): Likewise.
	* sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_broadcast.c
	(__pthread_cond_broadcast): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_destroy.c
	(__pthread_cond_destroy): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_init.c
	(__pthread_cond_init): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_signal.c
	(__pthread_cond_signal): Likewise.
	* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
	(__pthread_cond_wait): Likewise.
	* sysdeps/unix/sysv/linux/i386/getmsg.c (getmsg): Likewise.
	* sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c
	(__ftruncate64): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c
	(truncate64): Likewise.
	* sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise.
	* sysdeps/unix/sysv/linux/pthread_getcpuclockid.c
	(pthread_getcpuclockid): Likewise.
	* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigmask.c (pthread_sigmask):
	Likewise.
	* sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue):
	Likewise.
	* sysdeps/unix/sysv/linux/raise.c (raise): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c
	(__libc_sigaction): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/semget.c (semget): Likewise.
	* sysdeps/unix/sysv/linux/semop.c (semop): Likewise.
	* sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise.
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
	* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise.
	* sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise.
	* sysdeps/unix/sysv/linux/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise.
	* sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise.
	* sysdeps/unix/sysv/linux/sigstack.c (sigstack): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/speed.c (cfgetospeed): Likewise.
	(cfgetispeed): Likewise.
	(cfsetospeed): Likewise.
	(cfsetispeed): Likewise.
	* sysdeps/unix/sysv/linux/tcflow.c (tcflow): Likewise.
	* sysdeps/unix/sysv/linux/tcflush.c (tcflush): Likewise.
	* sysdeps/unix/sysv/linux/tcgetattr.c (__tcgetattr): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/sysv/linux/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/timer_create.c (timer_create): Likewise.
	* sysdeps/unix/sysv/linux/timer_delete.c (timer_delete): Likewise.
	* sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun):
	Likewise.
	* sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigpending.c (sigpending):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/x86_64/backtrace.c (__backtrace): Likewise.
2015-10-19 12:04:33 +00:00
Florian Weimer
6782806d8f malloc: Rewrite with explicit TLS access using __thread 2015-10-17 12:06:48 +02:00
Florian Weimer
52fb79d6cd Assume that SOCK_CLOEXEC is available and works
This fixes (harmless) data races when accessing the various
__have_sock_cloexec variables.
2015-10-17 12:02:37 +02:00
Steve Ellcey
45d8d77ad3 Make performance improvement to MIPS memcpy for small copies.
* sysdeps/mips/memcpy.S (memcpy):  Add word copies for small aligned
	data.
2015-10-16 14:32:49 -07:00
Joseph Myers
5ef193391b Fix i386 build for lll_unlock_elision change.
Tested for i386.

	* sysdeps/unix/sysv/linux/i386/lowlevellock.h
	(lll_unlock_elision): Add adapt_count parameter.
2015-10-16 16:04:06 +00:00
Joseph Myers
15306e3888 Remove NPTL configure errors based on top-level configure tests.
sysdeps/nptl/configure.ac has code to give errors if certain tests in
the top-level configure failed.  However, all those failure conditions
also produce errors in the top-level configure, so the errors in the
NPTL configure are completely redundant; this patch removes them.

(As suggested in
<https://sourceware.org/ml/libc-alpha/2015-10/msg00510.html>, I think
the top-level tests in question can be completely removed as
unnecessary given the version tests.  But even without that there is
clearly no point in duplicating code that gives an error if the test
fails.)

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

	* sysdeps/nptl/configure.ac: Do not give errors based on the
	results of top-level configure tests.
	* sysdeps/nptl/configure: Regenerated.
2015-10-15 23:59:54 +00:00
Joseph Myers
56ab386964 Remove -fexceptions configure test.
There is a configure test for -fexceptions.  This option was added in
GCC 2.8, so the test is obsolete - and indeed plenty of code is using
-fexceptions directly.  This patch removes the configure test and
makes all uses of $(exceptions) use -fexceptions directly.

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

	* configure.ac (libc_cv_gcc_exceptions): Remove configure test.
	* configure: Regenerated.
	* sysdeps/arm/configure.ac (libc_cv_gcc_exceptions): Do not set
	variable.
	(exceptions): Likewise.
	* sysdeps/arm/configure: Regenerated.
	* config.make.in (exceptions): Remove variable.
	* Makeconfig (uses-callbacks): Use -fexceptions instead of
	$(exceptions).
	* debug/Makefile (CFLAGS-dprintf_chk.c): Likewise.
	(CFLAGS-vdprintf_chk.c): Likewise.
	(CFLAGS-printf_chk.c): Likewise.
	(CFLAGS-fprintf_chk.c): Likewise.
	(CFLAGS-vprintf_chk.c): Likewise.
	(CFLAGS-vfprintf_chk.c): Likewise.
	(CFLAGS-gets_chk.c): Likewise.
	(CFLAGS-fgets_chk.c): Likewise.
	(CFLAGS-fgets_u_chk.c): Likewise.
	(CFLAGS-fread_chk.c): Likewise.
	(CFLAGS-fread_u_chk.c): Likewise.
	(CFLAGS-wprintf_chk.c): Likewise.
	(CFLAGS-fwprintf_chk.c): Likewise.
	(CFLAGS-vwprintf_chk.c): Likewise.
	(CFLAGS-vfwprintf_chk.c): Likewise.
	(CFLAGS-fgetws_chk.c): Likewise.
	(CFLAGS-fgetws_u_chk.c): Likewise.
	* libio/Makefile (CFLAGS-fileops.c): Likewise.
	(CFLAGS-fputc.c): Likewise.
	(CFLAGS-fputwc.c): Likewise.
	(CFLAGS-freopen64.c): Likewise.
	(CFLAGS-freopen.c): Likewise.
	(CFLAGS-fseek.c): Likewise.
	(CFLAGS-fseeko64.c): Likewise.
	(CFLAGS-fseeko.c): Likewise.
	(CFLAGS-ftello64.c): Likewise.
	(CFLAGS-ftello.c): Likewise.
	(CFLAGS-fwide.c): Likewise.
	(CFLAGS-genops.c): Likewise.
	(CFLAGS-getc.c): Likewise.
	(CFLAGS-getchar.c): Likewise.
	(CFLAGS-getwc.c): Likewise.
	(CFLAGS-getwchar.c): Likewise.
	(CFLAGS-iofclose.c): Likewise.
	(CFLAGS-iofflush.c): Likewise.
	(CFLAGS-iofgetpos64.c): Likewise.
	(CFLAGS-iofgetpos.c): Likewise.
	(CFLAGS-iofgets.c): Likewise.
	(CFLAGS-iofgetws.c): Likewise.
	(CFLAGS-iofputs.c): Likewise.
	(CFLAGS-iofputws.c): Likewise.
	(CFLAGS-iofread.c): Likewise.
	(CFLAGS-iofsetpos64.c): Likewise.
	(CFLAGS-iofsetpos.c): Likewise.
	(CFLAGS-ioftell.c): Likewise.
	(CFLAGS-iofwrite.c): Likewise.
	(CFLAGS-iogetdelim.c): Likewise.
	(CFLAGS-iogetline.c): Likewise.
	(CFLAGS-iogets.c): Likewise.
	(CFLAGS-iogetwline.c): Likewise.
	(CFLAGS-ioputs.c): Likewise.
	(CFLAGS-ioseekoff.c): Likewise.
	(CFLAGS-ioseekpos.c): Likewise.
	(CFLAGS-iosetbuffer.c): Likewise.
	(CFLAGS-iosetvbuf.c): Likewise.
	(CFLAGS-ioungetc.c): Likewise.
	(CFLAGS-ioungetwc.c): Likewise.
	(CFLAGS-oldfileops.c): Likewise.
	(CFLAGS-oldiofclose.c): Likewise.
	(CFLAGS-oldiofgetpos64.c): Likewise.
	(CFLAGS-oldiofgetpos.c): Likewise.
	(CFLAGS-oldiofsetpos64.c): Likewise.
	(CFLAGS-oldiofsetpos.c): Likewise.
	(CFLAGS-peekc.c): Likewise.
	(CFLAGS-putc.c): Likewise.
	(CFLAGS-putchar.c): Likewise.
	(CFLAGS-putwc.c): Likewise.
	(CFLAGS-putwchar.c): Likewise.
	(CFLAGS-rewind.c): Likewise.
	(CFLAGS-wfileops.c): Likewise.
	(CFLAGS-wgenops.c): Likewise.
	(CFLAGS-oldiofopen.c): Likewise.
	(CFLAGS-iofopen.c): Likewise.
	(CFLAGS-iofopen64.c): Likewise.
	(CFLAGS-oldtmpfile.c): Likewise.
	* stdio-common/Makefile (CFLAGS-vfprintf.c): Likewise.
	(CFLAGS-fprintf.c): Likewise.
	(CFLAGS-printf.c): Likewise.
	(CFLAGS-vfwprintf.c): Likewise.
	(CFLAGS-vfscanf.c): Likewise.
	(CFLAGS-vfwscanf.c): Likewise.
	(CFLAGS-fscanf.c): Likewise.
	(CFLAGS-scanf.c): Likewise.
	(CFLAGS-isoc99_vfscanf.c): Likewise.
	(CFLAGS-isoc99_vscanf.c): Likewise.
	(CFLAGS-isoc99_fscanf.c): Likewise.
	(CFLAGS-isoc99_scanf.c): Likewise.
	* wcsmbs/Makefile (CFLAGS-isoc99_wscanf.c): Likewise.
	(CFLAGS-isoc99_fwscanf.c): Likewise.
	(CFLAGS-isoc99_vwscanf.c): Likewise.
	(CFLAGS-isoc99_vfwscanf.c): Likewise.
2015-10-15 22:35:13 +00:00
Paul Murphy
fadd2ad9cc powerpc: Optimize lock elision for pthread_mutex_t
With TLE enabled, the adapt count variable update incurs
an 8% overhead before entering the critical section of an
elided mutex.

Instead, if it is done right after leaving the critical
section, this serialization can be avoided.

This alters the existing behavior of __lll_trylock_elision
as it will only decrement the adapt_count if it successfully
acquires the lock.

	* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
	(__lll_lock_elision): Remove adapt_count decrement...
	* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
	(__lll_trylock_elision): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/elision-unlock.c
	(__lll_unlock_elision): ... to here. And utilize
	new adapt_count parameter.
	* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
	(__lll_unlock_elision): Update to include adapt_count
	parameter.
	(lll_unlock_elision): Pass pointer to adapt_count
	variable.
2015-10-15 18:56:10 -03:00
Paul Murphy
e5e6bea22a nptl: Add adapt_count parameter to lll_unlock_elision
Adding this parameter will give architectures more freedom in
how they choose to update this variable.  This change has no
effect on architectures which choose not to use it.

	* nptl/pthread_mutex_unlock.c(lll_unlock_elision):
	Add elision adapt_count parameter to list of arguments.
	* sysdeps/unix/sysv/linux/powerpc/lowlevellock.h
	(lll_unlock_elision): Update with new parameter list
	* sysdeps/unix/sysv/linux/s390/lowlevellock.h
	(lll_unlock_elision): Likewise
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
	(lll_unlock_elision): Likewise
2015-10-15 18:55:48 -03:00
H.J. Lu
d6e855d810 Mark _dl_catch_error hidden
Since _dl_catch_error is only used internally in ld.so, it should be
declared in sysdeps/generic/ldsodefs.h, not include/dlfcn.h and it can
be made hidden.

	[BZ #19122]
	* include/dlfcn.h (_dl_catch_error): Moved to ...
	* sysdeps/generic/ldsodefs.h (_dl_catch_error): Add
	attribute_hidden.
2015-10-15 14:13:50 -07:00
H.J. Lu
a1afb41193 Mark internal _itoa functions hidden
Since internal _itoa functions are only used internally in ld.so and
libc.so, they can be made hidden.

	[BZ #19122]
	* sysdeps/generic/_itoa.h (_itoa): Add attribute_hidden.
	(_itoa_word): Likewise.
2015-10-15 14:07:06 -07:00
H.J. Lu
58c9ff1bdb Mark internal _dl_XXX functions hidden
Since internal _dl_XXX functions are only used internally in ld.so,
they can be made hidden.

	[BZ #19122]
	* elf/dl-runtime.c (_dl_fixup): Add attribute_hidden.
	* elf/dynamic-link.h (_dl_try_allocate_static_tls): Likewise.
	* sysdeps/generic/dl-cache.h (_dl_cache_libcmp): Likewise.
	* sysdeps/generic/ldsodefs.h (_dl_name_match_p): Likewise.
	(_dl_higher_prime_number): Likewise.
	(_dl_debug_printf_c): Likewise.
	(_dl_signal_cerror): Likewise.
	(_dl_receive_error): Likewise.
	(_dl_reloc_bad_type): Likewise.
	(_dl_resolve_conflicts): Likewise.
	(_dl_check_all_versions): Likewise.
	(_dl_check_map_versions): Likewise.
	(_dl_sort_fini): Likewise.
	(_dl_debug_initialize): Likewise.
	(_dl_init_paths): Likewise.
	(_dl_show_auxv): Likewise.
	(_dl_next_ld_env_entry): Likewise.
	(_dl_important_hwcaps): Likewise.
	(_dl_load_cache_lookup): Likewise.
	(_dl_update_slotinfo): Likewise.
	(_dl_show_scope): Likewise.
2015-10-15 14:04:31 -07:00
H.J. Lu
b8b21bde18 Mark _wordcopy_XXX functions hidden
Since _wordcopy_XXX functions are only used internally in ld.so and
libc.so, they can be made hidden.

	[BZ #19122]
	* sysdeps/generic/memcopy.h (_wordcopy_fwd_aligned): Add
	attribute_hidden.
	(_wordcopy_fwd_dest_aligned): Likewise.
	(_wordcopy_bwd_aligned): Likewise.
	(_wordcopy_bwd_dest_aligned): Likewise.
2015-10-15 14:01:48 -07:00
H.J. Lu
9edf9b18b1 Mark x86 _dl_unmap/_dl_make_tlsdesc_dynamic hidden
Since x86 _dl_unmap and _dl_make_tlsdesc_dynamic are only used
internally in ld.so, they can be made hidden.

	[BZ #19122]
	* sysdeps/i386/dl-lookupcfg.h (_dl_unmap): Add attribute_hidden.
	* sysdeps/i386/dl-tlsdesc.h (_dl_make_tlsdesc_dynamic):
	Likewise.
	* sysdeps/x86_64/dl-tlsdesc.h (_dl_make_tlsdesc_dynamic):
	Likewise.
	* sysdeps/x86_64/dl-lookupcfg.h (_dl_unmap): Likewise.
2015-10-15 13:48:54 -07:00
H.J. Lu
983a33fa7d Add comments for GCC 5 requirement
* sysdeps/unix/sysv/linux/i386/sysdep.h: Add comments for
	GCC 5 requirement.
2015-10-15 13:35:40 -07:00
Joseph Myers
b7d09f0d63 Remove assembler -mtune=i686 configure test.
There is a configure test for assembler support for -mtune=i686.  This
option was added in binutils 2.18 so the test is obsolete; this patch
removes it.

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

	* sysdeps/i386/configure.ac (libc_cv_as_i686): Remove configure
	test.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/i386/i686/Makefile [$(config-asflags-i686) = yes]: Make
	code unconditional.
2015-10-15 20:28:27 +00:00
H.J. Lu
b994fd7937 Remove i386/epoll_pwait.S
Only i386 implements epoll_pwait in assembly code withot cancellation
support.  All other architectures implement epoll_pwait in epoll_pwait.c
with

int epoll_pwait (int epfd, struct epoll_event *events,
		 int maxevents, int timeout,
		 const sigset_t *set)
{
  return SYSCALL_CANCEL (epoll_pwait, epfd, events, maxevents,
			 timeout, set, _NSIG / 8);
}

Although there is no test for epoll_pwait in glibc, since SYSCALL_CANCEL
works on i386 and epoll_pwait.c works for other architectures, it is
safe to assume that epoll_pwait.c with SYSCALL_CANCEL also works on
i386.

	[BZ #19137]
	* sysdeps/unix/sysv/linux/i386/Makefile (CFLAGS-epoll_pwait.c):
	Add -fomit-frame-pointer.
	* sysdeps/unix/sysv/linux/i386/epoll_pwait.S: Remove file.
2015-10-15 06:26:50 -07:00
H.J. Lu
98ad631cd0 Optimize i386 syscall inlining for GCC 5
Since GCC 5 and above can properly spill %ebx when needed, we can inline
syscalls with 6 arguments if GCC 5 or above is used to compile glibc.
This patch rewrites INTERNAL_SYSCALL macros and skips __libc_do_syscall
for GCC 5.

For sysdeps/unix/sysv/linux/i386/brk.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:

<__brk>:
   0:	push   %ebx
   1:	mov    $0x2d,%eax
   6:	mov    0x8(%esp),%ebx
   a:	call   b <__brk+0xb>	b: R_386_PC32	__x86.get_pc_thunk.dx
   f:	add    $0x2,%edx	11: R_386_GOTPC	_GLOBAL_OFFSET_TABLE_
  15:	call   *%gs:0x10
  1c:	mov    0x0(%edx),%edx	1e: R_386_GOT32	__curbrk
  22:	cmp    %eax,%ebx
  24:	mov    %eax,(%edx)
  26:	ja     30 <__brk+0x30>
  28:	xor    %eax,%eax
  2a:	pop    %ebx
  2b:	ret

instead of

<__brk>:
   0:	push   %ebx
   1:	mov    0x8(%esp),%ecx
   5:	call   6 <__brk+0x6>	6: R_386_PC32	__x86.get_pc_thunk.bx
   a:	add    $0x2,%ebx	c: R_386_GOTPC	_GLOBAL_OFFSET_TABLE_
  10:	xchg   %ecx,%ebx
  12:	mov    $0x2d,%eax
  17:	call   *%gs:0x10
  1e:	xchg   %ecx,%ebx
  20:	mov    %eax,%edx
  22:	mov    0x0(%ebx),%eax	24: R_386_GOT32	__curbrk
  28:	mov    %edx,(%eax)
  2a:	xor    %eax,%eax
  2c:	cmp    %edx,%ecx
  2e:	ja     38 <__brk+0x38>
  30:	pop    %ebx
  31:	ret

The new one is shorter by 2 instructions.

	* sysdeps/unix/sysv/linux/i386/libc-do-syscall.S
	(__libc_do_syscall): Defined only if !__GNUC_PREREQ (5,0).
	* sysdeps/unix/sysv/linux/i386/sysdep.h: Define assembler macros
	only if !__GNUC_PREREQ (5,0).
	(INTERNAL_SYSCALL_MAIN_6): Optimize for GCC 5.
	(INTERNAL_SYSCALL_MAIN_INLINE): Likewise.
	(INTERNAL_SYSCALL_NCS): Likewise.
	(LOADREGS_0): New macro for GCC 5.
	(ASMARGS_0): Likewise.
	(LOADREGS_1): Likewise.
	(ASMARGS_1): Likewise.
	(LOADREGS_2): Likewise.
	(ASMARGS_2): Likewise.
	(LOADREGS_3): Likewise.
	(ASMARGS_3): Likewise.
	(LOADREGS_4): Likewise.
	(ASMARGS_4): Likewise.
	(LOADREGS_5): Likewise.
	(ASMARGS_5): Likewise.
	(LOADREGS_6): Likewise.
	(ASMARGS_6): Likewise.
2015-10-15 05:23:58 -07:00
H.J. Lu
83c01ab32b i386: Remove syscall assembly codes with 6 arguments
This patch removes i386 assembly implementation for mmap, mmap64,
semtimeop now that i386 have 6 argument syscall support from C code
and GCC 5 can inline syscalls with 6 arguments.  We also compile mmap.c,
mmap64.c and semtimedop.c with -fomit-frame-pointer since %ebp may be
used to pass the 6th argument to syscall.

Fo sysdeps/unix/sysv/linux/i386/mmap.c, with -O2 -march=i686
-mtune=generic, GCC 5.2 now generates:

<__mmap>:
   0:	sub    $0x10,%esp
   3:	mov    0x28(%esp),%eax
   7:	mov    %ebx,(%esp)
   a:	mov    0x18(%esp),%ecx
   e:	mov    %esi,0x4(%esp)
  12:	mov    0x14(%esp),%ebx
  16:	mov    %edi,0x8(%esp)
  1a:	mov    0x1c(%esp),%edx
  1e:	test   $0xfff,%eax
  23:	mov    0x20(%esp),%esi
  27:	mov    %ebp,0xc(%esp)
  2b:	mov    0x24(%esp),%edi
  2f:	jne    60 <__mmap+0x60>
  31:	shr    $0xc,%eax
  34:	mov    %eax,%ebp
  36:	mov    $0xc0,%eax
  3b:	call   *%gs:0x10
  42:	cmp    $0xfffff000,%eax
  47:	ja     65 <__mmap+0x65>
  49:	mov    (%esp),%ebx
  4c:	mov    0x4(%esp),%esi
  50:	mov    0x8(%esp),%edi
  54:	mov    0xc(%esp),%ebp
  58:	add    $0x10,%esp
  5b:	ret
  5c:	lea    0x0(%esi,%eiz,1),%esi
  60:	mov    $0xffffffea,%eax
  65:	mov    (%esp),%ebx
  68:	mov    0x4(%esp),%esi
  6c:	mov    0x8(%esp),%edi
  70:	mov    0xc(%esp),%ebp
  74:	add    $0x10,%esp
  77:	jmp    78 <__mmap+0x78>

vs sysdeps/unix/sysv/linux/i386/mmap.S:

<__mmap>:
   0:	push   %ebp
   1:	push   %ebx
   2:	push   %esi
   3:	push   %edi
   4:	mov    0x14(%esp),%ebx
   8:	mov    0x18(%esp),%ecx
   c:	mov    0x1c(%esp),%edx
  10:	mov    0x20(%esp),%esi
  14:	mov    0x24(%esp),%edi
  18:	mov    0x28(%esp),%ebp
  1c:	test   $0xfff,%ebp
  22:	mov    $0xffffffea,%eax
  27:	jne    38 <__mmap+0x38>
  29:	shr    $0xc,%ebp
  2c:	mov    $0xc0,%eax
  31:	call   *%gs:0x10
  38:	pop    %edi
  39:	pop    %esi
  3a:	pop    %ebx
  3b:	pop    %ebp
  3c:	cmp    $0xfffff000,%eax
  41:	ja     44 <__mmap+0x44>
  43:	ret
  44:	call   45 <__mmap+0x45>	45: R_386_PC32	__x86.get_pc_thunk.cx
  49:	add    $0x2,%ecx	4b: R_386_GOTPC	_GLOBAL_OFFSET_TABLE_
  4f:	mov    0x0(%ecx),%ecx	51: R_386_TLS_GOTIE	__libc_errno
  55:	neg    %eax
  57:	mov    %eax,%gs:(%ecx)
  5a:	or     $0xffffffff,%eax
  5d:	ret

The C version has:

   3:	mov    0x28(%esp),%eax
...
  1e:	test   $0xfff,%eax
...
  31:	sar    $0xc,%eax
  34:	mov    %eax,%ebp

is due to missing $ebx register constraint for inline asm.  We have
to use "r" constraint with

register unsigned int _a6 asm ("ebp") = (unsigned int) (arg6);

and compiler chose %eax for offset (arg6) in

  if (offset & (MMAP_PAGE_UNIT - 1))

	* sysdeps/unix/sysv/linux/i386/Makefile (CFLAGS-epoll_pwait.c):
	Add -fomit-frame-pointer.
	(CFLAGS-mmap.c): Likewise.
	(CFLAGS-mmap64.c): Likewise.
	(CFLAGS-semtimedop.c): Likewise.
	* sysdeps/unix/sysv/linux/i386/mmap.c: New file.
	* sysdeps/unix/sysv/linux/i386/mmap.S: Remove file.
	* sysdeps/unix/sysv/linux/i386/mmap64.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/semtimedop.S: Likewise.
2015-10-15 05:03:24 -07:00
Florian Weimer
a014cecd82 Always enable pointer guard [BZ #18928]
Honoring the LD_POINTER_GUARD environment variable in AT_SECURE mode
has security implications.  This commit enables pointer guard
unconditionally, and the environment variable is now ignored.

        [BZ #18928]
        * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
        _dl_pointer_guard member.
        * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
        initializer.
        (security_init): Always set up pointer guard.
        (process_envvars): Do not process LD_POINTER_GUARD.
2015-10-15 09:23:32 +02:00
Joseph Myers
0c25f5b5bb Fix powerpc32 lround, lroundf spurious exceptions (bug 19134).
The powerpc32 implementation of lround and lroundf can produce
spurious exceptions from adding 0.5 then converting to integer.  This
includes "inexact" from the conversion to integer (not allowed for
integer arguments to these functions), and, for larger integer
arguments, "inexact", and "overflow" when rounding upward, from the
addition.  In addition, "inexact" is not allowed together with
"invalid" and so inexact addition must be avoided when the integer
will be out of range of 32-bit long, whether or not the argument is an
integer.

This patch fixes these problems.  As in the powerpc64 llround
implementation, a check is added for too-large arguments; in the
powerpc64 case that means arguments at least 2^52 in magnitude (so
that 0.5 cannot be added exactly), while in this case it means
arguments for which the result would overflow "long".  In those cases
a suitable overflowing value is used for the integer conversion
without adding 0.5, while for smaller arguments it's tested whether
the argument is an integer (by adding and subtracting 2^52 to the
absolute value and comparing with the original absolute value) to
avoid adding 0.5 to integers and generating spurious "inexact".

This code is not used when the power5+ sysdeps directories are used,
as there's a separate power5+ version of these functions..

Tested for powerpc.  This gets test-float (for a default powerpc32
hard-float build without any --with-cpu) back to the point where it
should pass once powerpc ulps are regenerated; test-double still needs
another problem with exceptions fixed to get back to that point (and I
haven't looked lately at what default powerpc64 results are like).

	[BZ #19134]
	* sysdeps/powerpc/powerpc32/fpu/s_lround.S (.LC1): New object.
	(.LC2): Likewise.
	(.LC3): Likewise.
	(__lround): Do not add 0.5 to integer or out-of-range arguments.
2015-10-14 21:13:42 +00:00
Szabolcs Nagy
1fae5a6800 [BZ #19129][ARM] Fix _dl_tlsdesc_resolve_hold to save r0
_dl_tlsdesc_resolve_hold calls into a C function that clobbers r0,
but it assumes the original argument is still in r0 after the call.
This can cause crash in case of concurrent TLS access when TLSDESC
is in use (-mtls-dialect=gnu2).

Run into this while fixing BZ 18572.

Both r0 and r1 are saved/restored so the stack remains 8 byte aligned.

	[BZ #19129]
	* sysdeps/arm/dl-tlsdesc.S (_dl_tlsdesc_resolve_hold): Save and restore
	r0 and r1.
2015-10-14 17:01:12 +01:00
H.J. Lu
d95453ef5d Avoid PLT when calling __sched_getaffinity_new
This patch adds an internal entry for __sched_getaffinity_new so that
__sched_getaffinity_old calls __sched_getaffinity_new without going
through PLT.

	[BZ #18822]
	* sysdeps/unix/sysv/linux/sched_getaffinity.c
	(__sched_getaffinity_new): Add libc_hidden_proto and
	libc_hidden_def.
2015-10-14 06:33:48 -07:00
H.J. Lu
d3d9c95aef Support PLT and GOT references in local PIC check
Linker in binutils 2.26 and newer generate GOT references instead
PLT references when -z now is passed to linker.  We need to extend
scripts/localplt.awk to allow PLT or GOT references.

	[BZ #19007]
	* scripts/localplt.awk: Also allow GOT references.
	* sysdeps/unix/sysv/linux/i386/localplt.data: Mark
	_Unwind_Find_FDE, calloc, memalign, realloc and __libc_memalign
	with "+ REL R_386_GLOB_DAT".
	* sysdeps/x86_64/localplt.data: Mark calloc, memalign, realloc
	and __libc_memalign with "+ RELA R_X86_64_GLOB_DAT".
2015-10-14 06:00:02 -07:00
H.J. Lu
8f763b04a0 Use INTERNAL_SYSCALL and INLINE_SYSCALL_ERROR_RETURN_VALUE
This patch uses INTERNAL_SYSCALL and INLINE_SYSCALL_ERROR_RETURN_VALUE
to avoid reading and writing errno directly so that we don't need to
call __x86.get_pc_thunk.reg to load PC into reg in case there is an
error.

	* sysdeps/unix/sysv/linux/i386/brk.c (__brk): Use
	INLINE_SYSCALL_ERROR_RETURN_VALUE.
	* sysdeps/unix/sysv/linux/i386/fxstatat.c (__fxstatat):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise.
	* sysdeps/unix/sysv/linux/i386/seteuid.c (seteuid): Likewise.
	* sysdeps/unix/sysv/linux/i386/fxstat.c (__fxstat): Use
	INTERNAL_SYSCALLINTERNAL_SYSCALL and
	INLINE_SYSCALL_ERROR_RETURN_VALUE.
	* sysdeps/unix/sysv/linux/i386/lockf64.c (lockf64): Likewise.
	* sysdeps/unix/sysv/linux/i386/lxstat.c (__lxstat): Likewise.
	* sysdeps/unix/sysv/linux/i386/sigaction.c (__libc_sigaction):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/xstat.c (__xstat): Likewise.
2015-10-14 03:45:46 -07:00
Joseph Myers
d7025badd8 Fix powerpc32 llround, llroundf exceptions (bug 19125).
The powerpc32 implementations of llroundf and llround produce spurious
and missing exceptions (some arising from such exceptions from
conversions to long long, some present even when fctidz is used).

This patch fixes those problems in a similar way to the llrint /
llrintf fixes.  The spurious exceptions in the fctidz case for large
arguments arise from a converted value that saturated as LLONG_MAX
being converted back to float or double (the conversion back being
inexact, but "inexact" must not be raised together with "invalid"),
and from the subtraction x - xrf also being inexact for sufficiently
large arguments (whether the saturation was to LLONG_MAX or
LLONG_MIN); those are fixed by returning early if the argument is
large enough that no rounding is needed.

This code is not used for --with-cpu=power4 builds (I suspect the code
used in that case may also produce spurious "inexact" exceptions, but
that's something to investigate later).

Tested for powerpc.

	[BZ #19125]
	* sysdeps/powerpc/powerpc32/fpu/s_llround.c: Include <limits.h>,
	<math_private.h> and <stdint.h>.
	(__llround): Avoid conversions to and from long long int, and
	subtractions, where those might raise spurious exceptions.
	* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: Include
	<math_private.h> and <stdint.h>.
	(__llroundf): Avoid conversions to and from long long int, and
	subtractions, where those might raise spurious exceptions.
2015-10-13 23:30:20 +00:00
H.J. Lu
2caca60d06 Use INLINE_SYSCALL_ERROR_RETURN_VALUE
This patch replaces

  {
    __set_errno (ERRNO);
    return -1;
  }

with INLINE_SYSCALL_ERROR_RETURN_VALUE (ERRNO).

	* sysdeps/unix/sysv/linux/adjtime.c (ADJTIME): Use
	INLINE_SYSCALL_ERROR_RETURN_VALUE.
	* sysdeps/unix/sysv/linux/dl-openat64.c (openat64): Likewise.
	* sysdeps/unix/sysv/linux/eventfd.c (eventfd): Likewise.
	* sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise.
	* sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise.
	* sysdeps/unix/sysv/linux/fcntl.c (do_fcntl): Likewise.
	* sysdeps/unix/sysv/linux/futimens.c (futimens): Likewise.
	* sysdeps/unix/sysv/linux/futimes.c (__futimes): Likewise.
	* sysdeps/unix/sysv/linux/fxstat.c (__fxstat): Likewise.
	* sysdeps/unix/sysv/linux/fxstatat.c (__fxstatat): Likewise.
	* sysdeps/unix/sysv/linux/fxstatat64.c (__fxstatat64): Likewise.
	* sysdeps/unix/sysv/linux/lutimes.c (lutimes): Likewise.
	* sysdeps/unix/sysv/linux/lxstat.c (__lxstat): Likewise.
	* sysdeps/unix/sysv/linux/lxstat64.c (___lxstat64): Likewise.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Likewise.
	* sysdeps/unix/sysv/linux/mq_unlink.c (mq_unlink): Likewise.
	* sysdeps/unix/sysv/linux/prlimit.c (prlimit): Likewise.
	* sysdeps/unix/sysv/linux/readahead.c (__readahead): Likewise.
	* sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise.
	* sysdeps/unix/sysv/linux/signalfd.c (signalfd): Likewise.
	* sysdeps/unix/sysv/linux/speed.c (cfsetospeed): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* sysdeps/unix/sysv/linux/ustat.c (ustat): Likewise.
	* sysdeps/unix/sysv/linux/utimensat.c (utimensat): Likewise.
	* sysdeps/unix/sysv/linux/xmknod.c (__xmknod): Likewise.
	* sysdeps/unix/sysv/linux/xmknodat.c (__xmknodat): Likewise.
	* sysdeps/unix/sysv/linux/xstat.c (__xstat): Likewise.
	* sysdeps/unix/sysv/linux/xstatconv.c (__xstat_conv): Likewise.
	(__xstat64_conv): Likewise.
	(__xstat32_conv): Likewise.
2015-10-13 12:01:10 -07:00
H.J. Lu
fb1cf10811 Add INLINE_SYSCALL_ERROR_RETURN_VALUE
For ia32 PIC, the first thing of many syscalls does is to call
__x86.get_pc_thunk.reg to load PC into reg in case there is an error,
which is required for setting errno.  In most cases, there are no
errors.  But we still call __x86.get_pc_thunk.reg.  This patch adds
INLINE_SYSCALL_ERROR_RETURN_VALUE so that i386 can optimize setting
errno by branching to the internal __syscall_error without PLT.

With i386 INLINE_SYSCALL_ERROR_RETURN_VALUE and i386 syscall inlining
optimization for GCC 5, for sysdeps/unix/sysv/linux/fchmodat.c with
-O2 -march=i686 -mtune=generic, GCC 5.2 now generates:

<fchmodat>:
   0:	push   %ebx
   1:	mov    0x14(%esp),%eax
   5:	mov    0x8(%esp),%ebx
   9:	mov    0xc(%esp),%ecx
   d:	mov    0x10(%esp),%edx
  11:	test   $0xfffffeff,%eax
  16:	jne    38 <fchmodat+0x38>
  18:	test   $0x1,%ah
  1b:	jne    48 <fchmodat+0x48>
  1d:	mov    $0x132,%eax
  22:	call   *%gs:0x10
  29:	cmp    $0xfffff000,%eax
  2e:	ja     58 <fchmodat+0x58>
  30:	pop    %ebx
  31:	ret
  32:	lea    0x0(%esi),%esi
  38:	pop    %ebx
  39:	mov    $0xffffffea,%eax
  3e:	jmp    3f <fchmodat+0x3f>	3f: R_386_PC32	__syscall_error
  43:	nop
  44:	lea    0x0(%esi,%eiz,1),%esi
  48:	pop    %ebx
  49:	mov    $0xffffffa1,%eax
  4e:	jmp    4f <fchmodat+0x4f>	4f: R_386_PC32	__syscall_error
  53:	nop
  54:	lea    0x0(%esi,%eiz,1),%esi
  58:	pop    %ebx
  59:	jmp    5a <fchmodat+0x5a>	5a: R_386_PC32	__syscall_error

instead of

<fchmodat>:
   0:	sub    $0x8,%esp
   3:	mov    0x18(%esp),%eax
   7:	mov    %ebx,(%esp)
   a:	call   b <fchmodat+0xb>	b: R_386_PC32	__x86.get_pc_thunk.bx
   f:	add    $0x2,%ebx	11: R_386_GOTPC	_GLOBAL_OFFSET_TABLE_
  15:	mov    %edi,0x4(%esp)
  19:	test   $0xfffffeff,%eax
  1e:	jne    70 <fchmodat+0x70>
  20:	test   $0x1,%ah
  23:	jne    88 <fchmodat+0x88>
  25:	mov    0x14(%esp),%edx
  29:	mov    0x10(%esp),%ecx
  2d:	mov    0xc(%esp),%edi
  31:	xchg   %ebx,%edi
  33:	mov    $0x132,%eax
  38:	call   *%gs:0x10
  3f:	xchg   %edi,%ebx
  41:	cmp    $0xfffff000,%eax
  46:	ja     58 <fchmodat+0x58>
  48:	mov    (%esp),%ebx
  4b:	mov    0x4(%esp),%edi
  4f:	add    $0x8,%esp
  52:	ret
  53:	nop
  54:	lea    0x0(%esi,%eiz,1),%esi
  58:	mov    0x0(%ebx),%edx	5a: R_386_TLS_GOTIE	__libc_errno
  5e:	neg    %eax
  60:	mov    %eax,%gs:(%edx)
  63:	mov    $0xffffffff,%eax
  68:	jmp    48 <fchmodat+0x48>
  6a:	lea    0x0(%esi),%esi
  70:	mov    0x0(%ebx),%eax	72: R_386_TLS_GOTIE	__libc_errno
  76:	movl   $0x16,%gs:(%eax)
  7d:	mov    $0xffffffff,%eax
  82:	jmp    48 <fchmodat+0x48>
  84:	lea    0x0(%esi,%eiz,1),%esi
  88:	mov    0x0(%ebx),%eax	8a: R_386_TLS_GOTIE	__libc_errno
  8e:	movl   $0x5f,%gs:(%eax)
  95:	mov    $0xffffffff,%eax
  9a:	jmp    48 <fchmodat+0x48>

	* sysdeps/unix/sysv/linux/sysdep.h: New file.
	* sysdeps/unix/sysv/linux/i386/sysdep.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sysdep.h: Include
	<sysdeps/unix/sysv/linux/sysdep.h>.
	* sysdeps/unix/sysv/linux/arm/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/generic/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) == csu]
	(sysdep-dl-routines): Add sysdep.
	[$(subdir) == nptl] (libpthread-routines): Likewise.
	[$(subdir) == rt] (librt-routines): Likewise.
	* sysdeps/unix/sysv/linux/i386/clone.S (__clone): Don't check
	PIC when branching to SYSCALL_ERROR_LABEL.
	* sysdeps/unix/sysv/linux/i386/sysdep.S: Removed.
	* sysdeps/unix/sysv/linux/i386/sysdep.h: Include
	<sysdeps/unix/sysv/linux/sysdep.h>.
	(SYSCALL_ERROR_LABEL): Changed to __syscall_error.
	(SYSCALL_ERROR_ERRNO): Removed.
	(SYSCALL_ERROR_HANDLER): Changed to empty.
	(SYSCALL_ERROR_HANDLER_TLS_STORE): Likewise.
	(__syscall_error): New prototype.
	[IS_IN (libc)] (INLINE_SYSCALL): New macro.
	(INLINE_SYSCALL_ERROR_RETURN_VALUE): Likewise.
2015-10-13 11:59:15 -07:00
H.J. Lu
0a5768fe9c Support x86-64 assmebler without AVX512
When x86-64 assmebler doesn't support AVX512, we should make
_dl_runtime_resolve_avx512/_dl_runtime_profile_avx512 as aliases of
_dl_runtime_resolve_avx/_dl_runtime_profile_avx.  Tested on x86-64
using GCC 5.2 with binutils 20151008 and GCC 4.8 with binutils 20130219.
There are no differences in ld.so with binutils 20151008.  There are no
unexpected failures with binutils 20130219 and 20151008.

	[BZ #19124]
	* sysdeps/x86_64/dl-trampoline.S [!HAVE_AVX512_ASM_SUPPORT]
	(_dl_runtime_resolve_avx512): Make it a hidden alias of
	_dl_runtime_resolve_avx.
	(_dl_runtime_profile_avx512): Make it a hidden alias of
	_dl_runtime_profile_avx.
2015-10-13 10:36:27 -07:00
Joseph Myers
2020748d8e Move powerpc llround implementations to powerpc32 directory.
sysdeps/powerpc/fpu/ has versions of llround and llroundf that are
actually used only for powerpc32 because
sysdeps/powerpc/powerpc64/fpu/ has its own versions of those
functions.  This patch moves them into sysdeps/powerpc/powerpc32/fpu
to reflect where they are actually used (in preparation for fixing
other problems with those functions).

Tested for powerpc that installed stripped shared libraries are
unchanged by this patch.

	* sysdeps/powerpc/fpu/s_llround.c: Move to ....
	* sysdeps/powerpc/powerpc32/fpu/s_llround.c: ...here.
	* sysdeps/powerpc/fpu/s_llroundf.c: Move to ....
	* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: ...here.
2015-10-13 16:53:09 +00:00
Joseph Myers
e8dab9477f Fix powerpc32 llrint, llrintf bad exceptions (bug 16422).
The versions of llrint and llrintf for older powerpc32 processors
convert the results of __rint / __rintf to long long int, resulting in
spurious exceptions from such casts in certain cases.  This patch
makes glibc work around the problems with the libgcc conversions when
the compiler used to build glibc doesn't use the fctidz instruction
for them.

Tested for powerpc.

	[BZ #16422]
	* sysdeps/powerpc/powerpc32/fpu/configure.ac (libc_cv_ppc_fctidz):
	New configure test.
	* sysdeps/powerpc/powerpc32/fpu/configure: Regenerated.
	* config.h.in [_LIBC] (HAVE_PPC_FCTIDZ): New macro.
	* sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include <limits.h>,
	<math_private.h> and <stdint.h>.
	(__llrint): Avoid conversions to long long int where those might
	raise spurious exceptions.
	* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c: Include
	<math_private.h> and <stdint.h>.
	(__llrintf): Avoid conversions to long long int where those might
	raise spurious exceptions.
2015-10-13 00:52:54 +00:00
Joseph Myers
368a24a0b2 Regenerate MIPS libm-test-ulps.
* sysdeps/mips/mips32/libm-test-ulps: Regenerated.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
2015-10-09 22:39:11 +00:00
Joseph Myers
5471d141ac Regenerate ARM libm-test-ulps.
* sysdeps/arm/libm-test-ulps: Regenerated.
2015-10-09 22:30:26 +00:00
Joseph Myers
f1226a2ae3 Fix llrint, llround missing exceptions for ARM (bug 15470).
Similar to the recent fix for MIPS, ARM is also missing correct
exceptions on overflow from llrint and llround functions because casts
from floating-point types to long long do not result in correct
exceptions on overflow.  This patch enables the fix for this for ARM.

Tested for ARM.

	[BZ #15470]
	* sysdeps/arm/fix-fp-int-convert-overflow.h: New file.
2015-10-09 22:23:39 +00:00
Joseph Myers
06d97e5e61 Fix lrint, llrint, lround, llround missing exceptions for MIPS (bug 16399).
For 32-bit MIPS and some other systems, various of the lrint, llrint,
lround, llround functions can be missing exceptions on overflow
because casts do not (in current GCC) result in the proper
exceptions.  In the MIPS case there are two problems here: MIPS I code
generation uses an assembler macro that doesn't raise exceptions,
while the libgcc conversions of floating-point values to long long
also do not raise "invalid" on all overflow cases (and can raise
spurious "inexact").

This patch adds support in the generic code (only the functions for
which this problem has actually been seen) for forcing the "invalid"
exception in the problem cases, and enables that support for the
affected MIPS cases.

Tested for MIPS; also tested for x86_64 and x86 that installed
stripped shared libraries are unchanged by this patch.

	[BZ #16399]
	* sysdeps/generic/fix-fp-int-convert-overflow.h: New file.
	* sysdeps/ieee754/dbl-64/s_llrint.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llrint) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_llround.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llround) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_lrint.c: Include
	<fix-fp-int-convert-overflow.h>.
	(__lrint) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_lround.c: Include
	<fix-fp-int-convert-overflow.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_llrintf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_llroundf.c: Include <fenv.h>,
	<limits.h> and <fix-fp-int-convert-overflow.h>.
	(__llroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_lrintf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__lrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_lroundf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__lroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/mips/mips32/fpu/fix-fp-int-convert-overflow.h: New file.
2015-10-09 21:02:19 +00:00
H.J. Lu
4b71ce6c1a Update lrint/lrintf/lrintl for x32
The x86_64 versions of lrint/lrintf/ lrintl are aliases for the long
long versions which isn't correct for x32, where exceptions must respect
overflow for 32-bit long.  Separate versions of the long functions for
x32 that convert to 32-bit long and raise the right exceptions for that
conversion, while keeping the aliases in the non-x32 case.

Tested on x86_64 and x32.  There are no code changes in libm.so on
x86_64.

	* sysdeps/x86_64/fpu/s_llrint.S (__lrint): Add alias only if
	__ILP32__ isn't defined.
	(lrint): Likewise.
	* sysdeps/x86_64/fpu/s_llrintf.S (__lrintf): Likewise.
	(lrintf): Likewise.
	* sysdeps/x86_64/fpu/s_llrintl.S (__lrintl): Likewise.
	(lrintl): Likewise.
	* sysdeps/x86_64/x32/fpu/s_lrint.S: New file.
	* sysdeps/x86_64/x32/fpu/s_lrintf.S: Likewise.
	* sysdeps/x86_64/x32/fpu/s_lrintl.S: Likewise.
2015-10-09 11:42:10 -07:00
Adhemerval Zanella
0fcc93bce9 Mark lseek/llseek as non-cancellable
This patch sets lseek/llseek for 64-bit, MIPS n32, and x86_32 as non-
cancelable.  This make it consistant with 32-bit platform.

Tested on i686, x86_64, and x32.

	* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (lseek): Set as
	non-cancelable.
	* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (llseek): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/lseek.S (__libc_lseek64):
	Likewise.
2015-10-09 14:26:08 -03:00
Joseph Myers
ae5d8eaed0 Remove configure tests for -mno-vzeroupper support.
GCC added support for -mno-vzeroupper in version 4.6.  Thus the
configure tests for this support are obsolete, and this patch removes
them.

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

	* sysdeps/i386/configure.ac (libc_cv_cc_novzeroupper): Remove
	configure test.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/x86_64/configure.ac (libc_cv_cc_novzeroupper): Remove
	configure test.
	* sysdeps/x86_64/configure: Regenerated.
	* sysdeps/x86_64/Makefile [$(config-cflags-novzeroupper) = yes]:
	Make code unconditional.
2015-10-09 16:03:48 +00:00
Joseph Myers
b7848899a5 Remove configure tests for FMA4 support.
GCC added support for -mfma4 in version 4.5.  Thus the configure tests
for this support are obsolete, and this patch removes them.

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

	* sysdeps/i386/configure.ac (libc_cv_cc_fma4): Remove configure
	test.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/x86_64/configure.ac (libc_cv_cc_fma4): Remove configure
	test.
	* sysdeps/x86_64/configure: Regenerated.
	* sysdeps/x86_64/fpu/multiarch/Makefile [$(have-mfma4) = yes]:
	Make code unconditional.
	* sysdeps/x86_64/fpu/multiarch/e_asin.c [HAVE_FMA4_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_atan2.c [HAVE_FMA4_SUPPORT]:
	Likewise.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/e_log.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	* sysdeps/x86_64/fpu/multiarch/s_atan.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/s_fma.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/s_fmaf.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/s_sin.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* sysdeps/x86_64/fpu/multiarch/s_tan.c [HAVE_FMA4_SUPPORT]: Make
	code unconditional.
	[!HAVE_FMA4_SUPPORT]: Remove conditional code.
	* config.h.in (HAVE_FMA4_SUPPORT): Remove #undef.
2015-10-09 16:02:54 +00:00
Joseph Myers
0e069029a8 Fix dbl-64 lrint for 64-bit long (bug 19095).
The dbl-64 implementation of lrint produces incorrect results for some
arguments with 64-bit long because a 32-bit (unsigned) low part of the
mantissa is shifted left, losing high bits in the process.  This patch
fixes this by casting to long int before shifting, as in lround (as
this case only applies for 64-bit long, there are no issues with
sign-extension).

Tested for mips64 (n64).

	[BZ #19095]
	* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Cast low part of
	mantissa to long int before shifting left.
2015-10-09 00:32:14 +00:00
Joseph Myers
d0d286d32d Fix lrint, llrint missing exceptions close to overflow threshold (bug 19094).
The dbl-64, ldbl-96 and ldbl-128 implementations of lrint and llrint
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions).  (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist.  It also obviously cannot arise in
FE_TOWARDZERO mode.)

This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT, while raising FE_INEXACT explicitly in the cases where it
is needed; unlike lround and llround, FE_INEXACT is required, not
optional, for these functions for a within-range inexact result).

The fixes are conditional on FE_INVALID or FE_INEXACT being defined.
If any future architecture supports one but not both of those
exceptions, the code will fail to compile and need fixing to handle
that case (this seemed better than conditioning on both macros being
defined, resulting in code that would compile but quietly miss
exceptions on such a system).

Tested for x86_64, x86 and mips64.  Tested the ldbl-96 changes (only
relevant for ia64, it appears) on x86_64 by removing the x86_64
versions of lrintl / llrintl.

	[BZ #19094]
	* sysdeps/ieee754/dbl-64/s_lrint.c: Include <fenv.h> and
	<limits.h>.
	(__lrint) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Include <fenv.h> and
	<limits.h>.
	(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Include <fenv.h> and
	<limits.h>.
	(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c: Include <fenv.h> and
	<limits.h>.
	(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c: Include <fenv.h> and
	<limits.h>.
	(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* math/libm-test.inc (lrint_test_data): Add more tests.
	(llrint_test_data): Likewise.
2015-10-08 22:17:45 +00:00
Joseph Myers
1b12cd7f4d Remove configure tests for AVX support.
GCC added support for -mavx and -msse2avx in version 4.4.  Thus the
configure tests for this support are obsolete, and this patch removes
them.

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

	* sysdeps/i386/configure.ac (libc_cv_cc_avx): Remove configure
	test.
	(libc_cv_cc_sse2avx): Likewise.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/i386/i686/multiarch/Makefile
	[$(subdir)$(config-cflags-avx) = mathyes]: Change conditional to
	[$(subdir) = math].
	* sysdeps/i386/i686/multiarch/s_fma-fma.c [HAVE_AVX_SUPPORT]: Make
	code unconditional.
	* sysdeps/i386/i686/multiarch/s_fma.c [HAVE_AVX_SUPPORT]:
	Likewise.
	* sysdeps/i386/i686/multiarch/s_fmaf-fma.c [HAVE_AVX_SUPPORT]:
	Likewise.
	* sysdeps/i386/i686/multiarch/s_fmaf.c [HAVE_AVX_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/configure.ac (libc_cv_cc_avx): Remove configure
	test.
	(libc_cv_cc_sse2avx): Likewise.
	* sysdeps/x86_64/configure: Regenerated.
	* sysdeps/x86_64/Makefile [$(config-cflags-avx) = yes]: Make code
	unconditional.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_profile)
	[HAVE_AVX_SUPPORT || HAVE_AVX512_ASM_SUPPORT]: Make code
	unconditional.
	(_dl_runtime_profile)
	[!(HAVE_AVX_SUPPORT || HAVE_AVX512_ASM_SUPPORT)]: Remove
	conditional code.
	* sysdeps/x86_64/fpu/multiarch/Makefile
	[$(config-cflags-sse2avx) = yes]: Make code unconditional.
	* sysdeps/x86_64/fpu/multiarch/e_atan2.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_log.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_atan.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_fma.c [HAVE_AVX_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_fmaf.c [HAVE_AVX_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_sin.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_tan.c
	[HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise.
	* sysdeps/x86_64/multiarch/strcmp.S [HAVE_AVX_SUPPORT]: Likewise.
	* config.h.in (HAVE_AVX_SUPPORT): Remove #undef.
	(HAVE_SSE2AVX_SUPPORT): Likewise.
2015-10-08 15:59:32 +00:00
Samuel Thibault
58a3a98d8f Add task_notify to mach_interface_list
* sysdeps/mach/configure.ac (mach_interface_list): Add task_notify.
2015-10-08 02:14:43 +02:00
Joseph Myers
8afdb7ac1e Fix lround, llround missing exceptions close to overflow threshold (bug 19088).
The dbl-64, ldbl-96 and ldbl-128 implementations of lround and llround
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions).  (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist.)

This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT).

Tested for x86_64, x86 and mips64.

	[BZ #19088]
	* sysdeps/ieee754/dbl-64/s_lround.c: Include <fenv.h> and
	<limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Include <fenv.h>
	and <limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* math/libm-test.inc (lround_test_data): Add more tests.
	(llround_test_data): Likewise.
2015-10-07 23:45:29 +00:00
Joseph Myers
119d073e33 Fix ldbl-128 lrintl, lroundl missing exceptions for 32-bit long (bug 19085).
The ldbl-128 implementations of lrintl and lroundl miss "invalid"
exceptions on systems with 32-bit long for arguments that overflow
long but have exponent below 48.  This patch fixes this by rearranging
the sequence of tests in the code so the exponent < 48 case is only
used for exponents that don't overflow long.

Tested for mips64 (n32 and n64).

	[BZ #19085]
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Move test for
	exponent below 48 inside case for non-overflowing exponent.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl): Likewise.
2015-10-07 16:10:59 +00:00
Joseph Myers
e88c14d009 Use dbl-64/wordsize-64 for MIPS64.
This patch enables use of sysdeps/ieee754/dbl-64/wordsize-64 for
MIPS64 (both n64 and n32), removing a #error in one case now that case
has been tested and found to work.

Tested for mips64 (n64 and n32).

	* sysdeps/mips/mips64/Implies: Use ieee754/dbl-64/wordsize-64.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
	(__issignaling) [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Remove #error.
2015-10-07 00:43:08 +00:00
Joseph Myers
b75bc69cdf Don't use dbl-64/wordsize-64 lround based on llround for ILP32 (bug 19079).
The implementation of lround in dbl-64/wordsize-64 as an alias or
wrapper for llround is always incorrect when long is not 64-bit,
because it misses required exceptions in overflow cases, as shown by
my recently added tests.  This patch removes that alias / wrapper in
the non-LP64 case, together with the REGISTER_CAST_INT32_TO_INT64
macro, restoring the previous version of lround for dbl-64/wordsize-64
(newly conditioned on !_LP64).

Tested for x86_64, and for mips64 with use of dbl-64/wordsize-64
enabled.

	[BZ #19079]
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Restore previous
	file, conditioned on [!_LP64].
	* sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
	[!_LP64] (__lround): Do not define as function or alias.
	[!_LP64] (lround): Likewise.
	[!_LP64] (__lroundl): Likewise.
	[!_LP64] (lroundl): Likewise.
	* sysdeps/tile/sysdep.h (REGISTER_CAST_INT32_TO_INT64): Remove
	macro.
	* sysdeps/x86_64/x32/sysdep.h (REGISTER_CAST_INT32_TO_INT64):
	Likewise.
2015-10-07 00:40:12 +00:00
Joseph Myers
3b7aa5bf59 Remove configure tests for SSE4 support.
GCC added support for -msse4 in version 4.3.  Thus the configure tests
for it are obsolete, and this patch removes them.

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

	* sysdeps/i386/configure.ac (libc_cv_cc_sse4): Remove configure
	test.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/i386/i686/multiarch/Makefile
	[$(config-cflags-sse4) = yes]: Make code unconditional.
	* sysdeps/i386/i686/multiarch/strcspn.S [HAVE_SSE4_SUPPORT]:
	Likewise.
	* sysdeps/i386/i686/multiarch/strspn.S [HAVE_SSE4_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/configure.ac (libc_cv_cc_sse4): Remove configure
	test.
	* sysdeps/x86_64/configure: Regenerated.
	* sysdeps/x86_64/multiarch/Makefile [$(config-cflags-sse4) = yes]:
	Make code unconditional.
	* sysdeps/x86_64/multiarch/strcspn.S [HAVE_SSE4_SUPPORT]:
	Likewise.
	* sysdeps/x86_64/multiarch/strspn.S [HAVE_SSE4_SUPPORT]: Likewise.
	* config.h.in (HAVE_SSE4_SUPPORT): Remove #undef.
2015-10-06 20:47:40 +00:00
Joseph Myers
6c9678ebd4 Fix ldbl-128ibm expl overflow in non-default rounding modes (bug 19078).
The ldbl-128ibm expl wrapper checks the argument to determine when to
call __kernel_standard_l, thereby overriding overflowing results from
__ieee754_expl that could otherwise (given appropriately patched
libgcc) be correct for the rounding mode.  This patch changes it to
check the result of __ieee754_expl instead, as other versions of this
wrapper do.

Tested for powerpc.

	[BZ #19078]
	* sysdeps/ieee754/ldbl-128ibm/w_expl.c (o_thres): Remove variable.
	(u_thres): Likewise.
	(__expl): Determine whether to call __kernel_standard_l based on
	value of result, not argument.
2015-10-06 17:37:49 +00:00
Joseph Myers
31d4459e42 Fix ldbl-128ibm logl (1) sign of zero result (bug 19077).
The ldbl-128ibm implementation of logl produces a zero with the wrong
sign for logl (1) in FE_DOWNWARD mode.  This patch makes it explicitly
return 0.0L in that case, as in e.g. the ldbl-128 implementation.

Tested for powerpc.

	[BZ #19077]
	* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): Return
	0.0L for argument 1.0L.
2015-10-06 15:32:06 +00:00
Joseph Myers
d79b568926 Fix ldbl-128ibm log1pl (-1) sign of infinity (bug 19076).
The ldbl-128ibm implementation of log1pl produces an infinity with the
wrong sign for log1pl (-1) in FE_DOWNWARD mode.  This patch fixes this
by changing a division (-1.0L / (x - x)) (incorrect in FE_DOWNWARD
mode) to (-1.0L / 0.0L) (correct in all rounding modes).

Tested for powerpc.

	[BZ #19076]
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Divide by
	constant 0.0L when computing infinite result.
2015-10-06 15:14:26 +00:00
Joseph Myers
cec7d28af8 Fix ldbl-96 lroundl just below powers of 2 (bug 19071).
The ldbl-96 version of lroundl is incorrect for systems with 64-bit
long when the argument's absolute value is just below a power of 2,
2^32 or more, and rounds up to the next integer; in such cases, it
returns 0.  The problem is incrementing the high part of the mantissa
loses the high bit of the value (which is not an issue for any other
floating-point format, and is handled specially in lround when the bit
corresponding to 0.5 was in the high part rather than the low part).

This patch fixes this in a similar way to that used in llroundl:
storing the high part in an unsigned long variable before incrementing
it, so problems cannot occur in the case when this code is reachable.
I improved test coverage for both lround and llround by making them
use the same test inputs (appropriately conditioned on the size of
long in the lround case) - complete with the same comments, to make
comparison as easy as possible.  (This test coverage improvement was
how I found the lroundl bug.)

Tested for x86_64 and x86.

	[BZ #19071]
	* sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Use unsigned
	long int variable to store possibly incremented high part of
	mantissa.
	* math/libm-test.inc (lround_test_data): Add tests used for
	llround.  Use [LONG_MAX > 0x7fffffff] consistently as condition
	for tests requiring 64-bit long.  Do not condition tests on
	[TEST_FLOAT] unnecessarily.
	(llround_test_data): Add tests used for lround.  Add another
	expectation for the "inexact" exception.  Do not condition tests
	on [TEST_FLOAT] unnecessarily.
2015-10-05 22:54:50 +00:00
Joseph Myers
bc3753638a Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug 19050).
On powerpc32 hard-float, older processors (ones where fcfid is not
available for 32-bit code), GCC generates conversions from integers to
floating point that wrongly convert integer 0 to -0 instead of +0 in
FE_DOWNWARD mode.  This in turn results in logb and a few other
functions wrongly returning -0 when they should return +0.

This patch works around this issue in glibc as I proposed in
<https://sourceware.org/ml/libc-alpha/2015-09/msg00728.html>, so that
the affected functions can be correct and the affected tests pass in
the absence of a GCC fix for this longstanding issue (GCC bug 67771 -
if fixed, of course we can put in GCC version conditionals, and
eventually phase out the workarounds).  A new macro
FIX_INT_FP_CONVERT_ZERO is added in a new sysdeps header
fix-int-fp-convert-zero.h, and the powerpc32/fpu version of that
header defines the macro based on the results of a configure test for
whether such conversions use the fcfid instruction.

Tested for x86_64 (that installed stripped shared libraries are
unchanged by the patch) and powerpc (that HAVE_PPC_FCFID comes out to
0 as expected and that the relevant tests are fixed).  Also tested a
build with GCC configured for -mcpu=power4 and verified that
HAVE_PPC_FCFID comes out to 1 in that case.

There are still some other issues to fix to get test-float and
test-double passing cleanly for older powerpc32 processors (apart from
the need for an ulps regeneration for powerpc).  (test-ldouble will be
harder to get passing cleanly, but with a combination of selected
fixes to ldbl-128ibm code that don't involve significant performance
issues, allowing spurious underflow and inexact exceptions for that
format, and lots of XFAILing for the default case of unpatched libgcc,
it should be doable.)

	[BZ #887]
	[BZ #19049]
	[BZ #19050]
	* sysdeps/generic/fix-int-fp-convert-zero.h: New file.
	* sysdeps/ieee754/dbl-64/e_log10.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log10): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/e_log2.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log2): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/s_erf.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfc): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/s_logb.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logb): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/e_log10f.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log10f): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/e_log2f.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log2f): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/s_erff.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfcf): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/s_logbf.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logbf): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfcl): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/ldbl-128ibm/s_logbl.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logbl): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/powerpc/powerpc32/fpu/configure.ac: New file.
	* sysdeps/powerpc/powerpc32/fpu/configure: New generated file.
	* sysdeps/powerpc/powerpc32/fpu/fix-int-fp-convert-zero.h: New
	file.
	* config.h.in [_LIBC] (HAVE_PPC_FCFID): New macro.
2015-10-05 17:46:50 +00:00
Paul Pluzhnikov
57352c2201 sysdeps/x86_64/fpu/libm-test-ulps: Regenerated on Haswell. 2015-10-03 11:31:21 -07:00
Joseph Myers
59a63cca11 Fix nexttoward overflow in non-default rounding modes (bug 19059).
ISO C requires overflowing results from nexttoward to be the
appropriate infinity independent of the rounding mode, but some
implementations use a rounding-mode-dependent result (this is the same
issue as was fixed for nextafter in bug 16677).  This patch fixes the
problem by making the nexttoward implementations discard the result
from the floating-point computation that forced an overflow exception
and then return the infinity previously computed with integer
arithmetic.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #19059]
	* math/s_nexttowardf.c (__nexttowardf): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
	Likewise.
	* math/libm-test.inc (nexttoward_test_data): Add more tests.
2015-10-02 17:11:13 +00:00
Gabriel F. T. Gomes
b0f81637d5 PowerPC: Add comments to optimized strncpy
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Added comments to some
	assembly instructions.
2015-10-01 17:36:55 -03:00
Gabriel F. T. Gomes
850713336e PowerPC: Fix operand prefixes
The file sysdeps/powerpc/sysdeps.h defines aliases for register operands,
which add the letter 'r' as a prefix to a register name.  E.g.: register 20
can be written as 'r20', instead of '20'.  On the one hand, this increases
readability, as it makes it easier for readers to know whether the operand is a
register or an immediate.  On the other hand, this permits that immediate
operands be written as if they were registers, and vice-versa, thus reducing
the readability of the code.

This commit removes some of these unintentional misuses.

This commit also increases readability of the code by adding the prefix 'cr' to
some uses of the control register.

Both changes have no effect on the final code.  Checked with objdump.

	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Remove or add register
	prefix from operands.
2015-10-01 17:36:46 -03:00
Joseph Myers
4b84e2471b Fix ldbl-128 / ldbl-128ibm lgamma overflow handling (bug 16347, bug 19046).
The ldbl-128 / ldbl-128ibm implementation of lgamma has problems with
its handling of large arguments.  It has an overflow threshold that is
correct only for ldbl-128, despite being used for both types - with
diagnostic control macros as a temporary measure to disable warnings
about that constant overflowing for ldbl-128ibm - and it has a
calculation that's roughly x * log(x) - x, resulting in overflows for
arguments that are roughly at most a factor 1/log(threshold) below the
overflow threshold.

This patch fixes both issues, using an overflow threshold appropriate
for the type in question and adding another case for large arguments
that avoids the possible intermediate overflow.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16347]
	[BZ #19046]
	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c: Do not include
	<libc-internal.h>.
	(MAXLGM): Do not use diagnostic control macros.
	[LDBL_MANT_DIG == 106] (MAXLGM): Change value to overflow
	threshold for ldbl-128ibm.
	(__ieee754_lgammal_r): For large arguments, multiply by log - 1
	instead of multiplying by log then subtracting.
	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
2015-10-01 17:15:54 +00:00
Joseph Myers
7cda516f5f Fix ldbl-128ibm exp10l spurious overflows (bug 16620).
The ldbl-128ibm implementation of exp10l uses a version of log(10)
split into high and low parts - but the low part is negative, so
causing spurious overflows from __ieee754_expl (exp_high) in cases
close to the overflow threshold (I added relevant tests close to the
overflow threshold to the testsuite earlier today).  The same issue
applies close to the underflow threshold as well (except that spurious
underflows in IBM long double arithmetic are harder to fix than the
other deficiencies, so we might end up permitting those for IBM long
double in the libm testsuite, as permitted by ISO C).

This patch fixes it to use a low part rounded downward to 48 bits
instead.  (The choice of 48 instead of 53 bits is to make it more
obviously safe even when the low part of the argument is negative.)

Tested for powerpc.  (Note that because of libgcc bugs with
multiplication very close to LDBL_MAX, libgcc also needs patching for
all the problem cases to be fixed, but this patch is still safe and
correct in the absence of such libgcc fixes.)

	[BZ #16620]
	* sysdeps/ieee754/ldbl-128ibm/e_exp10l.c (log10_high): Use value
	of log (10) rounded downward to 48 bits.
	(log10_low): Use corresponding low part of log (10).
2015-09-30 23:34:59 +00:00
Joseph Myers
8c6c923636 Fix i386 acosh (-qNaN) spurious "invalid" exception.
The i386 versions of acoshf and acosh raise a spurious "invalid"
exception for an argument that is a quiet NaN with the sign bit set.
The integer arithmetic to detect arguments < 1 also detects -NaN, and
then the computation 0 / 0 in that case raises the exception.  This
patch fixes this by using (x - x) / (x - x) as the computation in that
case instead, which will always raise the exception for non-NaN
arguments reaching that code, but not for quiet NaN arguments.

Tested for x86_64 and x86.

	[BZ #19032]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): For arguments < 1,
	compute result as (x - x) / (x - x) not as 0 / 0.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* math/libm-test.inc (acosh_test_data): Add another test of acosh.
2015-09-30 21:44:42 +00:00
Joseph Myers
93e448cbed Improve test coverage of real libm functions [a-e]*.
This patch improves test coverage of the real libm functions [a-e]*,
ensuring that special cases and ranges of input values of potential
significance (such as close to overflow and underflow thresholds) are
more systematically covered.

This is a followup to
<https://sourceware.org/ml/libc-alpha/2013-12/msg00757.html> which
covered [a-c]* (however, I found more weaknesses in the coverage of
those functions when preparing this patch, hence the additional tests
being added for them here).

Addition of a test for acosh (-qNaN) is temporarily deferred, to be
included as part of a fix for bug 19032 which was discovered in the
course of adding these tests (and which illustrates the use of testing
-qNaN as well as +qNaN as input even to functions for which the sign
of a NaN isn't meant to be significant).

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Add more tests of acos, acosh, asin,
	atan, atan2, atanh, cbrt, cos, cosh, erf, erfc, exp, exp10, exp2
	and expm1.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (acos_test_data): Add more tests.
	(asin_test_data): Likewise.
	(asinh_test_data): Likewise.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Likewise.
	(cbrt_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	(cos_test_data): Likewise.
	(cosh_test_data): Likewise.
	(erf_test_data): Likewise.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp10_test_data): Likewise.
	(exp2_test_data): Likewise.
	(expm1_test_data): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-09-30 18:06:02 +00:00
H.J. Lu
f6d1d86d0c Move sysdeps/unix/sysv/linux/i386/i486/*.? to i386
Since glibc doesn't support i386 any more, we can move
sysdeps/unix/sysv/linux/i386/i486/*.? to i386.

	[BZ #19006]
	* sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/libc-lowlevellock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lll_timedlock_wait.c: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lll_timedlock_wait.c: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lll_timedwait_tid.c: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lll_timedwait_tid.c: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Moved to ...
	* sysdeps/unix/sysv/linux/i386/lowlevellock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_barrier_wait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_broadcast.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_signal.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_wait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S:
	Removed.
	* sysdeps/unix/sysv/linux/i386/i586/lll_timedlock_wait.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lll_timedwait_tid.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lll_timedlock_wait.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lll_timedwait_tid.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S:
	Replace ../i486/pthread_cond_timedwait.S with
	../pthread_cond_timedwait.S.
2015-09-30 10:12:44 -07:00
Joseph Myers
a5721ebc68 Fix clog, clog10 inaccuracy (bug 19016).
For arguments with X^2 + Y^2 close to 1, clog and clog10 avoid large
errors from log(hypot) by computing X^2 + Y^2 - 1 in a way that avoids
cancellation error and then using log1p.

However, the thresholds for using that approach still result in log
being used on argument as large as sqrt(13/16) > 0.9, leading to
significant errors, in some cases above the 9ulp maximum allowed in
glibc libm.  This patch arranges for the approach using log1p to be
used in any cases where |X|, |Y| < 1 and X^2 + Y^2 >= 0.5 (with the
existing allowance for cases where one of X and Y is very small),
adjusting the __x2y2m1 functions to work with the wider range of
inputs.  This way, log only gets used on arguments below sqrt(1/2) (or
substantially above 1), where the error involved is much less.

Tested for x86_64, x86, mips64 and powerpc.  For the ulps regeneration
I removed the existing clog and clog10 ulps before regenerating to
allow any reduced ulps to appear.  Tests added include those found by
random test generation to produce large ulps either before or after
the patch, and some found by trying inputs close to the (0.75, 0.5)
threshold where the potential errors from using log are largest.

	[BZ #19016]
	* sysdeps/generic/math_private.h (__x2y2m1f): Update comment to
	allow more cases with X^2 + Y^2 >= 0.5.
	* sysdeps/ieee754/dbl-64/x2y2m1.c (__x2y2m1): Likewise.  Add -1 as
	normal element in sum instead of special-casing based on values of
	arguments.
	* sysdeps/ieee754/dbl-64/x2y2m1f.c (__x2y2m1f): Update comment.
	* sysdeps/ieee754/ldbl-128/x2y2m1l.c (__x2y2m1l): Likewise.  Add
	-1 as normal element in sum instead of special-casing based on
	values of arguments.
	* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c (__x2y2m1l): Likewise.
	* sysdeps/ieee754/ldbl-96/x2y2m1.c [FLT_EVAL_METHOD != 0]
	(__x2y2m1): Update comment.
	* sysdeps/ieee754/ldbl-96/x2y2m1l.c (__x2y2m1l): Likewise.  Add -1
	as normal element in sum instead of special-casing based on values
	of arguments.
	* math/s_clog.c (__clog): Handle more cases using log1p without
	hypot.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/auto-libm-test-in: Add more tests of clog and clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-09-28 22:11:22 +00:00
Joseph Myers
fa752c6981 Fix powf inaccuracy (bug 18956).
The flt-32 version of powf can be inaccurate because of bugs in the
extra-precision calculation of (x-1)/(x+1) or (x-1.5)/(x+1.5) as part
of calculating log(x) with extra precision: a constant used (as part
of adding 1 or 1.5 through integer arithmetic) is incorrect, and then
the code fails to mask a computed high part before using it in
arithmetic that relies on s_h*t_h being exactly representable.  This
patch fixes these bugs.

Tested for x86_64 and x86.  x86_64 ulps for powf removed and
regenerated to reflect reduced ulps from the increased accuracy for
existing tests.

	[BZ #18956]
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Add 0x00400000
	not 0x0040000 for high bit of mantissa.  Mask with 0xfffff000 when
	extracting high part.
	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-09-26 00:27:06 +00:00
Joseph Myers
6ace393821 Fix pow missing underflows (bug 18825).
Similar to various other bugs in this area, pow functions can fail to
raise the underflow exception when the result is tiny and inexact but
one or more low bits of the intermediate result that is scaled down
(or, in the i386 case, converted from a wider evaluation format) are
zero.  This patch forces the exception in a similar way to previous
fixes, thereby concluding the fixes for known bugs with missing
underflow exceptions currently filed in Bugzilla.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18825]
	* sysdeps/i386/fpu/i386-math-asm.h (FLT_NARROW_EVAL_UFLOW_NONNAN):
	New macro.
	(DBL_NARROW_EVAL_UFLOW_NONNAN): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	* sysdeps/i386/fpu/e_pow.S: Use DEFINE_DBL_MIN.
	(__ieee754_pow): Use DBL_NARROW_EVAL_UFLOW_NONNAN instead of
	DBL_NARROW_EVAL, reloading the PIC register as needed.
	* sysdeps/i386/fpu/e_powf.S: Use DEFINE_FLT_MIN.
	(__ieee754_powf): Use FLT_NARROW_EVAL_UFLOW_NONNAN instead of
	FLT_NARROW_EVAL.  Use separate return path for case when first
	argument is NaN.
	* sysdeps/i386/fpu/e_powl.S: Include <i386-math-asm.h>.  Use
	DEFINE_LDBL_MIN.
	(__ieee754_powl): Use LDBL_CHECK_FORCE_UFLOW_NONNAN, reloading the
	PIC register.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Force
	underflow for subnormal result.
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/x86/fpu/powl_helper.c (__powl_helper): Use
	math_check_force_underflow.
	* sysdeps/x86_64/fpu/x86_64-math-asm.h
	(LDBL_CHECK_FORCE_UFLOW_NONNAN): New macro.
	* sysdeps/x86_64/fpu/e_powl.S: Include <x86_64-math-asm.h>.  Use
	DEFINE_LDBL_MIN.
	(__ieee754_powl): Use LDBL_CHECK_FORCE_UFLOW_NONNAN.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
2015-09-25 22:29:10 +00:00
Joseph Myers
775e99641e Use soft-fp fma for no-FPU ColdFire (bug 13304).
Systems without floating-point exceptions and rounding modes should
use the soft-fp versions of fmaf and fma, not the sysdeps/ieee754
versions that rely on setting rounding to zero and testing for the
"inexact" exception; this has been noted on
<https://sourceware.org/glibc/wiki/PortStatus> for some time.  This
patch makes no-FPU ColdFire use the soft-fp files; sfp-machine.h is
made to include the nios2 version of sfp-machine.h which seems
sufficiently generic for 32-bit systems.

	[BZ #13304]
	* sysdeps/m68k/coldfire/nofpu/s_fma.c: New file.
	* sysdeps/m68k/coldfire/nofpu/s_fmaf.c: Likewise.
	* sysdeps/m68k/coldfire/nofpu/sfp-machine.h: Likewise.
2015-09-25 17:30:56 +00:00
Joseph Myers
02c48b21b5 Use soft-fp fma for MicroBlaze (bug 13304).
Systems without floating-point exceptions and rounding modes should
use the soft-fp versions of fmaf and fma, not the sysdeps/ieee754
versions that rely on setting rounding to zero and testing for the
"inexact" exception; this has been noted on
<https://sourceware.org/glibc/wiki/PortStatus> for some time.  This
patch makes MicroBlaze use the soft-fp files; sfp-machine.h is made to
include the nios2 version of sfp-machine.h which seems sufficiently
generic for 32-bit systems.

	[BZ #13304]
	* sysdeps/microblaze/s_fma.c: New file.
	* sysdeps/microblaze/s_fmaf.c: Likewise.
	* sysdeps/microblaze/sfp-machine.h: Likewise.
2015-09-25 17:29:19 +00:00
Joseph Myers
f6987f5aa4 Fix hypot missing underflows (bug 18803).
Similar to various other bugs in this area, hypot functions can fail
to raise the underflow exception when the result is tiny and inexact
but one or more low bits of the intermediate result that is scaled
down (or, in the i386 case, converted from a wider evaluation format)
are zero.  This patch forces the exception in a similar way to
previous fixes.

Note that this issue cannot arise for implementations of hypotf using
double (or wider) for intermediate evaluation (if hypotf should
underflow, that means the double square root is being computed of some
number of the form N*2^-298, for 0 < N < 2^46, which is exactly
represented as a double, and whatever the rounding mode such a square
root cannot have a mantissa with all zeroes after the initial 23
bits).  Thus no changes are made to hypotf implementations in this
patch, only to hypot and hypotl.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18803]
	* sysdeps/i386/fpu/e_hypot.S: Use DEFINE_DBL_MIN.
	(MO): New macro.
	(__ieee754_hypot) [PIC]: Load PIC register.
	(__ieee754_hypot): Use DBL_NARROW_EVAL_UFLOW_NONNEG instead of
	DBL_NARROW_EVAL.
	* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Use
	math_check_force_underflow_nonneg in case where result might be
	tiny.
	* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/powerpc/fpu/e_hypot.c (__ieee754_hypot): Likewise.
	* math/auto-libm-test-in: Add more tests of hypot.
	* math/auto-libm-test-out: Regenerated.
2015-09-24 23:43:57 +00:00
Steve Ellcey
35e977b003 Add unused attribute to declaration for mips16 builds.
2015-09-24  Steve Ellcey  <sellcey@imgtec.com>

 	* sysdeps/mips/math_private.h (libc_fesetenv_mips): Mark cw as unused.
2015-09-24 16:12:49 -07:00
Joseph Myers
b2a64460ba Refactor x86_64 libm code forcing underflow exceptions.
This patch refactors code in sysdeps/x86_64/fpu that forces underflow
exceptions and closely follows corresponding i386 code to use common
macros in x86_64-math-asm.h for that purpose.  This is mainly about
keeping the code similar to the i386 code as far as possible, since
each macro apart from DEFINE_LDBL_MIN ends up used only once.  It
would be possible to do a further refactoring to share these macros
between i386 and x86_64 (with i386 using the fcomip / fucomip versions
when building for i686 and above), but I have no immediate plans to do
so.

Tested for x86_64.

	* sysdeps/x86_64/fpu/x86_64-math-asm.h: New file.
	* sysdeps/x86_64/fpu/e_exp2l.S: Include <x86_64-math-asm.h>.
	(ldbl_min): Replace with use of DEFINE_LDBL_MIN.
	(__ieee754_exp2l): Use LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN.
	* sysdeps/x86_64/fpu/e_expl.S: Include <x86_64-math-asm.h>.
	[!USE_AS_EXPM1L] (cmin): Replace with use of DEFINE_LDBL_MIN.
	(IEEE754_EXPL): Use LDBL_CHECK_FORCE_UFLOW_NONNEG.
2015-09-24 22:25:30 +00:00
Joseph Myers
1a19b8894f Use LOAD_PIC_REG in i386 atanh.
sysdeps/i386/fpu/e_atanh.S, unlike all other functions in that
directory, loads the PIC register with its own code using
_GLOBAL_OFFSET_TABLE_, rather than with the LOAD_PIC_REG macro.  I see
no good reason for the difference; this patch makes it use the common
macro.

Tested for x86.

	* sysdeps/i386/fpu/e_atanh.S (__ieee754_atanh) [PIC]: Use
	LOAD_PIC_REG.
2015-09-24 21:48:22 +00:00
Joseph Myers
37825319ee Refactor i386 libm code forcing underflow exceptions.
This patch refactors code in sysdeps/i386/fpu that forces underflow
exceptions to use common macros for that purpose as far as possible.
(Although some of the macros end up used in only one place, I think
it's cleanest to define all these macros together so that all the code
forcing underflow uses such macros.  Some more uses of such macros
will also be introduced when fixing remaining bugs about missing
underflow exceptions, and it would be possible to do further
refactoring of the macros in i386-math-asm.h to share more code by
using other macros internally.  Places that test for underflow by
examining the representation of the argument with integer operations,
rather that using floating-point comparisons on the argument or
result, are unchanged by this patch.)

Most of this code uses a macro MO to abstract away the differences
between PIC and non-PIC memory references to constants.  log1p
functions, however, hardcoded PIC conditionals for this.  Because the
common macros rely on the use of MO, I changed the log1p functions to
use the normal style here, and, for consistency, also made that change
to log1pl which is otherwise unaffected by this patch.

Tested for x86.

	* sysdeps/i386/fpu/i386-math-asm.h (DEFINE_LDBL_MIN): New macro.
	(FLT_CHECK_FORCE_UFLOW): Likewise.
	(DBL_CHECK_FORCE_UFLOW): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NARROW): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NARROW): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	* sysdeps/i386/fpu/e_asin.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_asin): Use DBL_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/e_asinf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_asinf): Use FLT_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/e_atan2.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_atan2): Use DBL_CHECK_FORCE_UFLOW_NARROW.
	* sysdeps/i386/fpu/e_atan2f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_atan2f): Use FLT_CHECK_FORCE_UFLOW_NARROW.
	* sysdeps/i386/fpu/e_atanh.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_atanh): Use DBL_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_atanhf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_atanhf): Use FLT_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_exp2l.S: Include <i386-math-asm.h>.
	(ldbl_min): Replace with use of DEFINE_LDBL_MIN.
	(__ieee754_exp2l): Use LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_expl.S: Include <i386-math-asm.h>.
	[!USE_AS_EXPM1L] (cmin): Replace with use of DEFINE_LDBL_MIN.
	(IEEE754_EXPL): Use LDBL_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/s_atan.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__atan): Use DBL_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/s_atanf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__atanf): Use FLT_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/s_expm1.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__expm1): Use DBL_CHECK_FORCE_UFLOW.  Move underflow check after
	main computation.
	* sysdeps/i386/fpu/s_expm1f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__expm1f): Use FLT_CHECK_FORCE_UFLOW.  Move underflow check after
	main computation.
	* sysdeps/i386/fpu/s_log1p.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(MO): New macro.
	(__log1p): Use MO.  Use DBL_CHECK_FORCE_UFLOW_NONNAN.
	* sysdeps/i386/fpu/s_log1pf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(MO): New macro.
	(__log1pf): Use MO.  Use FLT_CHECK_FORCE_UFLOW_NONNAN.
	* sysdeps/i386/fpu/s_log1pl.S (MO): New macro.
	(__log1pl): Use MO.
2015-09-24 21:41:00 +00:00
Joseph Myers
51df260506 Fix x86_64 fma4 pow inappropriate contraction (bug 19003).
The x86_64 fma4 version of pow fails to disable contraction of
operations other than those explicitly intended to use fma
instructions, so resulting in large ulps errors on processors with
fma4 instructions, as in bug 18104 (165ulp for the test added for that
bug; error originally reported by "blaaa" on #glibc).  This patch adds
$(config-cflags-nofma) for e_pow-fma4.c, corresponding to the use for
e_pow.c in sysdeps/ieee754/dbl-64/Makefile.

Tested for x86_64 on a processor with fma4.

	[BZ #19003]
	* sysdeps/x86_64/fpu/multiarch/Makefile (CFLAGS-e_pow-fma4.c): Add
	$(config-cflags-nofma).
2015-09-24 16:48:32 +00:00
Szabolcs Nagy
24ffcbfc24 Regenerate aarch64 libm-test-ulps
* sysdeps/aarch64/libm-test-ulps: Regenerated.
2015-09-24 14:22:31 +01:00
Joseph Myers
cfcbebf7ac Don't use volatile in exp2f.
sysdeps/ieee754/flt-32/e_exp2f.c declares two variable as "static
const volatile float".  Maybe this use of "volatile" was originally
intended to inhibit optimization of underflowing / overflowing
operations such as TWOM100 * TWOM100; in any case, it's not currently
needed, as given -frounding-math constant folding of such expressions
is properly disabled when it would be unsafe.  This patch removes the
unnecessary use of "volatile".

Tested for x86_64.

	* sysdeps/ieee754/flt-32/e_exp2f.c (TWOM100): Remove volatile.
	(TWO127): Likewise.
2015-09-23 22:52:13 +00:00
Joseph Myers
d96164c330 Refactor code forcing underflow exceptions.
Various floating-point functions have code to force underflow
exceptions if a tiny result was computed in a way that might not have
resulted in such exceptions even though the result is inexact.  This
typically uses math_force_eval to ensure that the underflowing
expression is evaluated, but sometimes uses volatile.

This patch refactors such code to use three new macros
math_check_force_underflow, math_check_force_underflow_nonneg and
math_check_force_underflow_complex (which in turn use
math_force_eval).  In the limited number of cases not suited to a
simple conversion to these macros, existing uses of volatile are
changed to use math_force_eval instead.  The converted code does not
always execute exactly the same sequence of operations as the original
code, but the overall effects should be the same.

Tested for x86_64, x86, mips64 and powerpc.

	* sysdeps/generic/math_private.h (fabs_tg): New macro.
	(min_of_type): Likewise.
	(math_check_force_underflow): Likewise.
	(math_check_force_underflow_nonneg): Likewise.
	(math_check_force_underflow_complex): Likewise.
	* math/e_exp2l.c (__ieee754_exp2l): Use
	math_check_force_underflow_nonneg.
	* math/k_casinh.c (__kernel_casinh): Likewise.
	* math/k_casinhf.c (__kernel_casinhf): Likewise.
	* math/k_casinhl.c (__kernel_casinhl): Likewise.
	* math/s_catan.c (__catan): Use
	math_check_force_underflow_complex.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* math/s_ccosh.c (__ccosh): Likewise.
	* math/s_ccoshf.c (__ccoshf): Likewise.
	* math/s_ccoshl.c (__ccoshl): Likewise.
	* math/s_cexp.c (__cexp): Likewise.
	* math/s_cexpf.c (__cexpf): Likewise.
	* math/s_cexpl.c (__cexpl): Likewise.
	* math/s_clog.c (__clog): Use math_check_force_underflow_nonneg.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/s_csin.c (__csin): Use math_check_force_underflow_complex.
	* math/s_csinf.c (__csinf): Likewise.
	* math/s_csinh.c (__csinh): Likewise.
	* math/s_csinhf.c (__csinhf): Likewise.
	* math/s_csinhl.c (__csinhl): Likewise.
	* math/s_csinl.c (__csinl): Likewise.
	* math/s_csqrt.c (__csqrt): Use math_check_force_underflow.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/s_ctan.c (__ctan): Use math_check_force_underflow_complex.
	* math/s_ctanf.c (__ctanf): Likewise.
	* math/s_ctanh.c (__ctanh): Likewise.
	* math/s_ctanhf.c (__ctanhf): Likewise.
	* math/s_ctanhl.c (__ctanhl): Likewise.
	* math/s_ctanl.c (__ctanl): Likewise.
	* stdlib/strtod_l.c (round_and_return): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/e_atanh.c (__ieee754_atanh): Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Do not use
	volatile when forcing underflow.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
	Likewise.
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	* sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_atan.c (atan): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/s_erf.c (__erf): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/s_expm1.c (__expm1): Likewise.
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/dbl-64/s_log1p.c (__log1p): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Likewise.
	* sysdeps/ieee754/dbl-64/s_tan.c (tan): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/s_tanh.c (__tanh): Use
	math_check_force_underflow.
	* sysdeps/ieee754/flt-32/e_asinf.c (__ieee754_asinf): Likewise.
	* sysdeps/ieee754/flt-32/e_atanhf.c (__ieee754_atanhf): Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Use
	math_check_force_underflow.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
	* sysdeps/ieee754/flt-32/e_sinhf.c (__ieee754_sinhf): Likewise.
	* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.
	* sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Likewise.
	* sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise.
	* sysdeps/ieee754/flt-32/s_atanf.c (__atanf): Likewise.
	* sysdeps/ieee754/flt-32/s_erff.c (__erff): Likewise.
	* sysdeps/ieee754/flt-32/s_expm1f.c (__expm1f): Likewise.
	* sysdeps/ieee754/flt-32/s_log1pf.c (__log1pf): Likewise.
	* sysdeps/ieee754/flt-32/s_tanhf.c (__tanhf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_atanhl.c (__ieee754_atanhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_expl.c (__ieee754_expl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_sincosl.c (__kernel_sincosl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_tanl.c (__kernel_tanl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c (__asinhl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_atanl.c (__atanl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Likewise.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c (__ieee754_atanhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Use math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_sincosl.c (__kernel_sincosl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c (__kernel_tanl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_atanl.c (__atanl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-96/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-96/k_tanl.c (__kernel_tanl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-96/s_asinhl.c (__asinhl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-96/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/ldbl-96/s_tanhl.c (__tanhl): Use
	math_check_force_underflow.
2015-09-23 22:42:30 +00:00