Commit Graph

11725 Commits

Author SHA1 Message Date
Samuel Thibault 844bf92148 hurd: Fix warning
* sysdeps/mach/hurd/spawni.c (__spawni): Make relpath and abspath
	const char * instead of char *.
2018-01-28 16:21:28 +01:00
Samuel Thibault 660b7bff81 hurd: fix warning
* sysdeps/mach/hurd/getresgid.c (__getresgid): Set result from
	critical section to make code simpler and avoid warning.
	* sysdeps/mach/hurd/getresuid.c (__getresuid): Set result from
	critical section to make code simpler and avoid warning.
2018-01-27 23:49:18 +01:00
Samuel Thibault 41cdb1eb5a hurd: Fix enabling vm_copy
Benchmarked on
http://lists.gnu.org/archive/html/bug-hurd/2014-12/msg00081.html

	* sysdeps/mach/pagecopy.h (PAGE_THRESHOLD): Rename to
	PAGE_COPY_THRESHOLD and set to benchmarked 16384.
2018-01-27 22:09:30 +01:00
Samuel Thibault f817775364 hurd: fix warning
Making `special_profil_failure' both avoids warning "variable
'special_profil_failure' set but not used", and makes it easier to
access with gdb.

	* sysdeps/mach/hurd/profil.c (special_profil_failure): Move variable
	to global scope.
2018-01-27 22:01:34 +01:00
Samuel Thibault 06fac9f503 hurd: fix warning
* sysdeps/mach/hurd/dl-sysdep.c (_exit): Call LOSE and abort() if
	__task_terminate would ever return successfully.
2018-01-27 22:00:23 +01:00
Samuel Thibault 7dab2d00ee hurd: drop elder MACH_IPC_COMPAT handling
This was dropped from GNU Mach in 2006.

	* mach/Machrules (MIGFLAGS): Do not set -DMACH_IPC_COMPAT=0.
	* mach/mach/mach_traps.h: Drop comment about MACH_IPC_COMPAT.
	* sysdeps/mach/hurd/fork.c (__fork): Drop special casing
	MACH_IPC_COMPAT.
2018-01-27 21:40:08 +01:00
Samuel Thibault 903d3633ec hurd: fix warning
* sysdeps/mach/hurd/Makefile [$(subdir)==nis]: Add
	-DUSE_BINDINGDIR=1 to CFLAGS-ypclnt.c.
2018-01-27 21:37:29 +01:00
Samuel Thibault 61a3a8c6ce hurd: fix warning
timer_ptr2id and timer_id2ptr are used to convert between
application-visible timer_t and struct timer_node *. timer_ptr2id was made
to use void * instead of timer_t in 49b650430e ('Update.') for no reason.
It happens that on Linux timer_t is void *, so both that change and this
commit are no-ops there, but not on systems where timer_t is not void *.

Using timer_ptr2id for filling sival_ptr also does not make sense since that
actually is a void *.

	* sysdeps/pthread/posix-timer.h (timer_ptr2id): Cast to timer_t
	instead of void *.
	* sysdeps/pthread/timer_create.c (timer_create): Do not use
	timer_ptr2id to cast struct timer_node * to void *.
2018-01-27 17:17:49 +01:00
Samuel Thibault 05ebfe87fa hurd: fix warning
* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Cast
	vm_address_t * to ElfW(Addr) * for dl_main parameter.
2018-01-27 16:49:05 +01:00
Samuel Thibault 147d1dbb9d hurd: fix warnings
* sysdeps/generic/sigsetops.h (__sigemptyset, __sigfillset,
	__sigandset, __sigorset, __sigaddset, __sigdelset): Make them really
	return 0.
2018-01-27 16:47:36 +01:00
Samuel Thibault 4f66dc2390 hurd: fix warning
* sysdeps/generic/sigset-cvt-mask.h: Include <sigsetops.h>.
2018-01-27 16:45:55 +01:00
Samuel Thibault b29848b99b hurd: fix warnings
* sysdeps/generic/not-cancel.h: Include <fcntl.h>, <unistd.h>,
	<sys/wait.h>, <time.h>, <sys/uio.h>.
	(NOT_CANCEL_H): Add inclusion guard.
2018-01-27 16:45:10 +01:00
Samuel Thibault da8168df01 hurd: fix warning
* sysdeps/mach/hurd/profil.c: Reuse `a' variable instead of introducing
	a `c' variable.
2018-01-27 16:33:29 +01:00
Samuel Thibault 85285a0ce7 hurd: fix warning
* sysdeps/mach/hurd/xmknodat.c: Include <sys/sysmacros.h>.
2018-01-27 16:32:16 +01:00
James Clarke 7e23a7ddf8 Update hppa libm-test-ulps
* sysdeps/hppa/fpu/libm-test-ulps: Update.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
2018-01-27 13:32:36 +01:00
James Clarke 3854c5a847 Update Alpha libm-test-ulps
* sysdeps/alpha/fpu/libm-test-ulps: Update.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
2018-01-27 13:31:38 +01:00
Patrick McGehearty 1cbf818d25 Update sparc ULPs.
* sysdeps/sparc/fpu/libm-test-ulps: Update
        cpow, ctan, ctanh, j0, j1, y0, yn ulps.
2018-01-26 08:23:01 -08:00
Carlos O'Donell 2ec0e7eade Revert Intel CET changes to __jmp_buf_tag (Bug 22743)
In commit cba595c350 and commit
f81ddabffd, ABI compatibility with
applications was broken by increasing the size of the on-stack
allocated __pthread_unwind_buf_t beyond the oringal size.
Applications only have the origianl space available for
__pthread_unwind_register, and __pthread_unwind_next to use,
any increase in the size of __pthread_unwind_buf_t causes these
functions to write beyond the original structure into other
on-stack variables leading to segmentation faults in common
applications like vlc. The only workaround is to version those
functions which operate on the old sized objects, but this must
happen in glibc 2.28.

Thank you to Andrew Senkevich, H.J. Lu, and Aurelien Jarno, for
submitting reports and tracking the issue down.

The commit reverts the above mentioned commits and testing on
x86_64 shows that the ABI compatibility is restored. A tst-cleanup1
regression test linked with an older glibc now passes when run
with the newly built glibc. Previously a tst-cleanup1 linked with
an older glibc would segfault when run with an affected glibc build.

Tested on x86_64 with no regressions.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-01-25 23:43:46 -08:00
Palmer Dabbelt fb58aac5fe
Add support for the RISC-V-specific ELF flags
The RISC-V port defines ELF flags that enforce compatibility between
various objects.  This adds the shared support necessary for these
flags.

2018-01-25  Palmer Dabbelt  <palmer@sifive.com>

        * elf/cache.c (print_entry): Add FLAG_RISCV_FLOAT_ABI_SOFT and
        FLAG_RISCV_FLOAT_ABI_DOUBLE.
        * elf/elf.h (EF_RISCV_RVC): New define.
        (EF_RISCV_FLOAT_ABI): Likewise.
        (EF_RISCV_FLOAT_ABI_SOFT): Likewise.
        (EF_RISCV_FLOAT_ABI_SINGLE): Likewise.
        (EF_RISCV_FLOAT_ABI_DOUBLE): Likewise.
        (EF_RISCV_FLOAT_ABI_QUAD): Likewise.
        * sysdeps/generic/ldconfig.h (FLAG_RISCV_FLOAT_ABI_SOFT): New
        define.
        (FLAG_RISCV_FLOAT_ABI_DOUBLE): Likewise.
2018-01-25 10:06:19 -08:00
Andreas Schwab 128c43a2d6 LIBC_SLIBDIR_RTLDDIR: substitute arguments in single quotes
The arguments of the LIBC_SLIBDIR_RTLDDIR macro are used both in unquoted
and single quoted context, so that neither shell nor makefile variable
references work.  Consistently put them in single quotes so that they can
refer to makefile variables.
2018-01-25 17:20:28 +01:00
Joseph Myers 69231fabdd Add localplt.data for ColdFire.
The sole failure for ColdFire in the compilation part of the glibc
testsuite is the localplt test.  This patch adds a localplt baseline
for ColdFire to eliminate that failure.  The difference from the
existing m68k baseline is that no PLT entry for _Unwind_Find_FDE is
expected, because ColdFire does not set
libc_cv_gcc_unwind_find_fde=yes.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/m68k/localplt.data: Move to ....
	* sysdeps/unix/sysv/linux/m68k/m680x0/localplt.data: ... here.
	* sysdeps/unix/sysv/linux/m68k/coldfire/localplt.data: New file.
2018-01-24 23:43:33 +00:00
Joseph Myers d4c7e1d0fd Add no-FPU ColdFire math_private.h.
As with some other soft-float configurations, no-FPU ColdFire needs
various fenv.h functions and glibc-internal macros overridden in
math_private.h to avoid references to undefined FE_* macros when
building glibc.  This patch adds a suitable math_private.h, based on
the MicroBlaze one (Nios II and Tile also have similar files).

There's a case for having such a file in sysdeps/ieee754/soft-fp so
this logic is applied more generally to configurations without
exceptions and rounding modes, even when the relevant macros are
defined in fenv.h - the only case where that might be inappropriate is
ARM soft-float (where the fenv.h functions might or might not work at
runtime, depending on whether the processor used at runtime supports
VFP).  There's also a case that soft-float configurations (on
processors with both hard-float and soft-float) should more
consistently avoid defining FE_* macros in bits/fenv.h when not
actually supported.  But both of those are separate potential
cleanups.

This allows the no-FPU ColdFire build to get further (another fix is
needed to allow the build to complete).

	* sysdeps/m68k/coldfire/nofpu/math_private.h: New file.  Based on
	MicroBlaze file.
2018-01-24 23:33:03 +00:00
Joseph Myers 0cfe5be58f Add jmp_buf-macros.h for no-FPU ColdFire.
Continuing the fixes for ColdFire glibc build with
build-many-glibcs.py, given a GCC patch for the libgcc build failure,
this patch adds jmp_buf-macros.h for no-FPU ColdFire.  This allows the
no-FPU build to progress further than without the patch (although
other fixes are still needed for the build to complete).

	* sysdeps/unix/sysv/linux/m68k/coldfire/jmp_buf-macros.h: Move to
	....
	* sysdeps/unix/sysv/linux/m68k/coldfire/fpu/jmp_buf-macros.h:
	... here.
	* sysdeps/unix/sysv/linux/m68k/coldfire/nofpu/jmp_buf-macros.h:
	New file.
2018-01-24 23:22:28 +00:00
Joseph Myers 91b2cffa9f Add jmp_buf-macros.h for ColdFire.
This patch adds a jmp_buf-macros.h for ColdFire.  In conjunction with
a GCC patch to fix the libgcc build failure for ColdFire
<https://gcc.gnu.org/ml/gcc-patches/2018-01/msg02064.html> this
suffices to restore the build (tested with build-many-glibcs.py).  A
further patch will be needed for soft-float ColdFire (while the
function-calling ABI is the same for hard-float and soft-float
ColdFire, it turns out the glibc ABI is not - so another ColdFire
variant will be needed in build-many-glibcs.py), but I'll deal with
that separately.

Tested with build-many-glibcs.py (m68k-linux-gnu and
m68k-linux-gnu-coldfire).  (There's a localplt test failure for
coldfire; that's the only failure in the compilation part of the
testsuite.)

	* sysdeps/unix/sysv/linux/m68k/jmp_buf-macros.h: Move to ....
	* sysdeps/unix/sysv/linux/m68k/m680x0/jmp_buf-macros.h: ... here.
	* sysdeps/unix/sysv/linux/m68k/coldfire/jmp_buf-macros.h: New
	file.
2018-01-24 22:26:24 +00:00
Szabolcs Nagy c739e191d0 aarch64: Revert the change of the __reserved member of mcontext_t
The uc_mcontext.__reserved member of ucontext_t is a user visible API,
that should not be changed, because this is the only way to access cpu
states of various extensions of linux asm/sigcontext.h, it does not
violate namespace rules either, so revert this part of the commit

commit 4fa9b3bfe6
Commit:     Joseph Myers <joseph@codesourcery.com>

    Fix mcontext_t sigcontext namespace (bug 21457).

(In principle the user can type cast &uc_mcontext to struct sigcontext*
to use the linux sigcontext fields, but that's not the existing practice
since mcontext_t used to be a typedef of struct sigcontext.)

	[BZ #22742]
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h (__glibc_reserved1):
	Rename to __reserved and add comment.
	* sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym (__glibc_reserved1):
	Rename to __reserved.
2018-01-24 11:53:30 +00:00
Tulio Magno Quites Machado Filho 4612268a0a powerpc: Fix syscalls during early process initialization [BZ #22685]
The tunables framework needs to execute syscall early in process
initialization, before the TCB is available for consumption.  This
behavior conflicts with powerpc{|64|64le}'s lock elision code, that
checks the TCB before trying to abort transactions immediately before
executing a syscall.

This patch adds a powerpc-specific implementation of __access_noerrno
that does not abort transactions before the executing syscall.

Tested on powerpc{|64|64le}.

	[BZ #22685]
	* sysdeps/powerpc/powerpc32/sysdep.h (ABORT_TRANSACTION_IMPL): Renamed
	from ABORT_TRANSACTION.
	(ABORT_TRANSACTION): Redirect to ABORT_TRANSACTION_IMPL.
	* sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION,
	ABORT_TRANSACTION_IMPL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/not-errno.h: New file.  Reuse
	Linux code, but remove the code that aborts transactions.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
2018-01-19 09:50:09 -02:00
Samuel Thibault 64f63cb458 generic if_ether.h: Fix build
* sysdeps/generic/netinet/if_ether.h: Include <stdint.h>.
2018-01-19 01:51:10 +01:00
Joseph Myers 1eeddc5854 Fix backtrace for hppa (bug 22719).
The only architecture in glibc that uses the generic debug/backtrace.c
is hppa.  The debug/tst-backtrace* tests fail for hppa, so in fact the
generic debug/backtrace.c is not functional anywhere.  Instead, the
x86_64 version is a reasonably generic version that uses
_Unwind_Backtrace from libgcc to backtrace using unwind info, and is
used by several architectures.  This patch adds hppa to the
architectures using it (leaving open the possibility of a subsequent
cleanup for 2.28 of moving the x86_64 version to debug/backtrace.c,
and removing all the frame.h files that are now unused).

Reported by Adhemerval in
<https://sourceware.org/ml/libc-alpha/2018-01/msg00564.html> that this
does fix the backtrace test failures for hppa.

	[BZ #22719]
	* sysdeps/hppa/backtrace.c: New file.
2018-01-17 13:31:47 +00:00
H.J. Lu 207a72e298 x86-64: Properly align La_x86_64_retval to VEC_SIZE [BZ #22715]
_dl_runtime_profile calls _dl_call_pltexit, passing a pointer to
La_x86_64_retval which is allocated on stack.  The lrv_vector0
field in La_x86_64_retval must be aligned to size of vector register.
When allocating stack space for La_x86_64_retval, we need to make sure
that the address of La_x86_64_retval + RV_VECTOR0_OFFSET is aligned to
VEC_SIZE.  This patch checks the alignment of the lrv_vector0 field
and pads the stack space if needed.

Tested with x32 and x86-64 on SSE4, AVX and AVX512 machines.  It fixed

FAIL: elf/tst-audit10
FAIL: elf/tst-audit4
FAIL: elf/tst-audit5
FAIL: elf/tst-audit6
FAIL: elf/tst-audit7

on x32 AVX512 machine.

	[BZ #22715]
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_profile): Properly
	align La_x86_64_retval to VEC_SIZE.
2018-01-17 04:32:04 -08:00
Joseph Myers 4942c4ea48 Use LIBGCC_S_SO in x86_64 backtrace.
The x86_64 backtrace implementation is used as a generic
implementation (unwinding via unwind info and _Unwind_Backtrace) by
various other architectures.  This patch makes it more generic by
making it use LIBGCC_S_SO from gnu/lib-names.h instead of hardcoding
the libgcc_s.so.1 name, so that it can also be used on hppa which uses
libgcc_s.so.4.

Tested for x86_64.

	* sysdeps/x86_64/backtrace.c: Include <gnu/lib-names.h>.
	(init): Use LIBGCC_S_SO not hardcoded "libgcc_s.so.1".
2018-01-16 20:53:03 +00:00
Szabolcs Nagy 953c49cc3b aarch64: Update bits/hwcap.h for Linux 4.15.
Define new HWCAP bits and add their name to dl-procinfo.c following
the linux definitions. Synchronizing with v4.15-rc8 version of linux,
these are not expected to change before the 4.15 release.

	* sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h (HWCAP_SHA3): Define.
	(HWCAP_SM3, HWCAP_SM4, HWCAP_ASIMDDP, HWCAP_SHA512, HWCAP_SVE): Define.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c
	(_dl_aarch64_cap_flags): Update.
	(_DL_HWCAP_COUNT): Update.
2018-01-16 18:51:13 +00:00
Szabolcs Nagy afce1991f6 aarch64: make HWCAP updates less error prone
Remove unused _DL_HWCAP_LAST definition and move _DL_HWCAP_COUNT
where it is needed (dl-procinfo.h always includes dl-procinfo.c).

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h
	(_DL_HWCAP_LAST): Remove.
	(_DL_HWCAP_COUNT): Move to ...
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c
	(_DL_HWCAP_COUNT): ... here.
2018-01-16 18:50:34 +00:00
Tulio Magno Quites Machado Filho af1e6be4ba powerpc: Fix llround spurious inexact on 32-bit POWER4 [BZ #22697]
This issue is similar to BZ #19235, where spurious exceptions are
created from adding 0.5 then converting to an integer.
The solution is based on Joseph's fix for BZ #19235.

	[BZ #22697]
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S (__llround):
	Do not add 0.5 to integer or out-of-range arguments.
2018-01-12 20:39:42 -02:00
Szabolcs Nagy 3d1d79283e aarch64: fix static pie enabled libc when main is in a shared library
In the static pie enabled libc, crt1.o uses the same position independent
code as rcrt1.o and crt1.o is used instead of Scrt1.o when -no-pie
executables are linked.  When main is not defined in the executable, but
in a shared library crt1.o is currently broken, it assumes main is local.
(glibc has a test for this but i missed it in my previous testing.)

To make both rcrt1.o and crt1.o happy with the same code, a wrapper is
introduced around main: with this crt1.o works with extern main symbol
while rcrt1.o does not depend on GOT relocations. (The change only
affects static pie enabled libc. Further simplification of start.S is
possible in the future by using the same approach for Scrt1.o too.)

	* aarch64/start.S (_start): Use __wrap_main.
	(__wrap_main): New local symbol.
2018-01-12 18:10:03 +00:00
Dmitry V. Levin 52a713fdd0 linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]
Currently getcwd(3) can succeed without returning an absolute path
because the underlying getcwd syscall, starting with linux commit
v2.6.36-rc1~96^2~2, may succeed without returning an absolute path.

This is a conformance issue because "The getcwd() function shall
place an absolute pathname of the current working directory
in the array pointed to by buf, and return buf".

This is also a security issue because a non-absolute path returned
by getcwd(3) causes a buffer underflow in realpath(3).

Fix this by checking the path returned by getcwd syscall and falling
back to generic_getcwd if the path is not absolute, effectively making
getcwd(3) fail with ENOENT.  The error code is chosen for consistency
with the case when the current directory is unlinked.

[BZ #22679]
CVE-2018-1000001
* sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Fall back to
generic_getcwd if the path returned by getcwd syscall is not absolute.
* io/tst-getcwd-abspath.c: New test.
* io/Makefile (tests): Add tst-getcwd-abspath.
2018-01-12 14:49:49 +00:00
Joseph Myers c8924f1ff2 Fix s390 linknamespace fallout of bug 22702 patch.
My fix for bug 22702 introduced linknamespace test failures on
s390x-linux-gnu and s390-linux-gnu because it made remainder call
__feholdexcept, and the s390 __feholdexcept calls fegetenv, and
remainder is in Unix98 and XPG4.2 but fegetenv isn't.  This patch
makes __feholdexcept call __fegetenv instead to avoid that namespace
issue.

Tested (compilation) with build-many-glibcs.py for s390x-linux-gnu,
where it resolves the test failures.

	* sysdeps/s390/fpu/feholdexcpt.c (__feholdexcept): Call __fegetenv
	instead of fegetenv.
2018-01-12 00:12:57 +00:00
Joseph Myers da09e6fa2f Make default libc_feholdsetround_noex_ctx use __feholdexcept (bug 22702).
For soft-float powerpc, the math/test-nearbyint-except-2 test fails
because nearbyintl traps when traps on "inexact" are enabled on entry
(and an "inexact" exception is generated internally, though cleared
for the final return).

The problem is the default implementation of
libc_feholdsetround_noex_ctx, which does not disable exception traps.
There is some ambiguity about whether the *noex* interfaces are
required to do so or only permitted to do so.  But given that we
support fe* interfaces to enable and disable traps (on architectures
with that functionality), functions that must not raise an exception
(must not leave the flag set on exit if not set on entry) should also
not trap on it when traps on that exception are enabled.  So it is
appropriate to define these interfaces to have the feholdexcept effect
of disabling exception traps; this patch updates the default
implementation and comments accordingly.

At least some architecture versions already disable traps; there are
few uses of the *noex* interfaces at all, and while it's possible
there are bugs on any architecture versions failing to disable traps
that appear in the exp2 and remainder implementations, there are
currently no tests, other than this one for nearbyintl (where only the
ldbl-128ibm implementation uses SET_RESTORE_ROUND_NOEX), that would
fail as a result of such a bug.  (Hard-float powerpc does disable
traps here, hence the nearbyintl failure not appearing there.)

Tested for powerpc (soft-float).  This brings that configuration to
clean math/ test results, provided you build with GCC 8 to get the fix
for GCC bug 64811.

	[BZ #22702]
	* sysdeps/generic/math_private.h (libc_feresetround_noex): Update
	comment to say exceptions are discarded.
	(libc_feholdsetround_noex_ctx): Use __feholdexcept instead of
	__fegetenv.
	(SET_RESTORE_ROUND_NOEX): Update comment to say non-stop mode must
	be enabled.
2018-01-11 18:18:46 +00:00
Florian Weimer 08c6e95234 csu: Update __libgcc_s_init comment
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-01-11 13:13:28 +01:00
Joseph Myers b303185df9 Fix ldbl-128ibm log1pl (-qNaN) spurious "invalid" exception (bug 22693).
The ldbl-128ibm implementation of log1pl does ordered comparisons on a
negative qNaN argument, so resulting in spurious "invalid" exceptions
(for soft-float powerpc; hard-float only avoids this because of GCC
bug 58684 meaning ordered comparison instructions never get
generated).  This patch fixes this by arranging for the test for NaN
or infinity arguments to handle negative arguments as well.

Tested for powerpc (soft float).

	[BZ #22693]
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Handle
	negative arguments in test for NaN or infinity argument.
2018-01-10 17:59:01 +00:00
Florian Weimer f993b87540 nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
Disabling lazy binding reduces stack usage during unwinding.

Note that RTLD_NOW only makes a difference if libgcc.so has not
already been loaded, so this is only a partial fix.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-01-10 13:18:04 +01:00
Samuel Thibault 09085ede12 hurd: Implement faccessat without AT_EACCESS flag
* hurd/hurd/fd.h: Include <fcntl.h>
(__hurd_at_flags): New function.
* hurd/lookup-at.c (__file_name_lookup_at): Replace flag computation
with call to __hurd_at_flags.
* include/unistd.h (__faccessat, __faccessat_noerrno): Add declaration.
* sysdeps/mach/hurd/access.c (access_common): Move implementation to
__faccessat
(hurd_fail_seterrno, hurd_fail_noerrno): Move to sysdeps/mach/hurd/faccessat.c.
(__access_noerrno): Use __faccessat_common instead of access_common.
(__access): Likewise.
* sysdeps/mach/hurd/euidaccess.c (__euidaccess): Replace implementation
with a call to __faccessat.
* sysdeps/mach/hurd/faccessat.c (faccessat): Rename into...
(__faccessat_common): ... this. Move implementation of __access into it when
AT_FLAGS does not contain AT_EACCESS. Make it call __hurd_at_flags, add
reauthenticate_cwdir_at helper to implement AT mechanism.
(__faccessat_noerrno): New function, just calls __faccessat_common.
(__faccessat): New function, just calls __faccessat_common.
(faccessat): Define weak alias.
2018-01-10 02:03:28 +01:00
Joseph Myers 87faac5516 Fix powerpc-nofpu fmaxmagl, fminmagl spurious "invalid" exception (bug 22691).
For soft-float powerpc, fmaxmagl and fminmagl generate spurious
"invalid" exceptions for quiet NaN arguments.  This is another case of
the problems with fabsl inline expansion via comparisons, and so is
fixed by building those functions with -fno-builtin-fabsl.

Tested for powerpc (soft-float).

	[BZ #22691]
	* sysdeps/powerpc/nofpu/Makefile [$(subdir) = math]
	(CFLAGS-s_fmaxmagl.c): New variable.
	[$(subdir) = math] (CFLAGS-s_fminmagl.c: Likewise.
2018-01-10 00:38:12 +00:00
Joseph Myers 1272748886 Fix ldbl-128ibm lrintl, lroundl missing "invalid" exceptions (bug 22690).
The ldbl-128ibm implementations of lrintl and lroundl are missing
"invalid" exceptions for certain overflow cases when compiled with GCC
8.  The cause of this is after-the-fact integer overflow checks that
fail when the compiler optimizes on the basis of integer overflow
being undefined; GCC 8 must be able to detect new cases of
undefinedness here.

Failure: lrint (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_downward (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_towardzero (-0x80000001p0): Exception "Invalid operation" not set
Failure: lrint_upward (-0x80000001p0): Exception "Invalid operation" not set

Failure: lround (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_downward (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_towardzero (-0x80000001p0): Exception "Invalid operation" not set
Failure: lround_upward (-0x80000001p0): Exception "Invalid operation" not set

(Tested that these failures occur before the patch for powerpc
soft-float, but the issue applies in principle for hard-float as well,
whether or not the particular optimizations in fact occur there at
present.)

This patch fixes the bug by ensuring the additions / subtractions in
question cast arguments to unsigned long int, or use 1UL as a constant
argument, so that the arithmetic occurs in an unsigned type with the
result then converted back to a signed type.

Tested for powerpc (soft-float).

	[BZ #22690]
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c (__lrintl): Use unsigned
	long int for arguments of possibly overflowing addition or
	subtraction.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c (__lroundl): Likewise.
2018-01-10 00:02:35 +00:00
Joseph Myers b2584ac2a4 Fix powerpc-nofpu remainderl wrong sign of zero result (bug 22688).
For soft-float powerpc, the remainderl function produces zero results
with the wrong sign for various inputs.  This is another instance of
the problem with incorrect built-in fabsl expansion, so is fixed by
this patch using -fno-builtin-fabsl for this function.

Tested for powerpc (soft-float).

	[BZ #22688]
	* sysdeps/powerpc/nofpu/Makefile [$(subdir) = math]
	(CFLAGS-e_remainderl.c): New variable.
2018-01-09 23:14:45 +00:00
Joseph Myers e134ca1753 Fix powerpc-nofpu complex long double functions spurious "invalid" exception (bug 22687).
For soft-float powerpc, various _Complex long double functions
generate spurious "invalid" exceptions, even with a compiler with GCC
bug 64811 fixed.

The problem is GCC's built-in fabsl expansion.  Various files are
already built with -fno-builtin-fabsl because in this case (IBM long
double, for soft-float or e500v1) a fallback fabsl expansion based on
comparisons is used, which can produce the wrong sign of a zero
result.  Those comparisons can also produce spurious exceptions for
NaN arguments.  Furthermore, __builtin_fpclassify implemently uses
__builtin_fabsl, and is unaffected by -fno-builtin-fabsl, and the
fpclassify macro uses __builtin_fpclassify in the absence of
-fsignaling-nans.  Thus, this patch arranges for the problem files
using fpclassify to be built with -fsignaling-nans in this case, to
avoid spurious exceptions from fpclassify.

Tested for powerpc (soft-float).

	[BZ #22687]
	* sysdeps/powerpc/nofpu/Makefile (CFLAGS-s_cacosl.c): New
	variable.
	(CFLAGS-s_cacoshl.c): Likewise.
	(CFLAGS-s_casinhl.c): Likewise.
	(CFLAGS-s_catanl.c): Likewise.
	(CFLAGS-s_catanhl.c): Likewise.
	(CFLAGS-s_cexpl.c): Likewise.
	(CFLAGS-s_ccoshl.c): Add -fsignaling-nans.
	(CFLAGS-s_csinhl.c): Likewise.
	(CFLAGS-s_clogl.c): Likewise.
	(CFLAGS-s_clog10l.c): Likewise.
	(CFLAGS-s_csinl.c): Likewise.
	(CFLAGS-s_csqrtl.c): Likewise.
2018-01-09 22:34:35 +00:00
Samuel Thibault 311ba8dc44 hurd: Use the new file_exec_paths RPC
From: Emilio Pozuelo Monfort <pochu27@gmail.com>
From: Svante Signell <svante.signell@gmail.com>

Pass the file paths of executable to the exec server, both relative and
absolute, which exec needs to properly execute and avertise #!-scripts.
Previously, the exec server tried to guess the name from argv[0] but argv[0]
only contains the executable name by convention.

	* hurd/hurdexec.c (_hurd_exec): Deprecate function.
	(_hurd_exec_paths): New function.
	* hurd/hurd.h (_hurd_exec): Deprecate function.
	(_hurd_exec_paths): Declare function.
	* hurd/Versions: Export _hurd_exec_paths.
	* sysdeps/mach/hurd/execve.c: Include <stdlib.h> and <stdio.h>
	(__execve): Use __getcwd to build absolute path, and use
	_hurd_exec_paths instead of _hurd_exec.
	* sysdeps/mach/hurd/spawni.c: Likewise.
	* sysdeps/mach/hurd/fexecve.c: Use _hurd_exec_paths instead of
	_hurd_exec.
2018-01-09 01:37:34 +01:00
Dmitry V. Levin d7ff3f11b6 tst-ttyname: skip the test when /dev/ptmx is not available
* sysdeps/unix/sysv/linux/tst-ttyname.c (do_in_chroot_1): Skip the
test instead of failing in case of ENOENT returned by posix_openpt.
2018-01-08 22:02:53 +00:00
H.J. Lu c70e4e9c9e x86-64: Add sincosf with vector FMA
Since the x86-64 assembly version of sincosf is higly optimized with
vector instructions, there isn't much room for improvement.  However
s_sincosf.c written in C with vector math and intrinsics can be
optimized by GCC with FMA.

On Skylake, bench-sincosf reports performance improvement:

           Assembly       FMA         improvement
max        104.042       101.008         3%
min        9.426         8.586           10%
mean       20.6209       18.2238         13%

	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Add s_sincosf-sse2 and s_sincosf-fma.
	(CFLAGS-s_sincosf-fma.c): New.
	* sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c: New file.
	* sysdeps/x86_64/fpu/multiarch/s_sincosf-sse2.S: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_sincosf.c: Likewise.
	* sysdeps/x86_64/fpu/s_sincosf.S: Don't add alias if
	__sincosf is defined.
2018-01-08 08:04:40 -08:00
Aurelien Jarno c2e014cc33 getrlimit64: fix for 32-bit configurations with default version >= 2.2
Commit 24731685 ("prlimit: Translate old_rlimit from RLIM64_INFINITY to
RLIM_INFINITY") broken the getrlimit64 for 32-bit configurations which
do no need the 2GiB limited compat getrlimit (default version >= 2.2).

This patch fixes that by restoring the weak alias in that case.

Changelog:
	* sysdeps/unix/sysv/linux/getrlimit64 (getrlimit64)
	[!__RLIM_T_MATCHES_RLIM64_T]
	[!SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_2)]: Define as weak alias of
	__getrlimit64. Add libc_hidden_weak.
2018-01-07 20:33:32 +01:00
Samuel Thibault 200fc24b9d hurd: Fix pwritev*
This follows c45d78aac ('posix: Fix generic p{read,write}v buffer allocation
(BZ#22457)'), which made pwritev to use __mmap instead of __posix_memalign,
but didn't pass PROT_READ to it, while the pwrite() call does need to
read the data we have just copied over.

	* sysdeps/posix/pwritev_common.c: Add PROT_READ to __mmap prot.
2018-01-07 13:31:36 +01:00
Palmer Dabbelt 150bbac18b Add linux-4.15 VDSO hash for RISC-V
The RISC-V Linux port defines VDSO symbols

2018-01-06  Palmer Dabbelt  <palmer@sifive.com>

       * sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME_LINUX_4_15): New
       define.
       (VDSO_HASH_LINUX_4_15): Likewise.
2018-01-06 23:35:56 -08:00
Samuel Thibault f417d92c17 hurd: Fix glob64 compatibility symbols
This follows ccf970c7a ('posix: Add compat glob symbol to not follow
dangling symbols') by adding to gnu/ the same compatibility as for Linux.

	* sysdeps/gnu/glob64.c (__glob): Define macro instead of glob macro.
	(__glob64): Define GLIBC_2_27 versioned symbol instead of glob64.
	* sysdeps/gnu/glob-lstat-compat.c: New file.
	* sysdeps/gnu/glob64-lstat-compat.c: New file.
2018-01-06 22:28:36 +01:00
Samuel Thibault 107a35a575 i386: Regenerate libm-test-ulps for for gcc 7 on i686
* sysdeps/i386/fpu/libm-test-ulps: Regenerated for GCC 7 with
	"-O2 -march=i686".
2018-01-06 22:11:40 +01:00
Samuel Thibault 4a5ce6e908 hurd: Fix build without NO_HIDDEN
* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_dynamic) [NO_RTLD_HIDDEN]: Call
JUMPTARGET (___tls_get_addr) instead of HIDDEN_JUMPTARGET (___tls_get_addr).
* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_dynamic): Likewise.
2018-01-06 18:20:18 +01:00
Samuel Thibault fad7d57ef9 hurd: Add jmp_buf-macros.h
* sysdeps/mach/hurd/i386/jmp_buf-macros.h: New file.
2018-01-06 02:32:55 +01:00
Tulio Magno Quites Machado Filho 3a32b7168d powerpc: Fix error message during relocation overflow
The function _itoa_word() writes characters from the higher address to
the lower address, requiring the destination string to reserve that size
before calling it.

	* sysdeps/powerpc/powerpc64/dl-machine.c (_dl_reloc_overflow):
	Reserve 16 chars to reloc_addr before calling _itoa_word.

Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-01-05 18:34:09 -02:00
Aurelien Jarno 19be56d8ce Add test for getrlimit/setrlimit/prlimit with infinity value
Add a test to check that the getrlimit, setrlimit and prlimit functions
and their 64-bit equivalent behave correctly with RLIM_INFINITY and
RLIM64_INFINITY. For that it assumes that the prlimit64 function calls
the syscall directly without translating the value and that the kernel
uses the -1 value to represent infinity.

It first finds a resource with the hard limit set to infinity so the
soft limit can be manipulated easily and check for the consistency
between the value set or get by the prlimit64 and the other functions.

It is Linux specific add it uses the prlimit and prlimit64 functions.

Changelog:
	* sysdeps/unix/sysv/linux/tst-rlimit-infinity.c: New file.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add tst-rlimit-infinity.
2018-01-05 20:34:10 +01:00
Aurelien Jarno 24731685c8 prlimit: Translate old_rlimit from RLIM64_INFINITY to RLIM_INFINITY [BZ #22678]
prlimit called without a new value fails on 32-bit machines if any of
the soft or hard limits are infinity. This is because prlimit does not
translate old_rlimit from RLIM64_INFINITY to RLIM_INFINITY, but checks
that the value returned by the prlimit64 syscall fits into a 32-bit
value, like it is done for example in getrlimit. Note that on the
other hand new_rlimit is correctly translated from RLIM_INFINITY to
RLIM64_INFINITY before calling the syscall.

This patch fixes that.

Changelog:
	[BZ #22678]
	* sysdeps/unix/sysv/linux/prlimit.c (prlimit): Translate
	old_rlimit from RLIM64_INFINITY to RLIM_INFINITY.
2018-01-05 20:34:10 +01:00
Aurelien Jarno 8e900969db Alpha: Fix the RLIM_INFINITY and RLIM64_INFINITY constants
Fix the RLIM_INFINITY and RLIM64_INFINITY constants on alpha to match
the kernel one and all other architectures. Change the getrlimit,
getrlimit64, setrlimit, setrlimit64 into old compat symbols, and provide
the Linux generic functions as GLIBC_2_27 version.

Changelog:
	* sysdeps/unix/sysv/linux/getrlimit64.c [USE_VERSIONED_RLIMIT]: Do not
	define getrlimit and getrlimit64 as weak aliases of __getrlimit64.
	Define __GI_getrlimit64 as weak alias of __getrlimit64.
	[__RLIM_T_MATCHES_RLIM64_T]: Do not redefine SHLIB_COMPAT, use #elif
	instead.
	* sysdeps/unix/sysv/linux/setrlimit64.c [USE_VERSIONED_RLIMIT]: Do not
	define setrlimit and setrlimit64 as weak aliases of __setrlimit64.
	* sysdeps/unix/sysv/linux/alpha/bits/resource.h (RLIM_INFINITY,
	RLIM64_INFINITY): Fix values to match the kernel ones.
	* sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Define
	USE_VERSIONED_RLIMIT.  Rename __getrlimit64 into __old_getrlimit64 and
	provide it as getrlimit@@GLIBC_2_0 and getrlimit64@@GLIBC_2_1.  Add a
	__getrlimit64 function and provide it as getrlimit@@GLIBC_2_27 and
	getrlimit64@@GLIBC_2_27.
	* sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto with setrlimit
	and setrlimit64.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.27): Add
	getrlimit, setrlimit, getrlimit64 and setrlimit64.
	* sysdeps/unix/sysv/linux/alpha/Versions (libc): Add getrlimit,
	setrlimit, getrlimit64 and setrlimit64.
2018-01-05 20:34:10 +01:00
Aurelien Jarno 0d0bc784ca Alpha: Add wrappers to get/setrlimit64 to fix RLIM64_INFINITY constant [BZ #22648]
RLIM64_INFINITY was supposed to be a glibc convention rather than
anything seen by the kernel, but it ended being passed to the kernel
through the prlimit64 syscall.

* On the kernel side, the value is defined for the prlimit64 syscall for
  all architectures in include/uapi/linux/resource.h:

  #define RLIM64_INFINITY           (~0ULL)

* On the kernel side, the value is defined for getrlimit and setrlimit
  in arch/alpha/include/uapi/asm/resource.h

  #define RLIM_INFINITY            0x7ffffffffffffffful

* On the GNU libc side, the value is defined in
  sysdeps/unix/sysv/linux/alpha/bits/resource.h:

  # define RLIM64_INFINITY 0x7fffffffffffffffLL

This was not an issue until the getrlimit and setrlimit glibc functions
have been changed in commit 045c13d185 ("Consolidate Linux setrlimit and
getrlimit implementation") to use the prlimit64 syscall instead of the
getrlimit and setrlimit ones.

This patch fixes that by adding a wrapper to fix the value passed to or
received from the kernel, before or after calling the prlimit64 syscall.

Changelog:
	[BZ #22648]
	* sysdeps/unix/sysv/linux/alpha/getrlimit64.c: New file.
	* sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Ditto.
2018-01-05 20:34:10 +01:00
Adhemerval Zanella b0a4eca2fc alpha: Remove s_trunc{f} implementation (BZ#22666)
As discussed in libc-alpha [1], alpha trunc{f} implementation uses
addt/suc and subt/suc and although the Alpha Architecture
Handbook version 3 states that that ADDx SUBx OUTPUT Exceptions
(B.3 Mapping to IEEE Standard) should not generate Inexact if INE
bit is set, the Alpha 21264 [2] chip manual (A.8 IEEE Floating-Point
Conformance) states that ADDx SUBx OUTPUT does generate inexact
exception for inexact result regardless.

As Joseph noted [3] to correctly fix it on alpha we need to either
avoid the instruction or avoid any inexact bit from it being set
on return from the function (while preserving the inexact bit that
might be set on the entry to the function).  The later will result
mf_fpcr followed by a mt_fpcr to get and set the fpcr which will
defeat the optimization itself.

So the patch just remove the alpha optimized and rely on generic
implementation.  It fixes the math/test-*-{trunc} on alpha.

        [BZ #15479]
        [BZ #22666]
        * sysdeps/alpha/fpu/s_trunc.c: Remove file.
        * sysdeps/alpha/fpu/s_truncf.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2018-01/msg00114.html
[2] https://www.star.bnl.gov/public/daq/HARDWARE/21264_data_sheet.pdf
[3] https://sourceware.org/ml/libc-alpha/2018-01/msg00086.html

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-01-04 17:49:17 -02:00
Adhemerval Zanella 4854ddd874 alpha: Remove s_ceil{f} and s_floor{f} implementation (BZ#22665)
As discussed in libc-alpha [1], alpha ceil{f} and floor{f}
implementation uses cvttq/svm and although the Alpha Architecture
Handbook version 3 states that that CVTfi OUTPUT Exceptions
(B.3 Mapping to IEEE Standard) should not generate Inexact if INE
bit is set on fpcr, the Alpha 21264 [1] chip manual (A.8 IEEE
Floating-Point Conformance) states that CVTfi and CVTif OUTPUT
does generate inexact exception for inexact result regardless.

As Joseph noted [2] to correctly fix it on alpha we need to either
avoid the instruction or avoid any inexact bit from it being set
on return from the function (while preserving the inexact bit that
might be set on the entry to the function).  The later will result
mf_fpcr followed by a mt_fpcr to get and set the fpcr which will
defeat the optimization itself.

So the patch just remove the alpha optimized and rely on generic
implementation.  It fixes the math/test-*-{ceil,floor} on alpha.

	[BZ #15479]
	[BZ #22665]
	* sysdeps/alpha/fpu/s_ceil.c: Remove file.
	* sysdeps/alpha/fpu/s_ceilf.c: Likewise.
	* sysdeps/alpha/fpu/s_floor.c: Likewise.
	* sysdeps/alpha/fpu/s_floorf.c: Likewise.

[1] https://www.star.bnl.gov/public/daq/HARDWARE/21264_data_sheet.pdf
[2] https://sourceware.org/ml/libc-alpha/2018-01/msg00086.html

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-01-04 17:49:17 -02:00
Florian Weimer 8a5df95ffa i386: In makecontext, align the stack before calling exit [BZ #22667]
Before this change, if glibc was compiled with SSE instructions and a
sufficiently recent GCC, an unaligned stack access in
__run_exit_handlers would cause stdlib/tst-makecontext to crash.
2018-01-04 18:47:35 +01:00
Joseph Myers 7eff095459 Update MIPS libm-test-ulps.
* sysdeps/mips/mips32/libm-test-ulps: Update.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
2018-01-02 21:55:15 +00:00
Aurelien Jarno 3e4226ffdf Simplify getrlimit64.c
Changelog:
	* sysdeps/unix/sysv/linux/alpha/getrlimit64.c (__old_getrlimit64):
	Drop __RLIM_T_MATCHES_RLIM64_T conditional as __old_getrlimit64 is
	never defined in that case.
2018-01-02 21:05:29 +01:00
Aurelien Jarno d35989be87 Fix typos in getrlimit64.c and setrlimit64.c
Changelog:
	* sysdeps/unix/sysv/linux/alpha/getrlimit64.c: Fix a typo in the
	comment.
	* sysdeps/unix/sysv/linux/alpha/setrlimit64.c: Fix a typo in the
	comment.
	(settrlimit): Rename into setrlimit.
	(__sttrlimit): Rename into __setrlimit.
2018-01-02 21:05:29 +01:00
Joseph Myers 28fd6a44cb Update powerpc-nofpu libm-test-ulps.
* sysdeps/powerpc/nofpu/libm-test-ulps: Update.
2018-01-02 18:38:45 +00:00
Joseph Myers a4933a1562 Update ARM libm-test-ulps.
* sysdeps/arm/libm-test-ulps: Update.
2018-01-02 18:37:06 +00:00
Aurelien Jarno 6a9dd7a7c5 Remove alpha specific fmax, fmin to fix sNaN handling [BZ #22660]
Various fmax and fmin function implementations mishandle sNaN
arguments:

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

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

One way to fix that is to detect the sNaN and add a special case. That
said there is no FPU instruction to do that, so it requires transfering
the FP value to an integer register and testing bits. This becomes quite
complicated so it's probably better to just use the generic versions of
these functions which just do that through issignaling.

Changelog:
	[BZ #22660]
	* sysdeps/alpha/fpu/s_fmax.S: Remove file.
	* sysdeps/alpha/fpu/s_fmaxf.S: Likewise.
	* sysdeps/alpha/fpu/s_fmin.S: Likewise.
	* sysdeps/alpha/fpu/s_fminf.S: Likewise.
2018-01-02 09:56:02 +01:00
Dmitry V. Levin b05cb613e7 linux/arm: sync sys/ptrace.h with Linux 4.15 [BZ #22433]
Clone generic linux/sys/ptrace.h, remove x86-specific PTRACE_GETFPXREGS
and PTRACE_SETFPXREGS constants, add the following arm-specific
__ptrace_request constants: PTRACE_GETWMMXREGS, PTRACE_SETWMMXREGS,
PTRACE_GET_THREAD_AREA, PTRACE_SET_SYSCALL, PTRACE_GETCRUNCHREGS,
PTRACE_SETCRUNCHREGS, PTRACE_GETVFPREGS, PTRACE_SETVFPREGS,
PTRACE_GETHBPREGS, PTRACE_SETHBPREGS, and PTRACE_GETFDPIC.

Tested with strace.

* sysdeps/unix/sysv/linux/arm/sys/ptrace.h: New file.
2018-01-01 20:37:32 +00:00
Joseph Myers 09533208fe Update copyright dates not handled by scripts/update-copyrights.
I've updated copyright dates in glibc for 2018.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

Please remember to include 2018 in the dates for any new files added
in future (which means updating any existing uncommitted patches you
have that add new files to use the new copyright dates in them).

	* NEWS: Update copyright dates.
	* catgets/gencat.c (print_version): Likewise.
	* csu/version.c (banner): Likewise.
	* debug/catchsegv.sh: Likewise.
	* debug/pcprofiledump.c (print_version): Likewise.
	* debug/xtrace.sh (do_version): Likewise.
	* elf/ldconfig.c (print_version): Likewise.
	* elf/ldd.bash.in: Likewise.
	* elf/pldd.c (print_version): Likewise.
	* elf/sotruss.sh: Likewise.
	* elf/sprof.c (print_version): Likewise.
	* iconv/iconv_prog.c (print_version): Likewise.
	* iconv/iconvconfig.c (print_version): Likewise.
	* locale/programs/locale.c (print_version): Likewise.
	* locale/programs/localedef.c (print_version): Likewise.
	* login/programs/pt_chown.c (print_version): Likewise.
	* malloc/memusage.sh (do_version): Likewise.
	* malloc/memusagestat.c (print_version): Likewise.
	* malloc/mtrace.pl: Likewise.
	* manual/libc.texinfo: Likewise.
	* nptl/version.c (banner): Likewise.
	* nscd/nscd.c (print_version): Likewise.
	* nss/getent.c (print_version): Likewise.
	* nss/makedb.c (print_version): Likewise.
	* posix/getconf.c (main): Likewise.
	* scripts/test-installation.pl: Likewise.
	* sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
2018-01-01 00:41:16 +00:00
Joseph Myers 688903eb3e Update copyright dates with scripts/update-copyrights.
* All files with FSF copyright notices: Update copyright dates
	using scripts/update-copyrights.
	* locale/programs/charmap-kw.h: Regenerated.
	* locale/programs/locfile-kw.h: Likewise.
2018-01-01 00:32:25 +00:00
Dmitry V. Levin c48831d0ee linux/x86: sync sys/ptrace.h with Linux 4.14 [BZ #22433]
Clone generic linux/sys/ptrace.h, add the following x86-specific
__ptrace_request constants: PTRACE_GET_THREAD_AREA,
PTRACE_SET_THREAD_AREA, PTRACE_ARCH_PRCTL, PTRACE_SYSEMU,
PTRACE_SYSEMU_SINGLESTEP, and PTRACE_SINGLEBLOCK.

[BZ #22433]
* sysdeps/unix/sysv/linux/x86/sys/ptrace.h: New file.
2017-12-29 16:10:39 +00:00
Dmitry V. Levin ac583f5074 linux: update sys/ptrace.h comments
* sysdeps/unix/sysv/linux/sys/ptrace.h (__ptrace_request): Add comments
about PTRACE_PEEKSIGINFO, PTRACE_GETSIGMASK, PTRACE_SETSIGMASK, and
PTRACE_SECCOMP_GET_FILTER.  Update comments about PTRACE_SINGLESTEP
and PTRACE_SYSCALL.
* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
2017-12-29 16:10:39 +00:00
Dmitry V. Levin 7e21972bde linux: move a shared part of sys/ptrace.h to bits/ptrace-shared.h
Move a shared part of sys/ptrace.h which is the same on all
architectures to a separate file.

* sysdeps/unix/sysv/linux/sys/ptrace.h: Include <bits/ptrace-shared.h>.
(__ptrace_setoptions, __ptrace_eventcodes, __ptrace_peeksiginfo_args,
__ptrace_peeksiginfo_flags, ptrace): Move to ...
* sysdeps/unix/sysv/linux/bits/ptrace-shared.h: ... new file.
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/ptrace-shared.h.
* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h: Include
<bits/ptrace-shared.h>.
(__ptrace_setoptions, __ptrace_eventcodes, __ptrace_peeksiginfo_args,
__ptrace_peeksiginfo_flags, ptrace): Remove.
* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
2017-12-29 16:10:39 +00:00
Dmitry V. Levin 2bd86632b7 elf: remove redundant is_path argument
is_path argument is no longer used and could be safely removed.

* elf/dl-dst.h (DL_DST_COUNT): Remove is_path argument, all callers
updated.
* elf/dl-load.c (is_dst, _dl_dst_count, _dl_dst_substitute,
expand_dynamic_string_token): Likewise.
* sysdeps/generic/ldsodefs.h (_dl_dst_count, _dl_dst_substitute): Remove
is_path argument.
2017-12-27 22:12:51 +00:00
Zack Weinberg 48a8f83281 Deprecate external use of libio.h and _G_config.h.
libio.h was originally the header for a set of supported GNU
extensions, but they have not been maintained as such in many years,
they are now standing in the way of improvements to stdio, and we
don't think there are any remaining external users.  _G_config.h was
never intended for public use, but predates the bits convention.
Move both of these headers into the bits directory and provide stubs
at top level which issue deprecation warnings.

The contents of (bits/)libio.h and (bits/)_G_config.h are still
exposed to external software via stdio.h; changing that requires more
complex surgery than I have time to attempt right now.

	* libio/libio.h, libio/_G_config.h: New stub headers which issue a
	deprecation warning and then include <bits/libio.h>, <bits/_G_config.h>
	respectively.
	* libio/libio.h: Rename the original version of this file to
	libio/bits/libio.h.  Error out if not included by stdio.h or the
	stub libio.h.
	* include/libio.h: Move to include/bits.  Forward to libio/bits/libio.h.
	* sysdeps/generic/_G_config.h: Move to top-level bits/.  Error out
	if not included by bits/libio.h or the stub _G_config.h.
	* sysdeps/unix/sysv/linux/_G_config.h: Move to
	sysdeps/unix/sysv/linux/bits.  Error out if not included by
	bits/libio.h or the stub _G_config.h.
	* libio/stdio.h: Include bits/libio.h, not libio.h.
	* libio/Makefile: Install bits/libio.h and bits/_G_config.h as
	well as libio.h and _G_config.h.

	* csu/init.c, libio/fmemopen.c, libio/iolibio.h, libio/oldfmemopen.c
	* libio/strfile.h, stdio-common/vfscanf.c
	* sysdeps/pthread/flockfile.c, sysdeps/pthread/funlockfile.c
	Include stdio.h, not _G_config.h nor libio.h.
	* libio/iofgetpos.c: Also rename fgetpos64 out of the way.
	* libio/iofsetpos.c: Also rename fsetpos64 out of the way.

	* scripts/check-installed-headers.sh: Skip libio.h and _G_config.h.
2017-12-24 09:03:28 -08:00
Dmitry V. Levin a47ad79afa getrandom: fix comment [BZ #22347]
* stdlib/getrandom.c (getrandom): Fix comment.
* sysdeps/unix/sysv/linux/getrandom.c (getrandom): Likewise.
2017-12-23 14:27:30 +00:00
Florian Weimer bad7a0c81f copy_file_range: New function to copy file data
The semantics are based on the Linux system call, but a very close
emulation in user space is provided.
2017-12-22 10:55:40 +01:00
Adhemerval Zanella 8d2d239cb7 Simplify tile assembly definitions
With tilepro removal, the uppercase instruction are not anymore
required to be defines as potentially macros.  This is a
mechanical change done by the following shell script:

---
INSNS="LD LD4U ST ST4 BNEZ BEQZ BEQZT BGTZ CMPEQI CMPEQ CMOVEQZ CMOVNEZ"

FILES=$(find sysdeps/tile sysdeps/unix/sysv/linux/tile -iname *.S)

for insn in $INSNS; do
  repl=$(echo $insn | tr '[:upper:]' '[:lower:]')
  sed -i 's/\b'$insn'\b/'$repl'/g' $FILES
done
---

Checked with a build for tilegx-linux-gnu and tilegx-linux-gnu-32 with
and without the patch, there is no difference in generated binary with
a dissassemble.

	* sysdeps/tile/__longjmp.S (__longjmp): Use lowercase instructions.
	* sysdeps/tile/__tls_get_addr.S (__tls_get_addr): Likewise.
	* sysdeps/tile/_mcount.S (__mcount): Likewise.
	* sysdeps/tile/crti.S (_init, _fini): Likewise.
	* sysdeps/tile/crtn.S: Likewise.
	* sysdeps/tile/dl-start.S (_start): Likewise.
	* sysdeps/tile/dl-trampoline.S: Likewise.
	* sysdeps/tile/setjmp.S (__sigsetjmp): Likewise.
	* sysdeps/tile/start.S (_start): Likewise.
	* sysdeps/unix/sysv/linux/tile/clone.S (_clone): Likewise.
	* sysdeps/unix/sysv/linux/tile/getcontext.S (__getcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/ioctl.S (__ioctl): Likewise.
	* sysdeps/unix/sysv/linux/tile/setcontext.S (__setcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/swapcontext.S (__swapcontext): Likewise.
	* sysdeps/unix/sysv/linux/tile/syscall.S (syscall): Likewise.
	* sysdeps/unix/sysv/linux/tile/vfork.S (__vfork): Likewise.
2017-12-20 16:55:26 -02:00
Adhemerval Zanella 24d1d8ec9e Simplify tilegx sysdeps folder
With tilepro support removal we can now simplify internal tile support by
moving the directory structure to avoid the unnecessary directory levels
in tile/tilegx both on generic and linux folders.

Checked with a build for tilegx-linux-gnu and tilegx-linux-gnu-32 with
and without the patch, there is no difference in generated binary with
a dissassemble.

	* stdlib/bug-getcontext.c (do_test): Remove tilepro mention in
	comment.
	* sysdeps/tile/preconfigure: Remove tilegx folder.
	* sysdeps/tile/tilegx/Implies: Move definitions to ...
	* sysdeps/tile/Implies: ... here.
	* sysdeps/tile/tilegx/Makefile: Move rules to ...
	* sysdeps/tile/Makefile: ... here.
	* sysdeps/tile/tilegx/atomic-machine.h: Move definitions to ...
	* sysdeps/tile/atomic-machine.h: ... here.  Add include guards.
	* sysdeps/tile/tilegx/bits/wordsize.h: Move to ...
	* sysdeps/tile/bits/wordsize.h: ... here.
	* sysdeps/tile/tilegx/*: Move to ...
	* sysdeps/tile/*: ... here.
	* sysdeps/tile/tilegx/tilegx32/Implies: Move to ...
	* sysdeps/tile/tilegx32/Implies: ... here.
	* sysdeps/tile/tilegx/tilegx64/Implies: Move to ...
	* sysdeps/tile/tilegx64/Implies: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/Makefile: Move definitions
	to ...
	* sysdeps/unix/sysv/linux/tile/Makefile: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/*: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/tilegx32/*: ... here.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/*: Move to ...
	* sysdeps/unix/sysv/linux/tile/tilegx64/*: ... here.
2017-12-20 16:55:26 -02:00
Adhemerval Zanella ed95f61149 Remove tilepro-*-linux-gnu support
As from previous discussions [1] this patch removes tileprox-*-linux-gnu
support from GLIBC.  This patch is a straigthfoward one, which just remove
tilepro specific implementation and configurations (no sysdep simplfication
or reorganization is done).

	* README: Remove tilepro-*-linux-gnu from supported architecture.
	* scripts/build-many-glibcs.py: Likewise.
	* sysdeps/tile/__tls_get_addr.S (__tls_get_addr): Likewise.
	* sysdeps/tile/crti.S (PREINIT_FUNCTION): Likewise.
	* sysdeps/tile/dl-machine.h (ELF_MACHINE_NAME,
	elf_machine_matches_host, elf_machine_dynamic,
	elf_machine_load_address, elf_machine_runtime_setup, reloc_howto
	howto, elf_machine_rela): Likewise
	* sysdeps/tile/dl-start.S (_start): Likewise.
	* sysdeps/tile/memcmp.c (DBLALIGN, REVBYTES): Likewise.
	* sysdeps/tile/memcopy.h (MEMCPY_OK_FOR_FWD_MEMMOVE,
	MEMCPY_OK_FOR_FWD_MEMMOVE, op_t): Likewise.
	* sysdeps/tile/nptl/pthread_spin_lock.c (TNS, CMPTNS): Likewise.
	* sysdeps/tile/nptl/pthread_spin_trylock.c (TNS): Likewise.
	* sysdeps/tile/nptl/pthread_spin_unlock.c (pthread_spin_unlock):
	Likewise.
	* sysdeps/tile/nptl/tls.h (DB_THREAD_SELF): Likewise.
	* sysdeps/tile/preconfigure: Likewise.
	* sysdeps/tile/stackguard-macros.h (STACK_CHK_GUARD,
	POINTER_CHK_GUARD): Likewise.
	* sysdeps/tile/stackinfo.h (__stackinfo_sub): Likewise.
	* sysdeps/tile/start.S (_start): Likewise.
	* sysdeps/tile/tls-macros.h (TLS_GD_OFFSET, TLS_IE_OFFSET, _TLS_LE):
	Likewise.
	* sysdeps/tile/sysdep.h (REGSIZE): Likewise.
	(LD, LD4U, ST, ST4, BNEZ, BEQZ, BEQZT, BGTZ, CMPEQI, CMPEQ, CMOVEQZ,
	CMOVNEZ): Remove.
	* sysdeps/unix/sysv/linux/tile/bits/environments.h
	(__ILP32_OFF32_CFLAGS, __ILP32_OFFBIG_CFLAGS, __ILP32_OFF32_LDFLAGS,
	__ILP32_OFFBIG_LDFLAGS, __LP64_OFF64_CFLAGS, __LP64_OFF64_LDFLAGS):
	Likewise.
	* sysdeps/tile/wordcopy.c (DBLALIGN): Likewise.
	* sysdeps/tile/tilepro/Implies: Remove file.
	* sysdeps/tile/tilepro/atomic-machine.h: Likewise.
	* sysdeps/tile/tilepro/bits/wordsize.h: Likewise.
	* sysdeps/tile/tilepro/memchr.c: Likewise.
	* sysdeps/tile/tilepro/memcpy.S: Likewise.
	* sysdeps/tile/tilepro/memset.c: Likewise.
	* sysdeps/tile/tilepro/memusage.h: Likewise.
	* sysdeps/tile/tilepro/rawmemchr.c: Likewise.
	* sysdeps/tile/tilepro/strchr.c: Likewise.
	* sysdeps/tile/tilepro/strchrnul.c: Likewise.
	* sysdeps/tile/tilepro/strlen.c: Likewise.
	* sysdeps/tile/tilepro/strrchr.c: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/Implies: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/c++-types.data: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/ld.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/ldconfig.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libBrokenLocale.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libanl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libcrypt.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libdl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libnsl.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libresolv.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/librt.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libthread_db.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libutil.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/register-dump.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sysconf.c (linux_sysconf): Remove
	tilepro mention in comment.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00038.html
2017-12-20 16:55:24 -02:00
Adhemerval Zanella 4735850f7a nptl: Consolidate pthread_{timed,try}join{_np}
This patch consolidates the pthread_join and gnu extensions to avoid
code duplication.  The function pthread_join, pthread_tryjoin_np, and
pthread_timedjoin_np are now based on pthread_timedjoin_ex.

It also fixes some inconsistencies on ESRCH, EINVAL, EDEADLK handling
(where each implementation differs from each other) and also on
clenup handler (which now always use a CAS).

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

	* nptl/pthreadP.h (__pthread_timedjoin_np): Define.
	* nptl/pthread_join.c (pthread_join): Use __pthread_timedjoin_np.
	* nptl/pthread_tryjoin.c (pthread_tryjoin): Likewise.
	* nptl/pthread_timedjoin.c (cleanup): Use CAS on argument setting.
	(pthread_timedjoin_np): Define internal symbol and common code from
	pthread_join.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (__lll_timedwait_tid):
	Remove superflous checks.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (__lll_timedwait_tid):
	Likewise.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2017-12-20 11:32:54 -02:00
Szabolcs Nagy 8bfb461e20 aarch64: update libm-test-ulps
* sysdeps/aarch64/libm-test-ulps: Update.
2017-12-20 12:07:10 +00:00
Adhemerval Zanella 4e00196912 aarch64: fix memset with --disable-multi-arch
* sysdeps/aarch64/memset.S (MEMSET): Define.
2017-12-20 12:05:32 +00:00
Florian Weimer 8a26ad2ab7 nptl: Implement pthread_self in libc.so [BZ #22635]
All binaries use TLS and thus need a properly set up TCB, so we can
simply return its address directly, instead of forwarding to the
libpthread implementation from libc.

For versioned symbols, the dynamic linker checks that the soname matches
the name supplied by the link editor, so a compatibility symbol in
libpthread is needed.

To avoid linking against the libpthread function in all cases, we would
have to bump the symbol version of libpthread in libc.so and supply a
compat symbol.  This commit does not do that because the function
implementation is so small, so the overhead by two active copies of the
same function might well be smaller than the increase in symbol table
size.
2017-12-20 11:42:04 +01:00
Gabriel F. T. Gomes c85e54ac6c Provide a C++ version of iseqsig (bug 22377)
In C++ mode, __MATH_TG cannot be used for defining iseqsig, because
__MATH_TG relies on __builtin_types_compatible_p, which is a C-only
builtin.  This is true when float128 is provided as an ABI-distinct type
from long double.

Moreover, the comparison macros from ISO C take two floating-point
arguments, which need not have the same type.  Choosing what underlying
function to call requires evaluating the formats of the arguments, then
selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
information, however, only the type of the macro expansion is relevant
(actually evaluating the expression would be incorrect).

This patch provides a C++ version of iseqsig, in which only the type of
__MATH_EVAL_FMT2 (__typeof or decltype) is used as a template parameter
for __iseqsig_type.  This function calls the appropriate underlying
function.

Tested for powerpc64le and x86_64.

	[BZ #22377]
	* math/Makefile [C++] (tests): Add test for iseqsig.
	* math/math.h [C++] (iseqsig): New implementation, which does
	not rely on __MATH_TG/__builtin_types_compatible_p.
	* math/test-math-iseqsig.cc: New file.
	* sysdeps/powerpc/powerpc64le/Makefile
	(CFLAGS-test-math-iseqsig.cc): New variable.
2017-12-19 23:26:59 -02:00
Bernd Edlinger 648615e13f Avoid signed shift overflow in pow (bug 21309).
As noted in bug 21309, dbl-64/e_pow.c contains signed int shifts that,
although the shift count is in the range [0, 31], shift bits into and
beyond the sign bit and so are undefined in ISO C.  Although this is
defined in GNU C, this patch from the bug cleans up the code to avoid
those shifts.

Tested for x86_64.

	[BZ #21309]
	* sysdeps/ieee754/dbl-64/e_pow.c (checkint): Make m and n
	unsigned.
2017-12-19 18:41:01 +00:00
Joseph Myers f1e005022e Revert exp reimplementation (causes test failures).
Revert:

	2017-12-19  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/x86_64/fpu/libm-test-ulps: Update.

	2017-12-19  Patrick McGehearty  <patrick.mcgehearty@oracle.com>

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math-svid-compat.h> and
	<errno.h>.  Include "eexp.tbl".
	(half): New constant.
	(one): Likewise.
	(__ieee754_exp): Rewrite.
	(__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/eexp.tbl: New file.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove file.
	* sysdeps/i386/fpu/slowexp.c: Likewise.
	* sysdeps/ia64/fpu/slowexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise.
	* sysdeps/generic/math_private.h (__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/e_pow.c: Remove mention of slowexp.c in
	comment.
	* sysdeps/powerpc/power4/fpu/Makefile [$(subdir) = math]
	(CPPFLAGS-slowexp.c): Remove variable.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove slowexp-fma, slowexp-fma4 and slowexp-avx.
	(CFLAGS-slowexp-fma.c): Remove variable.
	(CFLAGS-slowexp-fma4.c): Likewise.
	(CFLAGS-slowexp-avx.c): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Do not
	define as macro.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Likewise.
	* math/Makefile (type-double-routines): Remove slowexp.
	* manual/probes.texi (slowexp_p6): Remove.
	(slowexp_p32): Likewise.
2017-12-19 18:11:37 +00:00
Joseph Myers 6f58c10ded Update x86_64 libm-test-ulps.
* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2017-12-19 17:38:41 +00:00
Patrick McGehearty 6fd0a3c6a8 Improve __ieee754_exp() performance by greater than 5x on sparc/x86.
These changes will be active for all platforms that don't provide
their own exp() routines. They will also be active for ieee754
versions of ccos, ccosh, cosh, csin, csinh, sinh, exp10, gamma, and
erf.

Typical performance gains is typically around 5x when measured on
Sparc s7 for common values between exp(1) and exp(40).

Using the glibc perf tests on sparc,
      sparc (nsec)    x86 (nsec)
      old     new     old     new
max   17629   395    5173     144
min     399    54      15      13
mean   5317   200    1349      23

The extreme max times for the old (ieee754) exp are due to the
multiprecision computation in the old algorithm when the true value is
very near 0.5 ulp away from an value representable in double
precision. The new algorithm does not take special measures for those
cases. The current glibc exp perf tests overrepresent those values.
Informal testing suggests approximately one in 200 cases might
invoke the high cost computation. The performance advantage of the new
algorithm for other values is still large but not as large as indicated
by the chart above.

Glibc correctness tests for exp() and expf() were run. Within the
test suite 3 input values were found to cause 1 bit differences (ulp)
when "FE_TONEAREST" rounding mode is set. No differences in exp() were
seen for the tested values for the other rounding modes.
Typical example:
exp(-0x1.760cd2p+0)  (-1.46113312244415283203125)
 new code:    2.31973271630014299393707e-01   0x1.db14cd799387ap-3
 old code:    2.31973271630014271638132e-01   0x1.db14cd7993879p-3
    exp    =  2.31973271630014285508337 (high precision)
Old delta: off by 0.49 ulp
New delta: off by 0.51 ulp

In addition, because ieee754_exp() is used by other routines, cexp()
showed test results with very small imaginary input values where the
imaginary portion of the result was off by 3 ulp when in upward
rounding mode, but not in the other rounding modes.  For x86, tgamma
showed a few values where the ulp increased to 6 (max ulp for tgamma
is 5). Sparc tgamma did not show these failures.  I presume the tgamma
differences are due to compiler optimization differences within the
gamma function.The gamma function is known to be difficult to compute
accurately.

	* sysdeps/ieee754/dbl-64/e_exp.c: Include <math-svid-compat.h> and
	<errno.h>.  Include "eexp.tbl".
	(half): New constant.
	(one): Likewise.
	(__ieee754_exp): Rewrite.
	(__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/eexp.tbl: New file.
	* sysdeps/ieee754/dbl-64/slowexp.c: Remove file.
	* sysdeps/i386/fpu/slowexp.c: Likewise.
	* sysdeps/ia64/fpu/slowexp.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/slowexp.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Likewise.
	* sysdeps/generic/math_private.h (__slowexp): Remove prototype.
	* sysdeps/ieee754/dbl-64/e_pow.c: Remove mention of slowexp.c in
	comment.
	* sysdeps/powerpc/power4/fpu/Makefile [$(subdir) = math]
	(CPPFLAGS-slowexp.c): Remove variable.
	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Remove slowexp-fma, slowexp-fma4 and slowexp-avx.
	(CFLAGS-slowexp-fma.c): Remove variable.
	(CFLAGS-slowexp-fma4.c): Likewise.
	(CFLAGS-slowexp-avx.c): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Do not
	define as macro.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Likewise.
	* sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Likewise.
	* math/Makefile (type-double-routines): Remove slowexp.
	* manual/probes.texi (slowexp_p6): Remove.
	(slowexp_p32): Likewise.
2017-12-19 17:27:31 +00:00
Adhemerval Zanella 3bb1ef58b9 ia64: Fix memchr for large input sizes (BZ #22603)
Current optimized ia64 memchr uses a strategy to check for last address
by adding the input one with expected size.  However it does not take
care for possible overflow.

It was triggered by 3038145ca2 where default rawmemchr now uses memchr
(p, c, (size_t)-1).

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

Checked on ia64-linux-gnu where it fixes both stratcliff and
test-rawmemchr failures.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	James Clarke <jrtc27@jrtc27.com>

	[BZ #22603]
	* sysdeps/ia64/memchr.S (__memchr): Avoid overflow in pointer
	addition.
2017-12-19 12:02:36 -02:00
Adhemerval Zanella 554e3d51ef sh: Fix clone exit return code (BZ #22605)
Since 3f823e87cc (Call exit directly in clone (BZ #21512)) SH clone
implementation fails to set the exit code resulting in the failures:

FAIL: nptl/tst-align-clone
FAIL: nptl/tst-getpid1

This patch fixes the both testcases.

	[BZ #22605]
	* sysdeps/unix/sysv/linux/sh/clone.S (__clone): Fix exit return
	code.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-19 12:02:01 -02:00
H.J. Lu cba595c350 x86: Add feature_1 to tcbhead_t [BZ #22563]
On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
to support Shadow Stack in Intel Control-flow Enforcemen Technology.
cancel_jmp_buf has been updated to include saved_mask so that it is as
large as struct __jmp_buf_tag.  We must suport the old cancel_jmp_buf
in existing binaries.  Since symbol versioning doesn't work on
cancel_jmp_buf, feature_1 is added to tcbhead_t so that setjmp and
longjmp can check if shadow stack is enabled.  NB: Shadow stack is
enabled only if all modules are shadow stack enabled.

	[BZ #22563]
	* sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Add feature_1.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Rename __glibc_unused1
	to feature_1.
2017-12-19 02:45:34 -08:00
H.J. Lu f81ddabffd Linux/x86: Update cancel_jmp_buf to match __jmp_buf_tag [BZ #22563]
On x86, padding in struct __jmp_buf_tag is used for shadow stack pointer
to support shadow stack in Intel Control-flow Enforcemen Technology.
Since the cancel_jmp_buf array is passed to setjmp and longjmp by
casting it to pointer to struct __jmp_buf_tag, it should be as large
as struct __jmp_buf_tag.  Otherwise when shadow stack is enabled,
setjmp and longjmp will write and read beyond cancel_jmp_buf when saving
and restoring shadow stack pointer.

This patch adds bits/types/__cancel_jmp_buf_tag.h to define struct
__cancel_jmp_buf_tag so that Linux/x86 can add saved_mask to
cancel_jmp_buf.

Tested natively on i386, x86_64 and x32.  Tested hppa-linux-gnu with
build-many-glibcs.py.

	[BZ #22563]
	* bits/types/__cancel_jmp_buf_tag.h: New file.
	* sysdeps/unix/sysv/linux/x86/bits/types/__cancel_jmp_buf_tag.h
	* sysdeps/unix/sysv/linux/x86/pthreaddef.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/nptl/pthreadP.h: Likewise.
	* nptl/Makefile (headers): Add
	bits/types/__cancel_jmp_buf_tag.h.
	* nptl/descr.h [NEED_SAVED_MASK_IN_CANCEL_JMP_BUF]
	(pthread_unwind_buf): Add saved_mask to cancel_jmp_buf.
	* sysdeps/nptl/pthread.h: Include
	<bits/types/__cancel_jmp_buf_tag.h>.
	(__pthread_unwind_buf_t): Use struct __cancel_jmp_buf_tag with
	__cancel_jmp_buf.
	* sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise.
2017-12-19 02:44:04 -08:00
Joseph Myers 6642518592 Fix m68k bits/mathinline.h attributes (bug 22631).
m68k bits/mathinline.h declares various functions with const
attributes.  These are inappropriate for functions that have results
depending on the rounding mode; the machine-independent
bits/mathcalls.h only uses const attributes for a very few functions
with no rounding mode dependence, and the m68k header should do
likewise.  GCC uses pure for such functions with -frounding-math,
resulting in GCC mainline warning for conflicts with between the
header and the built-in attributes and glibc failing to build for m68k
with GCC mainline.

This patch fixes the attributes to avoid using const except when
bits/mathcalls.h does so.  (There are a few functions where maybe
bits/mathcalls.h could do so but doesn't, but keeping the headers in
sync in this regard seems to be the safe approach.)

Tested compilation with build-many-glibcs.py with GCC mainline.

	[BZ #22631]
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h (__m81_defun): Add
	argument for attrubutes.  All callers changed.
	(__inline_mathop1): Likewise.  All callers changed.
	(__inline_mathop): Likewise.  All callers changed.
	[__USE_MISC] (scalbn): Use __inline_forward instead of
	__inline_forward_c.
	[__USE_ISOC99] (scalbln): Likewise.
	[__USE_ISOC99] (nearbyint): Likewise.
	[__USE_ISOC99] (lrint): Likewise.
	[__USE_MISC] (scalbnf): Likewise.
	[__USE_ISOC99] (scalblnf): Likewise.
	[__USE_ISOC99] (nearbyintf): Likewise.
	[__USE_ISOC99] (lrintf): Likewise.
	[__USE_MISC] (scalbnl): Likewise.
	[__USE_ISOC99] (scalblnl): Likewise.
	[__USE_ISOC99] (nearbyintl): Likewise.
	[__USE_ISOC99] (lrintl): Likewise.
	* sysdeps/m68k/m680x0/fpu/mathimpl.h: All callers of
	__inline_mathop and __m81_defun changed.
2017-12-19 02:02:26 +00:00
Florian Weimer 8e1472d2c1 ld.so: Examine GLRO to detect inactive loader [BZ #20204]
GLRO (_rtld_global_ro) is read-only after initialization and can
therefore not be patched at run time, unlike the hook table addresses
and their contents, so this is a desirable hardening feature.

The hooks are only needed if ld.so has not been initialized, and this
happens only after static dlopen (dlmopen uses a single ld.so object
across all namespaces).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2017-12-18 20:04:13 +01:00
Sergei Trofimovich c85c564d14 mips32: fix clobbering s0 in setjmp() [BZ #22624]
Similar to commit 1ab47db00dfbc0128119e3503d3ed640ffc4830b
("mips64: fix clobbering s0 in setjmp() [BZ #22624]")
as sysdeps/mips/setjmp_aux.c is almost an identical copy
of sysdeps/mips/mips64/setjmp_aux.c.

	[BZ #22624]
	* sysdeps/mips/setjmp_aux.c (__sigsetjmp_aux): Use
	inhibit_stack_protector.
2017-12-18 18:26:49 +00:00
Sergei Trofimovich 368b6c8da9 mips64: fix clobbering s0 in setjmp() [BZ #22624]
When configured as --enable-stack-protector=all glibc
inserts stack checking canary into every function
including __sigsetjmp_aux(). Stack checking code
ends up using s0 register to temporary hold address
of global canary value.

Unfortunately __sigsetjmp_aux assumes no caller' caller-save
registers should be clobbered as it stores them as-is.

The fix is to disable stack protection of __sigsetjmp_aux.

Tested on the following test:

    #include <setjmp.h>
    #include <stdio.h>

    int main() {
        jmp_buf jb;
        volatile register long s0 asm ("$s0");
        s0 = 1234;
        if (setjmp(jb) == 0)
            longjmp(jb, 1);
        printf ("$s0 = %lu\n", s0);
    }

Without the fix:
    $ qemu-mipsn32 -L . ./mips-longjmp-bug
    $s0 = 1082346228

With the fix:
    $ qemu-mipsn32 -L . ./mips-longjmp-bug
    $s0 = 1234

	[BZ #22624]
	* sysdeps/mips/mips64/setjmp_aux.c (__sigsetjmp_aux): Use
	inhibit_stack_protector.
2017-12-18 17:23:02 +00:00
Szabolcs Nagy 14d886edbd aarch64: fix start code for static pie
There are three flavors of the crt startup code:

1) crt1.o used for non-pie,
2) Scrt1.o used for dynamic linked pie (dynamic linker relocates),
3) rcrt1.o used for static linked pie (self relocation is needed)

In the --enable-static-pie case crt1.o is built with -DPIC and in case
of static linking it interposes _dl_relocate_static_pie in libc to
avoid self relocation.

Scrt1.o is built with -DPIC -DSHARED and it relies on GOT entries that
the static linker cannot relax and thus need relocation before the
start code is executed, so rcrt1.o needs separate implementation.

This implementation does not work for .text > 4G position independent
executables, which is fine since the toolchain does not support
-mcmodel=large with -fPIE.

Tests pass with ld/22269 and ld/22263 binutils bugs fixed.

	* sysdeps/aarch64/start.S (_start): Handle PIC && !SHARED case.
2017-12-18 10:07:07 +00:00
Rajalakshmi Srinivasaraghavan 2e77deef67 s390: Update ulps
* sysdeps/s390/fpu/libm-test-ulps: Update.
2017-12-16 14:11:56 +05:30
Rajalakshmi Srinivasaraghavan 0b9bef6d22 powerpc: Update ulps
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
2017-12-16 14:04:14 +05:30
Rajalakshmi Srinivasaraghavan 984ae9967b New generic sincosf
This implementation is based on generic s_sinf.c and s_cosf.c.
Tested on s390x, powerpc64le and powerpc32.
2017-12-16 14:01:37 +05:30
H.J. Lu 9d7a3741c9 Add --enable-static-pie configure option to build static PIE [BZ #19574]
Static PIE extends address space layout randomization to static
executables.  It provides additional security hardening benefits at
the cost of some memory and performance.

Dynamic linker, ld.so, is a standalone program which can be loaded at
any address.  This patch adds a configure option, --enable-static-pie,
to embed the part of ld.so in static executable to create static position
independent executable (static PIE).  A static PIE is similar to static
executable, but can be loaded at any address without help from a dynamic
linker.  When --enable-static-pie is used to configure glibc, libc.a is
built as PIE and all static executables, including tests, are built as
static PIE.  The resulting libc.a can be used together with GCC 8 or
above to build static PIE with the compiler option, -static-pie.  But
GCC 8 isn't required to build glibc with --enable-static-pie.  Only GCC
with PIE support is needed.  When an older GCC is used to build glibc
with --enable-static-pie, proper input files are passed to linker to
create static executables as static PIE, together with "-z text" to
prevent dynamic relocations in read-only segments, which are not allowed
in static PIE.

The following changes are made for static PIE:

1. Add a new function, _dl_relocate_static_pie, to:
   a. Get the run-time load address.
   b. Read the dynamic section.
   c. Perform dynamic relocations.
Dynamic linker also performs these steps.  But static PIE doesn't load
any shared objects.
2. Call _dl_relocate_static_pie at entrance of LIBC_START_MAIN in
libc.a.  crt1.o, which is used to create dynamic and non-PIE static
executables, is updated to include a dummy _dl_relocate_static_pie.
rcrt1.o is added to create static PIE, which will link in the real
_dl_relocate_static_pie.  grcrt1.o is also added to create static PIE
with -pg.  GCC 8 has been updated to support rcrt1.o and grcrt1.o for
static PIE.

Static PIE can work on all architectures which support PIE, provided:

1. Target must support accessing of local functions without dynamic
relocations, which is needed in start.S to call __libc_start_main with
function addresses of __libc_csu_init, __libc_csu_fini and main.  All
functions in static PIE are local functions.  If PIE start.S can't reach
main () defined in a shared object, the code sequence:

	pass address of local_main to __libc_start_main
	...

local_main:
	tail call to main via PLT

can be used.
2. start.S is updated to check PIC instead SHARED for PIC code path and
avoid dynamic relocation, when PIC is defined and SHARED isn't defined,
to support static PIE.
3. All assembly codes are updated check PIC instead SHARED for PIC code
path to avoid dynamic relocations in read-only sections.
4. All assembly codes are updated check SHARED instead PIC for static
symbol name.
5. elf_machine_load_address in dl-machine.h are updated to support static
PIE.
6. __brk works without TLS nor dynamic relocations in read-only section
so that it can be used by __libc_setup_tls to initializes TLS in static
PIE.

NB: When glibc is built with GCC defaulted to PIE, libc.a is compiled
with -fPIE, regardless if --enable-static-pie is used to configure glibc.
When glibc is configured with --enable-static-pie, libc.a is compiled
with -fPIE, regardless whether GCC defaults to PIE or not.  The same
libc.a can be used to build both static executable and static PIE.
There is no need for separate PIE copy of libc.a.

On x86-64, the normal static sln:

   text	   data	    bss	    dec	    hex	filename
 625425	   8284	   5456	 639165	  9c0bd	elf/sln

the static PIE sln:

   text	   data	    bss	    dec	    hex	filename
 657626	  20636	   5392	 683654	  a6e86	elf/sln

The code size is increased by 5% and the binary size is increased by 7%.

Linker requirements to build glibc with --enable-static-pie:

1. Linker supports --no-dynamic-linker to remove PT_INTERP segment from
static PIE.
2. Linker can create working static PIE.  The x86-64 linker needs the
fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21782

The i386 linker needs to be able to convert "movl main@GOT(%ebx), %eax"
to "leal main@GOTOFF(%ebx), %eax" if main is defined locally.

Binutils 2.29 or above are OK for i686 and x86-64.  But linker status for
other targets need to be verified.

3. Linker should resolve undefined weak symbols to 0 in static PIE:

https://sourceware.org/bugzilla/show_bug.cgi?id=22269

4. Many ELF backend linkers incorrectly check bfd_link_pic for TLS
relocations, which should check bfd_link_executable instead:

https://sourceware.org/bugzilla/show_bug.cgi?id=22263

Tested on aarch64, i686 and x86-64.

Using GCC 7 and binutils master branch, build-many-glibcs.py with
--enable-static-pie with all patches for static PIE applied have the
following build successes:

PASS: glibcs-aarch64_be-linux-gnu build
PASS: glibcs-aarch64-linux-gnu build
PASS: glibcs-armeb-linux-gnueabi-be8 build
PASS: glibcs-armeb-linux-gnueabi build
PASS: glibcs-armeb-linux-gnueabihf-be8 build
PASS: glibcs-armeb-linux-gnueabihf build
PASS: glibcs-arm-linux-gnueabi build
PASS: glibcs-arm-linux-gnueabihf build
PASS: glibcs-arm-linux-gnueabihf-v7a build
PASS: glibcs-arm-linux-gnueabihf-v7a-disable-multi-arch build
PASS: glibcs-m68k-linux-gnu build
PASS: glibcs-microblazeel-linux-gnu build
PASS: glibcs-microblaze-linux-gnu build
PASS: glibcs-mips64el-linux-gnu-n32 build
PASS: glibcs-mips64el-linux-gnu-n32-nan2008 build
PASS: glibcs-mips64el-linux-gnu-n32-nan2008-soft build
PASS: glibcs-mips64el-linux-gnu-n32-soft build
PASS: glibcs-mips64el-linux-gnu-n64 build
PASS: glibcs-mips64el-linux-gnu-n64-nan2008 build
PASS: glibcs-mips64el-linux-gnu-n64-nan2008-soft build
PASS: glibcs-mips64el-linux-gnu-n64-soft build
PASS: glibcs-mips64-linux-gnu-n32 build
PASS: glibcs-mips64-linux-gnu-n32-nan2008 build
PASS: glibcs-mips64-linux-gnu-n32-nan2008-soft build
PASS: glibcs-mips64-linux-gnu-n32-soft build
PASS: glibcs-mips64-linux-gnu-n64 build
PASS: glibcs-mips64-linux-gnu-n64-nan2008 build
PASS: glibcs-mips64-linux-gnu-n64-nan2008-soft build
PASS: glibcs-mips64-linux-gnu-n64-soft build
PASS: glibcs-mipsel-linux-gnu build
PASS: glibcs-mipsel-linux-gnu-nan2008 build
PASS: glibcs-mipsel-linux-gnu-nan2008-soft build
PASS: glibcs-mipsel-linux-gnu-soft build
PASS: glibcs-mips-linux-gnu build
PASS: glibcs-mips-linux-gnu-nan2008 build
PASS: glibcs-mips-linux-gnu-nan2008-soft build
PASS: glibcs-mips-linux-gnu-soft build
PASS: glibcs-nios2-linux-gnu build
PASS: glibcs-powerpc64le-linux-gnu build
PASS: glibcs-powerpc64-linux-gnu build
PASS: glibcs-tilegxbe-linux-gnu-32 build
PASS: glibcs-tilegxbe-linux-gnu build
PASS: glibcs-tilegx-linux-gnu-32 build
PASS: glibcs-tilegx-linux-gnu build
PASS: glibcs-tilepro-linux-gnu build

and the following build failures:

FAIL: glibcs-alpha-linux-gnu build

elf/sln is failed to link due to:

assertion fail bfd/elf64-alpha.c:4125

This is caused by linker bug and/or non-PIC code in PIE libc.a.

FAIL: glibcs-hppa-linux-gnu build

elf/sln is failed to link due to:

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

https://sourceware.org/bugzilla/show_bug.cgi?id=22537

FAIL: glibcs-ia64-linux-gnu build

elf/sln is failed to link due to:

collect2: fatal error: ld terminated with signal 11 [Segmentation fault]

FAIL: glibcs-powerpc-linux-gnu build
FAIL: glibcs-powerpc-linux-gnu-soft build
FAIL: glibcs-powerpc-linux-gnuspe build
FAIL: glibcs-powerpc-linux-gnuspe-e500v1 build

elf/sln is failed to link due to:

ld: read-only segment has dynamic relocations.

This is caused by linker bug and/or non-PIC code in PIE libc.a.  See:

https://sourceware.org/bugzilla/show_bug.cgi?id=22264

FAIL: glibcs-powerpc-linux-gnu-power4 build

elf/sln is failed to link due to:

findlocale.c:96:(.text+0x22c): @local call to ifunc memchr

This is caused by linker bug and/or non-PIC code in PIE libc.a.

FAIL: glibcs-s390-linux-gnu build

elf/sln is failed to link due to:

collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped

assertion fail bfd/elflink.c:14299

This is caused by linker bug and/or non-PIC code in PIE libc.a.

FAIL: glibcs-sh3eb-linux-gnu build
FAIL: glibcs-sh3-linux-gnu build
FAIL: glibcs-sh4eb-linux-gnu build
FAIL: glibcs-sh4eb-linux-gnu-soft build
FAIL: glibcs-sh4-linux-gnu build
FAIL: glibcs-sh4-linux-gnu-soft build

elf/sln is failed to link due to:

ld: read-only segment has dynamic relocations.

This is caused by linker bug and/or non-PIC code in PIE libc.a.  See:

https://sourceware.org/bugzilla/show_bug.cgi?id=22263

Also TLS code sequence in SH assembly syscalls in glibc doesn't match TLS
code sequence expected by ld:

https://sourceware.org/bugzilla/show_bug.cgi?id=22270

FAIL: glibcs-sparc64-linux-gnu build
FAIL: glibcs-sparcv9-linux-gnu build
FAIL: glibcs-tilegxbe-linux-gnu build
FAIL: glibcs-tilegxbe-linux-gnu-32 build
FAIL: glibcs-tilegx-linux-gnu build
FAIL: glibcs-tilegx-linux-gnu-32 build
FAIL: glibcs-tilepro-linux-gnu build

elf/sln is failed to link due to:

ld: read-only segment has dynamic relocations.

This is caused by linker bug and/or non-PIC code in PIE libc.a.  See:

https://sourceware.org/bugzilla/show_bug.cgi?id=22263

	[BZ #19574]
	* INSTALL: Regenerated.
	* Makeconfig (real-static-start-installed-name): New.
	(pic-default): Updated for --enable-static-pie.
	(pie-default): New for --enable-static-pie.
	(default-pie-ldflag): Likewise.
	(+link-static-before-libc): Replace $(DEFAULT-LDFLAGS-$(@F))
	with $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)).
	Replace $(static-start-installed-name) with
	$(real-static-start-installed-name).
	(+prectorT): Updated for --enable-static-pie.
	(+postctorT): Likewise.
	(CFLAGS-.o): Add $(pie-default).
	(CFLAGS-.op): Likewise.
	* NEWS: Mention --enable-static-pie.
	* config.h.in (ENABLE_STATIC_PIE): New.
	* configure.ac (--enable-static-pie): New configure option.
	(have-no-dynamic-linker): New LIBC_CONFIG_VAR.
	(have-static-pie): Likewise.
	Enable static PIE if linker supports --no-dynamic-linker.
	(ENABLE_STATIC_PIE): New AC_DEFINE.
	(enable-static-pie): New LIBC_CONFIG_VAR.
	* configure: Regenerated.
	* csu/Makefile (omit-deps): Add r$(start-installed-name) and
	gr$(start-installed-name) for --enable-static-pie.
	(extra-objs): Likewise.
	(install-lib): Likewise.
	(extra-objs): Add static-reloc.o and static-reloc.os
	($(objpfx)$(start-installed-name)): Also depend on
	$(objpfx)static-reloc.o.
	($(objpfx)r$(start-installed-name)): New.
	($(objpfx)g$(start-installed-name)): Also depend on
	$(objpfx)static-reloc.os.
	($(objpfx)gr$(start-installed-name)): New.
	* csu/libc-start.c (LIBC_START_MAIN): Call _dl_relocate_static_pie
	in libc.a.
	* csu/libc-tls.c (__libc_setup_tls): Add main_map->l_addr to
	initimage.
	* csu/static-reloc.c: New file.
	* elf/Makefile (routines): Add dl-reloc-static-pie.
	(elide-routines.os): Likewise.
	(DEFAULT-LDFLAGS-tst-tls1-static-non-pie): Removed.
	(tst-tls1-static-non-pie-no-pie): New.
	* elf/dl-reloc-static-pie.c: New file.
	* elf/dl-support.c (_dl_get_dl_main_map): New function.
	* elf/dynamic-link.h (ELF_DURING_STARTUP): Also check
	STATIC_PIE_BOOTSTRAP.
	* elf/get-dynamic-info.h (elf_get_dynamic_info): Likewise.
	* gmon/Makefile (tests): Add tst-gmon-static-pie.
	(tests-static): Likewise.
	(DEFAULT-LDFLAGS-tst-gmon-static): Removed.
	(tst-gmon-static-no-pie): New.
	(CFLAGS-tst-gmon-static-pie.c): Likewise.
	(CRT-tst-gmon-static-pie): Likewise.
	(tst-gmon-static-pie-ENV): Likewise.
	(tests-special): Likewise.
	($(objpfx)tst-gmon-static-pie.out): Likewise.
	(clean-tst-gmon-static-pie-data): Likewise.
	($(objpfx)tst-gmon-static-pie-gprof.out): Likewise.
	* gmon/tst-gmon-static-pie.c: New file.
	* manual/install.texi: Document --enable-static-pie.
	* sysdeps/generic/ldsodefs.h (_dl_relocate_static_pie): New.
	(_dl_get_dl_main_map): Likewise.
	* sysdeps/i386/configure.ac: Check if linker supports static PIE.
	* sysdeps/x86_64/configure.ac: Likewise.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/x86_64/configure: Likewise.
	* sysdeps/mips/Makefile (ASFLAGS-.o): Add $(pie-default).
	(ASFLAGS-.op): Likewise.
2017-12-15 17:12:14 -08:00
Thomas Schwinge d232f2e137 Don't set errno in Hurd rtld's __access_noerrno
* sysdeps/mach/hurd/dl-sysdep.c (__access_noerrno): Don't set
	errno.

Fixes commit 819ea3347e.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
2017-12-15 18:02:56 +01:00
Joseph Myers 174edbde7e Update SPARC divrem generation to match output.
While working on another patch I noticed that (a)
sysdeps/sparc/sparc32/Makefile is the only place with special
realclean settings, apart from po/, and (b) the generated files with a
rule in that Makefile to generate them (using m4) had been patched
manually so no longer corresponded with the output of the generator -
so if the timestamps were wrong, a build would result in changes to
the files in the source directory.  (They also didn't correspond
because of changes in make 3.81 to how make handles whitespace at the
start of a line in a sequence of backslash-newline continuation lines
within a recipe.)

This patch fixes the generation and output files to match.  The issue
with make and whitespace at start of continuation lines is fixed by
putting those newlines outside of arguments to echo, so the number of
spaces in the argument matches the number in the existing generated
files.  Then divrem.m4 is changed to avoid generating whitespace-only
lines (my fix to the outputs from 2013; this fix to the generator also
changes the indentation of a label in the output files) and to
generate an alias in udiv.S (Adhemerval's fix from March).

build-many-glibcs.py doesn't have a non-v9 SPARC configuration,
because non-v9 32-bit SPARC didn't build when I set up
build-many-glibcs.py but sparcv9 did build.  Whether or not non-v9
32-bit SPARC now builds (or indeed whether or not support for it is
obsolete), I tested by removing the sparcv8 and sparcv9 versions of
the four files in question, so forcing the generated files to be built
and used, and the compilation parts of the glibc testsuite passed.

	* sysdeps/sparc/sparc32/Makefile
	($(divrem:%=$(sysdep_dir)/sparc/sparc32/%.S)): Do not include
	start-of-line whitespace in argument of echo.
	* sysdeps/sparc/sparc32/divrem.m4: Avoid generating lines starting
	with whitespace.  Generate __wrap_.udiv alias.
	* sysdeps/sparc/sparc32/rem.S: Regenerated.
	* sysdeps/sparc/sparc32/sdiv.S: Likewise.
	* sysdeps/sparc/sparc32/udiv.S: Likewise.
	* sysdeps/sparc/sparc32/urem.S: Likewise.
2017-12-15 14:06:07 +00:00
Rajalakshmi Srinivasaraghavan 1e36806fb8 powerpc: st{r,p}cpy optimization for aligned strings
This patch makes use of vectors for aligned inputs.  Improvements
upto 30% seen for larger aligned inputs.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2017-12-15 10:55:58 +05:30
H.J. Lu 4ca945e9c5 x86-64: Remove sysdeps/x86_64/fpu/s_cosf.S
On Ivy Bridge, bench-cosf reports performance improvement:

           s_cosf.S      s_cosf.c       Improvement
max        114.136       82.401            39%
min        13.119        11.301            16%
mean       22.1882       21.8938           1%

	* sysdeps/x86_64/fpu/s_cosf.S: Removed.
2017-12-14 04:39:53 -08:00
Patrick McGehearty e6a1c5dc77 sparc: M7 optimized memset/bzero
Support added to identify Sparc M7/T7/S7/M8/T8 processor capability.
Performance tests run on Sparc S7 using new code and old niagara4 code.

Optimizations for memset also apply to bzero as they share code.

For memset/bzero, performance comparison with niagara4 code:
For memset nonzero data,
  256-1023 bytes - 60-90% gain (in cache); 5% gain (out of cache)
  1K+ bytes - 80-260% gain (in cache); 40-80% gain (out of cache)
For memset zero data (and bzero),
  256-1023 bytes - 80-120% gain (in cache), 0% gain (out of cache)
  1024+ bytes - 2-4x gain (in cache), 10-35% gain (out of cache)

Tested in sparcv9-*-* and sparc64-*-* targets in both multi and
non-multi arch configurations.

	Patrick McGehearty <patrick.mcgehearty@oracle.com>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
	(sysdeps_routines): Add memset-niagara7.
	* sysdeps/sparc/sparc64/multiarch/Makefile (sysdes_rotuines):
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/memset-niagara7.S: New
	file.
	* sysdeps/sparc/sparc64/multiarch/memset-niagara7.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add __bzero_niagara7 and __memset_niagara7.
	* sysdeps/sparc/sparc64/multiarch/ifunc-memset.h (IFUNC_SELECTOR):
	Add niagara7 option.
	* NEWS: Mention sparc m7 optimized memcpy, mempcpy, memmove, and
	memset.
2017-12-14 08:48:19 -02:00
Patrick McGehearty 1b6e07f8e0 sparc: M7 optimized memcpy/mempcpy/memmove
Support added to identify Sparc M7/T7/S7/M8/T8 processor capability.
Performance tests run on Sparc S7 using new code and old niagara4 code.

Optimizations for memcpy also apply to mempcpy and memmove
where they share code. Optimizations for memset also apply
to bzero as they share code.

For memcpy/mempcpy/memmove, performance comparison with niagara4 code:
Long word aligned data
  0-127 bytes - minimal changes
  128-1023 bytes - 7-30% gain
  1024+ bytes - 1-7% gain (in cache); 30-100% gain (out of cache)
Word aligned data
  0-127 bytes - 50%+ gain
  128-1023 bytes - 10-200% gain
  1024+ bytes - 0-15% gain (in cache); 5-50% gain (out of cache)
Unaligned data
  0-127 bytes - 0-70%+ gain
  128-447 bytes - 40-80%+ gain
  448-511 bytes - 1-3% loss
  512-4096 bytes - 2-3% gain (in cache); 0-20% gain (out of cache)
  4096+ bytes - ± 3% (in cache); 20-50% gain (out of cache)

Tested in sparcv9-*-* and sparc64-*-* targets in both multi and
non-multi arch configurations.

	Patrick McGehearty  <patrick.mcgehearty@oracle.com>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	* sysdeps/sparc/sparc32/sparcv9/multiarch/Makefile
	(sysdeps_routines): Add memcpy-memmove-niagara7 and memmove-ultra1.
	* sysdeps/sparc/sparc64/multiarch/Makefile (sysdeps_routines):
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/memcpy-memmove-niagara7.S:
	New file.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/memmove-ultra1.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/multiarch/rtld-memmove.c: Likewise.
	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add __memcpy_niagara7, __mempcpy_niagara7,
	and __memmove_niagara7.
	* sysdeps/sparc/sparc64/multiarch/ifunc-memcpy.h (IFUNC_SELECTOR):
	Add niagara7 option.
	* sysdeps/sparc/sparc64/multiarch/memmove.c: New file.
	* sysdeps/sparc/sparc64/multiarch/ifunc-memmove.h: Likewise.
	* sysdeps/sparc/sparc64/multiarch/memcpy-memmove-niagara7.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/memmove-ultra1.S: Likewise.
	* sysdeps/sparc/sparc64/multiarch/rtld-memmove.c: Likewise.
2017-12-14 08:47:38 -02:00
Jose E. Marchesi 767a26d6a0 sparc: assembly version of memmove for ultra1+
Tested in sparcv9-*-* and sparc64-*-* targets in both non-multi-arch and
multi-arch configurations.

	* sysdeps/sparc/sparc32/sparcv9/memmove.S: New file.
	* sysdeps/sparc/sparc32/sparcv9/rtld-memmove.c: Likewise.
	* sysdeps/sparc/sparc64/memmove.S: Likewise.
	* sysdeps/sparc/sparc64/rtld-memmove.c: Likewise.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-14 08:47:09 -02:00
Jose E. Marchesi bfb7bf2273 sparc: support the ADP hw capability
This patch adds support for the ADP (also known as adi) hardware
capability, as reported by the kernel sparc port when running on M7
machines.

Tested in both sparcv9-*-* and sparc64-*-* targets.

	* sysdeps/sparc/bits/hwcap.h (HWCAP_SPARC_ADP): Defined.
	* sysdeps/sparc/dl-procinfo.c: Added "adp" to the
	_dl_sparc_cap_flags array.
	* sysdeps/sparc/dl-procinfo.h (_DL_HWCAP_COUNT): Increment.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2017-12-14 08:47:07 -02:00
Siddhesh Poyarekar 2bce01ebba aarch64: Improve strcmp unaligned performance
Replace the simple byte-wise compare in the misaligned case with a
dword compare with page boundary checks in place.  For simplicity I've
chosen a 4K page boundary so that we don't have to query the actual
page size on the system.

This results in up to 3x improvement in performance in the unaligned
case on falkor and about 2.5x improvement on mustang as measured using
bench-strcmp.

	* sysdeps/aarch64/strcmp.S (misaligned8): Compare dword at a
	time whenever possible.
2017-12-13 18:50:27 +05:30
Joseph Myers 6f7c009282 Add sysdeps/ieee754/soft-fp.
The default sysdeps/ieee754 fma implementations rely on exceptions and
rounding modes to achieve correct results through internal use of
round-to-odd.  Thus, glibc configurations without support for
exceptions and rounding modes instead need to use implementations of
fma based on soft-fp.

At present, this is achieved via having implementation files in
soft-fp/ that are #included by sysdeps files for each glibc
configuration that needs them.  In general this means such a
configuration has its own s_fma.c and s_fmaf.c.

TS 18661-1 adds functions that do an operation (+ - * / sqrt fma) on
arguments wider than the return type, with a single rounding of the
infinite-precision result to that return type.  These are also
naturally implemented using round-to-odd on platforms with hardware
support for rounding modes and exceptions but lacking hardware support
for these narrowing operations themselves.  (Platforms that have
direct hardware support for such narrowing operations include at least
ia64, and Power ISA 2.07 or later, which I think means POWER8 or
later.)

So adding the remaining TS 18661-1 functions would mean at least six
narrowing function implementations (fadd fsub fmul fdiv ffma fsqrt),
with aliases for other types and further implementations in some
configurations, that need to be overridden for configurations lacking
hardware exceptions and rounding modes.  Requiring all such
configurations (currently seven of them) to have their own source
files for all those functions seems undesirable.

Thus, this patch adds a directory sysdeps/ieee754/soft-fp to contain
libm function implementations based on soft-fp.  This directory is
then used via Implies from all the configurations that need it, so no
more files need adding to every such configuration when adding more
functions with soft-fp implementations.  A configuration can still
selectively #include a particular file from this directory if desired;
thus, the MIPS #include of the fmal implementation is retained, since
that's appropriate even for hard float (because long double is always
implementated in software for MIPS64, so the soft-fp implementation of
fmal is better than the ldbl-128 one).

This also provides additional motivation for my recent patch removing
--with-fp / --without-fp: previously there was no need for correct use
of --without-fp for no-FPU ARM or SH3, and now we have autodetection
nofpu/ sysdeps directories can be used by this patch for those
configurations without imposing any new requirements on how glibc is
configured.

(The mips64/*/fpu/s_fma.c files added by this patch are needed to keep
the dbl-64 version of fma for double, rather than the ldbl-128 one,
used in that case.)

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

	* soft-fp/fmadf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fma.c: ... here.
	* soft-fp/fmasf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmaf.c: ... here.
	* soft-fp/fmatf4.c: Move to ....
	* sysdeps/ieee754/soft-fp/s_fmal.c: ... here.
	* sysdeps/ieee754/soft-fp/Makefile: New file.
	* sysdeps/arm/preconfigure.ac: Define with_fp_cond.
	* sysdeps/arm/preconfigure: Regenerated.
	* sysdeps/arm/nofpu/Implies: New file.
	* sysdeps/arm/s_fma.c: Remove file.
	* sysdeps/arm/s_fmaf.c: Likewise.
	* sysdeps/m68k/coldfire/nofpu/Implies: New file.
	* sysdeps/m68k/coldfire/nofpu/s_fma.c: Remove file.
	* sysdeps/m68k/coldfire/nofpu/s_fmaf.c: Likewise.
	* sysdeps/microblaze/Implies: Add ieee754/soft-fp.
	* sysdeps/microblaze/s_fma.c: Remove file.
	* sysdeps/microblaze/s_fmaf.c: Likewise.
	* sysdeps/mips/mips32/nofpu/Implies: New file.
	* sysdeps/mips/mips64/n32/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n32/nofpu/Implies: Likewise.
	* sysdeps/mips/mips64/n64/fpu/s_fma.c: Likewise.
	* sysdeps/mips/mips64/n64/nofpu/Implies: Likewise.
	* sysdeps/mips/ieee754/s_fma.c: Remove file.
	* sysdeps/mips/ieee754/s_fmaf.c: Likewise.
	* sysdeps/mips/ieee754/s_fmal.c: Update include for move of fmal
	implementation.
	* sysdeps/nios2/Implies: Add ieee754/soft-fp.
	* sysdeps/nios2/s_fma.c: Remove file.
	* sysdeps/nios2/s_fmaf.c: Likewise.
	* sysdeps/sh/nofpu/Implies: New file.
	* sysdeps/sh/s_fma.c: Remove file.
	* sysdeps/sh/s_fmaf.c: Likewise.
	* sysdeps/tile/Implies: Add ieee754/soft-fp.
	* sysdeps/tile/s_fma.c: Remove file.
	* sysdeps/tile/s_fmaf.c: Likewise.
2017-12-12 23:35:21 +00:00
H.J. Lu ac817e083b x86-64: Add cosf with FMA
On Skylake, bench-cosf reports performance improvement:

            Before        After         Improvement
max        135.362       94.552            43%
min        8.532         7.688             11%
mean       17.1446       11.8128           45%

	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Add s_cosf-sse2 and s_cosf-fma.
	(CFLAGS-s_cosf-fma.c): New.
	* sysdeps/x86_64/fpu/multiarch/s_cosf-fma.c: New file.
	* sysdeps/x86_64/fpu/multiarch/s_cosf-sse2.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_cosf.c: Likewise.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-12 15:32:58 -08:00
Adhemerval Zanella c80acdc325 Update IA64 libm-test-ulps
Ran on Itanium Processor 9020, GCC 7.2.1.

	* sysdeps/ia64/fpu/libm-test-ulps: Update.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-12 16:57:41 -02:00
James Clarke 89bd8016b3 ia64: Add ipc_priv.h header to set __IPC_64 to zero
When running strace, IPC_64 was set in the command, but ia64 is
an architecture where CONFIG_ARCH_WANT_IPC_PARSE_VERSION *isn't* set
in the kernel, so ipc_parse_version just returns IPC_64 without
clearing the IPC_64 bit in the command.

	* sysdeps/unix/sysv/linux/ia64/ipc_priv.h: New file defining
	__IPC_64 to 0 to avoid IPC_64 being set.

Signed-off-by: James Clarke <jrtc27@jrtc27.com>
2017-12-12 12:19:24 -02:00
Joseph Myers 8df5d34720 Remove --with-fp / --without-fp.
There is a configure option --without-fp that specifies that nofpu
sysdeps directories should be used instead of fpu directories.

For most glibc configurations, this option is of no use: either there
is no valid nofpu variant of that configuration, or there are no fpu
or nofpu sysdeps directories for that processor and so the option does
nothing.  For a few configurations, if you are using a soft-float
compiler this option is required, and failing to use it generally
results in compilation errors from inline asm using unavailable
floating-point instructions.

We're moving away from --with-cpu to configuring glibc based on how
the compiler generates code, and it is natural to do so for
--without-fp as well; in most cases the soft-float and hard-float ABIs
are incompatible so you have no hope of building a working glibc with
an inappropriately configured compiler or libgcc.

This patch eliminates --without-fp, replacing it entirely by automatic
configuration based on the compiler.  Configurations for which this is
relevant (coldfire / mips / powerpc32 / sh) define a variable
with_fp_cond in their preconfigure fragments (under the same
conditions under which those fragments do anything); this is a
preprocessor conditional which the toplevel configure script then uses
in a test to determine which sysdeps directories to use.

The config.make with-fp variable remains.  It's used only by powerpc
(sysdeps/powerpc/powerpc32/Makefile) to add -mhard-float to various
flags variables.  For powerpc, -mcpu= options can imply use of
soft-float.  That could be an issue if you want to build for
e.g. 476fp, but are using --with-cpu=476 because there isn't a 476fp
sysdeps directory.  If in future we eliminate --with-cpu and replace
it entirely by testing the compiler, it would be natural at that point
to eliminate that code as well (as the user should then just use a
compiler defaulting to 476fp and the 476 sysdeps directory would be
used automatically).

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

	* configure.ac (--with-fp): Remove configure option.
	(with_fp_cond): New variable.
	(libc_cv_with_fp): New configure test.  Use this variable instead
	of with_fp.
	* configure: Regenerated.
	* config.make.in (with-fp): Use @libc_cv_with_fp@.
	* manual/install.texi (Configuring and compiling): Remove
	--without-fp.
	* INSTALL: Regenerated.
	* sysdeps/m68k/preconfigure (with_fp_cond): Define for ColdFire.
	* sysdeps/mips/preconfigure (with_fp_cond): Define.
	* sysdeps/powerpc/preconfigure (with_fp_cond): Define for 32-bit.
	* sysdeps/sh/preconfigure (with_fp_cond): Define.
	* scripts/build-many-glibcs.py (Context.add_all_configs): Do not
	use --without-fp to configure glibc.
2017-12-12 13:56:47 +00:00
Paul Clarke f4b2aea6e1 New generic cosf
The same logic used in s_cosf.S version for x86 and powerpc
is used to create a generic s_cosf.c, so there is no performance
improvement in x86_64 and powerpc64.

	* sysdeps/ieee754/flt-32/s_cosf.c: New implementation.
2017-12-11 17:39:42 -02:00
Adhemerval Zanella c9cd7b0ce5 powerpc: POWER8 memcpy optimization for cached memory
On POWER8, unaligned memory accesses to cached memory has little impact
on performance as opposed to its ancestors.

It is disabled by default and will only be available when the tunable
glibc.tune.cached_memopt is set to 1.

                 __memcpy_power8_cached      __memcpy_power7
============================================================
    max-size=4096:     33325.70 ( 12.65%)        38153.00
    max-size=8192:     32878.20 ( 11.17%)        37012.30
   max-size=16384:     33782.20 ( 11.61%)        38219.20
   max-size=32768:     33296.20 ( 11.30%)        37538.30
   max-size=65536:     33765.60 ( 10.53%)        37738.40

	* manual/tunables.texi (Hardware Capability Tunables): Document
	glibc.tune.cached_memopt.
	* sysdeps/powerpc/cpu-features.c: New file.
	* sysdeps/powerpc/cpu-features.h: New file.
	* sysdeps/powerpc/dl-procinfo.c [!IS_IN(ldconfig)]: Add
	_dl_powerpc_cpu_features.
	* sysdeps/powerpc/dl-tunables.list: New file.
	* sysdeps/powerpc/ldsodefs.h: Include cpu-features.h.
	* sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h
	(INIT_ARCH): Initialize use_aligned_memopt.
	* sysdeps/powerpc/powerpc64/dl-machine.h [defined(SHARED &&
	IS_IN(rtld))]: Restrict dl_platform_init availability and
	initialize CPU features used by tunables.
	* sysdeps/powerpc/powerpc64/multiarch/Makefile (sysdep_routines):
	Add memcpy-power8-cached.
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Add
	__memcpy_power8_cached.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy.c: Likewise.
	* sysdeps/powerpc/powerpc64/multiarch/memcpy-power8-cached.S:
	New file.

Reviewed-by: Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
2017-12-11 17:39:42 -02:00
Stefan Liebler dee943668f S390: Add CFI rule in _dl_runtime_resolve[_vx] for unwinding.
In _dl_runtime_resolve[_vx], unwinding fails after the new stack frame
is created as there is no CFI rule for r15. This is also observeable in
GDB: Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Therefore this patch is now storing r15 on stack and is using cfi_offset rule.
The stmg/lmg instruction is used to store/load r14 and r15 with one instruction.
On 64bit, the offsets of the fprs have moved to store r15 directly after r14.
On 31bit, the r14/r15 is now stored between the other gprs and fprs as the space
wasn't used.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
	Store r15 on stack and add cfi rule.
	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
	Likewise.
2017-12-11 08:47:51 +01:00
H.J. Lu 9d0ffa60ad x86-64: Add sinf with FMA
On Skylake, bench-sinf reports performance improvement:

            Before        After         Improvement
max        153.996       100.094           54%
min        8.546         6.852             25%
mean       18.1223       11.802            54%

	* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
	Add s_sinf-sse2 and s_sinf-fma.
	(CFLAGS-s_sinf-fma.c): New.
	* sysdeps/x86_64/fpu/multiarch/s_sinf-fma.c: New file.
	* sysdeps/x86_64/fpu/multiarch/s_sinf-sse2.c: Likewise.
	* sysdeps/x86_64/fpu/multiarch/s_sinf.c: Likewise.
2017-12-07 10:11:16 -08:00
H.J. Lu 9574c7b68d x86-64: Remove sysdeps/x86_64/fpu/s_sinf.S
On Ivy Bridge, bench-sinf reports performance improvement:

          s_sinf.S      s_sinf.c       Improvement
max        91.521        86.148            6%
min        14.061        11.265            25%
mean       23.3758       23.3344           0.2%

	* sysdeps/x86_64/fpu/s_sinf.S: Removed.
2017-12-07 09:44:17 -08:00
Joseph Myers 1f9055ce04 Add _Float32 function aliases.
This patch concludes filling out TS 18661-3 support for different
types by adding *f32 function aliases of float functions to support
_Float32.  As with _Float64 and _Float32x, this is supported for all
glibc configurations.  As with the previous such patches there are
some x86 ulps updates because of inline functions present for float
but not for _Float32.  The patch also has the usual
bits/floatn-common.h update, symbol versions, ABI baselines updates,
test enablement and documentation.

Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.

	* bits/floatn-common.h (__HAVE_FLOAT32): Define to 1.
	* manual/math.texi (Mathematics): Document support for _Float32.
	* math/Makefile (test-types): Add float32.
	* math/Versions (GLIBC_2.27): Add _Float32 functions.
	* stdlib/Versions (GLIBC_2.27): Likewise.
	* wcsmbs/Versions (GLIBC_2.27): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.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/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.

	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.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/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-12-07 00:48:31 +00:00
Joseph Myers 26007a2f68 Support _Float32 in libm_alias_float.
This patch makes the libm_alias_float macro support creating _Float32
aliases, in preparation for enabling glibc support for that type.

Tested for x86_64; also tested with build-many-glibcs.py in
conjunction with other _Float32 changes.

	* sysdeps/generic/libm-alias-float.h: Include <bits/floatn.h>.
	[__HAVE_FLOAT32 && !__HAVE_DISTINCT_FLOAT32]
	(libm_alias_float_other_r): Create f32 alias.
	(libm_alias_float_r): Use semicolon before call to
	libm_alias_float_other_r.
2017-12-06 22:14:09 +00:00
Joseph Myers c191f64cd5 Correct some ia64 libm_alias_float_other calls.
This patch corrects three ia64 libm_alias_float_other calls so they
generate the intended _Float32 aliases when such aliases are enabled.

Tested with build-many-glibcs.py for ia64-linux-gnu (that installed
stripped shared libraries are unchanged when applied to current
sources, and that this enables compilation tests to pass when used in
conjunction with other _Float32 patches).

	* sysdeps/ia64/fpu/e_exp2f.S (__exp2f): Use exp2 not __exp2 as
	second argument to libm_alias_float_other.
	* sysdeps/ia64/fpu/e_log2f.S (__log2f): Use log2 not __log2 as
	second argument to libm_alias_float_other.
	* sysdeps/ia64/fpu/e_powf.S (__powf): Use pow not __pow as second
	argument to libm_alias_float_other.
2017-12-06 21:50:32 +00:00
Adhemerval Zanella d73fac82be Update Alpha libm-test-ulps
* sysdeps/alpha/fpu/libm-test-ulps: Update.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-06 18:55:09 -02:00
David S. Miller 7ec094e801 Sparc ulp update.
* sysdeps/sparc/fpu/libm-test-ulps: Update
	exp_{downward,towardzero,upward} ulps.
2017-12-06 12:18:51 -08:00
Joseph Myers 1dbe6f64ab Don't make local variables static in ldbl-96 j1l.
The ldbl-96 implementation of j1l has some function-local variables
that are declared static for no apparent reason (this dates back to
the first addition of that file).

Any vaguely recent compiler, probably including any that are supported
for building glibc, optimizes away the "static" here, as the values of
the variables on entry to the function are dead.  So there is not
actually a user-visible bug here at present (but with any compilers
that didn't optimize away the static at all, possibly building with
less or no optimization, so that the function stored intermediate
values to and then loaded them from the variables, there would have
been a thread-safety issue).  But the "static" clearly doesn't belong
there and might potentially make things unsafe were compilation
without optimization to be supported in future, so this patch removes
it.

Tested for x86_64.

	* sysdeps/ieee754/ldbl-96/e_j1l.c (qone): Don't make local
	variables static.
2017-12-06 15:19:06 +00:00
Joseph Myers 53994f1263 Make some ldbl-128, ldbl-128ibm arrays const.
I noticed that an x86_64 build of libm unexpectedly contained more
non-constant data than an older version (before _Float128 support)
did.  The problem is non-const arrays in the ldbl-128 j0l and j1l
implementations; this patch makes those arrays, and the corresponding
ldbl-128ibm ones, const.

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

	* sysdeps/ieee754/ldbl-128/e_j0l.c (Y0_2N): Make const.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j0l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j1l.c (Y0_2N): Likewise.
	(Y0_2D): Likewise.
2017-12-06 13:42:58 +00:00
Joseph Myers 0d93b7fd7c Add _Float64, _Float32x function aliases.
This patch continues filling out TS 18661-3 support by adding *f64 and
*f32x function aliases, supporting _Float64 and _Float32x, as aliases
for double functions.  These types are supported for all glibc
configurations.  The API corresponds exactly to that for _Float128 and
_Float64x.  _Float32 aliases to float functions remain to be added in
subsequent patches to complete this process (then there are a few
miscellaneous functions in TS 18661-3 to implement that aren't simply
versions of existing functions for new types).

The patch enables the feature in bits/floatn-common.h, adds symbol
versions and documentation with updates to ABI baselines, and arranges
for the libm functions for the new types to be tested.  As with the
_Float64x changes there are some x86 ulps updates because of header
inlines not used for the new types (and one other change to the
non-multiarch libm-test-ulps, which I suppose comes from using a
different compiler version / configuration from when it was last
regenerated).

Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.

	* bits/floatn-common.h (__HAVE_FLOAT64): Define to 1.
	(__HAVE_FLOAT32X): Likewise.
	* manual/math.texi (Mathematics): Document support for _Float64
	and _Float32x.
	* math/Makefile (test-types): Add float64 and float32x.
	* math/Versions (GLIBC_2.27): Add _Float64 and _Float32x
	functions.
	* stdlib/Versions (GLIBC_2.27): Likewise.
	* wcsmbs/Versions (GLIBC_2.27): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
	* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libm.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/nios2/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.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/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Likewise.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-12-06 00:58:03 +00:00
Rogerio Alves 07ed18d26a Add elision tunables
This patch adds several new tunables to control the behavior of
elision on supported platforms[1].   Since elision now depends
on tunables, we should always *compile* with elision enabled,
and leave the code disabled, but available for runtime
selection.  This gives us *much* better compile-time testing of
the existing code to avoid bit-rot[2].

Tested on ppc, ppc64, ppc64le, s390x and x86_64.

[1] This part of the patch was initially proposed by
Paul Murphy but was "staled" because the framework have changed
since the patch was originally proposed:

https://patchwork.sourceware.org/patch/10342/

[2] This part of the patch was inititally proposed as a RFC by
Carlos O'Donnell.  Make sense to me integrate this on the patch:

https://sourceware.org/ml/libc-alpha/2017-05/msg00335.html

	* elf/dl-tunables.list: Add elision parameters.
	* manual/tunables.texi: Add entries about elision tunable.
	* sysdeps/unix/sysv/linux/powerpc/elision-conf.c:
	Add callback functions to dynamically enable/disable elision.
	Add multiple callbacks functions to set elision parameters.
	Deleted __libc_enable_secure check.
	* sysdeps/unix/sysv/linux/s390/elision-conf.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/elision-conf.c: Likewise.
	* configure: Regenerated.
	* configure.ac: Option enable_lock_elision was deleted.
	* config.h.in: ENABLE_LOCK_ELISION flag was deleted.
	* config.make.in: Remove references to enable_lock_elision.
	* manual/install.texi: Elision configure option was removed.
	* INSTALL: Regenerated to remove enable_lock_elision.
	* nptl/Makefile:
	Disable elision so it can verify error case for destroying a mutex.
	* sysdeps/powerpc/nptl/elide.h:
	Cleanup ENABLE_LOCK_ELISION check.
	Deleted macros for the case when ENABLE_LOCK_ELISION was not defined.
	* sysdeps/s390/configure: Regenerated.
	* sysdeps/s390/configure.ac: Remove references to enable_lock_elision..
	* nptl/tst-mutex8.c:
	Deleted all #ifndef ENABLE_LOCK_ELISION from the test.
	* sysdeps/powerpc/powerpc32/sysdep.h:
	Deleted all ENABLE_LOCK_ELISION checks.
	* sysdeps/powerpc/powerpc64/sysdep.h: Likewise.
	* sysdeps/powerpc/sysdep.h: Likewise.
	* sysdeps/s390/nptl/bits/pthreadtypes-arch.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/force-elision.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/elision-conf.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/force-elision.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/lowlevellock.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/Makefile: Remove references to
	enable-lock-elision.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
2017-12-05 17:48:48 -02:00
Adhemerval Zanella 94d80dfc73 math: Use sign as double for reduced case in sinf
This patch avoid an extra floating point to integer conversion in
reduced internal function for generic sinf by defining the sign as
double instead of integers.

There is no much difference on Haswell with GCC 7.2.1:

           Before        After
min          9.11        9.108
mean       21.982      21.9224

However H.J. Lu reported gains on Skylake:

Before:

  "sinf": {
   "": {
    "duration": 3.4044e+10,
    "iterations": 1.9942e+09,
    "max": 141.106,
    "min": 7.704,
    "mean": 17.0715
   }
  }

After:

  "sinf": {
   "": {
    "duration": 3.40665e+10,
    "iterations": 2.03199e+09,
    "max": 95.994,
    "min": 7.704,
    "mean": 16.765
   }
  }

Checked on x86_64-linux-gnu.

	* sysdeps/ieee754/flt-32/s_sinf.c (ones): Define as double.
	(reduced): Use ones as double instead of integer.
2017-12-05 16:27:44 -02:00
Szabolcs Nagy 00d54af7c8 [PATCH] fix sinf(NAN)
sinf(NAN) should not signal invalid fp exception
so use isless instead of < where NAN is compared.

this makes the sinf tests pass on aarch64.

	* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Use isless.
2017-12-05 18:09:22 +00:00
Joseph Myers f2d64d621e Support _Float64, _Float32x in libm_alias_double.
This patch makes the libm_alias_double macros support creating
_Float64 and _Float32x aliases, in preparation for enabling glibc
support for those types.

Tested for x86_64; also tested with build-many-glibcs.py in
conjunction with other _Float64 / _Float32x changes.

	* sysdeps/generic/libm-alias-double.h: Include <bits/floatn.h>.
	(libm_alias_double_other_r_f64): New macro.
	(libm_alias_double_other_r_f32x): Likewise.
	(libm_alias_double_other_r): Use libm_alias_double_other_r_f64 and
	libm_alias_double_other_r_f32x.
	(libm_alias_double_r): Use semicolon before call to
	libm_alias_double_other_r.
	* sysdeps/ieee754/ldbl-opt/libm-alias-double.h: Include
	<bits/floatn.h>.
	(libm_alias_double_other_r_f64): New macro.
	(libm_alias_double_other_r_f32x): Likewise.
	(libm_alias_double_other_r): Use libm_alias_double_other_r_f64 and
	libm_alias_double_other_r_f32x.
2017-12-05 17:00:57 +00:00
H.J. Lu 91c318e7b9 s_sinf.c: Replace floor with simple casts
Since s_sinf.c either assigns the return value of floor to integer or
passes double converted from integer to floor, this patch replaces
floor with simple casts.

Also since long == int for 32-bit targets, we can use long instead of
int to avoid 64-bit integer for 64-bit targets.

On Skylake, bench-sinf reports performance improvement:

           Before        After         Improvement
max        130.566       129.564           30%
min        7.704         7.706             0%
mean       21.8188       19.1363           30%

	* sysdeps/ieee754/flt-32/s_sinf.c (reduced): Replace long with
	int.
	(SINF_FUNC): Likewise.  Replace floor with simple casts.
2017-12-05 08:47:27 -08:00
Chris Metcalf c7e882b705 tilegx: tag __insn_OP builtin issue with gcc bugzilla # 2017-12-05 11:36:26 -05:00
Chris Metcalf f18b8dc7d7 tilegx: work around vector insn bug in gcc
Avoid an issue in gcc where some of the vector (aka SIMD) ops will
sometimes end up getting wrongly optimized out.  We use these
instructions in many of the string implementations.  If/when we
have an upstreamed fix for this problem in gcc we can conditionalize
the use of the extended assembly workaround in glibc.
2017-12-05 10:24:56 -05:00
Florian Weimer 446d22e91d Linux: Implement interfaces for memory protection keys
This adds system call wrappers for pkey_alloc, pkey_free, pkey_mprotect,
and x86-64 implementations of pkey_get and pkey_set, which abstract over
the PKRU CPU register and hide the actual number of memory protection
keys supported by the CPU.  pkey_mprotect with a -1 key is implemented
using mprotect, so it will work even if the kernel does not support the
pkey_mprotect system call.

The system call wrapers use unsigned int instead of unsigned long for
parameters, so that no special treatment for x32 is needed.  The flags
argument is currently unused, and the access rights bit mask is limited
to two bits by the current PKRU register layout anyway.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2017-12-05 15:20:35 +01:00
Joseph Myers 216933b242 Use libm_alias_float for powerpc.
Continuing the preparation for additional _FloatN / _FloatNx function
aliases, this patch makes powerpc libm function implementations use
libm_alias_float to define function aliases.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged for all its hard-float powerpc configurations.

	* sysdeps/powerpc/fpu/s_cosf.c: Include <libm-alias-float.h>.
	(cosf): Define using libm_alias_float.
	* sysdeps/powerpc/fpu/s_fabs.S: Include <libm-alias-float.h>.
	(fabsf): Define using libm_alias_float.
	* sysdeps/powerpc/fpu/s_fmaf.S: Include <libm-alias-float.h>.
	(fmaf): Define using libm_alias_float.
	* sysdeps/powerpc/fpu/s_rintf.c: Include <libm-alias-float.h>.
	(rintf): Define using libm_alias_float.
	* sysdeps/powerpc/fpu/s_sinf.c: Include <libm-alias-float.h>.
	(sinf): Define using libm_alias_float.
	* sysdeps/powerpc/power5+/fpu/s_modff.c: Include
	<libm-alias-float.h>.
	(modff): Define using libm_alias_float.
	* sysdeps/powerpc/power7/fpu/s_logbf.c: Include
	<libm-alias-float.h>.
	(logbf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_ceilf.S: Include
	<libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Include
	<libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_floorf.S: Include
	<libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_lrint.S: Include
	<libm-alias-float.h>.
	(lrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_lround.S: Include
	<libm-alias-float.h>.
	(lroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S: Include
	<libm-alias-float.h>.
	(nearbyintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_rintf.S: Include
	<libm-alias-float.h>.
	(rintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_roundf.S: Include
	<libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/fpu/s_truncf.S: Include
	<libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf.c:
	Include <libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c:
	Include <libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_floorf.c:
	Include <libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrintf.c:
	Include <libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llroundf.c:
	Include <libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logbf.c:
	Include <libm-alias-float.h>.
	(logbf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrintf.c:
	Include <libm-alias-float.h>.
	(lrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lroundf.c:
	Include <libm-alias-float.h>.
	(lroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_modff.c:
	Include <libm-alias-float.h>.
	(modff): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf.c:
	Include <libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf.c:
	Include <libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llrintf.S: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S: Include
	<libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_floorf.S: Include
	<libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S: Include
	<libm-alias-float.h>.
	(lroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_roundf.S: Include
	<libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_truncf.S: Include
	<libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S: Include
	<libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llrintf.S: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power6x/fpu/s_lrint.S: Include
	<libm-alias-float.h>.
	(lrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S: Include
	<libm-alias-float.h>.
	(lroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c: Include
	<libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c: Include
	<libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_cosf.c: Include
	<libm-alias-float.h>.
	(cosf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_floorf.c: Include
	<libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrintf.c: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llroundf.c: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logbf.c: Include
	<libm-alias-float.h>.
	(logbf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_modff.c: Include
	<libm-alias-float.h>.
	(modff): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c: Include
	<libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_sinf.c: Include
	<libm-alias-float.h>.
	(sinf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c: Include
	<libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Include
	<libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Include
	<libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_floorf.S: Include
	<libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_llroundf.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Include
	<libm-alias-float.h>.
	(nearbyintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Include
	<libm-alias-float.h>.
	(rintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Include
	<libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Include
	<libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Include
	<libm-alias-float.h>.
	(ceilf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S: Include
	<libm-alias-float.h>.
	(floorf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S: Include
	<libm-alias-float.h>.
	(roundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S: Include
	<libm-alias-float.h>.
	(truncf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Include
	<libm-alias-float.h>.
	(copysignf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_cosf.S: Include
	<libm-alias-float.h>.
	(cosf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Include
	<libm-alias-float.h>.
	(llrintf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Include
	<libm-alias-float.h>.
	(llroundf): Define using libm_alias_float.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_sinf.S: Include
	<libm-alias-float.h>.
	(sinf): Define using libm_alias_float.
2017-12-05 00:26:26 +00:00
Chris Metcalf 2e49fed84c tile: update ca{cos,sin,tan}{,h} double ULPs 2017-12-04 12:31:20 -05:00
Joseph Myers 73895b499b Use __floor not floor in sinf.
The new sinf implementation introduced localplt failures for all
platforms where the compiler did not inline the calls to floor
(converted to trunc by machine-independent optimizations).  This patch
changes the calls to use __floor as normal in libm.

We can't use the public function names floor / floorf / floorl /
floorf128 in libm code in the absence of appropriate asms to redirect
floor/trunc calls, if not inlined, to use the internal names instead
(while avoiding breaking code building the floor functions themselves)
- while having such asms and then calling the public functions
unconditionally would be desirable for optimization (few architectures
have __floor inlines in math_private.h, and once the built-in function
is used you don't need them), using __floor is the minimum safe fix
for the present test regressions.

Tested with build-many-glibcs.py that this fixes the localplt test
failure for arm-linux-gnueabi.

	* sysdeps/ieee754/flt-32/s_sinf.c (SINF_FUNC): Use __floor instead
	of floor.
2017-12-04 16:58:08 +00:00
Siddhesh Poyarekar 4c1d801a59 aarch64: Avoid hidden symbols for memcpy/memmove into static binaries
The __GI_* symbol aliases for __memcpy_generic are unnecessary since
they're never used.  Add them only for libc.so to avoid PLT.  Maybe
some time in future we need to evaluate the relative cost of PLT vs
gains from multiarch memcpy implementations and take a call on whether
to drop this completely.

	* sysdeps/aarch64/multiarch/memcpy_generic.S (__GI_memcpy):
	Define only for libc.so.
2017-12-04 21:17:17 +05:30
Stefan Liebler 478593e637 S390: Fix backtrace in vdso functions.
On s390, GDB fails to show the complete backtrace from within vdso functions.
The macro INTERNAL_VSYSCALL_CALL saves the return address in r14 to r10
before branching to the vdso function. The branch-instruction updates r14
in order to let the vdso function return. Then the original address in r14 is
restored from r10. Unfortunately, there are no cfi-rules and GDB fails.

Furthermore the call of the vdso function does not comply with the s390 ABI
as no stack-frame for the vdso-function is generated.

This patch removes the s390 specific macro INTERNAL_VSYSCALL_CALL
and the common implementation in sysdeps/unix/sysv/linux/sysdep-vdso.h is used.
Then the vdso function is called via function-pointer and GCC generates a
new stack-frame and emits all needed cfi-rules.

The defines CLOBBER_[0-6] are removed as they  were only used in macro
INTERNAL_VSYSCALL_CALL.

The macro INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK is not used on s390.
The only user is power. Thus it is removed from s390 sysdep.h.

ChangeLog:

	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
	(INTERNAL_VSYSCALL_CALL, CLOBBER_0, CLOBBER_1, CLOBBER_2,
	 CLOBBER_3, CLOBBER_4, CLOBBER_5, CLOBBER_6,
	INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
2017-12-04 16:40:13 +01:00
Rajalakshmi Srinivasaraghavan 7863a71181 New generic sinf
This implementation is based on optimized sinf assembly versions
of x86_64 and powerpc.
2017-12-04 10:12:10 +05:30
John David Anglin b3f7fb12f5 Handle __gmon_start__ as undefined weak on hppa.
[BZ libc/19170]
	* sysdeps/hppa/crti.S: Declare PREINIT_FUNCTION weak_extern when
	PREINIT_FUNCTION_WEAK is nonzero.
	(gmon_initializer): New function.  Put procedure label for it in
	.init_array section.
	(_init): Don't call PREINIT_FUNCTION.
	* sysdeps/hppa/crtn.S (__gmon_start__): Remove.
	* sysdeps/hppa/dl-lookupcfg.h (DL_FIXUP_MAKE_VALUE): Create null fixup
	value when map argument is null.
2017-12-02 14:43:28 -05:00
John David Anglin 800a496acb Improve PIC pc-relative instruction sequences on hppa.
* sysdeps/hppa/dl-fptr.c (elf_machine_resolve): Remove unnecessary
	depi instruction from PIC pc-relative sequence.
	* sysdeps/hppa/dl-fptr.h (ELF_MACHINE_LOAD_ADDRESS): Likewise.
	* sysdeps/hppa/dl-machine.h (elf_machine_dynamic): Likewise.
	(elf_machine_load_address): Likewise.
	(elf_machine_runtime_setup): Likewise.
2017-12-02 11:04:16 -05:00
Joseph Myers d17542d235 Use libm_alias_double for remaining powerpc functions.
Continuing the preparation for additional _FloatN / _FloatNx function
aliases, this patch makes the remaining double powerpc functions use
libm_alias_double to define function aliases (with consequent removal
of the need for local compat symbol handling).  Previous cleanups
avoid this patch changing installed stripped shared libraries for any
build-many-glibcs.py configuration (there are still some functions in
this patch for which the order of double and float aliases changes
within an individual source file, but in this case this doesn't result
in changes to the final library).

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged for all its hard-float powerpc configurations.

	* sysdeps/powerpc/power7/fpu/s_logb.c: Include
	<libm-alias-double.h>.
	(logb): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/fpu/s_copysign.S: Include
	<libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/fpu/s_llround.c: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/fpu/s_lrint.S: Include
	<libm-alias-double.h>.
	(lrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/fpu/s_lround.S: Include
	<libm-alias-double.h>.
	(lround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c:
	Include <libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llrint.c:
	Include <libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_llround.c:
	Include <libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb.c: Include
	<libm-alias-double.h>.
	(logb): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lrint.c:
	Include <libm-alias-double.h>.
	(lrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_lround.c:
	Include <libm-alias-double.h>.
	(lround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llrint.S: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power5+/fpu/s_lround.S: Include
	<libm-alias-double.h>.
	(lround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S: Include
	<libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llrint.S: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power6/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power6x/fpu/s_lrint.S: Include
	<libm-alias-double.h>.
	(lrint): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc32/power6x/fpu/s_lround.S: Include
	<libm-alias-double.h>.
	(lround): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Include
	<libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llrint.c: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	(lrint): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	(lround): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb.c: Include
	<libm-alias-double.h>.
	(logb): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Include
	<libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	(lrint): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	(lround): Likewise.
	* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	(lround): Likewise.
	* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Include
	<libm-alias-double.h>.
	(copysign): Define using libm_alias_double.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	(lrint): Likewise.
	* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	(lround): Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Include
	<libm-alias-double.h>.
	(llrint): Define using libm_alias_double.
	(lrint): Likewise.
	* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Include
	<libm-alias-double.h>.
	(llround): Define using libm_alias_double.
	(lround): Likewise.
2017-12-02 00:11:37 +00:00
Joseph Myers 0ddde474db Define powerpc64 lroundl compat symbol only once.
sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c defines the
lroundl compat symbol, version GLIBC_2_1, twice, once based on llround
and once based on __lround.  Those are aliases for each other (llround
weak, __lround strong), but defining it twice does not make sense.
This patch changes it to define the compat symbol once only, matching
how libm_alias_double defines it.

Tested with build-many-glibcs.py for its powerpc64 configurations.

	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_llround.c
	[LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)] (lroundl): Do not define
	compat symbol based on llround.
2017-12-01 23:58:05 +00:00
Joseph Myers 0d5ba561c1 Base powerpc logbl compat symbols on __logb not logb.
Some powerpc logb implementations define a compat symbol for logbl
based on logb, whereas libm_alias_double defines such a compat symbol
based on __logb instead.  This difference (logb is weak, __logb isn't)
is enough to result in different installed stripped shared libraries.
The difference in the installed libraries isn't significant, but first
changing the compat_symbol calls helps make it possible to validate a
subsequent change to use libm_alias_double by comparison of libraries,
so this patch does such a preliminary change.

Tested with build-many-glibcs.py for all its hard-float powerpc
configurations.

	* sysdeps/powerpc/power7/fpu/s_logb.c
	[LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)] (logbl): Define as compat
	symbol based on __logb, not on logb.
	* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_logb.c
	[LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)] (logbl): Likewise.
	* sysdeps/powerpc/powerpc64/fpu/multiarch/s_logb.c
	[LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)] (logbl): Likewise.
2017-12-01 23:37:46 +00:00