platform/upstream/glibc.git
8 years agopowerpc: Add a POWER8-optimized version of expf()
Tulio Magno Quites Machado Filho [Mon, 27 Jun 2016 19:03:10 +0000 (16:03 -0300)]
powerpc: Add a POWER8-optimized version of expf()

This implementation is based on the one already used at
sysdeps/x86_64/fpu/e_expf.S.

This implementation improves the performance by ~14% on average in synthetic
benchmarks at the cost of decreasing accuracy to 1 ULP.

8 years agohppa: fix loading of global pointer in _start [BZ #20277]
John David Anglin [Tue, 21 Jun 2016 22:35:22 +0000 (18:35 -0400)]
hppa: fix loading of global pointer in _start [BZ #20277]

The patched change fixes a regression for executables compiled with the
-p option and linked with gcrt1.o.  The executables crash on startup.

This regression was introduced in 2.22 and was noticed in the gcc testsuite.

8 years agoCheck Prefer_ERMS in memmove/memcpy/mempcpy/memset
H.J. Lu [Thu, 30 Jun 2016 14:57:07 +0000 (07:57 -0700)]
Check Prefer_ERMS in memmove/memcpy/mempcpy/memset

Although the Enhanced REP MOVSB/STOSB (ERMS) implementations of memmove,
memcpy, mempcpy and memset aren't used by the current processors, this
patch adds Prefer_ERMS check in memmove, memcpy, mempcpy and memset so
that they can be used in the future.

* sysdeps/x86/cpu-features.h (bit_arch_Prefer_ERMS): New.
(index_arch_Prefer_ERMS): Likewise.
* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Return
__memcpy_erms for Prefer_ERMS.
* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
(__memmove_erms): Enabled for libc.a.
* ysdeps/x86_64/multiarch/memmove.S (__libc_memmove): Return
__memmove_erms or Prefer_ERMS.
* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Return
__mempcpy_erms for Prefer_ERMS.
* sysdeps/x86_64/multiarch/memset.S (memset): Return
__memset_erms for Prefer_ERMS.

8 years agoReturn proper status from _nss_nis_initgroups_dyn (bug 20262)
Andreas Schwab [Thu, 16 Jun 2016 10:44:29 +0000 (12:44 +0200)]
Return proper status from _nss_nis_initgroups_dyn (bug 20262)

8 years agoCorrect bug number in ChangeLog [BZ #18960]
Florian Weimer [Thu, 30 Jun 2016 09:43:58 +0000 (11:43 +0200)]
Correct bug number in ChangeLog [BZ #18960]

This updates commit 5fa268239b46e127f941c3510ad200ce5ef8df45.

8 years agoCompile tst-cleanupx4 test with -fexceptions
H.J. Lu [Thu, 30 Jun 2016 03:24:30 +0000 (20:24 -0700)]
Compile tst-cleanupx4 test with -fexceptions

tst-cleanupx4 is linked with tst-cleanupx4.o and tst-cleanup4aux.o.
Since tst-cleanupx4.o is compiled from tst-cleanup4.c with -fexceptions,
tst-cleanup4aux.c should also be compiled with -fexceptions.

Tested on x86-64 and i686.

[BZ #18645]
* nptl/Makefile (extra-test-objs): Add tst-cleanupx4aux.o.
(test-extras): Add tst-cleanupx4aux.
(CFLAGS-tst-cleanupx4aux.c): New.  Set to -fexceptions.
($(objpfx)tst-cleanupx4): Replace tst-cleanup4aux.o with
tst-cleanupx4aux.o.
* nptl/tst-cleanupx4aux.c: New file.

8 years agoi686/multiarch: Regenerate ulps
Aurelien Jarno [Wed, 29 Jun 2016 22:31:11 +0000 (00:31 +0200)]
i686/multiarch: Regenerate ulps

This comes from running “make regen-ulps” on AMD Opteron 6272 CPUs.

Changelog:
* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Regenerated.

8 years agoAvoid array-bounds warning for strncat on i586 (bug 20260)
Andreas Schwab [Tue, 28 Jun 2016 10:54:59 +0000 (12:54 +0200)]
Avoid array-bounds warning for strncat on i586 (bug 20260)

8 years agoelf.h: Add declarations for BPF
Richard Henderson [Mon, 20 Jun 2016 22:49:32 +0000 (15:49 -0700)]
elf.h: Add declarations for BPF

The EM_BPF number has been officially assigned, though it
has not yet been posted to the gabi webpage yet.

        * elf/elf.h (EM_BPF): New.
        (EM_NUM): Update.
        (R_BPF_NONE, R_BPF_MAP_FD): New.

8 years agoelf.h: Sync with the gabi webpage
Richard Henderson [Mon, 20 Jun 2016 22:06:48 +0000 (15:06 -0700)]
elf.h: Sync with the gabi webpage

  http://www.sco.com/developers/gabi/latest/ch4.eheader.html

Retrieved 2016-06-20.

        * elf/elf.h (EM_IAMCU, EM_SPU, EM_PDP10, EM_PDP11, EM_ARC_COMPACT,
        EM_VIDEOCORE, EM_TMM_GPP, EM_NS32K, EM_TPC, EM_SNP1K, EM_ST200,
        EM_IP2K, EM_MAX, EM_CR, EM_F2MC16, EM_MSP430, EM_BLACKFIN, EM_SE_C33,
        EM_SEP, EM_ARCA, EM_UNICORE, EM_EXCESS, EM_DXP, EM_ALTERA_NIOS2,
        EM_CRX, EM_XGATE, EM_C166, EM_M16C, EM_DSPIC30F, EM_CE, EM_M32C,
        EM_TSK3000, EM_RS08, EM_SHARC, EM_ECOG2, EM_SCORE7, EM_DSP24,
        EM_VIDEOCORE3, EM_LATTICEMICO32, EM_SE_C17, EM_TI_C6000, EM_TI_C2000,
        EM_TI_C5500, EM_TI_ARP32, EM_TI_PRU, EM_MMDSP_PLUS, EM_CYPRESS_M8C,
        EM_R32C, EM_TRIMEDIA, EM_QDSP6, EM_8051, EM_STXP7X, EM_NDS32,
        EM_ECOG1X, EM_MAXQ30, EM_XIMO16, EM_MANIK, EM_CRAYNV2, EM_RX,
        EM_METAG, EM_MCST_ELBRUS, EM_ECOG16, EM_CR16, EM_ETPU, EM_SLE9X,
        EM_L10M, EM_K10M, EM_AVR32, EM_STM8, EM_TILE64, EM_CUDA,
        EM_CLOUDSHIELD, EM_COREA_1ST, EM_COREA_2ND, EM_ARC_COMPACT2,
        EM_OPEN8, EM_RL78, EM_VIDEOCORE5, EM_78KOR, EM_56800EX, EM_BA1,
        EM_BA2, EM_XCORE, EM_MCHP_PIC, EM_KM32, EM_KMX32, EM_EMX16, EM_EMX8,
        EM_KVARC, EM_CDP, EM_COGE, EM_COOL, EM_NORC, EM_CSR_KALIMBA, EM_Z80,
        EM_VISIUM, EM_FT32, EM_MOXIE, EM_AMDGPU, EM_RISCV): New.
        (EM_NUM): Update.

8 years agoS390: Fix relocation of _nl_current_LC_CATETORY_used in static build. [BZ #19860]
Stefan Liebler [Tue, 28 Jun 2016 10:23:35 +0000 (12:23 +0200)]
S390: Fix relocation of _nl_current_LC_CATETORY_used in static build. [BZ #19860]

With shared libc, all locale categories are always loaded.
For static libc they aren't, but there exist a weak
_nl_current_LC_CATEGORY_used symbol for each category.
If the category is used, the locale/lc-CATEGORY.o is linked in
where _NL_CURRENT_DEFINE (LC_CATEGORY) defines and sets the
_nl_current_LC_CATEGORY_used symbol to one.

As reported by Marcin
"Bug 18960 - s390: _nl_locale_subfreeres uses larl opcode on misaligned symbol"
(https://sourceware.org/bugzilla/show_bug.cgi?id=18960)
In function _nl_locale_subfreeres (locale/setlocale.c) for each category
a check - &_nl_current_LC_CATEGORY_used != 0 - decides whether the category
is used or not.
There is also a second usage with the same mechanism in function __uselocale
(locale/uselocale.c).

On s390 a larl instruction with R_390_PC32DBL relocation is used to
get the address of _nl_current_LC_CATEGORY_used symbols. As larl loads the
address relative in halfwords and the code is always 2-byte aligned,
larl can only load even addresses.
At the end, the relocated address is always zero and never one.

Marcins patch (see bugzilla) uses the following declaration in locale/setlocale.c:
extern char _nl_current_##category##_used __attribute__((__aligned__(1)));
In function _nl_locale_subfreeres all categories are checked and therefore gcc
is now building an array of addresses in rodata section with an R_390_64
relocation for every address. This array is loaded with larl instruction and
each address is accessed by index.
This fixes only the usage in _nl_locale_subfreeres. Each user has to add the
alignment attribute.

This patch set the _nl_current_LC_CATEGORY_used symbols to two instead of one.
This way gcc can use larl instruction and the check against zero works on
every usage.

ChangeLog:

[BZ #19860]
* locale/localeinfo.h (_NL_CURRENT_DEFINE):
Set _nl_current_LC_CATEGORY_used to two instead of one.

8 years agoMIPS: run tst-mode-switch-{1,2,3}.c using test-skeleton.c
Aurelien Jarno [Mon, 27 Jun 2016 14:45:45 +0000 (16:45 +0200)]
MIPS: run tst-mode-switch-{1,2,3}.c using test-skeleton.c

For some reasons I have not investigated yet, tst-mode-switch-1 hangs on
a MIPS UTM-8 machine running an o32 userland and a 3.6.1 kernel.

This patch changes the test so that it runs under the test-skeleton
framework, causing the test to fail after a timeout instead of hanging
the whole testsuite. At the same time, also change the tst-mode-switch-2
and tst-mode-switch-3 tests.

Changelog:
* sysdeps/mips/tst-mode-switch-1.c (main): Converted to ...
(do_test): ... this.
(TEST_FUNCTION): New macro.
 Include test-skeleton.c.
* sysdeps/mips/tst-mode-switch-2.c (main): Likewise.
* sysdeps/mips/tst-mode-switch-3.c (main): Likewise.

8 years agoAvoid "inexact" exceptions in i386/x86_64 trunc functions (bug 15479).
Joseph Myers [Mon, 27 Jun 2016 17:26:52 +0000 (17:26 +0000)]
Avoid "inexact" exceptions in i386/x86_64 trunc functions (bug 15479).

As discussed in
<https://sourceware.org/ml/libc-alpha/2016-05/msg00577.html>, TS
18661-1 disallows ceil, floor, round and trunc functions from raising
the "inexact" exception, in accordance with general IEEE 754 semantics
for when that exception is raised.  Fixing this for x87 floating point
is more complicated than for the other versions of these functions,
because they use the frndint instruction that raises "inexact" and
this can only be avoided by saving and restoring the whole
floating-point environment.

As I noted in
<https://sourceware.org/ml/libc-alpha/2016-06/msg00128.html>, I have
now implemented a GCC option -fno-fp-int-builtin-inexact for GCC 7,
such that GCC will inline these functions on x86, without caring about
"inexact", when the default -ffp-int-builtin-inexact is in effect.
This allows users to get optimized code depending on the options they
pass to the compiler, while making the out-of-line functions follow TS
18661-1 semantics and avoid "inexact".

This patch duly fixes the out-of-line trunc function implementations
to avoid "inexact", in the same way as the nearbyint implementations.

I do not know how the performance of implementations such as these
based on saving the environment and changing the rounding mode
temporarily compares to that of the C versions or SSE 4.1 versions (of
course, for 32-bit x86 SSE implementations still need to get the
return value in an x87 register); it's entirely possible other
implementations could be faster in some cases.

Tested for x86_64 and x86.

[BZ #15479]
* sysdeps/i386/fpu/s_trunc.S (__trunc): Save and restore
floating-point environment rather than just control word.
* sysdeps/i386/fpu/s_truncf.S (__truncf): Likewise.
* sysdeps/i386/fpu/s_truncl.S (__truncl): Save and restore
floating-point environment, with "invalid" exceptions merged in,
rather than just control word.
* sysdeps/x86_64/fpu/s_truncl.S (__truncl): Likewise.
* math/libm-test.inc (trunc_test_data): Do not allow spurious
"inexact" exceptions.

8 years agoAvoid "inexact" exceptions in i386/x86_64 floor functions (bug 15479).
Joseph Myers [Mon, 27 Jun 2016 17:25:47 +0000 (17:25 +0000)]
Avoid "inexact" exceptions in i386/x86_64 floor functions (bug 15479).

As discussed in
<https://sourceware.org/ml/libc-alpha/2016-05/msg00577.html>, TS
18661-1 disallows ceil, floor, round and trunc functions from raising
the "inexact" exception, in accordance with general IEEE 754 semantics
for when that exception is raised.  Fixing this for x87 floating point
is more complicated than for the other versions of these functions,
because they use the frndint instruction that raises "inexact" and
this can only be avoided by saving and restoring the whole
floating-point environment.

As I noted in
<https://sourceware.org/ml/libc-alpha/2016-06/msg00128.html>, I have
now implemented a GCC option -fno-fp-int-builtin-inexact for GCC 7,
such that GCC will inline these functions on x86, without caring about
"inexact", when the default -ffp-int-builtin-inexact is in effect.
This allows users to get optimized code depending on the options they
pass to the compiler, while making the out-of-line functions follow TS
18661-1 semantics and avoid "inexact".

This patch duly fixes the out-of-line floor function implementations
to avoid "inexact", in the same way as the nearbyint implementations.

I do not know how the performance of implementations such as these
based on saving the environment and changing the rounding mode
temporarily compares to that of the C versions or SSE 4.1 versions (of
course, for 32-bit x86 SSE implementations still need to get the
return value in an x87 register); it's entirely possible other
implementations could be faster in some cases.

Tested for x86_64 and x86.

[BZ #15479]
* sysdeps/i386/fpu/s_floor.S (__floor): Save and restore
floating-point environment rather than just control word.
* sysdeps/i386/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/i386/fpu/s_floorl.S (__floorl): Save and restore
floating-point environment, with "invalid" exceptions merged in,
rather than just control word.
* sysdeps/x86_64/fpu/s_floorl.S (__floorl): Likewise.
* math/libm-test.inc (floor_test_data): Do not allow spurious
"inexact" exceptions.

8 years agoAvoid "inexact" exceptions in i386/x86_64 ceil functions (bug 15479).
Joseph Myers [Mon, 27 Jun 2016 17:23:19 +0000 (17:23 +0000)]
Avoid "inexact" exceptions in i386/x86_64 ceil functions (bug 15479).

As discussed in
<https://sourceware.org/ml/libc-alpha/2016-05/msg00577.html>, TS
18661-1 disallows ceil, floor, round and trunc functions from raising
the "inexact" exception, in accordance with general IEEE 754 semantics
for when that exception is raised.  Fixing this for x87 floating point
is more complicated than for the other versions of these functions,
because they use the frndint instruction that raises "inexact" and
this can only be avoided by saving and restoring the whole
floating-point environment.

As I noted in
<https://sourceware.org/ml/libc-alpha/2016-06/msg00128.html>, I have
now implemented a GCC option -fno-fp-int-builtin-inexact for GCC 7,
such that GCC will inline these functions on x86, without caring about
"inexact", when the default -ffp-int-builtin-inexact is in effect.
This allows users to get optimized code depending on the options they
pass to the compiler, while making the out-of-line functions follow TS
18661-1 semantics and avoid "inexact".

This patch duly fixes the out-of-line ceil function implementations to
avoid "inexact", in the same way as the nearbyint implementations.

I do not know how the performance of implementations such as these
based on saving the environment and changing the rounding mode
temporarily compares to that of the C versions or SSE 4.1 versions (of
course, for 32-bit x86 SSE implementations still need to get the
return value in an x87 register); it's entirely possible other
implementations could be faster in some cases.

Tested for x86_64 and x86.

[BZ #15479]
* sysdeps/i386/fpu/s_ceil.S (__ceil): Save and restore
floating-point environment rather than just control word.
* sysdeps/i386/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/i386/fpu/s_ceill.S (__ceill): Save and restore
floating-point environment, with "invalid" exceptions merged in,
rather than just control word.
* sysdeps/x86_64/fpu/s_ceill.S (__ceill): Likewise.
* math/libm-test.inc (ceil_test_data): Do not allow spurious
"inexact" exceptions.

8 years agoMIPS, SPARC: more fixes to the vfork aliases in libpthread.so
Aurelien Jarno [Tue, 21 Jun 2016 21:59:37 +0000 (23:59 +0200)]
MIPS, SPARC: more fixes to the vfork aliases in libpthread.so

Commit 43c29487 tried to fix the vfork aliases in libpthread.so on MIPS
and SPARC, but failed to do it correctly, introducing an ABI change.

This patch does the remaining changes needed to align the MIPS and SPARC
vfork implementations with the other architectures. That way the the
alpha version of pt-vfork.S works correctly for MIPS and SPARC. The
changes for alpha were done in 82aab97c.

Changelog:
* sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Rename into
__libc_vfork.
(__vfork) [IS_IN (libc)]: Remove alias.
(__libc_vfork) [IS_IN (libc)]: Define as an alias.
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.

8 years agoRemove atomic_compare_and_exchange_bool_rel.
Torvald Riegel [Tue, 14 Jun 2016 13:12:00 +0000 (15:12 +0200)]
Remove atomic_compare_and_exchange_bool_rel.

atomic_compare_and_exchange_bool_rel and
catomic_compare_and_exchange_bool_rel are removed and replaced with the
new C11-like atomic_compare_exchange_weak_release.  The concurrent code
in nscd/cache.c has not been reviewed yet, so this patch does not add
detailed comments.

* nscd/cache.c (cache_add): Use new C11-like atomic operation instead
of atomic_compare_and_exchange_bool_rel.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
* include/atomic.h (atomic_compare_and_exchange_bool_rel,
catomic_compare_and_exchange_bool_rel): Remove.
* sysdeps/aarch64/atomic-machine.h
(atomic_compare_and_exchange_bool_rel): Likewise.
* sysdeps/alpha/atomic-machine.h
(atomic_compare_and_exchange_bool_rel): Likewise.
* sysdeps/arm/atomic-machine.h
(atomic_compare_and_exchange_bool_rel): Likewise.
* sysdeps/mips/atomic-machine.h
(atomic_compare_and_exchange_bool_rel): Likewise.
* sysdeps/tile/atomic-machine.h
(atomic_compare_and_exchange_bool_rel): Likewise.

8 years agoFix i386/x86_64 scalbl with sNaN input (bug 20296).
Joseph Myers [Thu, 23 Jun 2016 22:17:41 +0000 (22:17 +0000)]
Fix i386/x86_64 scalbl with sNaN input (bug 20296).

The x86_64 and i386 versions of scalbl return sNaN for some cases of
sNaN input and are missing "invalid" exceptions for other cases.  This
results from overly complicated code that either returns a NaN input,
or discards both inputs when one is NaN and loads a NaN from memory.
This patch fixes this by simplifying the code to add the arguments
when either one is NaN.

Tested for x86_64 and x86.

[BZ #20296]
* sysdeps/i386/fpu/e_scalbl.S (__ieee754_scalbl): Add arguments
when either argument is a NaN.
* sysdeps/x86_64/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
* math/libm-test.inc (scalb_test_data): Add sNaN tests.

8 years agoAdd more sNaN tests (most remaining real functions).
Joseph Myers [Thu, 23 Jun 2016 21:59:34 +0000 (21:59 +0000)]
Add more sNaN tests (most remaining real functions).

This patch adds tests of sNaN inputs to more functions to
libm-test.inc.  This covers the remaining real functions except for
scalb, where there's a bug to fix, and hypot pow fmin fmax, where
there are cases where a qNaN input does not result in a qNaN output
and so sNaN support according to TS 18661-1 is more of a new feature.

Tested for x86_64 and x86.

* math/libm-test.inc (snan_value_ld): New macro.
(isgreater_test_data): Add sNaN tests.
(isgreaterequal_test_data): Likewise.
(isless_test_data): Likewise.
(islessequal_test_data): Likewise.
(islessgreater_test_data): Likewise.
(isunordered_test_data): Likewise.
(nextafter_test_data): Likewise.
(nexttoward_test_data): Likewise.
(remainder_test_data): Likewise.
(remquo_test_data): Likewise.
(significand_test_data): Likewise.
* math/gen-libm-test.pl (%beautify): Add snan_value_ld.

8 years agoFix up ChangeLog
Siddhesh Poyarekar [Thu, 23 Jun 2016 20:29:04 +0000 (01:59 +0530)]
Fix up ChangeLog

8 years agoAvoid attempt for runtime checks if all environments are defined
Siddhesh Poyarekar [Thu, 23 Jun 2016 20:28:44 +0000 (01:58 +0530)]
Avoid attempt for runtime checks if all environments are defined

getconf has the capability to do a runtime check for environment
support in cases where there is optional support for an environment
(_POSIX_V7_ILP32_OFF32 on x86_64 for example) and this is indicated by
not defining the _POSIX_V7_ILP32_OFF32 macro, which results in getconf
doing an additional execve of _POSIX_V7_ILP32_OFF32 in the
$GETCONF_DIR.

The default bits/environments.h however does not leave any environment
macros undefined, which means that no such additional execve is
needed.  gcc trunk catches this as a build failure since it finds that
the code block inside switch(specs[i].num) is not reachable.  Avoid
this error by not bothering about the additional exec (and looking in
specific environments) when all environments are defined.

Tested on aarch64.

* posix/getconf.c: Define ALL_ENVIRONMENTS_DEFINED if all
environment macros are defined.
(main): Avoid execve if ALL_ENVIRONMENTS_DEFINED is defined.

8 years agolibio: Implement vtable verification [BZ #20191]
Florian Weimer [Thu, 23 Jun 2016 18:01:40 +0000 (20:01 +0200)]
libio: Implement vtable verification [BZ #20191]

This commit puts all libio vtables in a dedicated, read-only ELF
section, so that they are consecutive in memory.  Before any indirect
jump, the vtable pointer is checked against the section boundaries,
and the process is terminated if the vtable pointer does not fall into
the special ELF section.

To enable backwards compatibility, a special flag variable
(_IO_accept_foreign_vtables), protected by the pointer guard, avoids
process termination if libio stream object constructor functions have
been called earlier.  Such constructor functions are called by the GCC
2.95 libstdc++ library, and this mechanism ensures compatibility with
old binaries.  Existing callers inside glibc of these functions are
adjusted to call the original functions, not the wrappers which enable
vtable compatiblity.

The compatibility mechanism is used to enable passing FILE * objects
across a static dlopen boundary, too.

8 years agotest-skeleton.c (xrealloc): Support realloc-as-free
Florian Weimer [Thu, 23 Jun 2016 12:17:57 +0000 (14:17 +0200)]
test-skeleton.c (xrealloc): Support realloc-as-free

If the requested size is zero, realloc returns NULL, but the
deallocation is still successful, unless the pointer is also
NULL, when realloc behaves as malloc (0).

8 years agotest-skeleton.c: xmalloc, xcalloc, xrealloc are potentially unused
Florian Weimer [Thu, 23 Jun 2016 09:01:21 +0000 (11:01 +0200)]
test-skeleton.c: xmalloc, xcalloc, xrealloc are potentially unused

__attribute__ ((used)) means that the function has to be
emitted in assembly because it is referenced in ways the
compiler cannot detect (such as asm statements, or some
post-processing on the generated assembly).

The unused attribute needs to come first, otherwise it is
applied to the return type and not the function definition.

8 years agotest-skeleton.c: Add write_message function
Florian Weimer [Thu, 23 Jun 2016 09:00:00 +0000 (11:00 +0200)]
test-skeleton.c: Add write_message function

8 years agoSimplify x86 nearbyint functions.
Joseph Myers [Wed, 22 Jun 2016 15:40:30 +0000 (15:40 +0000)]
Simplify x86 nearbyint functions.

The i386 implementations of nearbyint functions, and x86_64
nearbyintl, contain code to mask the "inexact" exception.  However,
the fnstenv instruction has the effect of masking all exceptions, so
this masking code has been redundant since fnstenv was added to those
implementations (by commit 846d9a4a3acdb4939ca7bf6aed48f9f6f26911be;
commit 71d1b0166b4ace0d804af2993b3815758b852efc added the test
math/test-nearbyint-except-2.c that verifies these functions do work
when called with "inexact" traps enabled); this patch removes the
redundant code.

Tested for x86_64 and x86.

* sysdeps/i386/fpu/s_nearbyint.S (__nearbyint): Do not mask
"inexact" exceptions after fnstenv.
* sysdeps/i386/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
* sysdeps/i386/fpu/s_nearbyintl.S (__nearbyintl): Likewise.
* sysdeps/x86_64/fpu/s_nearbyintl.S (__nearbyintl): Likewise.

8 years agoMove sysdeps/generic/bits/hwcap.h to top-level bits/
Zack Weinberg [Wed, 22 Jun 2016 12:51:12 +0000 (05:51 -0700)]
Move sysdeps/generic/bits/hwcap.h to top-level bits/

This file was added to sysdeps/generic/bits in 2012.  This appears to
have been an oversight, as the entire sysdeps/generic/bits directory was
moved to the top level in 2005.  Accordingly the generic bits/hwcap.h
belongs there too.

* sysdeps/generic/bits/hwcap.h: Moved to ...
* bits/hwcap.h: Here.

8 years agoMove sysdeps/generic/bits/hwcap.h to top-level bits/
Zack Weinberg [Wed, 22 Jun 2016 12:48:11 +0000 (05:48 -0700)]
Move sysdeps/generic/bits/hwcap.h to top-level bits/

This file was added to sysdeps/generic/bits in 2012.  This appears to
have been an oversight, as the entire sysdeps/generic/bits directory was
moved to the top level in 2005.  Accordingly the generic bits/hwcap.h
belongs there too.

* sysdeps/generic/bits/hwcap.h: Moved to ...
* bits/hwcap.h: Here.

8 years agoThis patch further tunes memcpy - avoid one branch for sizes 1-3,
Wilco Dijkstra [Wed, 22 Jun 2016 12:24:24 +0000 (13:24 +0100)]
This patch further tunes memcpy - avoid one branch for sizes 1-3,
add a prefetch and improve small copies that are exact powers of 2.

        * sysdeps/aarch64/memcpy.S (memcpy):
        Further tuning for performance.

8 years agomalloc: Avoid premature fallback to mmap [BZ #20284]
Florian Weimer [Tue, 21 Jun 2016 19:29:21 +0000 (21:29 +0200)]
malloc: Avoid premature fallback to mmap [BZ #20284]

Before this change, the while loop in reused_arena which avoids
returning a corrupt arena would never execute its body if the selected
arena were not corrupt.  As a result, result == begin after the loop,
and the function returns NULL, triggering fallback to mmap.

8 years agoFix p{readv,writev}{64} consolidation implementation
Adhemerval Zanella [Tue, 14 Jun 2016 20:56:33 +0000 (17:56 -0300)]
Fix p{readv,writev}{64} consolidation implementation

This patch fixes the p{readv,writev}{64} consolidation implementation
from commits 4e77815 and af5fdf5.  Different from pread/pwrite
implementation, preadv/pwritev implementation does not require
__ALIGNMENT_ARG because kernel syscall prototypes define
the high and low part of the off_t, if it is the case, directly
(different from pread/pwrite where the architecture ABI for passing
64-bit values must be in consideration for passsing the arguments).

It also adds some basic tests for preadv/pwritev.

Tested on x86_64, i686, and armhf.

* misc/Makefile (tests): Add tst-preadvwritev and tst-preadvwritev64.
* misc/tst-preadvwritev.c: New file.
* misc/tst-preadvwritev64.c: Likewise.
* sysdeps/unix/sysv/linux/preadv.c (preadv): Remove SYSCALL_LL{64}
usage.
* sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise.
* sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise.
* sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise.
* sysdeps/unix/sysv/linux/sysdep.h (LO_HI_LONG): New macro.

8 years agoAdded tests to ensure linkage through libmvec *_finite aliases which are
Andrew Senkevich [Mon, 20 Jun 2016 18:15:50 +0000 (21:15 +0300)]
Added tests to ensure linkage through libmvec *_finite aliases which are
defined in libmvec_nonshared.a (bug 19654).

    [BZ #19654]
    * sysdeps/x86_64/fpu/Makefile: Added new tests.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx-main.c: New.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx2-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx2-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx512-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx512-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-avx512.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-libmvec-alias.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx2-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx2-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx512-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx512-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-avx512.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-main.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias-mod.c: Likewise.
    * sysdeps/x86_64/fpu/test-float-libmvec-alias.c: Likewise.
    * sysdeps/x86_64/fpu/test-libmvec-alias-mod.c: Likewise.

8 years agoAdd a simple rawmemchr implementation. Use strlen for rawmemchr(s, '\0') as it
Wilco Dijkstra [Mon, 20 Jun 2016 16:48:20 +0000 (17:48 +0100)]
Add a simple rawmemchr implementation.  Use strlen for rawmemchr(s, '\0') as it
is the fastest way to search for '\0'.  Otherwise use memchr with an infinite
size.  This is 3x faster on benchtests for large sizes.  Passes GLIBC tests.

* sysdeps/aarch64/rawmemchr.S (__rawmemchr): New file.
* sysdeps/aarch64/strlen.S (__strlen): Change to __strlen to avoid PLT.

8 years agoThis is an optimized memcpy/memmove for AArch64. Copies are split into 3 main
Wilco Dijkstra [Mon, 20 Jun 2016 16:38:13 +0000 (17:38 +0100)]
This is an optimized memcpy/memmove for AArch64.  Copies are split into 3 main
cases: small copies of up to 16 bytes, medium copies of 17..96 bytes which are
fully unrolled.  Large copies of more than 96 bytes align the destination and
use an unrolled loop processing 64 bytes per iteration.  In order to share code
with memmove, small and medium copies read all data before writing, allowing
any kind of overlap.  All memmoves except for the large backwards case fall
into memcpy for optimal performance.  On a random copy test memcpy/memmove are
40% faster on Cortex-A57 and 28% on Cortex-A53.

* sysdeps/aarch64/memcpy.S (memcpy):
Rewrite of optimized memcpy and memmove.
* sysdeps/aarch64/memmove.S (memmove): Remove
memmove code (merged into memcpy.S).

8 years agoelf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h>
Florian Weimer [Mon, 20 Jun 2016 12:31:40 +0000 (14:31 +0200)]
elf: Consolidate machine-agnostic DTV definitions in <dl-dtv.h>

Identical definitions of dtv_t and TLS_DTV_UNALLOCATED were
repeated for all architectures using DTVs.

8 years agoRevert __malloc_initialize_hook symbol poisoning
Florian Weimer [Mon, 20 Jun 2016 09:11:29 +0000 (11:11 +0200)]
Revert __malloc_initialize_hook symbol poisoning

It turns out the Emacs-internal malloc implementation uses
__malloc_* symbols.  If glibc poisons them in <stdc-pre.h>,
Emacs will no longer compile.

8 years agoExpand comments in Linux times() implementation.
Carlos O'Donell [Sun, 19 Jun 2016 19:46:26 +0000 (15:46 -0400)]
Expand comments in Linux times() implementation.

8 years agoMIPS, SPARC: fix wrong vfork aliases in libpthread.so
Aurelien Jarno [Sat, 18 Jun 2016 17:11:23 +0000 (19:11 +0200)]
MIPS, SPARC: fix wrong vfork aliases in libpthread.so

With recent binutils versions the GNU libc fails to build on at least
MISP and SPARC, with this kind of error:

  /home/aurel32/glibc/glibc-build/nptl/libpthread.so:(*IND*+0x0): multiple definition of `vfork@GLIBC_2.0'
  /home/aurel32/glibc/glibc-build/nptl/libpthread.so::(.text+0xee50): first defined here

It appears that on these architectures pt-vfork.S includes vfork.S
(through the alpha version of pt-vfork.S) and that the __vfork aliases
are not conditionalized on IS_IN (libc) like on other architectures.
Therefore the aliases are also wrongly included in libpthread.so.

Fix this by properly conditionalizing the aliases like on other
architectures.

Changelog:
* sysdeps/unix/sysv/linux/mips/vfork.S (__vfork): Conditionalize
hidden_def, weak_alias and strong_alias on [IS_IN (libc)].
* sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: Likewise.

8 years agoAdd nextup and nextdown math functions
Rajalakshmi Srinivasaraghavan [Thu, 16 Jun 2016 15:51:26 +0000 (21:21 +0530)]
Add nextup and nextdown math functions

TS 18661 adds nextup and nextdown functions alongside nextafter to provide
support for float128 equivalent to it.  This patch adds nextupl, nextup,
nextupf, nextdownl, nextdown and nextdownf to libm before float128 support.

The nextup functions return the next representable value in the direction of
positive infinity and the nextdown functions return the next representable
value in the direction of negative infinity.  These are currently enabled
as GNU extensions.

8 years agomanual: fix typos in the pattern chapter
Rical Jasan [Fri, 6 May 2016 07:54:38 +0000 (00:54 -0700)]
manual: fix typos in the pattern chapter

8 years agolocaledata: ro_RO: update Tuesday translation [BZ #18911]
Simion Onea [Fri, 10 Jun 2016 15:51:08 +0000 (11:51 -0400)]
localedata: ro_RO: update Tuesday translation [BZ #18911]

Enough fonts support ț now that we can change the Tuesday translation
to be what it should rather than use the incorrect ţ.

8 years agomanual: fix typos in the search chapter
Rical Jasan [Fri, 6 May 2016 07:54:37 +0000 (00:54 -0700)]
manual: fix typos in the search chapter

8 years agomanual: fix typos in the message chapter
Rical Jasan [Fri, 6 May 2016 07:54:36 +0000 (00:54 -0700)]
manual: fix typos in the message chapter

8 years agomanual: fix spelling typos
Mike Frysinger [Sun, 28 Oct 2012 02:59:54 +0000 (22:59 -0400)]
manual: fix spelling typos

I've bracketed the changes to make it easier to pick out.

enlengthen -> extend
enlengthened -> extended
excep[e]tions -> exceptions
exten[da]ble -> exten[si]ble
implement[o]r -> implement[e]r
licen[c]e -> licen[s]e
optimzed -> optim[i]zed
overriden -> overrid[d]en
param[a]ter -> param[e]ter

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-27  Mike Frysinger  <vapier@gentoo.org>

* manual/arith.texi: Fix spelling typos.
* manual/contrib.texi: Likewise.
* manual/crypt.texi: Likewise.
* manual/filesys.texi: Likewise.
* manual/llio.texi: Likewise.
* manual/locale.texi: Likewise.
* manual/message.texi: Likewise.
* manual/nss.texi: Likewise.
* manual/socket.texi: Likewise.
* manual/stdio.texi: Likewise.
* manual/string.texi: Likewise.
* manual/sysinfo.texi: Likewise.

8 years agomanual: fix typos in the locale chapter
Rical Jasan [Thu, 16 Jun 2016 04:54:47 +0000 (00:54 -0400)]
manual: fix typos in the locale chapter

8 years agomanual: fix typos in the locale chapter
Rical Jasan [Fri, 6 May 2016 07:54:35 +0000 (00:54 -0700)]
manual: fix typos in the locale chapter

8 years agomanual: fix typos in character set handling
Rical Jasan [Fri, 6 May 2016 07:54:34 +0000 (00:54 -0700)]
manual: fix typos in character set handling

8 years agomanual: fix typos in the string chapters
Rical Jasan [Fri, 6 May 2016 07:54:33 +0000 (00:54 -0700)]
manual: fix typos in the string chapters

8 years agomanual: fix typos in the character handling chapter
Rical Jasan [Fri, 6 May 2016 07:54:32 +0000 (00:54 -0700)]
manual: fix typos in the character handling chapter

8 years agomanual: fix typos in the memory chapter
Rical Jasan [Fri, 6 May 2016 07:54:31 +0000 (00:54 -0700)]
manual: fix typos in the memory chapter

Some of these are obvious grammar fixes while others fix references
to the function prototypes.

8 years agoFix i386 fdim double rounding (bug 20255).
Joseph Myers [Tue, 14 Jun 2016 16:41:50 +0000 (16:41 +0000)]
Fix i386 fdim double rounding (bug 20255).

fdim suffers from double rounding on i386 because subtracting two
double values can produce an inexact long double value exactly half
way between two double values.  This patch fixes this by creating an
i386-specific version of fdim - C, based on the generic version,
unlike the previous .S version - which sets the x87 precision control
to double precision for the subtraction and then restores it
afterwards.  As noted in the comment added, there are no issues of
double rounding for subnormals (a case that setting precision control
does not address) because subtraction cannot produce an inexact result
in the subnormal range.

Tested for x86_64 and x86.

[BZ #20255]
* sysdeps/i386/fpu/s_fdim.c: New file.  Based on math/s_fdim.c.
* math/libm-test.inc (fdim_test_data): Add another test.

8 years agoUse generic fdim on more architectures (bug 6796, bug 20255, bug 20256).
Joseph Myers [Tue, 14 Jun 2016 16:04:19 +0000 (16:04 +0000)]
Use generic fdim on more architectures (bug 6796, bug 20255, bug 20256).

Some architectures have their own versions of fdim functions, which
are missing errno setting (bug 6796) and may also return sNaN instead
of qNaN for sNaN input, in the case of the x86 / x86_64 long double
versions (bug 20256).

These versions are not actually doing anything that a compiler
couldn't generate, just straightforward comparisons / arithmetic (and,
in the x86 / x86_64 case, testing for NaNs with fxam, which isn't
actually needed once you use an unordered comparison and let the NaNs
pass through the same subtraction as non-NaN inputs).  This patch
removes the x86 / x86_64 / powerpc versions, so that those
architectures use the generic C versions, which correctly handle
setting errno and deal properly with sNaN inputs.  This seems better
than dealing with setting errno in lots of .S versions.

The i386 versions also return results with excess range and precision,
which is not appropriate for a function exactly defined by reference
to IEEE operations.  For errno setting to work correctly on overflow,
it's necessary to remove excess range with math_narrow_eval, which
this patch duly does in the float and double versions so that the
tests can reliably pass on x86.  For float, this avoids any double
rounding issues as the long double precision is more than twice that
of float.  For double, double rounding issues will need to be
addressed separately, so this patch does not fully fix bug 20255.

Tested for x86_64, x86 and powerpc.

[BZ #6796]
[BZ #20255]
[BZ #20256]
* math/s_fdim.c: Include <math_private.h>.
(__fdim): Use math_narrow_eval on result.
* math/s_fdimf.c: Include <math_private.h>.
(__fdimf): Use math_narrow_eval on result.
* sysdeps/i386/fpu/s_fdim.S: Remove file.
* sysdeps/i386/fpu/s_fdimf.S: Likewise.
* sysdeps/i386/fpu/s_fdiml.S: Likewise.
* sysdeps/i386/i686/fpu/s_fdim.S: Likewise.
* sysdeps/i386/i686/fpu/s_fdimf.S: Likewise.
* sysdeps/i386/i686/fpu/s_fdiml.S: Likewise.
* sysdeps/powerpc/fpu/s_fdim.c: Likewise.
* sysdeps/powerpc/fpu/s_fdimf.c: Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_fdim.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_fdim.c: Likewise.
* sysdeps/x86_64/fpu/s_fdiml.S: Likewise.
* math/libm-test.inc (fdim_test_data): Expect errno setting on
overflow.  Add sNaN tests.

8 years agoSimplify generic fdim implementations.
Joseph Myers [Tue, 14 Jun 2016 14:56:42 +0000 (14:56 +0000)]
Simplify generic fdim implementations.

The generic fdim implementations have unnecessarily complicated code,
using fpclassify to determine whether the arguments are NaNs,
subtracting NaNs if so and otherwise subtracting the non-NaN arguments
if not (x <= y), then using fpclassify on the result to see if it is
infinite.

This patch simplifies the code.  Instead of handling NaNs separately,
it suffices to use an unordered comparison with islessequal (x, y) to
determine whether to return zero, and otherwise NaNs can go through
the same subtraction as non-NaN arguments; no explicit tests for NaN
are needed at all.  Then, isinf instead of fpclassify can be used to
determine whether to set errno (in the normal non-overflow case, only
one classification will need to occur, unlike the three in the
previous code, of which two occurred even if returning zero, because
the result will not be infinite in the normal case).

The resulting logic is essentially the same as that in the powerpc
version, except that the powerpc version is missing errno setting and
uses <= not islessequal, so relying on
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, the GCC bug that
unordered comparison instructions are wrongly used on powerpc for
ordered comparisons.

The compiled code for fdim and fdimf on x86_64 is less than half the
size of the previous code.

Tested for x86_64.

* math/s_fdim.c (__fdim): Use islessequal and isinf instead of
fpclassify.
* math/s_fdimf.c (__fdimf): Likewise.
* math/s_fdiml.c (__fdiml): Likewise.

8 years agopowerpc: strcasecmp/strncasecmp optmization for power8
raji [Tue, 14 Jun 2016 09:21:16 +0000 (14:51 +0530)]
powerpc: strcasecmp/strncasecmp optmization for power8

This implementation utilizes vectors to improve performance
compared to current byte by byte implementation for POWER7.
The performance improvement is upto 4x.  This patch is tested
on powerpc64 and powerpc64le.

8 years agoFix dbl-64 atan2 (sNaN, qNaN) (bug 20252).
Joseph Myers [Mon, 13 Jun 2016 21:43:22 +0000 (21:43 +0000)]
Fix dbl-64 atan2 (sNaN, qNaN) (bug 20252).

The dbl-64 implementation of atan2, passed arguments (sNaN, qNaN),
fails to raise the "invalid" exception.  This patch fixes it to add
both arguments, rather than just adding the second argument to itself,
in the case where the second argument is a NaN (which is checked for
before checking for the first argument being a NaN).  sNaN tests for
atan2 are added, along with some qNaN tests I noticed were missing but
should have been there by analogy with other tests present.

Tested for x86_64 and x86.

[BZ #20252]
* sysdeps/ieee754/dbl-64/e_atan2.c (__ieee754_atan2): Add both
arguments when second argument is a NaN.
* math/libm-test.inc (atan2_test_data): Add sNaN tests and more
qNaN tests.

8 years agoAdd more sNaN tests (cimag, conj, copysign, creal, fma, fmod).
Joseph Myers [Mon, 13 Jun 2016 21:26:28 +0000 (21:26 +0000)]
Add more sNaN tests (cimag, conj, copysign, creal, fma, fmod).

This patch adds tests of sNaN inputs to further libm functions.

Tested for x86_64 and x86.

* math/libm-test.inc (cimag_test_data): Add sNaN tests.
(conj_test_data): Likewise.
(copysign_test_data): Likewise.
(creal_test_data): Likewise.
(fma_test_data): Likewise.
(fmod_test_data): Likewise.

8 years agoFix frexp (NaN) (bug 20250).
Joseph Myers [Mon, 13 Jun 2016 17:27:19 +0000 (17:27 +0000)]
Fix frexp (NaN) (bug 20250).

Various implementations of frexp functions return sNaN for sNaN
input.  This patch fixes them to add such arguments to themselves so
that qNaN is returned.

Tested for x86_64, x86, mips64 and powerpc.

[BZ #20250]
* sysdeps/i386/fpu/s_frexpl.S (__frexpl): Add non-finite input to
itself.
* sysdeps/ieee754/dbl-64/s_frexp.c (__frexp): Add non-finite or
zero input to itself.
* sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c (__frexp):
Likewise.
* sysdeps/ieee754/flt-32/s_frexpf.c (__frexpf): Likewise.
* sysdeps/ieee754/ldbl-128/s_frexpl.c (__frexpl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_frexpl.c (__frexpl): Likewise.
* sysdeps/ieee754/ldbl-96/s_frexpl.c (__frexpl): Likewise.
* math/libm-test.inc (frexp_test_data): Add sNaN tests.

8 years agonptl: Add sendmmsg and recvmmsg cancellation tests
Adhemerval Zanella [Fri, 10 Jun 2016 13:03:04 +0000 (10:03 -0300)]
nptl: Add sendmmsg and recvmmsg cancellation tests

This patch adds cancellation tests for both sendmmsg and recvmmsg
syscalls.  Since for some system configuration (x86_64/i686 on
older kernels and non-Linux platforms), the tests are added as
two independent that report as unsupported if the syscall is not
presented.

Both new tests uses the already tst-cancel4.c code, which as moved
to a common tst-cancel4-common{.c,h} files.

Tested on x86_64 and i686.

* nptl/Makefile (test): Add tst-cancel4_1 and tst-cancel4_2.
* nptl/tst-cancel4-common.c: New file.
* nptl/tst-cancel4-common.h: Likewise.
* nptl/tst-cancel4.c: Move common definitions to
tst-cancel4-common.{c,h} file.
* nptl/tst-cancel4_1.c: New test.
* nptl/tst-cancel4_2.c: New test.

8 years agodebug/tst-longjmp_chk2: Make signal handler more conservative [BZ #20248]
Florian Weimer [Mon, 13 Jun 2016 11:08:39 +0000 (13:08 +0200)]
debug/tst-longjmp_chk2: Make signal handler more conservative [BZ #20248]

Currently, printf needs more stack space than what is available with
SIGSTKSZ.  This commit use the the write system call directly instead.

Also use sig_atomic_t for the “pass” variable (for general
correctness), and restore signal handlers to their defaults, to avoid
masking crashes.

8 years agoRemove __ASSUME_FUTEX_LOCK_PI
Adhemerval Zanella [Mon, 16 May 2016 13:35:25 +0000 (10:35 -0300)]
Remove __ASSUME_FUTEX_LOCK_PI

This patch removes __ASSUME_FUTEX_LOCK_PI usage and assumes that
kernel will correctly return if it supports or not
futex_atomic_cmpxchg_inatomic.

Current PI mutex code already has runtime support by calling
prio_inherit_missing and returns ENOTSUP if the futex operation fails
at initialization (it issues a FUTEX_UNLOCK_PI futex operation).

Also, current minimum supported kernel (v3.2) will return ENOSYS if
futex_atomic_cmpxchg_inatomic is not supported in the system:

kernel/futex.c:

2628 long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2629                 u32 __user *uaddr2, u32 val2, u32 val3)
2630 {
2631         int ret = -ENOSYS, cmd = op & FUTEX_CMD_MASK;
[...]
2667         case FUTEX_UNLOCK_PI:
2668                 if (futex_cmpxchg_enabled)
2669                         ret = futex_unlock_pi(uaddr, flags);
[...]
2686         return ret;
2687 }

The futex_cmpxchg_enabled is initialized by calling cmpxchg_futex_value_locked,
which calls futex_atomic_cmpxchg_inatomic.

For ARM futex_atomic_cmpxchg_inatomic will be either defined (if both
CONFIG_CPU_USE_DOMAINS and CONFIG_SMP are not defined) or use the
default generic implementation that returns ENOSYS.

For m68k is uses the default generic implementation.

For mips futex_atomic_cmpxchg_inatomic will return ENOSYS if cpu has no
'cpu_has_llsc' support (defined by each chip supporte inside kernel).

For sparc, 32-bit kernel will just use default generic implementation,
while 64-bit kernel has support.

Tested on ARM (v3.8 kernel) and x86_64.

* nptl/pthread_mutex_init.c [__ASSUME_FUTEX_LOCK_PI]
(prio_inherit_missing): Remove define.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_FUTEX_LOCK_PI):
Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_FUTEX_LOCK_PI): Likewise.

8 years agoFix rt/tst-aio64.c as well, and mention login/tst-utmp.c in ChangeLog
Paul Pluzhnikov [Sat, 11 Jun 2016 21:59:27 +0000 (14:59 -0700)]
Fix rt/tst-aio64.c as well, and mention login/tst-utmp.c in ChangeLog
(it was fixed in previous commit).

8 years ago2016-06-11 Paul Pluzhnikov <ppluzhnikov@google.com>
Paul Pluzhnikov [Sat, 11 Jun 2016 21:50:16 +0000 (14:50 -0700)]
2016-06-11  Paul Pluzhnikov  <ppluzhnikov@google.com>

[BZ #19670]
[BZ #19672]

* io/test-lfs.c (do_prepare): Use xmalloc.
* io/tst-fcntl.c (do_prepare): Likewise.
* libio/tst-fopenloc.c (do_bz17916): Likewise.
* libio/tst-mmap2-eofsync.c (do_prepare): Likewise.
* posix/tst-exec.c (do_prepare): Likewise.
* posix/tst-pathconf.c (prepare): Likewise.
* posix/tst-spawn.c (do_prepare): Likewise.
* posix/tst-truncate.c (do_prepare): Likewise.
* rt/tst-aio.c (do_prepare): Likewise.

8 years agoNEWS: clarify localedef --old-style update
Mike Frysinger [Sat, 11 Jun 2016 18:33:32 +0000 (14:33 -0400)]
NEWS: clarify localedef --old-style update

8 years agonss_db: Fix initialization of iteration position [BZ #20237]
Florian Weimer [Sat, 11 Jun 2016 10:12:56 +0000 (12:12 +0200)]
nss_db: Fix initialization of iteration position [BZ #20237]

When get*ent is called without a preceding set*ent, we need
to set the initial iteration position in get*ent.

Reproducer: Add “services: db files” to /etc/nsswitch.conf, then run
“perl -e getservent”.  It will segfault before this change, and exit
silently after it.

8 years agomalloc_usable_size: Use correct size for dumped fake mapped chunks
Florian Weimer [Sat, 11 Jun 2016 10:09:19 +0000 (12:09 +0200)]
malloc_usable_size: Use correct size for dumped fake mapped chunks

The adjustment for the size computation in commit
1e8a8875d69e36d2890b223ffe8853a8ff0c9512 is needed in
malloc_usable_size, too.

8 years agofopencookie: Mangle function pointers stored on the heap [BZ #20222]
Florian Weimer [Sat, 11 Jun 2016 10:07:14 +0000 (12:07 +0200)]
fopencookie: Mangle function pointers stored on the heap [BZ #20222]

8 years agolocaledata: ne_NP: misc updates [BZ #1170]
Paras pradhan [Thu, 19 May 2016 22:05:31 +0000 (18:05 -0400)]
localedata: ne_NP: misc updates [BZ #1170]

This locale was originally copied from ne_IN and it shows: many
fields are incorrect for the Nepal territory, and many fields are
missing translations.  I've vetted most of these against CLDR as
not all fields are covered by it.

LC_TIME
  abday
    tuesday:    मगल -> मङगल
    thursday:   बिहि -> बिही
  day
    tuesday:    मगलबार -> मङगलबार
    thursday:   बिहिबार -> बिहीबार
  abmon:
    january:    जनवरी  -> जन
    february:   फरवरी  -> फब
    april:      अपरल  -> अपरि
    may:        मई    -> म
    july:       जलाई  -> जला
    august:     अगसत  -> अग
    september:  सितमबर -> सपट
    october:    अकटबर -> अकट
    november:   नवमबर  -> नोभ
    december:   दिसमबर -> डिस
  mon:
    february:   फरवरी  -> फबरअरी
    april:      अपरल  -> अपरिल
    may:        मई    -> म
    september:  सितमबर -> सपटमबर
    october:    अकटबर -> अकटोबर
    november:   नवमबर -> नोभमबर
    december:   दिसमबर -> डिसमबर
  d_t_fmt:      %A %d %b %Y %I:%M:%S %p %Z -> %Y %B %d %I:%M:%S %p
  d_fmt:        %A %d %b %Y                -> %Y %B %d %A
  t_fmt:        %I:%M:%S  %Z               -> %H:%M:%S
  t_fmt_ampm:   %I:%M:%S %p %Z             -> %I:%M:%S %p

LC_NAME:
  name_fmt:     %p%t%f%t%g -> %p%t%g%t%m%t%f
  name_gen:     setting to ज्यू
  name_mr:      setting to श्रीमान्
  name_mrs:     setting to श्रीमती
  name_miss:    setting to सुश्री

LC_ADDRESS:
  postal_fmt:   %z%c%T%s%b%e%r -> %f%N%h%s%N%T

LC_TELEPHONE:
  tel_int_fmt:  +%c ;%a ;%l -> +%c %a%t%l

8 years agounicode-gen: include standard comment file header
Mike Frysinger [Sat, 23 Apr 2016 19:42:54 +0000 (15:42 -0400)]
unicode-gen: include standard comment file header

We deployed this header to all the locale files, so make sure
we include it in the generated ones too so we don't lose it.

8 years agolocaledef: drop unused --old-style
Marko Myllynen [Mon, 30 May 2016 04:52:15 +0000 (07:52 +0300)]
localedef: drop unused --old-style

The --old-style option for localedef is a no-op and has been for 16
years.  Delete the code.

8 years agolocaledata: pt_BR/pt_PT: make days/months lowercase [BZ #19133]
Mike Frysinger [Fri, 10 Jun 2016 16:15:15 +0000 (12:15 -0400)]
localedata: pt_BR/pt_PT: make days/months lowercase [BZ #19133]

8 years agolocaledata: eo: new Esperanto locale [BZ #16190]
Eduardo Trápani [Sat, 11 Jun 2016 05:22:58 +0000 (01:22 -0400)]
localedata: eo: new Esperanto locale [BZ #16190]

8 years agoFix modf (sNaN) (bug 20240).
Joseph Myers [Fri, 10 Jun 2016 23:16:27 +0000 (23:16 +0000)]
Fix modf (sNaN) (bug 20240).

Various modf implementations return sNaN (both outputs) for sNaN
input.  In fact they contain code to convert sNaN to qNaN for both
outputs, but the way this is done is multiplying by 1.0 (for a wider
range of inputs that includes NaNs as well as numbers with exponent
large enough to ensure that they are integers), and that
multiplication by 1.0 is optimized away by GCC in the absence of
-fsignaling-nans, unlike other operations on NaNs used for this
purpose that are not no-ops for non-sNaN input.  This patch arranges
for those files to be built with -fsignaling-nans so that this
existing code is effective as intended.

Tested for x86_64 and x86.

[BZ #20240]
* math/Makefile (CFLAGS-s_modf.c): New variable.
(CFLAGS-s_modff.c): Likewise.
(CFLAGS-s_modfl.c): Likewise.
* math/libm-test.inc (modf_test_data): Add sNaN tests.

8 years agoBug 20215: Always undefine __always_inline before defining it.
Carlos O'Donell [Fri, 10 Jun 2016 18:40:38 +0000 (14:40 -0400)]
Bug 20215: Always undefine __always_inline before defining it.

The Linux kernel defines __always_inline in stddef.h (283d7573),
and it conflicts with the definition in misc/sys/cdefs.h.  To fix
this we undefine it first and always use the glibc definition.

8 years agoRevert {send,sendm,recv,recvm}msg conformance changes
Adhemerval Zanella [Thu, 9 Jun 2016 15:27:57 +0000 (12:27 -0300)]
Revert {send,sendm,recv,recvm}msg conformance changes

After some discussion in libc-alpha about this POSIX compliance fix, I see
that GLIBC should indeed revert back to previous definition of msghdr and
cmsghdr and implementation of sendmsg, recvmsg, sendmmsg, recvmmsg due some
reasons:

 * The possible issue where the syscalls wrapper add the compatibility
   layer is quite limited in scope and range.  And kernel current
   also add some limits to the values on the internal msghdr and
   cmsghdr fields:

     - msghdr::msg_iovlen larger than UIO_MAXIOV (1024) returns
       EMSGSIZE.
     - msghdr::msg_controllen larger than INT_MAX returns ENOBUFS.

 * There is a small performance hit for recvmsg/sendmsg/recmmsg which
   is neglectable, but it is a big hit for sendmmsg since now instead
   of calling the syscall for the packed structure, GLIBC is calling
   multiple sendmsg.  This defeat the very existence of the syscall.

 * It currently breaks libsanitizer build on GCC [1] (I fixed on compiler-rt).
   However the fix is incomplete because it does add any runtime check
   since libsanitizer currently does not have any facility to intercept
   symbols with multiple version [2].

   This, along with incorret dlsym/dlvsym return for versioned symbol due
   another bug [3], makes hard to interpose versioned symbols.

   Also, current approach of fixing GCC PR#71445 leads to half-baked
   solutions without versioned symbol interposing.

This patch basically reverts commits 2f0dc39029ae08222c2d7f4357d66,
af7f7c7ec8dea1.  I decided to not revert abf29edd4a3918 (Adjust
kernel-features.h defaults for recvmsg and sendmsg) mainly because it
does not really address the POSIX compliance original issue and also
adds some cleanups.

Tested on x86, i386, s390, s390x, aarch64, and powerpc64le.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71445
[2] https://github.com/google/sanitizers/issues/628
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=14932

* conform/data/sys/socket.h-data (msghdr.msg_iovlen): Add xfail-.
(msghdr.msg_controllen): Likewise.
(cmsghdr.cmsg_len): Likewise.
* nptl/Makefile (libpthread-routines): Remove ptw-oldrecvmsg and
ptw-oldsendmsg.
(CFLAGS-oldrecvmsg.c): Remove rule.
(CFLAGS-oldsendmsg.c): Likewise.
(CFLAGS-recvmsg.c): Add rule.
(CFLAGS-sendmsg.c): Likewise.
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove
oldrecvmsg, oldsendmsg, oldrecvmmsg, oldsendmmsg.
(CFLAGS-recvmsg.c): Remove rule.
(CFLAGS-sendmsg.c): Likewise.
(CFLAGS-oldrecvmsg.c): Likewise.
(CFLAGS-oldsendmsg.c): Likewise.
(CFLAGS-recvmmsg.c): Likewise.
* sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Revert
to kernel defined interfaces.
(msghdr.msg_controllen): Likewise.
(cmsghdr.cmsg_len): Likewise.
(msghdr.__glibc_reserved1): Remove member.
(msghdr.__glibc_reserved2): Likewise.
(cmsghdr.__glibc_reserved1): Likewise.
* sysdeps/unix/sysv/linux/oldrecvmmsg.c: Remove file.
* sysdeps/unix/sysv/linux/oldrecvmsg.c: Likewise.
* sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmmsg.c: Revert back to previous
version.
* sysdeps/unix/sysv/linux/recvmsg.c: Likewise.
* sysdeps/unix/sysv/linux/sendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/sendmsg.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/Versions [libc] (GLIBC_2.24):
Remove recvmsg and sendmsg.
* sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/m68k/Versions [libc] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/microblaze/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/Versions
[libc] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/nios2/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/Versions
[libc] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/sh/Versions [libc] (GLIBC_2.24): Likewise.
* sysdeps/unix/sysv/linux/sparc/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/tile/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/Versions: Remove file
* sysdeps/unix/sysv/linux/x86_64/64/Versions: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/Versions: Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Remove new 2.24
version for {recv,send,recm,sendm}msg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.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/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.

8 years agomalloc: Remove __malloc_initialize_hook from the API [BZ #19564]
Florian Weimer [Fri, 10 Jun 2016 08:46:05 +0000 (10:46 +0200)]
malloc: Remove __malloc_initialize_hook from the API [BZ #19564]

__malloc_initialize_hook is interposed by application code, so
the usual approach to define a compatibility symbol does not work.
This commit adds a new mechanism based on #pragma GCC poison in
<stdc-predef.h>.

8 years agoFix i386/x86_64 log2l (sNaN) (bug 20235).
Joseph Myers [Thu, 9 Jun 2016 18:04:30 +0000 (18:04 +0000)]
Fix i386/x86_64 log2l (sNaN) (bug 20235).

The i386/x86_64 versions of log2l return sNaN for sNaN input.  This
patch fixes them to add NaN inputs to themselves so that qNaN is
returned in this case.

Tested for x86_64 and x86.

[BZ #20235]
* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Add NaN input to
itself.
* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Likewise.
* math/libm-test.inc (log2_test_data): Add sNaN tests.

8 years agoFix ldbl-128ibm log1pl (sNaN) (bug 20234).
Joseph Myers [Thu, 9 Jun 2016 17:25:54 +0000 (17:25 +0000)]
Fix ldbl-128ibm log1pl (sNaN) (bug 20234).

The ldbl-128ibm version of log1pl returns sNaN for sNaN input.  This
patch fixes it to add such inputs to themselves so that qNaN is
returned in this case.

Tested for powerpc.

[BZ #20234]
* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Add positive
infinity or NaN input to itself.

8 years agoFix ldbl-128ibm expm1l (sNaN) (bug 20233).
Joseph Myers [Thu, 9 Jun 2016 17:24:52 +0000 (17:24 +0000)]
Fix ldbl-128ibm expm1l (sNaN) (bug 20233).

The ldbl-128ibm version of expm1l returns sNaN for sNaN input.  This
patch fixes it to add such inputs to themselves so that qNaN is
returned in this case.

Tested for powerpc.

[BZ #20233]
* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (__expm1l): Add NaN input
to itself.

8 years agoFix ldbl-128 expm1l (sNaN) (bug 20232).
Joseph Myers [Thu, 9 Jun 2016 17:23:51 +0000 (17:23 +0000)]
Fix ldbl-128 expm1l (sNaN) (bug 20232).

The ldbl-128 version of expm1l returns sNaN for sNaN input.  This
patch fixes it to add such inputs to themselves so that qNaN is
returned in this case.

Tested for mips64.

[BZ #20232]
* sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Add NaN input to
itself.

8 years agoAlways indirect branch to __libc_start_main via GOT
H.J. Lu [Thu, 9 Jun 2016 11:43:16 +0000 (04:43 -0700)]
Always indirect branch to __libc_start_main via GOT

Since __libc_start_main in libc.so is called very early, lazy binding
isn't relevant.  Always call __libc_start_main with indirect branch via
GOT to avoid extra branch to PLT slot.  In case of static executable,
ld in binutils 2.26 or above can convert indirect branch into direct
branch:

0000000000400a80 <_start>:
  400a80:       31 ed                   xor    %ebp,%ebp
  400a82:       49 89 d1                mov    %rdx,%r9
  400a85:       5e                      pop    %rsi
  400a86:       48 89 e2                mov    %rsp,%rdx
  400a89:       48 83 e4 f0             and    $0xfffffffffffffff0,%rsp
  400a8d:       50                      push   %rax
  400a8e:       54                      push   %rsp
  400a8f:       49 c7 c0 20 1b 40 00    mov    $0x401b20,%r8
  400a96:       48 c7 c1 90 1a 40 00    mov    $0x401a90,%rcx
  400a9d:       48 c7 c7 c0 03 40 00    mov    $0x4003c0,%rdi
  400aa4:       67 e8 96 09 00 00       addr32 callq 401440 <__libc_start_main>
  400aaa:       f4                      hlt

* sysdeps/x86_64/start.S (_start): Always indirect branch to
__libc_start_main via GOT.

8 years agoX86-64: Add dummy memcopy.h and wordcopy.c
H.J. Lu [Thu, 9 Jun 2016 11:38:34 +0000 (04:38 -0700)]
X86-64: Add dummy memcopy.h and wordcopy.c

Since x86-64 no longer uses memory copy functions, add dummy memcopy.h
and wordcopy.c to reduce code size.  It reduces the size of libc.so by
about 1 KB.

* sysdeps/x86_64/memcopy.h: New file.
* sysdeps/x86_64/wordcopy.c: Likewise.

8 years agoquick_exit tests: Do not use C++ headers
Florian Weimer [Thu, 9 Jun 2016 10:02:42 +0000 (12:02 +0200)]
quick_exit tests: Do not use C++ headers

If C++ headers such as <cstdlib> or <thread> are used, GCC 6
will include /usr/include/stdlib.h (instead of stdlib/stdlib.h
in the glibc source directory), and this turns up as a make
dependency.  An implicit rule will kick in and make will try to
install stdlib/stdlib.h as /usr/include/stdlib.h because the
target is out of date.

This commit switches to <stdlib.h> and <pthread.h> instead of
<cstdlib> and <thread>.

8 years agoFix nscd assertion failure in gc (bug 19755)
Andreas Schwab [Wed, 2 Mar 2016 16:58:42 +0000 (17:58 +0100)]
Fix nscd assertion failure in gc (bug 19755)

If a GETxxBYyy request (for passwd or group) is running in parallel to
an INVALIDATE request (for the same database) then in a particular order
of events the garbage collector is not properly marking all used memory
and fails an assertion:

   GETGRBYNAME (root)
Haven't found "root" in group cache!
add new entry "root" of type GETGRBYNAME for group to cache (first)
handle_request: request received (Version = 2) from PID 7413
   INVALIDATE (group)
pruning group cache; time 9223372036854775807
considering GETGRBYNAME entry "root", timeout 1456763027
add new entry "0" of type GETGRBYGID for group to cache
remove GETGRBYNAME entry "root"
nscd: mem.c:403: gc: Assertion `next_data == &he_data[db->head->nentries]' failed.

Here the first call to cache_add added the GETGRBYNAME entry, which is
immediately marked for collection by prune_cache.  Then the GETGRBYGID
entry is added which shares the data packet with the first entry and
therefore is marked as !first, while the marking look in prune_cache has
already finished.  When the garbage collector runs, it only considers
references by entries marked as first, missing the reference by the
secondary entry.

The only way to fix that is to prevent prune_cache from running while the
two related entries are added.

8 years ago2016-06-09 Paul Pluzhnikov <ppluzhnikov@gmail.com>
Paul Pluzhnikov [Thu, 9 Jun 2016 04:36:37 +0000 (21:36 -0700)]
2016-06-09  Paul Pluzhnikov  <ppluzhnikov@gmail.com>

* test-skeleton.c (oom_error, xmalloc, xcalloc, xrealloc):
New functions.
(add_temp_file): Use them.

8 years agomach: Add mach_print sycsall declaration
Samuel Thibault [Wed, 8 Jun 2016 23:43:49 +0000 (01:43 +0200)]
mach: Add mach_print sycsall declaration

* mach/mach/mach_traps.h (mach_print): Add syscall declaration.

8 years agoFix i386/x86_64 log1pl (sNaN) (bug 20229).
Joseph Myers [Wed, 8 Jun 2016 23:11:42 +0000 (23:11 +0000)]
Fix i386/x86_64 log1pl (sNaN) (bug 20229).

The i386/x86_64 versions of log1pl return sNaN for sNaN input.  This
patch fixes them to add a NaN input to itself so that qNaN is returned
in this case.

Tested for x86_64 and x86.

[BZ #20229]
* sysdeps/i386/fpu/s_log1pl.S (__log1pl): Add NaN input to itself.
* sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Likewise.
* math/libm-test.inc (log1p_test_data): Add sNaN tests.

8 years agoFix i386/x86_64 log10l (sNaN) (bug 20228).
Joseph Myers [Wed, 8 Jun 2016 22:59:18 +0000 (22:59 +0000)]
Fix i386/x86_64 log10l (sNaN) (bug 20228).

The i386/x86_64 versions of log10l return sNaN for sNaN input.  This
patch fixes them to add a NaN input to itself so that qNaN is returned
in this case.

Tested for x86_64 and x86.

[BZ #20228]
* sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Add NaN input to
itself.
* sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Likewise.
* math/libm-test.inc (log10_test_data): Add sNaN tests.

8 years agoFix i386/x86_64 logl (sNaN) (bug 20227).
Joseph Myers [Wed, 8 Jun 2016 22:24:06 +0000 (22:24 +0000)]
Fix i386/x86_64 logl (sNaN) (bug 20227).

The i386/x86_64 versions of logl return sNaN for sNaN input.  This
patch fixes them to add a NaN input to itself so that qNaN is returned
in this case.

Tested for x86_64 and x86 (including a build for i586 to cover the
non-i686 logl version).

[BZ #20227]
* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Add NaN input to
itself.
* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
* sysdeps/x86_64/fpu/e_logl.S (__ieee754_logl): Likewise.
* math/libm-test.inc (log_test_data): Add sNaN tests.

8 years agoFix i386/x86_64 expl, exp10l, expm1l for sNaN input (bug 20226).
Joseph Myers [Wed, 8 Jun 2016 21:55:06 +0000 (21:55 +0000)]
Fix i386/x86_64 expl, exp10l, expm1l for sNaN input (bug 20226).

The i386 and x86_64 implementations of expl, exp10l and expm1l (code
shared between the functions) return sNaN for sNaN input.  This patch
fixes them to add NaN inputs to themselves so that qNaN is returned in
this case.

Tested for x86_64 and x86.

[BZ #20226]
* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Add NaN argument to
itself.
* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise.
* math/libm-test.inc (exp_test_data): Add sNaN tests.
(exp10_test_data): Likewise.
(expm1_test_data): Likewise.

8 years agoFix ldexp, scalbn, scalbln for sNaN input (bug 20225).
Joseph Myers [Wed, 8 Jun 2016 21:32:57 +0000 (21:32 +0000)]
Fix ldexp, scalbn, scalbln for sNaN input (bug 20225).

The wrapper implementations of ldexp / scalbn / scalbln
(architecture-independent), and their float / long double variants,
return sNaN for sNaN input.  This patch fixes them to add relevant
arguments to themselves so that qNaN is returned in this case.

Tested for x86_64 and x86.

[BZ #20225]
* math/s_ldexp.c (__ldexp): Add non-finite or zero argument to
itself.
* math/s_ldexpf.c (__ldexpf): Likewise.
* math/s_ldexpl.c (__ldexpl): Likewise.
* math/w_scalbln.c (__w_scalbln): Likewise.
* math/w_scalblnf.c (__w_scalblnf): Likewise.
* math/w_scalblnl.c (__w_scalblnl): Likewise.
* math/libm-test.inc (scalbn_test_data): Add sNaN tests.
(scalbln_test_data): Likewise.

8 years agoFix i386 cbrtl (sNaN) (bug 20224).
Joseph Myers [Wed, 8 Jun 2016 21:02:40 +0000 (21:02 +0000)]
Fix i386 cbrtl (sNaN) (bug 20224).

The i386 version of cbrtl returns sNaN (without raising any
exceptions) for sNaN input.  This patch fixes it to add non-finite
arguments to themselves (the code path in question is also reached for
zero arguments, for which adding them to themselves is also harmless),
so that "invalid" is raised and qNaN returned.

Tested for x86_64 and x86.

[BZ #20224]
* sysdeps/i386/fpu/s_cbrtl.S (__cbrtl): Add non-finite or zero
argument to itself.
* math/libm-test.inc (cbrt_test_data): Add sNaN tests.

8 years agoX86-64: Remove previous default/SSE2/AVX2 memcpy/memmove
H.J. Lu [Wed, 8 Jun 2016 20:57:50 +0000 (13:57 -0700)]
X86-64: Remove previous default/SSE2/AVX2 memcpy/memmove

Since the new SSE2/AVX2 memcpy/memmove are faster than the previous ones,
we can remove the previous SSE2/AVX2 memcpy/memmove and replace them with
the new ones.

No change in IFUNC selection if SSE2 and AVX2 memcpy/memmove weren't used
before.  If SSE2 or AVX2 memcpy/memmove were used, the new SSE2 or AVX2
memcpy/memmove optimized with Enhanced REP MOVSB will be used for
processors with ERMS.  The new AVX512 memcpy/memmove will be used for
processors with AVX512 which prefer vzeroupper.

Since the new SSE2 memcpy/memmove are faster than the previous default
memcpy/memmove used in libc.a and ld.so, we also remove the previous
default memcpy/memmove and make them the default memcpy/memmove, except
that non-temporal store isn't used in ld.so.

Together, it reduces the size of libc.so by about 6 KB and the size of
ld.so by about 2 KB.

[BZ #19776]
* sysdeps/x86_64/memcpy.S: Make it dummy.
* sysdeps/x86_64/mempcpy.S: Likewise.
* sysdeps/x86_64/memmove.S: New file.
* sysdeps/x86_64/memmove_chk.S: Likewise.
* sysdeps/x86_64/multiarch/memmove.S: Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.S: Likewise.
* sysdeps/x86_64/memmove.c: Removed.
* sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: Likewise.
* sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S: Likewise.
* sysdeps/x86_64/multiarch/memmove-avx-unaligned.S: Likewise.
* sysdeps/x86_64/multiarch/memmove-sse2-unaligned-erms.S:
Likewise.
* sysdeps/x86_64/multiarch/memmove.c: Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.c: Likewise.
* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Remove
memcpy-sse2-unaligned, memmove-avx-unaligned,
memcpy-avx-unaligned and memmove-sse2-unaligned-erms.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Replace
__memmove_chk_avx512_unaligned_2 with
__memmove_chk_avx512_unaligned.  Remove
__memmove_chk_avx_unaligned_2.  Replace
__memmove_chk_sse2_unaligned_2 with
__memmove_chk_sse2_unaligned.  Remove __memmove_chk_sse2 and
__memmove_avx_unaligned_2.  Replace __memmove_avx512_unaligned_2
with __memmove_avx512_unaligned.  Replace
__memmove_sse2_unaligned_2 with __memmove_sse2_unaligned.
Remove __memmove_sse2.  Replace __memcpy_chk_avx512_unaligned_2
with __memcpy_chk_avx512_unaligned.  Remove
__memcpy_chk_avx_unaligned_2.  Replace
__memcpy_chk_sse2_unaligned_2 with __memcpy_chk_sse2_unaligned.
Remove __memcpy_chk_sse2.  Remove __memcpy_avx_unaligned_2.
Replace __memcpy_avx512_unaligned_2 with
__memcpy_avx512_unaligned.  Remove __memcpy_sse2_unaligned_2
and __memcpy_sse2.  Replace __mempcpy_chk_avx512_unaligned_2
with __mempcpy_chk_avx512_unaligned.  Remove
__mempcpy_chk_avx_unaligned_2.  Replace
__mempcpy_chk_sse2_unaligned_2 with
__mempcpy_chk_sse2_unaligned.  Remove __mempcpy_chk_sse2.
Replace __mempcpy_avx512_unaligned_2 with
__mempcpy_avx512_unaligned.  Remove __mempcpy_avx_unaligned_2.
Replace __mempcpy_sse2_unaligned_2 with
__mempcpy_sse2_unaligned.  Remove __mempcpy_sse2.
* sysdeps/x86_64/multiarch/memcpy.S (__new_memcpy): Support
__memcpy_avx512_unaligned_erms and __memcpy_avx512_unaligned.
Use __memcpy_avx_unaligned_erms and __memcpy_sse2_unaligned_erms
if processor has ERMS.  Default to __memcpy_sse2_unaligned.
(ENTRY): Removed.
(END): Likewise.
(ENTRY_CHK): Likewise.
(libc_hidden_builtin_def): Likewise.
Don't include ../memcpy.S.
* sysdeps/x86_64/multiarch/memcpy_chk.S (__memcpy_chk): Support
__memcpy_chk_avx512_unaligned_erms and
__memcpy_chk_avx512_unaligned.  Use
__memcpy_chk_avx_unaligned_erms and
__memcpy_chk_sse2_unaligned_erms if if processor has ERMS.
Default to __memcpy_chk_sse2_unaligned.
* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
Change function suffix from unaligned_2 to unaligned.
* sysdeps/x86_64/multiarch/mempcpy.S (__mempcpy): Support
__mempcpy_avx512_unaligned_erms and __mempcpy_avx512_unaligned.
Use __mempcpy_avx_unaligned_erms and __mempcpy_sse2_unaligned_erms
if processor has ERMS.  Default to __mempcpy_sse2_unaligned.
(ENTRY): Removed.
(END): Likewise.
(ENTRY_CHK): Likewise.
(libc_hidden_builtin_def): Likewise.
Don't include ../mempcpy.S.
(mempcpy): New.  Add a weak alias.
* sysdeps/x86_64/multiarch/mempcpy_chk.S (__mempcpy_chk): Support
__mempcpy_chk_avx512_unaligned_erms and
__mempcpy_chk_avx512_unaligned.  Use
__mempcpy_chk_avx_unaligned_erms and
__mempcpy_chk_sse2_unaligned_erms if if processor has ERMS.
Default to __mempcpy_chk_sse2_unaligned.

8 years agoX86-64: Remove the previous SSE2/AVX2 memsets
H.J. Lu [Wed, 8 Jun 2016 20:55:45 +0000 (13:55 -0700)]
X86-64: Remove the previous SSE2/AVX2 memsets

Since the new SSE2/AVX2 memsets are faster than the previous ones, we
can remove the previous SSE2/AVX2 memsets and replace them with the
new ones.  This reduces the size of libc.so by about 900 bytes.

No change in IFUNC selection if SSE2 and AVX2 memsets weren't used
before.  If SSE2 or AVX2 memset was used, the new SSE2 or AVX2 memset
optimized with Enhanced REP STOSB will be used for processors with
ERMS.  The new AVX512 memset will be used for processors with AVX512
which prefer vzeroupper.

[BZ #19881]
* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Folded
into ...
* sysdeps/x86_64/memset.S: This.
(__bzero): Removed.
(__memset_tail): Likewise.
(__memset_chk): Likewise.
(memset): Likewise.
(MEMSET_CHK_SYMBOL): New. Define only if MEMSET_SYMBOL isn't
defined.
(MEMSET_SYMBOL): Define only if MEMSET_SYMBOL isn't defined.
* sysdeps/x86_64/multiarch/memset-avx2.S: Removed.
(__memset_zero_constant_len_parameter): Check SHARED instead of
PIC.
* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Remove
memset-avx2 and memset-sse2-unaligned-erms.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Remove __memset_chk_sse2,
__memset_chk_avx2, __memset_sse2 and __memset_avx2_unaligned.
* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(__bzero): Enabled.
* sysdeps/x86_64/multiarch/memset.S (memset): Replace
__memset_sse2 and __memset_avx2 with __memset_sse2_unaligned
and __memset_avx2_unaligned.  Use __memset_sse2_unaligned_erms
or __memset_avx2_unaligned_erms if processor has ERMS.  Support
__memset_avx512_unaligned_erms and __memset_avx512_unaligned.
(memset): Removed.
(__memset_chk): Likewise.
(MEMSET_SYMBOL): New.
(libc_hidden_builtin_def): Replace __memset_sse2 with
__memset_sse2_unaligned.
* sysdeps/x86_64/multiarch/memset_chk.S (__memset_chk): Replace
__memset_chk_sse2 and __memset_chk_avx2 with
__memset_chk_sse2_unaligned and __memset_chk_avx2_unaligned_erms.
Use __memset_chk_sse2_unaligned_erms or
__memset_chk_avx2_unaligned_erms if processor has ERMS.  Support
__memset_chk_avx512_unaligned_erms and
__memset_chk_avx512_unaligned.

8 years agoGenerate new format names in auto-libm-test-out
Paul E. Murphy [Wed, 8 Jun 2016 19:56:04 +0000 (14:56 -0500)]
Generate new format names in auto-libm-test-out

This converts the inclusion macro for each test to use
the format specific macro. In addition, the format
specifier is removed as it is applied via the LIT() macro
which is itself applied when converting the auto inputs and
libm-test.inc into libm-test.c.

8 years agoRemove type specific information from auto-libm-test-in
Paul E. Murphy [Wed, 8 Jun 2016 19:41:05 +0000 (14:41 -0500)]
Remove type specific information from auto-libm-test-in

Apply the following sed regexes to auto-libm-test-in in order:

s/flt-32/binary32/
s/dbl-64/binary64/
s/ldbl-96-intel/intel96/
s/ldbl-96-m68k/m68k96/
s/ldbl-128ibm/ibm128/
s/ldbl-128/binary128/

and fixup ldbl-96 comment manually.

8 years agoRemove CHOOSE() macro from libm-tests.inc
Paul E. Murphy [Wed, 8 Jun 2016 19:37:15 +0000 (14:37 -0500)]
Remove CHOOSE() macro from libm-tests.inc

Use gen-libm-test.pl to generate a list of macros
mapping to libm-test-ulps.h as this simplifies adding new
types without having to modify a growing number of
static headers each time a type is added.

This also removes the final usage of the TEST_(DOUBLE|FLOAT|LDOUBLE)
macros.  Thus, they too are removed.

8 years agoApply LIT(x) to floating point literals in libm-test.c
Paul E. Murphy [Wed, 8 Jun 2016 19:28:07 +0000 (14:28 -0500)]
Apply LIT(x) to floating point literals in libm-test.c

With the exception of the second argument of nexttoward,
any suffixes should be stripped from the test input, and
the macro LIT(x) should be applied to use the correct
suffix for the type being tested.

This adds a new argument type "j" to gen-test-libm.pl
to signify an argument to a test input which does not
require fixup.  The test cases of nexttoward have
been updated to use this new feature.

This applies post-processing to all of the test inputs
through gen-libm-test.pl to strip literal suffixes and
apply the LIT(x) macro, with one exception stated above.
This seems a bit cleaner than tossing the macro onto
everything, albeit slightly more obfuscated.

8 years agomalloc: Correct size computation in realloc for dumped fake mmapped chunks
Florian Weimer [Wed, 8 Jun 2016 18:50:21 +0000 (20:50 +0200)]
malloc: Correct size computation in realloc for dumped fake mmapped chunks

For regular mmapped chunks there are two size fields (hence a reduction
by 2 * SIZE_SZ bytes), but for fake chunks, we only have one size field,
so we need to subtract SIZE_SZ bytes.

This was initially reported as Emacs bug 23726.

8 years agoFix i386 atanhl (sNaN) (bug 20219).
Joseph Myers [Tue, 7 Jun 2016 23:08:32 +0000 (23:08 +0000)]
Fix i386 atanhl (sNaN) (bug 20219).

The i386 version of atanhl returns sNaN for sNaN input.  This patch
fixes it to add NaN arguments to themselves so it returns qNaN in this
case.

Tested for x86_64 and x86.

[BZ #20219]
* sysdeps/i386/fpu/e_atanhl.S (__ieee754_atanhl): Add NaN argument
to itself.
* math/libm-test.inc (atanh_test_data): Add sNaN tests.

8 years agoFix i386 asinhl (sNaN) (bug 20218).
Joseph Myers [Tue, 7 Jun 2016 22:54:58 +0000 (22:54 +0000)]
Fix i386 asinhl (sNaN) (bug 20218).

The i386 version of asinhl returns sNaN (without raising any
exceptions) for sNaN input.  This patch fixes it to add non-finite
arguments to themselves, so that "invalid" is raised and qNaN
returned.

Tested for x86_64 and x86.

[BZ #20218]
* sysdeps/i386/fpu/s_asinhl.S (__asinhl): Add non-finite argument
to itself.
* math/libm-test.inc (asinh_test_data): Add sNaN tests.