platform/upstream/glibc.git
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.

8 years agoCheck FMA after COMMON_CPUID_INDEX_80000001
H.J. Lu [Tue, 7 Jun 2016 15:00:21 +0000 (08:00 -0700)]
Check FMA after COMMON_CPUID_INDEX_80000001

Since the FMA4 bit is in COMMON_CPUID_INDEX_80000001 and FMA4 requires
AVX, determine if FMA4 is usable after COMMON_CPUID_INDEX_80000001 is
available and if AVX is usable.

[BZ #20195]
* sysdeps/x86/cpu-features.c (get_common_indeces): Move FMA4
check to ...
(init_cpu_features): Here.

8 years agoBug 20214: Fix linux/in6.h and netinet/in.h sync.
Carlos O'Donell [Tue, 7 Jun 2016 08:46:37 +0000 (04:46 -0400)]
Bug 20214: Fix linux/in6.h and netinet/in.h sync.

In: https://sourceware.org/glibc/wiki/Synchronizing_Headers
we explain how we synchronize our headers with Linux kernel
headers.

In order to synchronize with the Linux linux/in6.h and
linux/ipv6.h headers we checked for their guard macros and
then defined __USE_KERNEL_IPV6_DEFS and conditionalized code
on this macro.

In upstream kernel 56c176c9 the _UAPI prefix was stripped and
this broke our synchronized headers again. We now need to check
for _LINUX_IN6_H and _IPV6_H, and keep checking the old versions
of the header guard checks for maximum backwards compatibility
with older Linux headers (the history is actually a bit muddled
here and it appears upstream linus kernel broke this 10 months
*before* our fix was ever applied to glibc, but without glibc
testing we didn't notice and distro kernels have their own
testing to fix this).

This patch fixes synchronization with linux/in6.h and
with netinet/in.h.

8 years agoBug 20198: quick_exit should not call destructors.
Carlos O'Donell [Mon, 6 Jun 2016 18:20:58 +0000 (14:20 -0400)]
Bug 20198: quick_exit should not call destructors.

In C++11 18.5.12 says "Objects shall not be destroyed as a
result of calling quick_exit." In C11 quick_exit is silent
about thread object destruction. Therefore to make glibc
C++ compliant we do not call any thread local destructors.
A new regression test verifies the fix.

I will note that C++11 18.5.3 makes it clear that C++
defines additional requirements for _Exit() to prevent it
from executing destructors.

Given that the point of _Exit() is to terminate the process
immediately it makes sense the C and C++ should line up
and avoid calling destructors.

No failures. New regtest passes.

8 years agoFix a typo in comments in memmove-vec-unaligned-erms.S
H.J. Lu [Mon, 6 Jun 2016 23:03:21 +0000 (16:03 -0700)]
Fix a typo in comments in memmove-vec-unaligned-erms.S

* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: Fix
a typo in comments.

8 years agoFix dbl-64 asin (sNaN) (bug 20213).
Joseph Myers [Mon, 6 Jun 2016 22:21:11 +0000 (22:21 +0000)]
Fix dbl-64 asin (sNaN) (bug 20213).

The dbl-64 version of asin returns sNaN for sNaN arguments.  This
patch fixes it to add NaN arguments to themselves so that qNaN is
returned in this case.

Tested for x86_64 and x86.

[BZ #20213]
* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Add NaN
argument to itself.
* math/libm-test.inc (asin_test_data): Add sNaN tests.

8 years agoConsolidate pwritev/pwritev64 implementations
Adhemerval Zanella [Mon, 11 Apr 2016 18:07:12 +0000 (15:07 -0300)]
Consolidate pwritev/pwritev64 implementations

This patch consolidates all the pwritev{64} implementation for Linux
in only one (sysdeps/unix/sysv/linux/pwritev{64}.c).  It also removes the
syscall from the auto-generation using assembly macros.

It was based on previous pwrite/pwrite64 consolidation patch.  The new macro
SYSCALL_LL{64} is used to handle the offset argument and alias is created
for __ASSUME_OFF_DIFF_OFF64 in case of pread64.

Checked on x86_64, i386, aarch64, and powerpc64le.

* misc/Makefile (CFLAGS-pwritev.c): New variable: add cancellation
required flags.
(CFLAGS-pwritev64.c): Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/pwritev.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/pwritev64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/pwritev64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/pwritev.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/pwritev64.: Likwise.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (pwritev): Remove
syscall from auto-generation.
* sysdeps/unix/sysv/linux/pwritev.c: Rewrite implementation.
[WORDSIZE == 64] (pwritev64): Remove macro.
[!PWRITEV] (PWRITEV): Likewise.
[!PWRITEV] (PWRITEV_REPLACEMENT): Likewise.
[!PWRITEV] (PWRITE): Likewise.
[!PWRITEV] (OFF_T): Likewise.
[!__ASSUME_PWRITEV] (PWRITEV_REPLACEMENT): Likewise.
(LO_HI_LONG): Remove macro.
[__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (pwritev): Add function.
* sysdeps/unix/sysv/linux/pwritev64.c: Rewrite implementation.
(PWRITEV): Remove macro.
(PWRITEV_REPLACEMENTE): Likewise.
(PWRITE): Likewise.
(OFF_T): Likewise.
(pwritev64): New function.
* nptl/tst-cancel4.c (tf_writev): Add test.

8 years agoConsolidate preadv/preadv64 implementation
Adhemerval Zanella [Mon, 11 Apr 2016 18:06:17 +0000 (15:06 -0300)]
Consolidate preadv/preadv64 implementation

This patch consolidates all the preadv{64} implementation for Linux
in only one (sysdeps/unix/sysv/linux/preadv{64}.c).  It also removes the
syscall from the auto-generation using assembly macros.

It was based on previous pread/pread64 consolidation patch.  The new macro
SYSCALL_LL{64} is used to handle the offset argument and alias is created
for __ASSUME_OFF_DIFF_OFF64 in case of pread64.

Checked on x86_64, i386, aarch64, and powerpc64le.

* misc/Makefile (CFLAGS-preadv.c): New variable: add cancellation
required flags.
(CFLAGS-preadv64.c): Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/preadv.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/preadv64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/preadv64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/preadv.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/preadv64.: Likwise.
* sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list (preadv): Remove
syscall from auto-generation.
* sysdeps/unix/sysv/linux/preadv.c: Rewrite implementation.
[WORDSIZE == 64] (preadv64): Remove macro.
[!PREADV] (PREADV): Likewise.
[!PREADV] (PREADV_REPLACEMENT): Likewise.
[!PREADV] (PREAD): Likewise.
[!PREADV] (OFF_T): Likewise.
[!__ASSUME_PREADV] (PREADV_REPLACEMENT): Likewise.
(LO_HI_LONG): Remove macro.
[__WORDSIZE != 64 || __ASSUME_OFF_DIFF_OFF64] (preadv): Add function.
* sysdeps/unix/sysv/linux/preadv64.c: Rewrite implementation.
(PREADV): Remove macro.
(PREADV_REPLACEMENTE): Likewise.
(PREAD): Likewise.
(OFF_T): Likewise.
(preadv64): New function.
* nptl/tst-cancel4.c (tf_preadv): Add test.

8 years agoFix dbl-64 acos (sNaN) (bug 20212).
Joseph Myers [Mon, 6 Jun 2016 22:10:11 +0000 (22:10 +0000)]
Fix dbl-64 acos (sNaN) (bug 20212).

The dbl-64 version of acos returns sNaN for sNaN arguments.  This
patch fixes it to add NaN arguments to themselves so that qNaN is
returned in this case.

Tested for x86_64 and x86.

[BZ #20212]
* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_acos): Add NaN
argument to itself.
* math/libm-test.inc (acos_test_data): Add sNaN tests.

8 years agopowerpc: Fix --disable-multi-arch build on POWER8
Tulio Magno Quites Machado Filho [Mon, 30 May 2016 21:00:57 +0000 (18:00 -0300)]
powerpc: Fix --disable-multi-arch build on POWER8

Add missing symbols of stpncpy and strcasestr when multi-arch is
disabled.
Fix memset call from strncpy/stpncpy when multi-arch is disabled.

8 years agotst-rec-dlopen: Fix build fail due to missing inclusion of string.h
Stefan Liebler [Mon, 6 Jun 2016 09:03:04 +0000 (11:03 +0200)]
tst-rec-dlopen: Fix build fail due to missing inclusion of string.h

on S390, I get a compile error for dlfcn/tst-rec-dlopen.c:
tst-rec-dlopen.c: In function ‘malloc’:
tst-rec-dlopen.c:101:4: error: implicit declaration of function ‘strlen’ [-Werror=implicit-function-declaration]
    (void) write (STDOUT_FILENO, message, strlen (message));
    ^
tst-rec-dlopen.c:101:42: error: incompatible implicit declaration of built-in function ‘strlen’ [-Werror]
    (void) write (STDOUT_FILENO, message, strlen (message));
                                          ^
tst-rec-dlopen.c:112:42: error: incompatible implicit declaration of built-in function ‘strlen’ [-Werror]
    (void) write (STDOUT_FILENO, message, strlen (message));
                                          ^

This patch adds the missing "#include <string.h>" for strlen.

ChangeLog:

* dlfcn/tst-rec-dlopen.c: Include string.h.

8 years ago2016-06-05 Paul Pluzhnikov <ppluzhnikov@google.com>
Paul Pluzhnikov [Sun, 5 Jun 2016 15:41:13 +0000 (08:41 -0700)]
2016-06-05  Paul Pluzhnikov  <ppluzhnikov@google.com>

* manual/install.texi: Remove mention of --without-tls
* INSTALL: Regenerate.

8 years agotst-rec-dlopen: Use interposed malloc instead of hooks
Florian Weimer [Sun, 5 Jun 2016 14:44:06 +0000 (16:44 +0200)]
tst-rec-dlopen: Use interposed malloc instead of hooks

This avoids use of the deprecated hook variables.

8 years agoUse __typeof instead of typeof
Andreas Schwab [Sat, 4 Jun 2016 07:16:12 +0000 (09:16 +0200)]
Use __typeof instead of typeof

8 years agoFix include/wchar.h for C++
Carlos O'Donell [Fri, 3 Jun 2016 21:21:53 +0000 (17:21 -0400)]
Fix include/wchar.h for C++

When trying to compile regression tests that use
C++ and the threads header you get this failure:

In file included from /usr/include/c++/5.3.1/cwchar:44:0,
from /usr/include/c++/5.3.1/bits/postypes.h:40,
from /usr/include/c++/5.3.1/bits/char_traits.h:40,
from /usr/include/c++/5.3.1/string:40,
from /usr/include/c++/5.3.1/stdexcept:39,
from /usr/include/c++/5.3.1/array:38,
from /usr/include/c++/5.3.1/tuple:39,
from /usr/include/c++/5.3.1/functional:55,
from /usr/include/c++/5.3.1/thread:39,
from tst-thread-quick_exit.cc:19:
../include/wchar.h:105:23: error: invalid conversion from ‘wchar_t*
(*)(wchar_t*, wchar_t, size_t) throw () {aka wchar_t* (*)(wchar_t*,
wchar_t, long unsigned int) throw ()}’ to ‘int’ [-fpermissive]
extern typeof (wmemset) __wmemset;
^
../include/wchar.h:105:25: error: expected ‘,’ or ‘;’ before ‘__wmemset’
extern typeof (wmemset) __wmemset;
^

The simplest fix for C++ is to avoid the use of
typeof and just declare the prototype as expected.

No regressions on x86_64. Committed as obvious.
The include/wchar.h header is only for internal
build uses and therefore is not ever seen by any
external users and needs no bug #.

8 years agoFix x86/x86_64 nextafterl incrementing negative subnormals (bug 20205).
Joseph Myers [Fri, 3 Jun 2016 21:30:12 +0000 (21:30 +0000)]
Fix x86/x86_64 nextafterl incrementing negative subnormals (bug 20205).

The x86 / x86_64 implementation of nextafterl (also used for
nexttowardl) produces incorrect results (NaNs) when negative
subnormals, the low 32 bits of whose mantissa are zero, are
incremented towards zero.  This patch fixes this by disabling the
logic to decrement the exponent in that case.

Tested for x86_64 and x86.

[BZ #20205]
* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Do not adjust
exponent when incrementing negative subnormal with low mantissa
word zero.
* math/libm-test.inc (nextafter_test_data) [TEST_COND_intel96]:
Add another test.

8 years agolibio: Use wmemset instead of __wmemset to avoid linknamespace issue
Florian Weimer [Fri, 3 Jun 2016 07:48:14 +0000 (09:48 +0200)]
libio: Use wmemset instead of __wmemset to avoid linknamespace issue

If the wide string operations are pulled into the link, the
wmemset symbol can cause a linknamespace failure.

8 years agoFix macro API for __USE_KERNEL_IPV6_DEFS.
Carlos O'Donell [Fri, 3 Jun 2016 03:30:11 +0000 (23:30 -0400)]
Fix macro API for __USE_KERNEL_IPV6_DEFS.

The use of __USE_KERNEL_IPV6_DEFS with ifndef is bad
practice per: https://sourceware.org/glibc/wiki/Wundef.
This change moves it to use 'if' and always define the
macro.

Please note that this is not the only problem with this
code. I have a series of fixes after this one to resolve
breakage with this code and add regression tests for it
via compile-only source testing (to be discussed in another
thread).

Unfortunately __USE_KERNEL_XATTR_DEFS is set by the kernel
and not glibc, and uses 'define', so we can't fix that yet.

8 years agofork in libpthread cannot use IFUNC resolver [BZ #19861]
Florian Weimer [Wed, 1 Jun 2016 05:14:42 +0000 (07:14 +0200)]
fork in libpthread cannot use IFUNC resolver [BZ #19861]

This commit only addresses the fork case, the vfork case has to be a
tail call, which is why the generic code needs an IFUNC resolver
there.

8 years agoMerge branch 'master' of ssh://sourceware.org/git/glibc
Paul Pluzhnikov [Mon, 30 May 2016 22:33:13 +0000 (15:33 -0700)]
Merge branch 'master' of ssh://sourceware.org/git/glibc

8 years ago2016-05-30 Paul Pluzhnikov <ppluzhnikov@google.com>
Paul Pluzhnikov [Mon, 30 May 2016 22:32:09 +0000 (15:32 -0700)]
2016-05-30  Paul Pluzhnikov  <ppluzhnikov@google.com>

[BZ 19653]
* inet/if_index.c (__protocol_available): Delete #if 0'd code.
* inet/ruserpass.c (ruserpass): Delete #if 0'd code.

8 years agohurd: disable ifunc for now
Samuel Thibault [Mon, 30 May 2016 20:13:47 +0000 (22:13 +0200)]
hurd: disable ifunc for now

* sysdeps/mach/hurd/configure.ac (libc_cv_ld_gnu_indirect_function):
Set to no.
* sysdeps/mach/hurd/configure: Refresh.

8 years agoAdd more hurd exception to local headers list
Samuel Thibault [Mon, 30 May 2016 17:03:01 +0000 (19:03 +0200)]
Add more hurd exception to local headers list

* scripts/check-local-headers.sh (exclude): Add hurd/ihash.h, and
include .*-.*/ in addition to .*-.*-.*/ (i.e. i386-gnu in addition to
i386-linux-gnu).

8 years agoposix: Call _exit in failure case for posix_spawn{p} (BZ#20178)
Adhemerval Zanella [Mon, 30 May 2016 13:04:47 +0000 (10:04 -0300)]
posix: Call _exit in failure case for posix_spawn{p} (BZ#20178)

This patch call _exit instead of exit in failure case for the spawned
child in Linux posix_spawn{p} implementation.

Tested on x86_64.

[BZ #20178]
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Call _exit
on failure instead of exit.

8 years agostpcpy is part of POSIX.1-2008 [BZ #3629]
Roland McGrath [Mon, 30 May 2016 11:28:25 +0000 (13:28 +0200)]
stpcpy is part of POSIX.1-2008 [BZ #3629]

8 years agohurd: fix _hurd_self_sigstate reference from ____longjmp_chk
Samuel Thibault [Sun, 29 May 2016 23:24:09 +0000 (01:24 +0200)]
hurd: fix _hurd_self_sigstate reference from ____longjmp_chk

* sysdeps/mach/hurd/i386/____longjmp_chk.S (____longjmp_chk) [PIC]:
  Use PLT entry for calling _hurd_self_sigstate.

8 years agoCount number of logical processors sharing L2 cache
H.J. Lu [Fri, 27 May 2016 22:16:22 +0000 (15:16 -0700)]
Count number of logical processors sharing L2 cache

For Intel processors, when there are both L2 and L3 caches, SMT level
type should be ued to count number of available logical processors
sharing L2 cache.  If there is only L2 cache, core level type should
be used to count number of available logical processors sharing L2
cache.  Number of available logical processors sharing L2 cache should
be used for non-inclusive L2 and L3 caches.

* sysdeps/x86/cacheinfo.c (init_cacheinfo): Count number of
available logical processors with SMT level type sharing L2
cache for Intel processors.

8 years agoFix powerpc64 ceil, rint etc. on sNaN input (bug 20160).
Joseph Myers [Fri, 27 May 2016 17:47:54 +0000 (17:47 +0000)]
Fix powerpc64 ceil, rint etc. on sNaN input (bug 20160).

The powerpc64 versions of ceil, floor, round, trunc, rint, nearbyint
and their float versions return sNaN for sNaN input when they should
return qNaN.  This patch fixes them to add a NaN argument to itself to
quiet sNaNs before returning.

Tested for powerpc64.

[BZ #20160]
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S (__ceil): Add NaN
argument to itself before returning the result.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floor.S (__floor): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S (__nearbyint):
Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S (__nearbyintf):
Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rint.S (__rint): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rintf.S (__rintf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_round.S (__round): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_roundf.S (__roundf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_trunc.S (__trunc): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_truncf.S (__truncf): Likewise.

8 years agoFix powerpc32 ceil, rint etc. on sNaN input (bug 20160).
Joseph Myers [Fri, 27 May 2016 17:31:21 +0000 (17:31 +0000)]
Fix powerpc32 ceil, rint etc. on sNaN input (bug 20160).

The powerpc32 versions of ceil, floor, round, trunc, rint, nearbyint
and their float versions return sNaN for sNaN input when they should
return qNaN.  This patch fixes them to add a NaN argument to itself to
quiet sNaNs before returning.  The powerpc64 versions, which have the
same bug, will be addressed separately.

Tested for powerpc32.

[BZ #20160]
* sysdeps/powerpc/powerpc32/fpu/s_ceil.S (__ceil): Add NaN
argument to itself before returning the result.
* sysdeps/powerpc/powerpc32/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_floor.S (__floor): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S (__nearbyint):
Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S (__nearbyintf):
Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_rint.S (__rint): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_rintf.S (__rintf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_round.S (__round): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_roundf.S (__roundf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_trunc.S (__trunc): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_truncf.S (__truncf): Likewise.

8 years agoReplace M_El with lit_e in libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 17:05:47 +0000 (12:05 -0500)]
Replace M_El with lit_e in libm-test.inc

This is useful in situations where the long double type is
less precise than the type under test.

8 years agoReplace M_PI_4l with lit_pi_4_d in libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 17:05:02 +0000 (12:05 -0500)]
Replace M_PI_4l with lit_pi_4_d in libm-test.inc

This is useful in situations where the long double type is
less precise than the type under test.

8 years agoReplace M_PIl with lit_pi in libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 17:04:23 +0000 (12:04 -0500)]
Replace M_PIl with lit_pi in libm-test.inc

This is useful in situations where the long double type is
less precise than the type under test.

8 years agoReplace M_PI2l with lit_pi_2_d in libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 17:03:33 +0000 (12:03 -0500)]
Replace M_PI2l with lit_pi_2_d in libm-test.inc

This is useful in situations where the long double type is
less precise than the type under test.  This adds a new
wrapper macro LITM(x) to each type to append the proper
suffix onto macro constants found in math.h.

8 years agoRefactor M_ macros defined in libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 17:02:34 +0000 (12:02 -0500)]
Refactor M_ macros defined in libm-test.inc

These are local to the test suite.  Rename them as a macro starting
with lit_pi and a series of postfix operations to give us a constant
starting with lit_pi.

The lit prefix is intended to enable easy substitutions via
gen-test-libm.pl if needed.

8 years agoAvoid "invalid" exceptions from powerpc fabsl (sNaN) (bug 20157).
Joseph Myers [Fri, 27 May 2016 15:29:31 +0000 (15:29 +0000)]
Avoid "invalid" exceptions from powerpc fabsl (sNaN) (bug 20157).

The powerpc implementations of fabsl for ldbl-128ibm (both powerpc32
and powerpc64) wrongly raise the "invalid" exception for sNaN
arguments.  fabs functions should be quiet for all inputs including
signaling NaNs.  The problem is the use of a comparison instruction
fcmpu to determine if the high part of the argument is negative and so
the low part needs to be negated; such instructions raise "invalid"
for sNaNs.

There is a pure integer implementation of fabsl in
sysdeps/ieee754/ldbl-128ibm/s_fabsl.c.  However, it's not necessary to
use it to avoid such exceptions.  The fsel instruction does not raise
exceptions for sNaNs, and can be used in place of the original
comparison.  (Note that if the high part is zero or a NaN, it does not
matter whether the low part is negated; the choice of whether the low
part of a zero is +0 or -0 does not affect the value, and the low part
of a NaN does not affect the value / payload either.)

The condition in GCC for fsel to be available is TARGET_PPC_GFXOPT,
corresponding to the _ARCH_PPCGR predefined macro.  fsel is available
on all 64-bit processors supported by GCC.  A few 32-bit processors
supported by GCC do not have TARGET_PPC_GFXOPT despite having hard
float support.  To support those processors, integer code (similar to
that in copysignl) is included for the !_ARCH_PPCGR case for
powerpc32.

Tested for powerpc32 (configurations with and without _ARCH_PPCGR) and
powerpc64.

[BZ #20157]
* sysdeps/powerpc/powerpc32/fpu/s_fabsl.S (__fabsl): Use fsel to
determine whether to negate low half if [_ARCH_PPCGR], and integer
comparison otherwise.
* sysdeps/powerpc/powerpc64/fpu/s_fabsl.S (__fabsl): Use fsel to
determine whether to negate low half.

8 years agoRemove unused macros from libm-test.inc.
Joseph Myers [Fri, 27 May 2016 15:26:48 +0000 (15:26 +0000)]
Remove unused macros from libm-test.inc.

This patch removes various no-longer-used macros from libm-test.inc.
NO_TEST_INLINE_FLOAT, NO_TEST_INLINE_DOUBLE and M_PI_6l would have
been used before relevant tests were moved to auto-libm-test-in.
TEST_COND_x86_64 and TEST_COND_x86 were for tests in auto-libm-test-in
XFAILed for x86, and are no longer relevant now the bugs in question
have been fixed and the XFAILing removed (if future x86-specific
XFAILs become needed, they can always be added back).

Tested for x86_64 and x86.

* math/libm-test.inc (NO_TEST_INLINE_FLOAT): Remove macro.
(NO_TEST_INLINE_DOUBLE): Likewise.
(TEST_COND_x86_64): Likewise.
(TEST_COND_x86): Likewise.
(M_PI_6l): Likewise.

8 years agoRefactor type specific macros using regexes
Paul E. Murphy [Thu, 12 May 2016 16:35:34 +0000 (11:35 -0500)]
Refactor type specific macros using regexes

Replace most of the type specific macros  with the equivalent
type-generic macro using the following sed replacement command below:

sed -ri -e 's/defined TEST_FLOAT/TEST_COND_binary32/' \
        -e 's/ndef TEST_FLOAT/ !TEST_COND_binary32/'  \
        -e 's/def TEST_FLOAT/ TEST_COND_binary32/'    \
        -e 's/defined TEST_DOUBLE/TEST_COND_binary64/'\
        -e 's/ndef TEST_DOUBLE/ !TEST_COND_binary64/' \
        -e 's/def TEST_DOUBLE/ TEST_COND_binary64/'   \
        -e 's/defined TEST_LDOUBLE && //'             \
        -e 's/ifdef TEST_LDOUBLE/if MANT_DIG >= 64/'  \
        -e 's/defined TEST_LDOUBLE/MANT_DIG >= 64/'   \
        -e '/nexttoward_test_data\[\]/,/  };/!s/LDBL_(MIN_EXP|MAX_EXP|MANT_DIG)/\1/g' \
        libm-test.inc

With a little extra manual cleanup to simplify the following case:

#if MANT_DIG >= 64
# if MANT_DIG >= 64
...
# endif
...

Note, TEST_LDOUBLE checks are replaced by MANT_DIG >= 64 excepting
where another property of the type is being tested. And, the final
regex is intended to avoid replacing LDBL_ macro usage within the
nexttoward tests which explicitly take argument 2 as long double.

8 years agoBegin refactor of libm-test.inc
Paul E. Murphy [Fri, 27 May 2016 14:53:51 +0000 (09:53 -0500)]
Begin refactor of libm-test.inc

Attempt to creatively redefine the macros
to choose tests based on the format being
tested, not the type.

Note, TS 18661 does not define any printf
modifiers, so we need to be a little more
verbose about constructing strings to
output.

8 years agoFix ldbl-128ibm ceill, rintl etc. for sNaN arguments (bug 20156).
Joseph Myers [Fri, 27 May 2016 13:59:24 +0000 (13:59 +0000)]
Fix ldbl-128ibm ceill, rintl etc. for sNaN arguments (bug 20156).

The ldbl-128ibm implementations of ceill, floorl, roundl, truncl,
rintl and nearbyintl wrongly return an sNaN when given an sNaN
argument.  This patch fixes them to add such an argument to itself to
turn it into a quiet NaN.  (The code structure means this "else" case
applies to any argument which is zero or not finite; it's OK to do
this in all such cases.)

Tested for powerpc.

[BZ #20156]
* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Add high part
to itself when zero or not finite.
* sysdeps/ieee754/ldbl-128ibm/s_floorl.c (__floorl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c (__rintl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_roundl.c (__roundl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_truncl.c (__truncl): Likewise.

8 years agoFix ldbl-128ibm sqrtl (sNaN) (bug 20153).
Joseph Myers [Thu, 26 May 2016 22:58:36 +0000 (22:58 +0000)]
Fix ldbl-128ibm sqrtl (sNaN) (bug 20153).

The ldbl-128ibm implementation of sqrtl wrongly returns an sNaN for
signaling NaN arguments.  This patch fixes it to quiet its argument,
using the same x * x + x return for infinities and NaNs as the dbl-64
implementation uses to ensure that +Inf maps to +Inf while -Inf and
NaN map to NaN.

Tested for powerpc.

[BZ #20153]
* sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (__ieee754_sqrtl): Return
x * x + x for infinities and NaNs.

8 years agoFix ldbl-128 j0l, j1l, y0l, y1l for sNaN argument (bug 20151).
Joseph Myers [Thu, 26 May 2016 20:55:03 +0000 (20:55 +0000)]
Fix ldbl-128 j0l, j1l, y0l, y1l for sNaN argument (bug 20151).

The ldbl-128 implementations of j0l, j1l, y0l, y1l (also used for
ldbl-128ibm) return an sNaN argument unchanged.  This patch fixes them
to add a NaN argument to itself to quiet it before return.

Tested for mips64.

[BZ #20151]
* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Add NaN
argument to itself before returning result.
(__ieee754_y0l): Likewise.
* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Likewise.
(__ieee754_y1l).

8 years agoAdd more sNaN tests to libm-test.inc.
Joseph Myers [Thu, 26 May 2016 18:07:04 +0000 (18:07 +0000)]
Add more sNaN tests to libm-test.inc.

This patch adds more tests of signaling NaN inputs to libm-test.inc.
These tests are for a subset of functions with a single floating-point
input where no failures appeared in x86_64 or x86 testing.  I intend
to investigate any failures of these new tests on some other
architectures before dealing with other functions.

Tested for x86_64 and x86.

* math/libm-test.inc (acosh_test_data): Add sNaN tests.
(atan_test_data): Likewise.
(ceil_test_data): Likewise.
(cos_test_data): Likewise.
(cosh_test_data): Likewise.
(erf_test_data): Likewise.
(exp2_test_data): Likewise.
(fabs_test_data): Likewise.
(floor_test_data): Likewise.
(ilogb_test_data): Likewise.
(j0_test_data): Likewise.
(j1_test_data): Likewise.
(jn_test_data): Likewise.
(lgamma_test_data): Likewise.
(lrint_test_data): Likewise.
(llrint_test_data): Likewise.
(logb_test_data): Likewise.
(lround_test_data): Likewise.
(llround_test_data): Likewise.
(nearbyint_test_data): Likewise.
(rint_test_data): Likewise.
(round_test_data): Likewise.
(sin_test_data): Likewise.
(sincos_test_data): Likewise.
(sinh_test_data): Likewise.
(sqrt_test_data): Likewise.
(tan_test_data): Likewise.
(tanh_test_data): Likewise.
(tgamma_test_data): Likewise.
(trunc_test_data): Likewise.
(y0_test_data): Likewise.
(y1_test_data): Likewise.
(yn_test_data): Likewise.

8 years agoSupport sNaN testing in libm-test.inc.
Joseph Myers [Thu, 26 May 2016 16:38:04 +0000 (16:38 +0000)]
Support sNaN testing in libm-test.inc.

This patch adds support in libm-test.inc for tests with signaling NaN
arguments.  gen-libm-test.pl is made to set a flag TEST_SNAN for such
tests, so that they can be disabled automatically when sNaN testing
isn't supported for a given type (at present, for float and double on
32-bit x86 because it's unpredictable when a value might be loaded
into a floating-point register and so automatically converted to long
double with sNaNs converted to quiet NaNs).  -fsignaling-nans is used
where needed.

Tests are added for classification macros, as a starting point; this
is deliberately more conservative than Thomas's patch
<https://sourceware.org/ml/libc-ports/2013-04/msg00008.html>, to allow
more tests to be added, and issues exposed fixed, bit by bit.

Tested for x86_64 and x86.

* math/libm-test.inc: Update comment about NaN testing.
(TEST_SNAN): New macro.
(snan_value): Likewise.
(enable_test): Disable tests of sNaNs when SNAN_TESTS fails.
(fpclassify_test_data): Add sNaN tests.
(isfinite_test_data): Likewise.
(isinf_test_data): Likewise.
(isnan_test_data): Likewise.
(isnormal_test_data): Likewise.
(issignaling_test_data): Likewise.
(signbit_test_data): Likewise.
* math/gen-libm-test.pl (%beautify): Add snan_value.
(show_exceptions): Add argument $test_snan.
(parse_args): Handle snan_value as non-finite.  Update call to
show_exceptions.
* math/Makefile (libm-test-no-inline-cflags): Add
-fsignaling-nans.

8 years agonetwork: Fix missing bits from {recv,send}{m}msg standard com,pliance
Adhemerval Zanella [Thu, 26 May 2016 14:11:33 +0000 (11:11 -0300)]
network: Fix missing bits from {recv,send}{m}msg standard com,pliance

This patch fixes wrong/missing bits from the Fix {recv,send}{m}msg
standard compliance (BZ#16919) patches:

  * nptl/Makefile sets CFLAGS-oldrecvfrom.c, but there's no such file as
    oldrecvfrom.c.  It should be oldsendmsg.c as defined by ChangeLog.

  * sysdeps/unix/sysv/linux/hppa/Versions and
    sysdeps/unix/sysv/linux/i386/Versions list a symbol recvms instead of
    recvmsg at version GLIBC_2.24.

* nptl/Makefile (CFLAGS-oldrecvfrom.c): Remove rule.
(CFLAGS-oldsendmsg.c): Add rule.
* sysdeps/unix/sysv/linux/hppa/Versions [libc] (GLIBC_2.24):
Correct recvmsg symbol name.
* sysdeps/unix/sysv/linux/i386/Versions [libc] (GLIBC_2.24):
Likewise.

8 years agonetwork: recvmmsg and sendmmsg standard compliance (BZ#16919)
Adhemerval Zanella [Thu, 17 Mar 2016 12:52:17 +0000 (09:52 -0300)]
network: recvmmsg and sendmmsg standard compliance (BZ#16919)

POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively, however Linux implements
it as a size_t.  So for 64-bits architecture where sizeof of size_t is
larger than socklen_t, both sendmmsg and recvmmsg need to adjust the
mmsghdr::msg_hdr internal fields before issuing the syscall itself.

This patch fixes it by operating on the padding if it the case.
For recvmmsg, the most straightfoward case, only zero padding the fields
is suffice.  However, for sendmmsg, where adjusting the buffer is out
of the contract (since it may point to a read-only data), the function
is rewritten to use sendmsg instead (which from previous patch
allocates a temporary msghdr to operate on).

Also for 64-bit ports that requires it, a new recvmmsg and sendmmsg
compat version is created (which uses size_t for both cmsghdr::cmsg_len
and internal

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

* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket] (sysdep_routines): Add oldrecvmmsg and
oldsendmmsg.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add recvmmsg and
sendmmsg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/oldrecvmmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmmsg.c (__recvmmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmmsg.c (__sendmmsg): Likewise.

8 years agonetwork: recvmsg and sendmsg standard compliance (BZ#16919)
Adhemerval Zanella [Fri, 18 Mar 2016 20:34:33 +0000 (17:34 -0300)]
network: recvmsg and sendmsg standard compliance (BZ#16919)

POSIX specifies that both msghdr::msg_iovlen and msghdr::msg_controllen
to be of size int and socklen_t respectively.  However Linux defines it as
both size_t and for 64-bit it requires some adjustments to make the
functions standard compliance.

This patch fixes it by creating a temporary header and zeroing the pad
fields for 64-bits architecture where size of size_t exceeds the size of
the int.

Also the new recvmsg and sendmsg implementation is only added on libc,
with libpthread only containing a compat symbol.

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

* conform/data/sys/socket.h-data (msghdr.msg_iovlen): Remove xfail-
and change to correct expected type.
(msghdr.msg_controllen): Likewise.
(cmsghdr.cmsg_len): Likewise.
* sysdeps/unix/sysv/linux/bits/socket.h (msghdr.msg_iovlen): Fix
expected POSIX assumption about the size.
(msghdr.msg_controllen): Likewise.
(msghdr.__glibc_reserved1): Likewise.
(msghdr.__glibc_reserved2): Likewise.
(cmsghdr.cmsg_len): Likewise.
(cmsghdr.__glibc_reserved1): Likewise.
* nptl/Makefile (libpthread-routines): Remove ptw-recvmsg and ptw-sendmsg.
Add ptw-oldrecvmsg and ptw-oldsendmsg.
(CFLAGS-sendmsg.c): Remove rule.
(CFLAGS-recvmsg.c): Likewise.
(CFLAGS-oldsendmsg.c): Add rule.
(CFLAGS-oldrecvmsg.c): Likewise.
* sysdeps/unix/sysv/linux/alpha/Versions [libc] (GLIBC_2.24): Add
recvmsg and sendmsg.
* sysdeps/unix/sysv/linux/aarch64/Version [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/arm/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/ia64/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/mips/mips64/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/tile/tilegx/tilegx64/Versions [libc]
(GLIBC_2.24): Likewise.
( sysdeps/unix/sysv/linux/x86_64/64/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/x84_64/Versions [libc] (GLIBC_2.24):
Likewise.
* sysdeps/unix/sysv/linux/Makefile
[$(subdir) = socket)] (sysdep_headers): Add oldrecvmsg and oldsendmsg.
(CFLAGS-sendmsg.c): Add rule.
(CFLAGS-recvmsg.c): Likewise.
(CFLAGS-oldsendmsg.c): Likewise.
(CFLAGS-oldrecvmsg.c): Likewise.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Fix msghdr
initialization.
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise.
* sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise.
* sysdeps/unix/sysv/linux/oldrecvmsg.c: New file.
* sysdeps/unix/sysv/linux/oldsendmsg.c: Likewise.
* sysdeps/unix/sysv/linux/recvmsg.c (__libc_recvmsg): Adjust msghdr
iovlen and controllen fields to adjust to POSIX specification.
* sysdeps/unix/sysv/linux/sendmsg.c (__libc_sendmsg): Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: New version and
added recvmsg and sendmsg.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdepe/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
Likewise.
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.

8 years agoAdjust kernel-features.h defaults for recvmsg and sendmsg
Adhemerval Zanella [Tue, 15 Mar 2016 20:42:26 +0000 (17:42 -0300)]
Adjust kernel-features.h defaults for recvmsg and sendmsg

This patch removes the auto-generation for recvmsg and sendmsg syscall
and adjust the kernel-features.h for all architectures supported on
Linux.  This patch follows the idea of 'Adjust kernel-features.h defaults
for socket syscalls.' (35ade9f11b9007ee9683529f2d33698ff35255c8) by define
__ASSUME_SENDMSG_SYSCALL and __ASSUME_RECVMSG_SYSCALL as supported by
default and undefine it for the architecture that do not support it
directly.

The main rationale is to make is easier add code wrapper over the syscall
to fix BZ#16919 (recvmsg standard compliance).

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

* sysdeps/unix/sysv/linux/alpha/syscalls.list (recvmsg): Remove
from auto-generation.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/arm/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/mips/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (recvmsg):
Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (recvmsg): Likewise.
(sendmsg): Likewise.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Define.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Remove.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[__LINUX_KERNEL_VERSION < 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Undefine.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Likewise.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SENDMSG_SYSCALL): Likewise.
(__ASSUME_RECVMSG_SYSCALL): Likewise.

8 years agoRefactor tst-strtod-round.c for type-generic-ness
Paul E. Murphy [Mon, 9 May 2016 22:59:37 +0000 (17:59 -0500)]
Refactor tst-strtod-round.c for type-generic-ness

Reduce much of the redundancy in this file, and attempt
to coral the type specific stuff to ease adding an new type.

8 years agoDo not raise "inexact" from powerpc64 ceil, floor, trunc (bug 15479).
Joseph Myers [Wed, 25 May 2016 17:42:22 +0000 (17:42 +0000)]
Do not raise "inexact" from powerpc64 ceil, floor, trunc (bug 15479).

Continuing fixes for ceil, floor and trunc functions not to raise the
"inexact" exception, this patch fixes the versions used on older
powerpc64 processors.  As was done with the round implementations some
time ago, the save of floating-point state is moved after the first
floating-point operation on the input to ensure that any "invalid"
exception from signaling NaN input is included in the saved state, and
then the whole state gets restored rather than just the rounding mode.

This has no effect on configurations using the power5+ code, since
such processors can do these operations with a single instruction (and
those instructions do not set "inexact", so are correct for TS 18661-1
semantics).

Tested for powerpc64.

[BZ #15479]
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S (__ceil): Move save of
floating-point state after first floating-point operation on
input.  Restore full floating-point state instead of just rounding
mode.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floor.S (__floor): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_trunc.S (__trunc): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_truncf.S (__truncf): Likewise.

8 years agoDo not raise "inexact" from powerpc32 ceil, floor, trunc (bug 15479).
Joseph Myers [Wed, 25 May 2016 16:53:23 +0000 (16:53 +0000)]
Do not raise "inexact" from powerpc32 ceil, floor, trunc (bug 15479).

Continuing fixes for ceil, floor and trunc functions not to raise the
"inexact" exception, this patch fixes the versions used on older
powerpc32 processors.  As was done with the round implementations some
time ago, the save of floating-point state is moved after the first
floating-point operation on the input to ensure that any "invalid"
exception from signaling NaN input is included in the saved state, and
then the whole state gets restored rather than just the rounding mode.

This has no effect on configurations using the power5+ code, since
such processors can do these operations with a single instruction (and
those instructions do not set "inexact", so are correct for TS 18661-1
semantics).

Tested for powerpc32.

[BZ #15479]
* sysdeps/powerpc/powerpc32/fpu/s_ceil.S (__ceil): Move save of
floating-point state after first floating-point operation on
input.  Restore full floating-point state instead of just rounding
mode.
* sysdeps/powerpc/powerpc32/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_floor.S (__floor): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_trunc.S (__trunc): Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_truncf.S (__truncf): Likewise.

8 years agoFix UTF-16 surrogate handling. [BZ #19727]
Stefan Liebler [Wed, 25 May 2016 15:18:06 +0000 (17:18 +0200)]
Fix UTF-16 surrogate handling. [BZ #19727]

According to the latest Unicode standard, a conversion from/to UTF-xx has
to report an error if the character value is in range of an utf16 surrogate
(0xd800..0xdfff). See https://sourceware.org/ml/libc-help/2015-12/msg00015.html.
Thus this patch fixes this behaviour for converting from utf32 to internal and
from internal to utf8.

Furthermore the conversion from utf16 to internal does not report an error if the
input-stream consists of two low-surrogate values. If an uint16_t value is in the
range of 0xd800 .. 0xdfff, the next uint16_t value is checked, if it is in the
range of a low surrogate (0xdc00 .. 0xdfff). Afterwards these two uint16_t
values are interpreted as a high- and low-surrogates pair. But there is no test
if the first uint16_t value is really in the range of a high-surrogate
(0xd800 .. 0xdbff). If there would be two uint16_t values in the range of a low
surrogate, then they will be treated as a valid high- and low-surrogates pair.
This patch adds this test.

This patch also adds a new testcase, which checks UTF conversions with input
values in range of UTF16 surrogates. The test converts from UTF-xx to INTERNAL,
INTERNAL to UTF-xx and directly between UTF-xx to UTF-yy. The latter conversion
is needed because s390 has iconv-modules, which converts from/to UTF in one step.
The new testcase was tested on a s390, power and intel machine.

ChangeLog:

[BZ #19727]
* iconvdata/utf-16.c (BODY): Report an error if first word is not a
valid high surrogate.
* iconvdata/utf-32.c (BODY): Report an error if the value is in range
of an utf16 surrogate.
* iconv/gconv_simple.c (BODY): Likewise.
* iconvdata/bug-iconv12.c: New file.
* iconvdata/Makefile (tests): Add bug-iconv12.

rename test

8 years agoFix ucs4le_internal_loop in error case. [BZ #19726]
Stefan Liebler [Wed, 25 May 2016 15:18:06 +0000 (17:18 +0200)]
Fix ucs4le_internal_loop in error case. [BZ #19726]

When converting from UCS4LE to INTERNAL, the input-value is checked for a too
large value and the iconv() call sets errno to EILSEQ. In this case the inbuf
argument of the iconv() call should point to the invalid character, but it
points to the beginning of the inbuf.
Thus this patch updates the pointers inptrp and outptrp before returning in
this error case.

This patch also adds a new testcase for this issue.
The new test was tested on a s390, power, intel machine.

ChangeLog:

[BZ #19726]
* iconv/gconv_simple.c (ucs4le_internal_loop): Update inptrp and
outptrp in case of an illegal input.
* iconv/tst-iconv6.c: New file.
* iconv/Makefile (tests): Add tst-iconv6.

8 years agoS390: Fix utf32 to utf16 handling of low surrogates (disable cu42).
Stefan Liebler [Wed, 25 May 2016 15:18:06 +0000 (17:18 +0200)]
S390: Fix utf32 to utf16 handling of low surrogates (disable cu42).

According to the latest Unicode standard, a conversion from/to UTF-xx has
to report an error if the character value is in range of an utf16 surrogate
(0xd800..0xdfff). See https://sourceware.org/ml/libc-help/2015-12/msg00015.html.

Thus the cu42 instruction, which converts from utf32 to utf16,  has to be
disabled because it does not report an error in case of a value in range of
a low surrogate (0xdc00..0xdfff). The etf3eh variant is removed and the c,
vector variant is adjusted to handle the value in range of an utf16 low
surrogate correctly.

ChangeLog:

* sysdeps/s390/utf16-utf32-z9.c: Disable cu42 instruction and report
an error in case of a value in range of an utf16 low surrogate.

8 years agoS390: Fix utf32 to utf8 handling of low surrogates (disable cu41).
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Fix utf32 to utf8 handling of low surrogates (disable cu41).

According to the latest Unicode standard, a conversion from/to UTF-xx has
to report an error if the character value is in range of an utf16 surrogate
(0xd800..0xdfff). See https://sourceware.org/ml/libc-help/2015-12/msg00015.html.

Thus the cu41 instruction, which converts from utf32 to utf8,  has to be
disabled because it does not report an error in case of a value in range of
a low surrogate (0xdc00..0xdfff). The etf3eh variant is removed and the c,
vector variant is adjusted to handle the value in range of an utf16 low
surrogate correctly.

ChangeLog:

* sysdeps/s390/utf8-utf32-z9.c: Disable cu41 instruction and report
an error in case of a value in range of an utf16 low surrogate.

8 years agoS390: Use s390-64 specific ionv-modules on s390-32, too.
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Use s390-64 specific ionv-modules on s390-32, too.

This patch reworks the existing s390 64bit specific iconv modules in order
to use them on s390 31bit, too.

Thus the parts for subdirectory iconvdata in sysdeps/s390/s390-64/Makefile
were moved to sysdeps/s390/Makefile so that they apply on 31bit, too.
All those modules are moved from sysdeps/s390/s390-64 directory to sysdeps/s390.

The iso-8859-1 to/from cp037 module was adjusted, to use brct (branch relative
on count) instruction on 31bit s390 instead of brctg, because the brctg is a
zarch instruction and is not available on a 31bit kernel.

The utf modules are using zarch instructions, thus the directive machinemode
zarch_nohighgprs was added to the inline assemblies to omit the high-gprs flag
in the shared libraries. Otherwise they can't be loaded on a 31bit kernel.
The ifunc resolvers were adjusted in order to call the etf3eh or vector variants
only if zarch instructions are available (64bit kernel in 31bit compat-mode).
Furthermore some variable types were changed. E.g. unsigned long long would be
a register pair on s390 31bit, but we want only one single register.
For variables of type size_t the register contents have to be enlarged from a
32bit to a 64bit value on 31bit, because the inline assemblies uses 64bit values
in such cases.

ChangeLog:

* sysdeps/s390/s390-64/Makefile (iconvdata-subdirectory):
Move to ...
* sysdeps/s390/Makefile: ... here.
* sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c: Move to ...
* sysdeps/s390/iso-8859-1_cp037_z900.c: ... here.
(BRANCH_ON_COUNT): New define.
(TR_LOOP): Use BRANCH_ON_COUNT instead of brctg.
* sysdeps/s390/s390-64/utf16-utf32-z9.c: Move to ...
* sysdeps/s390/utf16-utf32-z9.c: ... here and adjust to
run on s390-32, too.
* sysdeps/s390/s390-64/utf8-utf16-z9.c: Move to ...
* sysdeps/s390/utf8-utf16-z9.c: ... here and adjust to
run on s390-32, too.
* sysdeps/s390/s390-64/utf8-utf32-z9.c: Move to ...
* sysdeps/s390/utf8-utf32-z9.c: ... here and adjust to
run on s390-32, too.

8 years agoS390: Optimize utf16-utf32 module.
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Optimize utf16-utf32 module.

This patch reworks the s390 specific module to convert between utf16 and utf32.
Now ifunc is used to choose either the c or etf3eh (with convert utf
instruction) variants at runtime.
Furthermore a new vector variant for z13 is introduced which will be build
and chosen if vector support is available at build / runtime.

In case of converting utf 32 to utf16, the vector variant optimizes input of
2byte utf16 characters. The convert utf instruction is used if an utf16
surrogate is found.

For the other direction utf16 to utf32, the cu24 instruction can't be re-
enabled, because it does not report an error, if the input-stream consists of
a single low surrogate utf16 char (e.g. 0xdc00). This applies to the newest z13,
too. Thus there is only the c or the new vector variant, which can handle utf16
surrogate characters.

This patch also fixes some whitespace errors. Furthermore, the etf3eh variant is
handling the "UTF-xx//IGNORE" case now. Before they ignored the ignore-case and
always stopped at an error.

ChangeLog:

* sysdeps/s390/s390-64/utf16-utf32-z9.c: Use ifunc to select c,
etf3eh or new vector loop-variant.

8 years agoS390: Optimize utf8-utf16 module.
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Optimize utf8-utf16 module.

This patch reworks the s390 specific module to convert between utf8 and utf16.
Now ifunc is used to choose either the c or etf3eh (with convert utf instruction)
variants at runtime. Furthermore a new vector variant for z13 is introduced
which will be build and chosen if vector support is available at build / runtime.

In case of converting utf 8 to utf16, the vector variant optimizes input of
1byte utf8 characters. The convert utf instruction is used if a multibyte utf8
character is found.

For the other direction utf16 to utf8, the cu21 instruction can't be re-enabled,
because it does not report an error, if the input-stream consists of a single
low surrogate utf16 char (e.g. 0xdc00). This applies to the newest z13, too.
Thus there is only the c or the new vector variant, which can handle 1..4 byte
utf8 characters.

The c variant from utf16 to utf8 has beed fixed. If a high surrogate was at the
end of the input-buffer, then errno was set to EINVAL and the input-pointer
pointed just after the high surrogate. Now it points to the beginning of the
high surrogate.

This patch also fixes some whitespace errors. The c variant from utf8 to utf16
is now checking that tail-bytes starts with 0b10... and the value is not in
range of an utf16 surrogate.

Furthermore, the etf3eh variants are handling the "UTF-xx//IGNORE" case now.
Before they ignored the ignore-case and always stopped at an error.

ChangeLog:

* sysdeps/s390/s390-64/utf8-utf16-z9.c: Use ifunc to select c,
etf3eh or new vector loop-variant.

8 years agoS390: Optimize utf8-utf32 module.
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Optimize utf8-utf32 module.

This patch reworks the s390 specific module to convert between utf8 and utf32.
Now ifunc is used to choose either the c or etf3eh (with convert utf
instruction) variants at runtime.
Furthermore a new vector variant for z13 is introduced which will be build
and chosen if vector support is available at build / runtime.
The vector variants optimize input of 1byte utf8 characters. The convert utf
instruction is used if a multibyte utf8 character is found.

This patch also fixes some whitespace errors. The c variants are rejecting
UTF-16 surrogates and values above 0x10ffff now.
Furthermore, the etf3eh variants are handling the "UTF-xx//IGNORE" case now.
Before they ignored the ignore-case and always stopped at an error.

ChangeLog:

* sysdeps/s390/s390-64/utf8-utf32-z9.c: Use ifunc to select c, etf3eh
or new vector loop-variant.

8 years agoS390: Optimize iso-8859-1 to ibm037 iconv-module.
Stefan Liebler [Wed, 25 May 2016 15:18:05 +0000 (17:18 +0200)]
S390: Optimize iso-8859-1 to ibm037 iconv-module.

This patch reworks the s390 specific module which used the z900
translate one to one instruction. Now the g5 translate instruction is used,
because it outperforms the troo instruction.

ChangeLog:

* sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c (TROO_LOOP):
Rename to TR_LOOP and usage of tr instead of troo instruction.

8 years agoS390: Optimize builtin iconv-modules.
Stefan Liebler [Wed, 25 May 2016 15:18:04 +0000 (17:18 +0200)]
S390: Optimize builtin iconv-modules.

This patch introduces a s390 specific gconv_simple.c file which provides
optimized versions for z13 with vector instructions, which will be chosen at
runtime via ifunc.
The optimized conversions can convert between internal and ascii, ucs4, ucs4le,
ucs2, ucs2le.
If the build-environment lacks vector support, then iconv/gconv_simple.c
is used wihtout any change. Otherwise iconvdata/gconv_simple.c is used to create
conversion loop routines without vector instructions as fallback, if vector
instructions aren't available at runtime.

ChangeLog:

* sysdeps/s390/multiarch/gconv_simple.c: New File.
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add gconv_simple.

8 years agoS390: Optimize 8bit-generic iconv modules.
Stefan Liebler [Wed, 25 May 2016 15:18:04 +0000 (17:18 +0200)]
S390: Optimize 8bit-generic iconv modules.

This patch introduces a s390 specific 8bit-generic.c file which provides an
optimized version for z13 with translate-/vector-instructions, which will be
chosen at runtime via ifunc.
If the build-environment lacks vector support, then iconvdata/8bit-generic.c
is used wihtout any change. Otherwise iconvdata/8bit-generic.c is used to create
conversion loop routines without vector instructions as fallback, if vector
instructions aren't available at runtime.

The vector routines can only be used with charsets where the maximum UCS4 value
fits in 1 byte size. Then the hardware translate-instruction is used
to translate between up to 256 generic characters and "1 byte UCS4"
characters at once. The vector instructions are used to convert between
the "1 byte UCS4" and UCS4.

The gen-8bit.sh script in sysdeps/s390/multiarch generates the conversion
table to_ucs1. Therefore in sysdeps/s390/multiarch/Makefile is added an
override define generate-8bit-table, which is originally defined in
iconvdata/Makefile. This version calls the gen-8bit.sh in iconvdata folder
and the s390 one.

ChangeLog:

* sysdeps/s390/multiarch/8bit-generic.c: New File.
* sysdeps/s390/multiarch/gen-8bit.sh: New File.
* sysdeps/s390/multiarch/Makefile (generate-8bit-table):
New override define.
* sysdeps/s390/multiarch/iconv/skeleton.c: Likewise.

8 years agoS390: Configure check for vector support in gcc.
Stefan Liebler [Wed, 25 May 2016 15:18:04 +0000 (17:18 +0200)]
S390: Configure check for vector support in gcc.

The S390 specific test checks if the gcc has support for vector registers
by compiling an inline assembly which clobbers vector registers.
On success the macro HAVE_S390_VX_GCC_SUPPORT is defined.
This macro can be used to determine if e.g. clobbering vector registers
is allowed or not.

ChangeLog:

* config.h.in (HAVE_S390_VX_GCC_SUPPORT): New macro undefine.
* sysdeps/s390/configure.ac: Add test for S390 vector register
support in gcc.
* sysdeps/s390/configure: Regenerated.

8 years agoS390: Get rid of make warning: overriding recipe for target gconv-modules.
Stefan Liebler [Wed, 25 May 2016 15:18:04 +0000 (17:18 +0200)]
S390: Get rid of make warning: overriding recipe for target gconv-modules.

This patch introduces a way to provide an architecture dependent gconv-modules
file. Before this patch, the gconv-modules file was normally installed from
src-dir/iconvdata/gconv-modules. The S390 Makefile had overridden the
installation recipe (with a make warning) in order to install the
gconv-module-s390 file from build-dir.
The iconvdata/Makefile provides another recipe, which copies the gconv-modules
file from src to build dir, which are used by the testcases.
Thus the testcases does not use the currently build s390-modules.

This patch uses build-dir/iconvdata/gconv-modules for installation, which
is generated by concatenating src-dir/iconvdata/gconv-modules and the
architecture specific one. The latter one can be specified by setting the variable
sysdeps-gconv-modules in sysdeps/.../Makefile.

The architecture specific gconv-modules file is emitted before the common one
because these modules aren't used in all possible conversions. E.g. the converting
from INTERNAL to UTF-16 used the common UTF-16.so module instead of UTF16_UTF32_Z9.so.

This way, the s390-Makefile does not need to override the recipe for gconv-modules
and no warning is emitted anymore.
Since we no longer support empty objpfx the conditional test in iconvdata/Makefile
is removed.

ChangeLog:

* iconvdata/Makefile ($(inst_gconvdir)/gconv-modules):
Install file from $(objpfx)gconv-modules.
($(objpfx)gconv-modules): Concatenate architecture specific file
in variable sysdeps-gconv-modules and gconv-modules in src dir.
* sysdeps/s390/gconv-modules: New file.
* sysdeps/s390/s390-64/Makefile: ($(inst_gconvdir)/gconv-modules):
Deleted.
($(objpfx)gconv-modules-s390): Deleted.
(sysdeps-gconv-modules): New variable.

8 years agoDo not raise "inexact" from x86_64 SSE4.1 ceil, floor (bug 15479).
Joseph Myers [Tue, 24 May 2016 21:11:18 +0000 (21:11 +0000)]
Do not raise "inexact" from x86_64 SSE4.1 ceil, floor (bug 15479).

Continuing fixes for ceil and floor functions not to raise the
"inexact" exception, this patch fixes the x86_64 SSE4.1 versions.  The
roundss / roundsd instructions take an immediate operand that
determines the rounding mode and whether to raise "inexact"; this just
needs bit 3 set to disable "inexact", which this patch does.

Remark: we don't have an SSE4.1 version of trunc / truncf (using this
instruction with operand 11); I'd expect one to make sense, but of
course it should be benchmarked against the existing C code.  I'll
file a bug in Bugzilla for the lack of such a version.

Tested for x86_64.

[BZ #15479]
* sysdeps/x86_64/fpu/multiarch/s_ceil.S (__ceil_sse41): Set bit 3
of immediate operand to rounding instruction.
* sysdeps/x86_64/fpu/multiarch/s_ceilf.S (__ceilf_sse41):
Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floor.S (__floor_sse41):
Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floorf.S (__floorf_sse41):
Likewise.

8 years agoFixup usage of MIN_EXP in libm-test.inc
Paul E. Murphy [Thu, 19 May 2016 22:09:02 +0000 (17:09 -0500)]
Fixup usage of MIN_EXP in libm-test.inc

Make MANT_DIG shadow the types *_MIN_EXP macro. Replace
calls sites with (MIN_EXP - 1), and simplify.

8 years agoFixup usage of MANT_DIG in libm-test.inc
Paul E. Murphy [Thu, 19 May 2016 22:01:16 +0000 (17:01 -0500)]
Fixup usage of MANT_DIG in libm-test.inc

Make MANT_DIG shadow the types *_MANT_DIG macro. Replace
calls sites with (MANT_DIG - 1), and simplify.