]> sourceware.org Git - glibc.git/log
glibc.git
8 years agoEnable Silvermont optimizations for Knights Landing
H.J. Lu [Tue, 15 Dec 2015 19:46:54 +0000 (11:46 -0800)]
Enable Silvermont optimizations for Knights Landing

Knights Landing processor is based on Silvermont.  This patch enables
Silvermont optimizations for Knights Landing.

* sysdeps/x86/cpu-features.c (init_cpu_features): Enable
Silvermont optimizations for Knights Landing.

8 years agoDon't emit invalid extra shift character at block boundary by iconv (bug 17197)
Andreas Schwab [Thu, 24 Jul 2014 15:32:56 +0000 (17:32 +0200)]
Don't emit invalid extra shift character at block boundary by iconv (bug 17197)

8 years agoFix aliasing violation in tst-rec-dlopen
Florian Weimer [Tue, 15 Dec 2015 08:49:17 +0000 (09:49 +0100)]
Fix aliasing violation in tst-rec-dlopen

8 years agoMake obsolete syscall wrappers into compat symbols (bug 18472).
Joseph Myers [Mon, 14 Dec 2015 22:52:15 +0000 (22:52 +0000)]
Make obsolete syscall wrappers into compat symbols (bug 18472).

Various Linux kernel syscalls have become obsolete over time.
Specifically, the following are obsolete in all kernel versions
supported by glibc, are not present for architectures more recently
added to the kernel, and as such, the wrapper functions for them
should be compat symbols, not in static libc and not available for new
links with shared libc.

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

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

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

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

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

[BZ #18472]
* sysdeps/unix/Makefile ($(objpfx)stub-syscalls.c): Handle entries
for the form NAME@VERSION:OBSOLETED and generate SHLIB_COMPAT
conditionals for them.
* sysdeps/unix/make-syscalls.sh (emit_weak_aliases): Likewise.
* sysdeps/unix/sysv/linux/sys/kdaemon.h: Remove file.
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Remove
sys/kdaemon.h.
* sysdeps/unix/sysv/linux/syscalls.list (bdflush): Make into
compat-only syscall, obsoleted in glibc 2.23.
(create_module): Likewise.
(get_kernel_syms): Likewise.
(query_module): Likewise.
(uselib): Likewise.
* manual/sysinfo.texi (System Parameters): Do not mention bdflush.

8 years agoCleanup ARM ioperm implementation
Aurelien Jarno [Fri, 11 Dec 2015 21:16:34 +0000 (22:16 +0100)]
Cleanup ARM ioperm implementation

Since GLIBC requires a minimum 2.6.32 kernel, the patch cleanups
the ARM ioperm by removing pre-2.4.23 kernel support.

8 years agoFix indentation.
Steve Ellcey [Fri, 11 Dec 2015 17:19:37 +0000 (09:19 -0800)]
Fix indentation.

* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
Fix indentation.

8 years ago Fix indentation.
Steve Ellcey [Fri, 11 Dec 2015 17:08:45 +0000 (09:08 -0800)]
Fix indentation.

* stdio-common/vfscanf.c (_IO_vfscanf_internal): Fix indentation.

8 years ago Fix indentation.
Steve Ellcey [Fri, 11 Dec 2015 17:02:16 +0000 (09:02 -0800)]
Fix indentation.

* stdlib/strtol_l.c (__strtol_l): Fix indentation.

8 years agoAutomate LC_CTYPE generation for tr_TR, update to Unicode 8.0.0 (bug 18491).
Joseph Myers [Fri, 11 Dec 2015 12:45:19 +0000 (12:45 +0000)]
Automate LC_CTYPE generation for tr_TR, update to Unicode 8.0.0 (bug 18491).

This patch makes the automation of Unicode LC_CTYPE generation also
support generating the modified LC_CTYPE used for Turkish (where case
conversions of 'i' and 'I' differ from ASCII conventions), so allowing
that to be more readily kept in sync for future Unicode updates.  The
patch includes the locale update generated by the scripts.

Tested for x86_64.

[BZ #18491]
* unicode-gen/unicode_utils.py (to_upper_turkish): New function.
(to_lower_turkish): Likewise.
* unicode-gen/gen_unicode_ctype.py (output_tables): Support
producing output with Turkish case conversions.
(--turkish): New command-line option.
* unicode-gen/Makefile (GENERATED): Add tr_TR.
(tr_TR): New rule.
* locales/tr_TR: Regenerate LC_CTYPE.

8 years agograntpt: trust the kernel about pty group and permission mode
Aurelien Jarno [Thu, 10 Dec 2015 21:33:10 +0000 (22:33 +0100)]
grantpt: trust the kernel about pty group and permission mode

According to POSIX the grantpt() function does the following:

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

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

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

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

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

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

With this patch there should not be any reason left to build the GNU
libc with the --enable-pt_chown configure option on a GNU/Linux system.

8 years agoSplit large string section; add truncation advice
Paul Eggert [Thu, 10 Dec 2015 16:17:18 +0000 (08:17 -0800)]
Split large string section; add truncation advice

* manual/examples/strncat.c: Remove.
This example was misleading, as the code would have undefined
behavior if "hello" was longer than SIZE.  Anyway, the manual
shouldn't encourage strncpy+strncat for this sort of thing.
* manual/string.texi (Copying Strings and Arrays): Split into
three sections Copying Strings and Arrays, Concatenating Strings,
and Truncating Strings, as this section was way too long.  All
cross-referenced changed.  Add advice about string-truncation
functions.  Remove misleading strncat example.

8 years agoDocument best practice for disconnected NSS modules.
Carlos O'Donell [Thu, 10 Dec 2015 05:48:15 +0000 (00:48 -0500)]
Document best practice for disconnected NSS modules.

NSS modules which can run in disconnected modes should
return NSS_STATUS_NOTFOUND and SUCCESS in order to follow
best practice for such modules and ensure user applications
can have these modules configured without causing problems
if the data sources are not connected.

8 years agoUpdate to Unicode 8.0.0.
Mike FABIAN [Thu, 10 Dec 2015 05:30:51 +0000 (00:30 -0500)]
Update to Unicode 8.0.0.

Update __STDC_ISO_10646__ to 201505L for Unicode 8.0.0.
Update character encoding, ctype, and transliteration tables.
New scripts autogenerate transliteration tables.

8 years agoUpdate da, nb, nn, and sv locales (Bug 89)
Mike FABIAN [Thu, 10 Dec 2015 04:08:36 +0000 (23:08 -0500)]
Update da, nb, nn, and sv locales (Bug 89)

Add transliteration rules for da, nb, nn, and sv locales.

8 years agoUpdate transliteration support to Unicode 7.0.0.
Carlos O'Donell [Thu, 10 Dec 2015 03:27:41 +0000 (22:27 -0500)]
Update transliteration support to Unicode 7.0.0.

The transliteration files are now autogenerated from upstream Unicode
data.

8 years agoRegenerate locale/C-translit.h.
Carlos O'Donell [Thu, 10 Dec 2015 03:24:26 +0000 (22:24 -0500)]
Regenerate locale/C-translit.h.

8 years agoGeneric updates to transliterations.
Mike FABIAN [Thu, 10 Dec 2015 02:51:26 +0000 (21:51 -0500)]
Generic updates to transliterations.

- Remove duplicate transliterations for U+0152 and U+0153 from
  C-translit.h.in.
- Change Ö U+00D6 LATIN CAPITAL LETTER O WITH STROKE → O
  (instead of → OE)
- Change ö U+00F6 LATIN SMALL LETTER O WITH STROKE → o
  (instead of → oe)
- Add ₹ U+20B9 INDIAN RUPEE SIGN → INR
- Add ₫ U+20AB DONG SIGN → Dong (in addition to "₫ → Đồng")
- Add many others from
  http://unicode.org/cldr/trac/browser/trunk/common/transforms/Latin-ASCII.xml
- Add some more currency signs suggested by Marko Myllynen
- Add another patch with more characters by Marko Myllynen

8 years agoFix ldbl-128ibm logl inaccuracy near 1 (bug 19351).
Joseph Myers [Wed, 9 Dec 2015 23:51:11 +0000 (23:51 +0000)]
Fix ldbl-128ibm logl inaccuracy near 1 (bug 19351).

The ldbl-128ibm implementation of logl is inaccurate for arguments
near 1, because when deciding whether to bypass a series expansion for
log(1+z), where z = x-1, it compares the square of z rather than z
itself with an epsilon value.  This patch fixes that comparison, so
eliminating the test failures for inaccuracy of logl in such cases.

Tested for powerpc.

[BZ #19351]
* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): When
expanding log(1+z), compare z rather than its square with epsilon
to determine when to avoid evaluating the expansion.

8 years agoFix ldbl-128ibm sinhl spurious overflows (bug 19350).
Joseph Myers [Wed, 9 Dec 2015 22:37:08 +0000 (22:37 +0000)]
Fix ldbl-128ibm sinhl spurious overflows (bug 19350).

The ldbl-128ibm implementation of sinhl uses a slightly too small
overflow threshold (similar to bug 16407 for coshl).  This patch fixes
it to use a safe threshold (so that values whose high part is above
the value compared with definitely result in an overflow in all
rounding modes).

Tested for powerpc.

[BZ #19350]
* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl):
Increase overflow threshold.

8 years agoFix ldbl-128ibm tanhl inaccuracy for small arguments (bug 19349).
Joseph Myers [Wed, 9 Dec 2015 21:20:18 +0000 (21:20 +0000)]
Fix ldbl-128ibm tanhl inaccuracy for small arguments (bug 19349).

The ldbl-128ibm implementation of tanhl is inaccurate for small
arguments, because it returns x*(1+x) (maybe in an attempt to raise
"inexact") when x itself would be the accurate return value but
multiplying by 1+x introduces large errors.  This patch fixes it to
return x in that case (when the mathematical result is x plus a
negligible remainder on the order of x^3) to avoid those errors.

Tested for powerpc.

[BZ #19349]
* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Return argument
when small.

8 years agoUse direct socket syscalls for new kernels on i386, m68k, microblaze, sh.
Joseph Myers [Wed, 9 Dec 2015 20:59:43 +0000 (20:59 +0000)]
Use direct socket syscalls for new kernels on i386, m68k, microblaze, sh.

Now that we have __ASSUME_* macros for direct socket syscalls to use
them instead of socketcall when they can be assumed to be available on
socketcall architectures, this patch defines those macros when
appropriate for i386, m68k, microblaze and sh (for 4.3, 4.3, all
supported kernels and 2.6.37, respectively; the only use of socketcall
support on microblaze is it allows accept4 and sendmmsg to be
supported on a wider range of kernel versions).

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

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

* sysdeps/unix/sysv/linux/i386/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
New macro.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SOCKET_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_BIND_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_CONNECT_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_LISTEN_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_ACCEPT4_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDTO_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SENDMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVFROM_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300]
(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_RECVMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040300] (__ASSUME_SHUTDOWN_SYSCALL):
Likewise.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
(__ASSUME_SOCKET_SYSCALL): Likewise.
(__ASSUME_BIND_SYSCALL): Likewise.
(__ASSUME_CONNECT_SYSCALL): Likewise.
(__ASSUME_LISTEN_SYSCALL): Likewise.
(__ASSUME_ACCEPT_SYSCALL): Likewise.
(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
(__ASSUME_SEND_SYSCALL): Likewise.
(__ASSUME_SENDTO_SYSCALL): Likewise.
(__ASSUME_RECV_SYSCALL): Likewise.
(__ASSUME_RECVFROM_SYSCALL): Likewise.
(__ASSUME_SHUTDOWN_SYSCALL): Likewise.
(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
(__ASSUME_SENDMSG_SYSCALL): Likewise.
(__ASSUME_RECVMSG_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SOCKET_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_BIND_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_CONNECT_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_LISTEN_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_ACCEPT_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625]
(__ASSUME_GETSOCKNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625]
(__ASSUME_GETPEERNAME_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625]
(__ASSUME_SOCKETPAIR_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SEND_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDTO_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECV_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVFROM_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SHUTDOWN_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625]
(__ASSUME_GETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625]
(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_SENDMSG_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x020625] (__ASSUME_RECVMSG_SYSCALL):
Likewise.

8 years agomips: fix testsuite build for O32 FPXX ABI on pre-R2 CPU
Aurelien Jarno [Mon, 7 Dec 2015 22:07:17 +0000 (23:07 +0100)]
mips: fix testsuite build for O32 FPXX ABI on pre-R2 CPU

On MIPS when the toolchain is using the O32 FPXX ABI, the testsuite
fails to build for pre-R2 CPU.

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

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

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

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

This patches changes that by checking the usability of -mfp64 and
-modd-spreg options in configure, and disable those tests when they can
not be used.

8 years agoFix grantpt basename namespace bug
Aurelien Jarno [Fri, 4 Dec 2015 13:49:03 +0000 (14:49 +0100)]
Fix grantpt basename namespace bug

Commit cf06a4e3 removed test-xfail-POSIX2008/unistd.h/linknamespace, but
left one basename namespace issue in grantpt. However this issue is not
visible with the default configuration buy only when configure is passed
the --enable-pt_chown option.

8 years agobenchtests: ffs and ffsll are string functions, not math
Siddhesh Poyarekar [Tue, 8 Dec 2015 18:45:14 +0000 (00:15 +0530)]
benchtests: ffs and ffsll are string functions, not math

The ffs and ffsll functions were listed as math functions when they
are actually defined in strings.h and string.h respectively.  Shuffle
around the Makefile variables a bit and make a separate space for ffs
and ffsll.

8 years agobenchtests: Add inputs from sin and cos to sincos
Siddhesh Poyarekar [Tue, 8 Dec 2015 18:40:51 +0000 (00:10 +0530)]
benchtests: Add inputs from sin and cos to sincos

The sincos benchmark has only about a dozen inputs that don't measure
the impact of changes to various passes.  Since much of the code
properties are inherited from sin and cos, copy those inputs in to get
more comprehensive coverage.

8 years agoUtilize x86_64 vector math functions w/o -fopenmp.
Andrew Senkevich [Mon, 7 Dec 2015 18:58:26 +0000 (21:58 +0300)]
Utilize x86_64 vector math functions w/o -fopenmp.

This patch allows to use x86_64 vector math functions with GCC 6.*
without OpenMP SIMD constructs.  For additional details please visit
<https://sourceware.org/glibc/wiki/libmvec#Example_2>.

    * sysdeps/x86/fpu/bits/math-vector.h: W/o -fopenmp declare vector math
    functions with GCC 6.* __attribute__ ((__simd__)).

8 years agoFix typo in strncat, wcsncat manual entries
Paul Eggert [Fri, 4 Dec 2015 23:23:18 +0000 (15:23 -0800)]
Fix typo in strncat, wcsncat manual entries

* manual/string.texi (Copying and Concatenation): Fix typos in
sample implementations of strncat and wcsncat, by having them use
the old value of the destination length, not the new one.

8 years agoFix nan functions handling of payload strings (bug 16961, bug 16962).
Joseph Myers [Fri, 4 Dec 2015 20:36:28 +0000 (20:36 +0000)]
Fix nan functions handling of payload strings (bug 16961, bug 16962).

The nan, nanf and nanl functions handle payload strings by doing e.g.:

  if (tagp[0] != '\0')
    {
      char buf[6 + strlen (tagp)];
      sprintf (buf, "NAN(%s)", tagp);
      return strtod (buf, NULL);
    }

This is an unbounded stack allocation based on the length of the
argument.  Furthermore, if the argument starts with an n-char-sequence
followed by ')', that n-char-sequence is wrongly treated as
significant for determining the payload of the resulting NaN, when ISO
C says the call should be equivalent to strtod ("NAN", NULL), without
being affected by that initial n-char-sequence.  This patch fixes both
those problems by using the __strtod_nan etc. functions recently
factored out of strtod etc. for that purpose, with those functions
being exported from libc at version GLIBC_PRIVATE.

Tested for x86_64, x86, mips64 and powerpc.

[BZ #16961]
[BZ #16962]
* math/s_nan.c (__nan): Use __strtod_nan instead of constructing a
string on the stack for strtod.
* math/s_nanf.c (__nanf): Use __strtof_nan instead of constructing
a string on the stack for strtof.
* math/s_nanl.c (__nanl): Use __strtold_nan instead of
constructing a string on the stack for strtold.
* stdlib/Versions (libc): Add __strtof_nan, __strtod_nan and
__strtold_nan to GLIBC_PRIVATE.
* math/test-nan-overflow.c: New file.
* math/test-nan-payload.c: Likewise.
* math/Makefile (tests): Add test-nan-overflow and
test-nan-payload.

8 years agoRevert "tst-res_hconf_reorder: Set RESOLV_REORDER environment variable"
Florian Weimer [Fri, 4 Dec 2015 18:25:59 +0000 (19:25 +0100)]
Revert "tst-res_hconf_reorder: Set RESOLV_REORDER environment variable"

This reverts commit 731a713b72e1281d58b3304738f04efb7bfca8b7.

This change is unnecessary because the Makefile already sets up the
environment for the test.

8 years agotst-res_hconf_reorder: Set RESOLV_REORDER environment variable
Florian Weimer [Fri, 4 Dec 2015 18:02:04 +0000 (19:02 +0100)]
tst-res_hconf_reorder: Set RESOLV_REORDER environment variable

Otherwise, the problematic code does not run.

8 years agoConsistency about byte vs character in string.texi
Paul Eggert [Fri, 4 Dec 2015 16:27:14 +0000 (08:27 -0800)]
Consistency about byte vs character in string.texi

* manual/string.texi (String and Array Utilities):
Distinguish more carefully among bytes, multibyte characters,
and wide characters.  Use "byte" when talking about C 'char',
to distinguish it more clearly from multibyte characters.
Say "wide character" or "multibyte character" instead of
"character", when a wide or multibyte character is intended.
Similarly for "multibyte string" versus "string".
Define these terms more carefully.

8 years agomath: add LDBL_CLASSIFY_COMPAT support
Chris Metcalf [Tue, 1 Dec 2015 19:59:38 +0000 (14:59 -0500)]
math: add LDBL_CLASSIFY_COMPAT support

If a platform does not define "long-double-fcts = yes" in its
Makefiles and it does define __NO_LONG_DOUBLE_MATH in its installed
headers, it will currently create exported symbols for __finitel,
__isinfl, and __isnanl that can't be reached from userspace by
correct use of the finite(), isinf(), or isnan() macros in <math.h>.

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

For tile, remove the now-unnecessary exports of those functions from
libc and libm.

8 years agoCorrected path to installed libmvec_nonshared.a
Andrew Senkevich [Thu, 3 Dec 2015 17:24:37 +0000 (20:24 +0300)]
Corrected path to installed libmvec_nonshared.a

    * math/Makefile ($(inst_libdir)/libm.so): Corrected path to
    libmvec_nonshared.a

8 years agopowerpc: Add hwcap/hwcap2/platform data to TCB.
Carlos Eduardo Seo [Fri, 23 Oct 2015 00:26:58 +0000 (19:26 -0500)]
powerpc: Add hwcap/hwcap2/platform data to TCB.

This patch adds a new feature for powerpc.  In order to get faster access to
the HWCAP/HWCAP2 bits and platform number (i.e. for implementing
__builtin_cpu_is () / __builtin_cpu_supports () in GCC) without the overhead of
reading from the auxiliary vector, we now reserve space for them in the TCB.
This is an ABI change for GLIBC 2.23.

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

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

8 years agoUse shell's builtin pwd.
Ludovic Courtès [Thu, 3 Dec 2015 04:58:15 +0000 (23:58 -0500)]
Use shell's builtin pwd.

Insisting on /bin/pwd is unnecessary nowadays.  Autoconf-generated
scripts have been using the shell's built-in "pwd" for a long time.`

8 years agoComment on IBM930, IBM933, IBM935, IBM937, IBM939.
Carlos O'Donell [Thu, 3 Dec 2015 03:13:47 +0000 (22:13 -0500)]
Comment on IBM930, IBM933, IBM935, IBM937, IBM939.

Add comments for IBM930, IBM933, IBM935, IBM937, and IBM939 which
explain exactly what purpose these encodings have and provide a URL to
the upstream IBM database that further provides the details of the
encoding.

8 years agonptl: Fix racy pipe closing in tst-cancel{20,21}
Adhemerval Zanella [Wed, 14 Oct 2015 15:15:46 +0000 (12:15 -0300)]
nptl: Fix racy pipe closing in tst-cancel{20,21}

The tst-cancel20 open two pipes and creates a thread which blocks
reading the first pipe.  It then issues a signal to activate the
signal handler which in turn blocks reading the second pipe end.
Finally the cancellation cleanup-up handlers are tested by first
closing the all the pipes ends and issuing a pthread_cancel.
The tst-cancel21 have a similar behavior, but use an extra fork
after the test itself.

The race condition occurs if the cancellation handling acts after the
pipe close: in this case read will return EOF (indicating side-effects)
and thus the cancellation must not act.  However current GLIBC
cancellation behavior acts regardless the syscalls returns with
sid-effects.

This patch adjust the test by moving the pipe closing after the
cancellation handling.  This avoid spurious cancellation if the case
of the race described.

Checked on x86_64 and i386.

* nptl/tst-cancel20.c (do_one_test): Move the pipe closing after
pthread_join.
* nptl/tst-cancel21.c (tf): Likewise.

8 years agoAdd __CPU_MASK_TYPE for __cpu_mask
H.J. Lu [Tue, 1 Dec 2015 18:25:44 +0000 (10:25 -0800)]
Add __CPU_MASK_TYPE for __cpu_mask

Since x86-64 and x32 use the same set of sched_XXX system call interface:

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

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

[BZ #19313]
* bits/typesizes.h (__CPU_MASK_TYPE): New.
* sysdeps/mach/hurd/bits/typesizes.h (__CPU_MASK_TYPE): Likewise.
* sysdeps/nacl/bits/typesizes.h (__CPU_MASK_TYPE): Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h (__CPU_MASK_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/generic/bits/typesizes.h (__CPU_MASK_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h (__CPU_MASK_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h (__CPU_MASK_TYPE):
Likewise.
* sysdeps/unix/sysv/linux/x86/bits/typesizes.h (__CPU_MASK_TYPE):
* sysdeps/unix/sysv/linux/bits/sched.h (__cpu_mask): Replace
unsigned long int with __CPU_MASK_TYPE.

8 years ago[AArch64] Regenerate libm-test-ulps
Szabolcs Nagy [Tue, 1 Dec 2015 12:57:16 +0000 (12:57 +0000)]
[AArch64] Regenerate libm-test-ulps

* sysdeps/aarch64/libm-test-ulps: Regenerated.

8 years agoUse hex float constants in sysdeps/ieee754/dbl-64/e_sqrt.c.
Joseph Myers [Tue, 1 Dec 2015 01:01:36 +0000 (01:01 +0000)]
Use hex float constants in sysdeps/ieee754/dbl-64/e_sqrt.c.

Various sysdeps/ieee754/dbl-64 functions use double constants defined
using a union between a double and two ints, with separate big-endian
and little-endian definitions of the constants.

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

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

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

* sysdeps/ieee754/dbl-64/e_sqrt.c: Do not include uroot.h.
(__ieee754_sqrt): Use hex float constants instead of tm256.x and
t512.x.
* sysdeps/ieee754/dbl-64/uroot.h: Remove file.

8 years agoUpdate family and model detection for AMD CPUs
H.J. Lu [Mon, 30 Nov 2015 16:53:37 +0000 (08:53 -0800)]
Update family and model detection for AMD CPUs

AMD CPUs uses the similar encoding scheme for extended family and model
as Intel CPUs as shown in:

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

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

[BZ #19214]
* sysdeps/x86/cpu-features.c (get_common_indeces): Add an
argument to return extended model.  Update family and model
with extended family and model when family == 0x0f.
(init_cpu_features): Updated.

8 years agohurd: Make mmap64 use vm_offset_t for overflow check
Samuel Thibault [Sun, 29 Nov 2015 16:25:53 +0000 (17:25 +0100)]
hurd: Make mmap64 use vm_offset_t for overflow check

The RPC interface used by mmap uses the unsigned vm_offset_t, not the
signed off_t, so 32bit bigger than 2GiB values are fine actually.

* sysdeps/mach/hurd/mmap64.c: New file.

8 years agohurd: install correct number of send rights on fork
Thomas Schwinge [Sun, 29 Nov 2015 15:41:00 +0000 (16:41 +0100)]
hurd: install correct number of send rights on fork

* sysdeps/mach/hurd/fork.c (__fork): Install correct number of send
rights for its main user thread in NEWTASK.

8 years agoMIPS: Wire FCSR.ABS2008 to FCSR.NAN2008
Maciej W. Rozycki [Sat, 28 Nov 2015 11:01:16 +0000 (11:01 +0000)]
MIPS: Wire FCSR.ABS2008 to FCSR.NAN2008

Revision 3.50 of the MIPS architecture defined FCSR ABS2008 and NAN2008
bits as optionally read/write [1][2].  No hardware implementation has
ever made use of this feature though.  For example the first processor
to implement these bits, the MIPS32r3 proAptiv core, has both bits
read-only, hardwired to 1 [3].  And as from revision 5.03 of the MIPS
architecture the bits are required to be read-only, preset by hardware
[4][5].  Additionally all hardware implementations in existence have the
bits hardwired both to the same value, either of `0' and `1'.

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

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

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

References:

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

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

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

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

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

* sysdeps/mips/fpu_control.h (_FPU_RESERVED): Include ABS2008.
(_FPU_DEFAULT, _FPU_IEEE) [__mips_nan2008]: Set ABS2008.

8 years agoRename localedir to complocaledir (bug 14259).
Carlos O'Donell [Fri, 27 Nov 2015 15:09:45 +0000 (10:09 -0500)]
Rename localedir to complocaledir (bug 14259).

In preparation to fix the --localedir configure argument we must
move the existing conflicting definition of localedir to a more
appropriate name. Given that all current internal uses of localedir
relate to the compiled locales we rename to complocaledir.

8 years agoBetter workaround for aliases of *_finite symbols in vector math library.
Andrew Senkevich [Fri, 27 Nov 2015 13:22:26 +0000 (16:22 +0300)]
Better workaround for aliases of *_finite symbols in vector math library.

Old workaround based on assembly aliases can lead to link fail (bug 19058).
This patch makes workaround in another way to avoid it.

    [BZ #19058]
    * math/Makefile ($(inst_libdir)/libm.so): Added libmvec_nonshared.a
    to AS_NEEDED.
    * sysdeps/x86/fpu/bits/math-vector.h: Removed code with old workaround.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support,
    libmvec-static-only-routines): Added new file.
    * sysdeps/x86_64/fpu/svml_finite_alias.S: New file.

8 years agohurd: Initialize __libc_stack_end for hidden support
Samuel Thibault [Wed, 25 Nov 2015 16:48:51 +0000 (17:48 +0100)]
hurd: Initialize __libc_stack_end for hidden support

* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Initialize to get
into initialized data instead of common.

8 years agoDo not add relro attribute to __libc_stack_end
Samuel Thibault [Wed, 25 Nov 2015 16:05:53 +0000 (17:05 +0100)]
Do not add relro attribute to __libc_stack_end

It does not actually work yet

* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Remove relro attribute.

8 years agoRevert not defining NO_HIDDEN on hurd
Samuel Thibault [Wed, 25 Nov 2015 01:48:22 +0000 (02:48 +0100)]
Revert not defining NO_HIDDEN on hurd

       * sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Define.
       * sysdeps/mach/hurd/configure: Regenerate.

8 years agoFix hurd build with hidden support
Samuel Thibault [Wed, 25 Nov 2015 01:35:18 +0000 (02:35 +0100)]
Fix hurd build with hidden support

* hurd/sigunwind.c (_hurdsig_longjmp_from_handler): Destroy reply port
of interrupted RPC instead of restoring it.

* sysdeps/i386/setjmp.S (__sigsetjmp): Add hidden_def.
* sysdeps/mach/hurd/accept4.c (__libc_accept4): Remove
libc_hidden_def.
* sysdeps/mach/hurd/dl-sysdep.c (__libc_stack_end): Add relro
attribute, define rtld_hidden_data_def.
* sysdeps/mach/hurd/fxstatat64.c (__fxstatat64): Add libc_hidden_def.
* sysdeps/mach/hurd/if_index.c (__if_freenameindex): Add
libc_hidden_def.
(if_freenameindex): Add libc_hidden_weak.
(if_nameindex): Add libc_hidden_weak.
* sysdeps/mach/hurd/open.c (_open64): Rename libc_hidden_weak into
__open64.
* sysdeps/mach/hurd/sigwait.c (__sigwait): Add libc_hidden_def.
* sysdeps/mach/hurd/xmknodat.c (__xmknodat): Add libc_hidden_def.
* sysdeps/mach/nanosleep.c: Include <time.h>
(__nanosleep): Rename to __libc_nanosleep.
(__nanosleep): Add weak_alias.
(nanosleep): Update alias.
* sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Do not define.
* sysdeps/mach/hurd/configure: Regenerate.

8 years agoFix RPC breakage when longjumping from signal handler
Samuel Thibault [Wed, 25 Nov 2015 00:09:13 +0000 (01:09 +0100)]
Fix RPC breakage when longjumping from signal handler

* hurd/sigunwind.c (_hurdsig_longjmp_from_handler): Destroy reply port
of interrupted RPC instead of restoring it.

8 years agoRefactor strtod parsing of NaN payloads.
Joseph Myers [Tue, 24 Nov 2015 22:24:52 +0000 (22:24 +0000)]
Refactor strtod parsing of NaN payloads.

The nan* functions handle their string argument by constructing a
NAN(...) string on the stack as a VLA and passing it to strtod
functions.

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

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

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

Tested for x86_64, x86, mips64 and powerpc.

* stdlib/strtod_nan.c: New file.
* stdlib/strtod_nan_double.h: Likewise.
* stdlib/strtod_nan_float.h: Likewise.
* stdlib/strtod_nan_main.c: Likewise.
* stdlib/strtod_nan_narrow.h: Likewise.
* stdlib/strtod_nan_wide.h: Likewise.
* stdlib/strtof_nan.c: Likewise.
* stdlib/strtold_nan.c: Likewise.
* sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h: Likewise.
* sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h: Likewise.
* sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h: Likewise.
* wcsmbs/wcstod_nan.c: Likewise.
* wcsmbs/wcstof_nan.c: Likewise.
* wcsmbs/wcstold_nan.c: Likewise.
* stdlib/Makefile (routines): Add strtof_nan, strtod_nan and
strtold_nan.
* wcsmbs/Makefile (routines): Add wcstod_nan, wcstold_nan and
wcstof_nan.
* include/stdlib.h (__strtof_nan): Declare and use
libc_hidden_proto.
(__strtod_nan): Likewise.
(__strtold_nan): Likewise.
(__wcstof_nan): Likewise.
(__wcstod_nan): Likewise.
(__wcstold_nan): Likewise.
* include/wchar.h (____wcstoull_l_internal): Declare.
* stdlib/strtod_l.c: Do not include <ieee754.h>.
(____strtoull_l_internal): Remove declaration.
(STRTOF_NAN): Define macro.
(SET_MANTISSA): Remove macro.
(STRTOULL): Likewise.
(____STRTOF_INTERNAL): Use STRTOF_NAN to parse NaN payload.
* stdlib/strtof_l.c (____strtoull_l_internal): Remove declaration.
(STRTOF_NAN): Define macro.
(SET_MANTISSA): Remove macro.
* sysdeps/ieee754/ldbl-128/strtold_l.c (STRTOF_NAN): Define macro.
(SET_MANTISSA): Remove macro.
* sysdeps/ieee754/ldbl-128ibm/strtold_l.c (STRTOF_NAN): Define
macro.
(SET_MANTISSA): Remove macro.
* sysdeps/ieee754/ldbl-64-128/strtold_l.c (STRTOF_NAN): Define
macro.
(SET_MANTISSA): Remove macro.
* sysdeps/ieee754/ldbl-96/strtold_l.c (STRTOF_NAN): Define macro.
(SET_MANTISSA): Remove macro.
* wcsmbs/wcstod_l.c (____wcstoull_l_internal): Remove declaration.
* wcsmbs/wcstof_l.c (____wcstoull_l_internal): Likewise.
* wcsmbs/wcstold_l.c (____wcstoull_l_internal): Likewise.

8 years agoFix strtod ("NAN(I)") in Turkish locales (bug 19266).
Joseph Myers [Tue, 24 Nov 2015 22:21:59 +0000 (22:21 +0000)]
Fix strtod ("NAN(I)") in Turkish locales (bug 19266).

The implementations of strtod and related functions use
locale-specific conversions to lower case when parsing the contents of
a string NAN(n-char-sequence_opt).  This has the consequence that
NAN(I) is not treated as being of that form (only the initial NAN part
is accepted).  The syntax of n-char-sequence directly maps to the
ASCII letters, digits and underscore as in identifiers, so it is
unambiguous that all ASCII letters must be accepted in all locales.

This patch, relative to a tree with
<https://sourceware.org/ml/libc-alpha/2015-11/msg00258.html> (pending
review) applied and depending on that patch, fixes this problem by
checking directly for ASCII letters.  This will have the side effect
of no longer accepting 'İ' (dotted 'I') inside NAN() in Turkish
locales, which seems appropriate (that letter wouldn't have been
interpreted as having any meaning in the NaN payload anyway, as not
acceptable to strtoull).

Tested for x86_64 and x86.

[BZ #19266]
* stdlib/strtod_l.c (____STRTOF_INTERNAL): Check directly for
upper case and lower case letters inside NAN(), not using TOLOWER.
* stdlib/tst-strtod-nan-locale-main.c: New file.
* stdlib/tst-strtod-nan-locale.c: Likewise.
* stdlib/Makefile (tests): Add tst-strtod-nan-locale.
[$(run-built-tests) = yes] ($(objpfx)tst-strtod-nan-locale.out):
Depend on $(gen-locales).
($(objpfx)tst-strtod-nan-locale): Depend on $(libm).
* wcsmbs/tst-wcstod-nan-locale.c: New file.
* wcsmbs/Makefile (tests): Add tst-wcstod-nan-locale.
[$(run-built-tests) = yes] ($(objpfx)tst-wcstod-nan-locale.out):
Depend on $(gen-locales).
($(objpfx)tst-wcstod-nan-locale): Depend on $(libm).

8 years agomisc/tst-tsearch.c: bump up TIMEOUT to 10 seconds.
Chris Metcalf [Tue, 24 Nov 2015 19:07:02 +0000 (14:07 -0500)]
misc/tst-tsearch.c: bump up TIMEOUT to 10 seconds.

8 years agotile: define __NO_LONG_DOUBLE_MATH
Chris Metcalf [Tue, 24 Nov 2015 15:09:16 +0000 (10:09 -0500)]
tile: define __NO_LONG_DOUBLE_MATH

This avoids build failures in the tests, and matches what is in
bits/mathdef.h.

Update the libc and libm abilist files to include __finitel,
__isinfl, and __isnanl.

8 years agomalloc: remove redundant getenv call
Gleb Fotengauer-Malinovskiy [Tue, 24 Nov 2015 16:19:32 +0000 (16:19 +0000)]
malloc: remove redundant getenv call

* malloc/memusage.c (me): Remove redundant getenv call.

8 years agoRemove CPU set size checking from affinity functions [BZ #19143]
Florian Weimer [Tue, 24 Nov 2015 16:21:01 +0000 (17:21 +0100)]
Remove CPU set size checking from affinity functions [BZ #19143]

With current kernel versions, the check does not reliably detect that
unavailable CPUs are requested, for these reasons:

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

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

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

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

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

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

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

* nptl/check-cpuset.h: Remove.
* nptl/pthread_attr_setaffinity.c (__pthread_attr_setaffinity_new):
Remove CPU set size check.
* nptl/pthread_setattr_default_np.c (pthread_setattr_default_np):
Likewise.
* sysdeps/unix/sysv/linux/check-cpuset.h: Remove.
* sysdeps/unix/sysv/linux/pthread_setaffinity.c
(__kernel_cpumask_size, __determine_cpumask_size): Remove.
(__pthread_setaffinity_new): Remove CPU set size check.
* sysdeps/unix/sysv/linux/sched_setaffinity.c
(__kernel_cpumask_size): Remove.
(__sched_setaffinity_new): Remove CPU set size check.
* manual/threads.texi (Default Thread Attributes): Remove stale
reference to check_cpuset_attr, determine_cpumask_size in comment.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) == posix] (tests):
Remove tst-getcpu.  Add tst-affinity, tst-affinity-pid.
[$(subdir) == nptl] (tests): Add tst-thread-affinity-pthread,
tst-thread-affinity-pthread2, tst-thread-affinity-sched.
* sysdeps/unix/sysv/linux/tst-affinity.c: New file.
* sysdeps/unix/sysv/linux/tst-affinity-pid.c: New file.
* sysdeps/unix/sysv/linux/tst-skeleton-affinity.c: New skeleton test file.
* sysdeps/unix/sysv/linux/tst-thread-affinity-sched.c: New file.
* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread.c: New file.
* sysdeps/unix/sysv/linux/tst-thread-affinity-pthread2.c: New file.
* sysdeps/unix/sysv/linux/tst-thread-skeleton-affinity.c: New
skeleton test file.
* sysdeps/unix/sysv/linux/tst-getcpu.c: Remove.  Superseded by
tst-affinity-pid.

8 years agoImplement "make update-all-abi"
Florian Weimer [Tue, 24 Nov 2015 16:10:19 +0000 (17:10 +0100)]
Implement "make update-all-abi"

* scripts/update-abilist.sh: New file.
* Makefile (+subdir_targets): Add subdir_update-all-abi.
* Makerules (update-all-abi-%, update-all-abi)
(subdir_update-all-abi): New targets.
* elf/Makefile (update-all-abi): New target.

8 years agoReplace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code
Florian Weimer [Tue, 24 Nov 2015 15:37:15 +0000 (16:37 +0100)]
Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code

* sysdeps/mach/hurd/libc-lock.h (_LIBC_LOCK_INITIALIZER): Define.
(__libc_lock_define_initialized): Use it.
* sysdeps/nptl/libc-lockP.h (_LIBC_LOCK_INITIALIZER): Define.
* malloc/arena.c (list_lock): Use _LIBC_LOCK_INITIALIZER.
* malloc/malloc.c (main_arena): Likewise.
* sysdeps/generic/malloc-machine.h (MUTEX_INITIALIZER): Remove.
* sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Remove.

8 years agoUpdate <sys/ptrace.h> for Linux 4.3.
Joseph Myers [Mon, 23 Nov 2015 17:53:08 +0000 (17:53 +0000)]
Update <sys/ptrace.h> for Linux 4.3.

This patch updates <sys/ptrace.h> for Linux 4.3, adding
PTRACE_O_SUSPEND_SECCOMP and updating the value of PTRACE_O_MASK.
Some architectures were missing the older PTRACE_O_EXITKILL, so that
was added to the files missing it as well.

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

* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
(PTRACE_O_EXITKILL): New value in enum __ptrace_setoptions.
(PTRACE_O_SUSPEND_SECCOMP): Likewise.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h (PTRACE_O_EXITKILL):
New value in enum __ptrace_setoptions.
(PTRACE_O_SUSPEND_SECCOMP): Likewise.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
(PTRACE_O_SUSPEND_SECCOMP): New value in enum __ptrace_setoptions.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/sys/ptrace.h (PTRACE_O_SUSPEND_SECCOMP):
New value in enum __ptrace_setoptions.
(PTRACE_O_MASK): Update value.
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h (PTRACE_O_EXITKILL):
New value in enum __ptrace_setoptions.
(PTRACE_O_SUSPEND_SECCOMP): Likewise.
(PTRACE_O_MASK): Update value.

8 years agoUpdate <netpacket/packet.h> for Linux 4.3.
Joseph Myers [Mon, 23 Nov 2015 17:52:08 +0000 (17:52 +0000)]
Update <netpacket/packet.h> for Linux 4.3.

In the course of reviewing Linux 4.3 changes for any glibc header
updates needed, I found that
sysdeps/unix/sysv/linux/netpacket/packet.h was extremely out of date
(last updated for Linux 2.3.15, it seems).  This patch updates the
sets of constants present in that header to include those added to
those sets in newer kernels (include/uapi/linux/if_packet.h).

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

* sysdeps/unix/sysv/linux/netpacket/packet.h (PACKET_COPY_THRESH):
New macro.
(PACKET_AUXDATA): Likewise.
(PACKET_ORIGDEV): Likewise.
(PACKET_VERSION): Likewise.
(PACKET_HDRLEN): Likewise.
(PACKET_RESERVE): Likewise.
(PACKET_TX_RING): Likewise.
(PACKET_LOSS): Likewise.
(PACKET_VNET_HDR): Likewise.
(PACKET_TX_TIMESTAMP): Likewise.
(PACKET_TIMESTAMP): Likewise.
(PACKET_FANOUT): Likewise.
(PACKET_TX_HAS_OFF): Likewise.
(PACKET_QDISC_BYPASS): Likewise.
(PACKET_ROLLOVER_STATS): Likewise.
(PACKET_FANOUT_DATA): Likewise.
(PACKET_MR_UNICAST): Likewise.

8 years agoFix strtol in Turkish locales (bug 19242).
Joseph Myers [Mon, 23 Nov 2015 08:50:53 +0000 (08:50 +0000)]
Fix strtol in Turkish locales (bug 19242).

The implementations of strtol and related functions use
locale-specific conversions to upper case before determining whether a
character is a valid letter in the argument.  This means that in
Turkish locales such as tr_TR.UTF-8 and tr_TR.ISO-8859-9, "i" is
interpreted as not being a valid number, when if the base passed to
strtol is 19 or more it should be interpreted as the number 18.

ISO C explicitly says "The letters from a (or A) through z (or Z) are
ascribed the values 10 through 35", so clearly intends the standard
ASCII letters (otherwise you wouldn't generally have exactly 26
letters to ascribe such values) (whereas white-space must be
identified according to the locale).  In particular, 'i' and 'I' must
be understood to be in that sequence.

This patch makes the code do the case conversions and classification
in the C locale; the user's locale remains used for whitespace testing
(explicitly correct according to ISO C).  Note that the way the code
worked, the only non-ASCII letter that would previously have been
accepted would have been the Turkish 'ı' (dotless 'i'), because the
uppercase version of that in Turkish locales is 'I'.  This patch means
that will no longer be accepted, which seems appropriate.

Tested for x86_64 and x86.

[BZ #19242]
* stdlib/strtol_l.c (ISALPHA): Use _nl_C_locobj_ptr for locale.
(TOUPPER): Likewise.
* stdlib/tst-strtol-locale-main.c: New file.
* stdlib/tst-strtol-locale.c: Likewise.
* stdlib/Makefile (tests): Add tst-strtol-locale.
[$(run-built-tests) = yes] (LOCALES): Add tr_TR.ISO-8859-9.
[$(run-built-tests) = yes] ($(objpfx)tst-strtol-locale.out):
Depend on $(gen-locales).
* wcsmbs/tst-wcstol-locale.c: New file.
* wcsmbs/Makefile (tests): Add tst-wcstol-locale.
[$(run-built-tests) = yes] (LOCALES): Add tr_TR.UTF-8 and
tr_TR.ISO-8859-9.
[$(run-built-tests) = yes] ($(objpfx)tst-wcstol-locale.out):
Depend on $(gen-locales).

8 years agoNaCl: Use allocate_code_data after dyncode_create
Roland McGrath [Sat, 21 Nov 2015 00:16:35 +0000 (16:16 -0800)]
NaCl: Use allocate_code_data after dyncode_create

8 years agoFix math_private.h multiple include guards.
Joseph Myers [Fri, 20 Nov 2015 23:46:23 +0000 (23:46 +0000)]
Fix math_private.h multiple include guards.

Various math_private.h headers are guarded by "#ifndef
_MATH_PRIVATE_H", but never define the macro.  Nothing else defines
the macro either (the generic math_private.h that they include defines
a different macro, _MATH_PRIVATE_H_), so those guards are ineffective.

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

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

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

* sysdeps/arm/math_private.h [!_MATH_PRIVATE_H]: Change guard to
[!ARM_MATH_PRIVATE_H].
[!ARM_MATH_PRIVATE_H] (ARM_MATH_PRIVATE_H): Define macro.
* sysdeps/hppa/math_private.h [!_MATH_PRIVATE_H]: Change guard to
[!HPPA_MATH_PRIVATE_H].
[!HPPA_MATH_PRIVATE_H] (HPPA_MATH_PRIVATE_H): Define macro.
* sysdeps/i386/fpu/math_private.h [!_MATH_PRIVATE_H]: Change guard
to [!I386_MATH_PRIVATE_H].
[!I386_MATH_PRIVATE_H] (I386_MATH_PRIVATE_H): Define macro.
* sysdeps/m68k/m680x0/fpu/math_private.h [!_MATH_PRIVATE_H]:
Change guard to [!M68K_MATH_PRIVATE_H].
[!M68K_MATH_PRIVATE_H] (M68K_MATH_PRIVATE_H): Define macro.
* sysdeps/microblaze/math_private.h [!_MATH_PRIVATE_H]: Change
guard to [!MICROBLAZE_MATH_PRIVATE_H].
[!MICROBLAZE_MATH_PRIVATE_H] (MICROBLAZE_MATH_PRIVATE_H): Define
macro.
* sysdeps/mips/math_private.h [!_MATH_PRIVATE_H]: Change guard to
[!MIPS_MATH_PRIVATE_H].
[!MIPS_MATH_PRIVATE_H] (MIPS_MATH_PRIVATE_H): Define macro.
* sysdeps/nios2/math_private.h [!_MATH_PRIVATE_H]: Change guard to
[!NIO2_MATH_PRIVATE_H].
[!NIO2_MATH_PRIVATE_H] (NIO2_MATH_PRIVATE_H): Define macro.
* sysdeps/tile/math_private.h [!_MATH_PRIVATE_H]: Change guard to
[!TILE_MATH_PRIVATE_H].
[!TILE_MATH_PRIVATE_H] (TILE_MATH_PRIVATE_H): Define macro.

8 years agoFix lgamma setting signgam for ISO C (bug 15421).
Joseph Myers [Fri, 20 Nov 2015 22:49:59 +0000 (22:49 +0000)]
Fix lgamma setting signgam for ISO C (bug 15421).

The lgamma (and likewise lgammaf, lgammal) function wrongly sets the
signgam variable even when building for strict ISO C conformance
(-std=c99 / -std=c11), although the user may define such a variable
and it's only in the implementation namespace for POSIX with XSI
extensions enabled.

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

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

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

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

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

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

[BZ #15421]
* sysdeps/ieee754/s_signgam.c (signgam): Rename to __signgam,
initialize with 0 and define as weak alias of __signgam.
* include/math.h [!_ISOMAC] (__signgam): Declare.
* math/Makefile (libm-calls): Add w_lgamma_compat.
(tests): Add test-signgam-uchar, test-signgam-uchar-init,
test-signgam-uint, test-signgam-uint-init, test-signgam-ullong and
test-signgam-ullong-init.
(tests-static): Add test-signgam-uchar-static,
test-signgam-uchar-init-static, test-signgam-uint-static,
test-signgam-uint-init-static, test-signgam-ullong-static and
test-signgam-ullong-init-static.
(CFLAGS-test-signgam-uchar.c): New variable.
(CFLAGS-test-signgam-uchar-init.c): Likewise.
(CFLAGS-test-signgam-uchar-static.c): Likewise.
(CFLAGS-test-signgam-uchar-init-static.c): Likewise.
(CFLAGS-test-signgam-uint.c): Likewise.
(CFLAGS-test-signgam-uint-init.c): Likewise.
(CFLAGS-test-signgam-uint-static.c): Likewise.
(CFLAGS-test-signgam-uint-init-static.c): Likewise.
(CFLAGS-test-signgam-ullong.c): Likewise.
(CFLAGS-test-signgam-ullong-init.c): Likewise.
(CFLAGS-test-signgam-ullong-static.c): Likewise.
(CFLAGS-test-signgam-ullong-init-static.c): Likewise.
* math/Versions (libm): Add GLIBC_2.23.
* math/lgamma-compat.h: New file.
* math/test-signgam-main.c: Likewise.
* math/test-signgam-uchar-init-static.c: Likewise.
* math/test-signgam-uchar-init.c: Likewise.
* math/test-signgam-uchar-static.c: Likewise.
* math/test-signgam-uchar.c: Likewise.
* math/test-signgam-uint-init-static.c: Likewise.
* math/test-signgam-uint-init.c: Likewise.
* math/test-signgam-uint-static.c: Likewise.
* math/test-signgam-uint.c: Likewise.
* math/test-signgam-ullong-init-static.c: Likewise.
* math/test-signgam-ullong-init.c: Likewise.
* math/test-signgam-ullong-static.c: Likewise.
* math/test-signgam-ullong.c: Likewise.
* math/w_lgamma.c: Rename to w_lgamma_main.c and replace by
wrapper of w_lgamma_main.c.
* math/w_lgamma_compat.c: New file.
* math/w_lgamma_compatf.c: Likewise.
* math/w_lgamma_compatl.c: Likewise.
* math/w_lgamma_main.c: New file.  Based on w_lgamma.c.  Include
<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
defining compatibility symbols.
(__lgamma): Change to LGFUNC (__lgamma).  Use CALL_LGAMMA.
* math/w_lgammaf.c: Rename to w_lgammaf_main.c and replace by
wrapper of w_lgammaf_main.c.
* math/w_lgammaf_main.c: New file.  Based on w_lgammaf.c.  Include
<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
defining compatibility symbols.
(__lgammaf): Change to LGFUNC (__lgammaf).  Use CALL_LGAMMA.
* math/w_lgammal.c: Rename to w_lgammal_main.c and replace by
wrapper of w_lgammal_main.c.
* math/w_lgammal_main.c: New file.  Based on w_lgammal.c.  Include
<lgamma-compat.h>.  Condition contents on [BUILD_LGAMMA].  Support
defining compatibility symbols.
(__lgammal): Change to LGFUNC (__lgammal).  Use CALL_LGAMMA.
* sysdeps/ia64/fpu/lgamma-compat.h: New file.
* sysdeps/ia64/fpu/w_lgamma.c: Move to ....
* sysdeps/ia64/fpu/w_lgamma_main.c: ...here.  Include
<lgamma-compat.h>.
(__ieee754_lgamma): Change to LGFUNC (lgamma).  Use CALL_LGAMMA.
(__ieee754_gamma): Define as alias.
* sysdeps/ia64/fpu/w_lgammaf.c: Move to ....
* sysdeps/ia64/fpu/w_lgammaf_main.c: ...here.  Include
<lgamma-compat.h>.
(__ieee754_lgammaf): Change to LGFUNC (lgammaf).  Use CALL_LGAMMA.
(__ieee754_gammaf): Define as alias.
* sysdeps/ia64/fpu/w_lgammal.c: Move to ....
* sysdeps/ia64/fpu/w_lgammal_main.c: ...here.  Include
<lgamma-compat.h>.
(__ieee754_lgammal): Change to LGFUNC (lgammal).  Use CALL_LGAMMA.
(__ieee754_gammal): Define as alias.
* sysdeps/ieee754/ldbl-opt/w_lgamma.c: Move to ....
* sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c: ...here.  Include
<math/w_lgamma_compat.c>.
[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (__lgammal_dbl_compat):
Define as alias of __lgamma_compat and use in defining lgammal.
* sysdeps/ieee754/ldbl-opt/w_lgammal.c: Move to ....
* sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c: ...here.  Include
<math/lgamma-compat.h> and <math/w_lgamma_compatl.c>.
(USE_AS_COMPAT): New macro.
(LGAMMA_OLD_VER): Undefine and redefine.
(lgammal): Do not define here.
(gammal): Only define here if [GAMMA_ALIAS].
* conform/linknamespace.pl (@whitelist): Remove signgam.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

8 years agoRemove signal handling for nanosleep (bug 16364)
Adhemerval Zanella [Sun, 8 Nov 2015 22:06:42 +0000 (20:06 -0200)]
Remove signal handling for nanosleep (bug 16364)

Linux 2.6.32 and forward do not show the issue regarding SysV SIGCHLD
vs. SIG_IGN for nanosleep which make it feasible to use it for sleep
implementation without requiring any hacking to handle the spurious
wake up.  The issue is likely being fixed before 2.6 and git
history [1] [2].

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

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

Checked on x86_64, ppc64le, and aarch64.

[BZ #16364]
* sysdeps/unix/sysv/linux/sleep.c: Remove file
* sysdeps/posix/sleep.c (__sleep): Simplify cancellation handling.

8 years agoS390: Use __asm__ instead of asm.
Stefan Liebler [Fri, 20 Nov 2015 07:56:40 +0000 (08:56 +0100)]
S390: Use __asm__ instead of asm.

* sysdeps/s390/fpu/bits/mathinline.h:
Use __asm__ [__volatile__] instead of asm [volatile].
* sysdeps/s390/abort-instr.h: Likewise.
* sysdeps/s390/atomic-machine.h: Likewise.
* sysdeps/s390/bits/string.h: Likewise.
* sysdeps/s390/dl-tls.h: Likewise.
* sysdeps/s390/fpu/e_sqrt.c: Likewise.
* sysdeps/s390/fpu/e_sqrtf.c: Likewise.
* sysdeps/s390/fpu/e_sqrtl.c: Likewise.
* sysdeps/s390/fpu/fesetround.c: Likewise.
* sysdeps/s390/fpu/fpu_control.h: Likewise.
* sysdeps/s390/fpu/s_fma.c: Likewise.
* sysdeps/s390/fpu/s_fmaf.c: Likewise.
* sysdeps/s390/memusage.h: Likewise.
* sysdeps/s390/multiarch/ifunc-resolve.h: Likewise.
* sysdeps/s390/nptl/pthread_spin_lock.c: Likewise.
* sysdeps/s390/nptl/pthread_spin_trylock.c: Likewise.
* sysdeps/s390/nptl/pthread_spin_unlock.c: Likewise.
* sysdeps/s390/nptl/tls.h: Likewise.
* sysdeps/s390/s390-32/__longjmp.c: Likewise.
* sysdeps/s390/s390-32/backtrace.c: Likewise.
* sysdeps/s390/s390-32/dl-machine.h: Likewise.
* sysdeps/s390/s390-32/multiarch/memcmp.c: Likewise.
* sysdeps/s390/s390-32/stackguard-macros.h: Likewise.
* sysdeps/s390/s390-32/tls-macros.h: Likewise.
* sysdeps/s390/s390-64/__longjmp.c: Likewise.
* sysdeps/s390/s390-64/backtrace.c: Likewise.
* sysdeps/s390/s390-64/dl-machine.h: Likewise.
* sysdeps/s390/s390-64/iso-8859-1_cp037_z900.c: Likewise.
* sysdeps/s390/s390-64/multiarch/memcmp.c: Likewise.
* sysdeps/s390/s390-64/stackguard-macros.h: Likewise.
* sysdeps/s390/s390-64/tls-macros.h: Likewise.
* sysdeps/s390/s390-64/utf16-utf32-z9.c: Likewise.
* sysdeps/s390/s390-64/utf8-utf16-z9.c: Likewise.
* sysdeps/s390/s390-64/utf8-utf32-z9.c: Likewise.
* sysdeps/unix/sysv/linux/s390/brk.c: Likewise.
* sysdeps/unix/sysv/linux/s390/elision-trylock.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/____longjmp_chk.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/____longjmp_chk.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sysconf.c: Likewise.

8 years agopowerpc: Spinlock optimization and cleanup
Paul Murphy [Thu, 29 Oct 2015 20:48:47 +0000 (15:48 -0500)]
powerpc: Spinlock optimization and cleanup

This patch optimizes powerpc spinlock implementation by:

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

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

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

* sysdeps/powerpc/nptl/pthread_spin_lock.c (pthread_spin_lock):
Add lwarx hint, and use macro for acquire instruction.
* sysdeps/powerpc/nptl/pthread_spin_trylock.c (pthread_spin_trylock):
Likewise.
* sysdep/unix/sysv/linux/powerpc/pthread_spin_unlock.c: Move to ...
* sysdeps/powerpc/nptl/pthread_spin_unlock.c: ... here, and
update to use new atomic macros.

8 years agopowerpc: More elision improvements
Paul Murphy [Wed, 28 Oct 2015 22:34:31 +0000 (17:34 -0500)]
powerpc: More elision improvements

__lll_trylock_elision sets the adapt_count variable too
aggressively, and incorrectly on persistent aborts.  Taking
a cue from s390, adapt_count is only updated if the lock
is locked, or a persistent failure occurs.

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

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

* sysdeps/unix/sysv/linux/powerpc/elision-trylock.c
(__lll_trylock_elision): Fix setting of adapt_count.
* sysdeps/unix/sysv/linux/powerpc/htm.h
(_ABORT_PERSISTENT): Define to clarify persistent aborts.
(_ABORT_NESTED_TRYLOCK): Renumber, and make persistent.
(_ABORT_SYSCALL): Renumber, and clarify definition.
(_ABORT_LOCK_BUSY): Renumber, make non-persistent.

8 years agoShuffle includes in ldbl-128ibm/mpn2ldl.c
Paul Murphy [Tue, 17 Nov 2015 18:27:39 +0000 (12:27 -0600)]
Shuffle includes in ldbl-128ibm/mpn2ldl.c

Kind of hokey, but errno.h drags in misc/sys/param.h which
defines MIN/MAX causing an error.  Include system headers
first to grab MIN/MAX definition in param.h, and define
HAVE_ALLOCA to preserve existing behavior.

* sysdeps/ieee754/ldbl-128ibm/mpn2ldl.c: Include gmp headers
after system headers to prevent MIN/MAX redefinition.  Define
HAVE_ALLOCA to preserve builtin alloca usage.

8 years agoInclude s_sin.c in s_sincos.c
Siddhesh Poyarekar [Tue, 17 Nov 2015 10:50:20 +0000 (16:20 +0530)]
Include s_sin.c in s_sincos.c

Include the __sin and __cos functions as local static copies to allow
deper optimization of the functions.  This change shows an improvement
of about 17% in the min case and 12.5% in the mean case for the sincos
microbenchmark on x86_64.

* sysdeps/ieee754/dbl-64/s_sin.c (__sin)[IN_SINCOS]: Mark function
static and don't set or restore rounding.
(__cos)[IN_SINCOS]: Likewise.
* sysdeps/ieee754/dbl-64/s_sincos.c: Include s_sin.c.
(__sincos): Set and restore rounding mode.  Remove check for infinite
or NaN input.

8 years agoRemove redundant else clauses in s_sin.c
Siddhesh Poyarekar [Tue, 17 Nov 2015 10:33:11 +0000 (16:03 +0530)]
Remove redundant else clauses in s_sin.c

Makes the code easier to read due to the reduced nesting.  The
generated binary is unchanged.

8 years agobenchtests: Mark output variables as used
Siddhesh Poyarekar [Tue, 17 Nov 2015 10:31:15 +0000 (16:01 +0530)]
benchtests: Mark output variables as used

Prevent function calls that don't return anything from being optimized
out by the compiler by marking its input variables as used.

This prevents the sincos function call from being optimized out in the
benchmark.

8 years agoWork around conflicting declarations of math functions
Florian Weimer [Mon, 16 Nov 2015 20:29:14 +0000 (21:29 +0100)]
Work around conflicting declarations of math functions

This restores compilation on architectures such as armhfp which
alias acos and acosl because double and long double are the same.

8 years agoRun tst-prelink test for GLOB_DAT reloc
H.J. Lu [Sat, 14 Nov 2015 20:00:16 +0000 (12:00 -0800)]
Run tst-prelink test for GLOB_DAT reloc

Run tst-prelink test on targets with GLOB_DAT relocaton.

* config.make.in (have-glob-dat-reloc): New.
* configure.ac (libc_cv_has_glob_dat): New.  Set to yes if
target supports GLOB_DAT relocaton. AC_SUBST.
* configure: Regenerated.
* elf/Makefile (tests): Add tst-prelink.
(tests-special): Add $(objpfx)tst-prelink-cmp.out.
(tst-prelink-ENV): New.
($(objpfx)tst-prelink-conflict.out): Likewise.
($(objpfx)tst-prelink-cmp.out): Likewise.
* sysdeps/x86/tst-prelink.c: Moved to ...
* elf/tst-prelink.c: Here.
* sysdeps/x86/tst-prelink.exp: Moved to ...
* elf/tst-prelink.exp: Here.
* sysdeps/x86/Makefile (tests): Don't add tst-prelink.
(tst-prelink-ENV): Removed.
($(objpfx)tst-prelink-conflict.out): Likewise.
($(objpfx)tst-prelink-cmp.out): Likewise.
(tests-special): Don't add $(objpfx)tst-prelink-cmp.out.

8 years agoFix ldbl-128ibm strtold overflow handling (bug 14551).
Joseph Myers [Fri, 13 Nov 2015 12:03:46 +0000 (12:03 +0000)]
Fix ldbl-128ibm strtold overflow handling (bug 14551).

For ldbl-128ibm, if the result of strtold overflows in the final
conversion from MPN to IBM long double (because the exponent for a
106-bit IEEE result is 1023 but the high part would end up as
0x1p1024, which overflows), that conversion code fails to handle this
and produces an invalid long double value (high part infinite, low
part not zero) without raising exceptions or setting errno.  This
patch adds an explicit check for this case to ensure an appropriate
result is returned in a way that ensures the right exceptions are
raised, with errno set.

Tested for powerpc.

[BZ #14551]
* sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c: Include <errno.h>.
(__mpn_construct_long_double): If high part overflows to infinity,
set errno and recompute overflowed result of the correct sign.
* sysdeps/ieee754/ldbl-128ibm/Makefile
[$(subdir) = stdlib] (tests): Add tst-strtold-ldbl-128ibm.
[$(subdir) = stdlib] ($(objpfx)tst-strtold-ldbl-128ibm): Depend on
$(libm).
* sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c: New file.

8 years agoFix powerpc round, roundf spurious "inexact" (bug 19238).
Joseph Myers [Thu, 12 Nov 2015 19:00:06 +0000 (19:00 +0000)]
Fix powerpc round, roundf spurious "inexact" (bug 19238).

The powerpc hard-float round and roundf functions, both 32-bit and
64-bit, raise spurious "inexact" exceptions for integer arguments from
adding 0.5 and rounding to integer toward zero.

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

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

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

Tested for powerpc32 and powerpc64.

[BZ #15479]
[BZ #19238]
* sysdeps/powerpc/powerpc32/fpu/s_round.S (__round): Save
floating-point state after first operation on input.  Restore full
state rather than just rounding mode.
* sysdeps/powerpc/powerpc32/fpu/s_roundf.S (__roundf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_round.S (__round): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_roundf.S (__roundf): Likewise.

8 years agoFix powerpc64 lround, lroundf, llround, llroundf spurious "inexact" exceptions (bug...
Joseph Myers [Thu, 12 Nov 2015 16:24:00 +0000 (16:24 +0000)]
Fix powerpc64 lround, lroundf, llround, llroundf spurious "inexact" exceptions (bug 19235).

Similar to bug 19134 for powerpc32, the powerpc64 implementations of
lround, lroundf, llround, llroundf can raise spurious "inexact"
exceptions for integer arguments from adding 0.5 then converting to
integer (this does not apply to the power5+ version for double, which
uses the frin instruction which is defined never to raise "inexact"; I
don't know why power5+ doesn't use that version for float as well).

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

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

Tested for powerpc64.

[BZ #19235]
* sysdeps/powerpc/powerpc64/fpu/s_llround.S (__llround): Do not
add 0.5 to integer arguments.
* sysdeps/powerpc/powerpc64/fpu/s_llroundf.S (__llroundf):
Likewise.
(.LC2): New object.

8 years agopylintrc: disable reports
Mike Frysinger [Tue, 10 Nov 2015 05:45:41 +0000 (00:45 -0500)]
pylintrc: disable reports

I've never found these useful, nor found anyone else who likes them.
Turn them off by default.

8 years agoNaCl: Use open_resource API for shared objects
Roland McGrath [Wed, 11 Nov 2015 03:44:48 +0000 (19:44 -0800)]
NaCl: Use open_resource API for shared objects

8 years agoFix powerpc nearbyint wrongly clearing "inexact" and leaving traps disabled (bug...
Joseph Myers [Wed, 11 Nov 2015 00:06:09 +0000 (00:06 +0000)]
Fix powerpc nearbyint wrongly clearing "inexact" and leaving traps disabled (bug 19228).

Similar to bug 15491 recently fixed for x86_64 / x86, the powerpc
(both powerpc32 and powerpc64) hard-float implementations of
nearbyintf and nearbyint wrongly clear an "inexact" exception that was
raised before the function was called; this shows up as failure of the
test math/test-nearbyint-except added when that bug was fixed.  They
also wrongly leave traps on "inexact" disabled if they were enabled
before the function was called.

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

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

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

[BZ #19228]
* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S (__nearbyint): Save
and restore full floating-point state.
* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S (__nearbyintf):
Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S (__nearbyint):
Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S (__nearbyintf):
Likewise.
* math/test-nearbyint-except-2.c: New file.
* math/Makefile (tests): Add test-nearbyint-except-2.

8 years agoAdd a test for prelink output
H.J. Lu [Tue, 10 Nov 2015 20:27:24 +0000 (12:27 -0800)]
Add a test for prelink output

This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.

[BZ #19178]
* sysdeps/x86/Makefile (tests): Add tst-prelink.
(tst-prelink-ENV): New.
($(objpfx)tst-prelink-conflict.out): Likewise.
($(objpfx)tst-prelink-cmp.out): Likewise.
(tests-special): Add $(objpfx)tst-prelink-cmp.out.
* sysdeps/x86/tst-prelink.c: New file.
* sysdeps/x86/tst-prelink.exp: Likewise.

8 years agoAdd more tests of pow.
Joseph Myers [Tue, 10 Nov 2015 17:34:13 +0000 (17:34 +0000)]
Add more tests of pow.

Prompted by a gcc-patches discussion, this patch adds tests of pow for
the cases where pow (x, 0.5) is required to return a different result
from sqrt (x), as those cases were previously missing from the tests
(although they worked correctly).

Tested for x86_64 and x86.

* math/auto-libm-test-in: Add another test of pow.
* math/auto-libm-test-out: Regenerated.
* math/libm-test.inc (pow_test_data): Add another test.

8 years agoFix nearbyintl linkage for ia64 (bug 19219)
Adhemerval Zanella [Mon, 2 Nov 2015 17:19:45 +0000 (15:19 -0200)]
Fix nearbyintl linkage for ia64 (bug 19219)

GLIBC fails to build for ia64 since commit d0d286d32dda654f8983e8fe77bca0a2cda2051b.
It is because this commit uses the internal definition for nearbyintl,
but ia64 specialized implementation (sysdeps/ia64/fpu/s_nearbyintl.S)
does not define it.

Tested with a ia64 build.

        [BZ #19219]
        * sysdeps/ia64/fpu/s_nearbyintl.S (__nearbyint): Define and
        weak_alias to nearbyintl.

8 years agoEnable _STRING_ARCH_unaligned on AArch64.
Wilco Dijkstra [Tue, 10 Nov 2015 11:13:23 +0000 (11:13 +0000)]
Enable _STRING_ARCH_unaligned on AArch64.

        * sysdeps/aarch64/bits/string.h: New file.
        (_STRING_ARCH_unaligned): Define.

8 years agoRemove __signbit* from localplt.data as they are no longer called from within GLIBC.
Wilco Dijkstra [Tue, 10 Nov 2015 11:07:33 +0000 (11:07 +0000)]
Remove __signbit* from localplt.data as they are no longer called from within GLIBC.

* sysdeps/unix/sysv/linux/aarch64/localplt.data: Remove __signbit*.
* sysdeps/unix/sysv/linux/arm/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/microblaze/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/nios2/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/localplt.data: Likewise.

8 years agold.so: Add original DSO name if overridden by audit module [BZ #18251]
Florian Weimer [Mon, 9 Nov 2015 15:52:31 +0000 (16:52 +0100)]
ld.so: Add original DSO name if overridden by audit module [BZ #18251]

* elf/dl-load.c (_dl_map_object_from_fd): Add additional parameter
for original name of the DSO.  Add it to the name list of the DSO
if it is actually given.
(_dl_map_object): Keep track of whether an audit module rewrote
the file name.  If yes, pass the original name to
_dl_map_object_from_fd in a new parameter, otherwise NULL.  When
debugging is enabled, log the change of the file name.
* sysdeps/mach/hur/dl-sysdep.c: Adjust commented-out call to
_dl_map_object_from_fd.
* elf/Makefile: Build and run tst-audit11 and tst-audit12.
* elf/tst-audit11.c: New file
* elf/tst-auditmod11.c: New file.
* elf/tst-audit11mod1.c: New file.
* elf/tst-audit11mod2.c: New file.
* elf/tst-audit11mod2.map: New file.
* elf/tst-audit12.c: New file
* elf/tst-auditmod12.c: New file.
* elf/tst-audit12mod1.c: New file.
* elf/tst-audit12mod2.c: New file.
* elf/tst-audit12mod2.map: New file.
* elf/tst-audit12mod3.c: New file.

8 years agoS390: Clean setjmp, longjmp, getcontext symbols.
Stefan Liebler [Mon, 9 Nov 2015 15:14:49 +0000 (16:14 +0100)]
S390: Clean setjmp, longjmp, getcontext symbols.

For each function setjmp, longjmp, getcontext, there exist a symbol
<func> and a default/versioned symbol <func>@@GLIBC_2.x in the build
obj-files.
This is wrong because it should only exist an unversioned or a
default-versioned symbol with the same name in an obj-file.
Glibc can't be build with recent binutils. See the already fixed linker
bug https://sourceware.org/bugzilla/show_bug.cgi?id=19073.
Nevertheless, this patch cleans this up.

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

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

ChangeLog:

* sysdeps/s390/longjmp.c (longjmp, _longjmp, siglongjmp):
Don't create weak aliases,
because versioned symbols are created later.
* sysdeps/s390/s390-32/setjmp.S
(setjmp, _setjmp): Remove weak and rename to an unique name
in SHARED case due to existing versioned symbols.
* sysdeps/s390/s390-64/setjmp.S: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/getcontext.S
(getcontext): Create weak alias only in non SHARED case.
* sysdeps/unix/sysv/linux/s390/s390-64/getcontext.S: Likewise.

8 years agoS390: Call direct system calls for socket operations.
Stefan Liebler [Mon, 9 Nov 2015 15:14:49 +0000 (16:14 +0100)]
S390: Call direct system calls for socket operations.

this patch calls direct system calls for socket operations in the same way as power does. The system calls were introduced in kernel commit https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=977108f89c989b1eeb5c8d938e1e71913391eb5f.
There are no direct recv, send, accept syscalls available on s390. Thus
recvfrom, sendto, accept4 are called instead of the socketcall by defining __ASSUME_*_FOR_*_SYSCALL macros. See recv.c, send.c, accept.c in sysdeps/unix/sysv/linux/ folder.

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

ChangeLog:

* sysdeps/unix/sysv/linux/s390/kernel-features.h:
(__ASSUME_*_SYSCALL) Define new macros.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list:
Remove socketcall syscalls.
* sysdeps/unix/sysv/linux/accept.c (__libc_accept):
Use accept4 if defined __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL.
* sysdeps/unix/sysv/linux/recv.c (__libc_recv):
Use recvfrom if defined __ASSUME_RECVFROM_FOR_RECV_SYSCALL.
* sysdeps/unix/sysv/linux/send.c (__libc_send):
Use sendto if defined __ASSUME_SENDTO_FOR_SEND_SYSCALL.

8 years agoTerminate process on invalid netlink response from kernel [BZ #12926]
Florian Weimer [Mon, 9 Nov 2015 11:48:41 +0000 (12:48 +0100)]
Terminate process on invalid netlink response from kernel [BZ #12926]

The recvmsg system calls for netlink sockets have been particularly
prone to picking up unrelated data after a file descriptor race
(where the descriptor is closed and reopened concurrently in a
multi-threaded process, as the result of a file descriptor
management issue elsewhere).  This commit adds additional error
checking and aborts the process if a datagram of unexpected length
(without the netlink header) is received, or an error code which
cannot happen due to the way the netlink socket is used.

[BZ #12926]
Terminate process on invalid netlink response.
* sysdeps/unix/sysv/linux/netlinkaccess.h
(__netlink_assert_response): Declare.
* sysdeps/unix/sysv/linux/netlink_assert_response.c: New file.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) == inet]
(sysdep_routines): Add netlink_assert_response.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Call
__netlink_assert_response.
* sysdeps/unix/sysv/linux/check_pf.c (make_request): Likewise.
* sysdeps/unix/sysv/linux/ifaddrs.c (__netlink_request): Likewise.
* sysdeps/unix/sysv/linux/Versions (GLIBC_PRIVATE): Add
__netlink_assert_response.

8 years agoKeep only ELF_RTYPE_CLASS_{PLT|COPY} bits for prelink
H.J. Lu [Sat, 7 Nov 2015 14:32:30 +0000 (06:32 -0800)]
Keep only ELF_RTYPE_CLASS_{PLT|COPY} bits for prelink

prelink runs ld.so with the environment variable LD_TRACE_PRELINKING
set to dump the relocation type class from _dl_debug_bindings.  prelink
has the following relocation type classes:

 #define RTYPE_CLASS_VALID       8
 #define RTYPE_CLASS_PLT         (8|1)
 #define RTYPE_CLASS_COPY        (8|2)
 #define RTYPE_CLASS_TLS         (8|4)

where ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA has a conflict with
RTYPE_CLASS_TLS.

Since prelink only uses ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY
bits, we should clear the other bits when the DL_DEBUG_PRELINK bit is
set.

[BZ #19178]
* elf/dl-lookup.c (RTYPE_CLASS_VALID): New.
(RTYPE_CLASS_PLT): Likewise.
(RTYPE_CLASS_COPY): Likewise.
(RTYPE_CLASS_TLS): Likewise.
(_dl_debug_bindings): Use RTYPE_CLASS_TLS and RTYPE_CLASS_VALID
to set relocation type class for DL_DEBUG_PRELINK.  Keep only
ELF_RTYPE_CLASS_PLT and ELF_RTYPE_CLASS_COPY bits for
DL_DEBUG_PRELINK.

8 years agoFix typo in signgam test messages.
Joseph Myers [Fri, 6 Nov 2015 18:45:32 +0000 (18:45 +0000)]
Fix typo in signgam test messages.

I noticed a typo in the messages from the signgam tests I recently
added.  This patch fixes it.

Tested for x86_64 and x86.

* math/test-signgam-finite.c (RUN_TESTS): Correct messages about
calls with argument -0.5.
* math/test-signgam-finite-c99.c (RUN_TESTS): Likewise.

8 years agoRemove configure tests for some linker -z options.
Joseph Myers [Fri, 6 Nov 2015 13:20:26 +0000 (13:20 +0000)]
Remove configure tests for some linker -z options.

There are configure tests for the linker -z nodelete, -z nodlopen and
-z initfirst options.  These options were added in binutils 2.11, so
the tests are obsolete; this patch removes them.

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

* configure.ac (libc_cv_z_nodelete): Remove configure test.
(libc_cv_z_nodlopen): Likewise.
(libc_cv_z_initfirst): Likewise.
* configure: Regenerated.

8 years agoSimplify the abilist format
Florian Weimer [Thu, 29 Oct 2015 14:33:54 +0000 (15:33 +0100)]
Simplify the abilist format

The new format lists the version on each line, as in:

VERSION SYMBOL TYPE [VALUE]

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

The abilist files were converted with this awk script:

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

And sorted under the "C" locale with sort.

8 years agoAdd LFS support for fts functions (bug 11460)
Mark Wielaard [Fri, 6 Nov 2015 10:22:38 +0000 (11:22 +0100)]
Add LFS support for fts functions (bug 11460)

fts didn't have large-file support yet and fts.h had an #error preventing
usage when _FILE_OFFSET_BITS was set. This required nasty workarounds for
programs using fts with LFS. This patch implements LFS support for fts by
adding FTS64 and FTENT64 variants plus fts64 functions. Which are simple
aliases for 64bit off_t arches.

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

[BZ #11460]
* io/Makefile (routines): Add fts64.
(tests): Add tst-fts and tst-fts-lfs.
(CFLAGS-fts64.c): New.
* io/Versions (GLIBC_2.23): New.
* io/fts.c: Replace FTS with FTSOBJ, FTSENT with FTSENTRY. Use
function defines FTS_OPEN, FTS_CLOSE, FTS_READ, FTS_SET and
FTS_CHILDREN. Define FTSOBJ, FTSENTRY, FTS_OPEN, FTS_CLOSE,
FTS_READ, FTS_SET, FTS_CHILDREN, INO_T, STAT and LSTAT if necessary.
* io/fts.h (FTS64): New if _USE_LARGEFILE64.
(FTSENT64): Likewise.
(fts64_children): Likewise.
(fts64_close): Likewise.
(fts64_open): Likewise.
(fts64_read): Likewise.
(fts64_set): Likewise.
* io/fts64.c: New file.
* io/tst-fts.c: New test.
* io/tst-fts-lfs.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.23): Add
GLIBC_2.23, fts64_children, fts64_close, fts64_open, fts64_read and
fts64_set.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* sysdeps/wordsize-64/fts.c: New file.
* sysdeps/wordsize-64/fts64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/fts.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/fts64.c: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/fts.c: likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/fts64.c: likewise.

8 years agoRun libm-test tests for finite-math-only functions.
Joseph Myers [Thu, 5 Nov 2015 23:28:16 +0000 (23:28 +0000)]
Run libm-test tests for finite-math-only functions.

This patch arranges for the libm-test tests to be run for the
finite-math-only function variants, in addition to the existing runs
for out-of-line and bits/mathinline.h inline variants.

gen-libm-test.pl is made to add a flag to all tests with non-finite
inputs or outputs so that they can be skipped at runtime when the
finite-math-only variants are being tested (skipping is for all
rounding modes; that is, -ffinite-math-only is being treated as
excluding overflow cases even when the rounding mode is such that the
overflowed result is finite).  errno setting is not tested for these
variants (in general they don't set it, and it's
implementation-defined in ISO C whether it's set on underflow, with
the glibc definition being that it may not be for -ffinite-math-only;
other cases where errno would normally be expected to be set are
mostly excluded as having non-finite or overflowing arguments or
results).

As with the inline function tests, these ones are built with
-D__FINITE_MATH_ONLY=1 to select the function variants, rather than
-ffinite-math-only.  Use of -ffinite-math-only would not be suitable
for these tests because it would also affect libm-test.inc code that
e.g. tests whether results are infinities or NaNs - if these function
variants have bugs that incorrectly produce such results, we want them
to show up in the tests, which means the compiler should not be
optimizing the tests on the basis of results being finite.

The finite-math-only functions share the same ulps settings as the
main out-of-line functions.

These interfaces were one significant group of untested ABIs listed at
<https://sourceware.org/ml/libc-alpha/2013-07/msg00386.html>.  I
haven't rerun the script to list untested interfaces, but I expect
that the vast bulk of interfaces there are still untested and could do
with testcases being added (or, if applicable, being made compat
symbols; in general, most symbols not starting '_' are safe bets to
add tests for, while _* need more investigation of what the actual
public API is, if any).  I'd like to encourage people to help reduce
the accumulation of untested interfaces by adding more tests.

Tested for x86_64 and x86.  Given my recent lgamma/gamma and log*
fixes, the new tests pass (before those fixes, the new tests showed up
those bugs, so illustrating the practical utility of having tests for
these function variants).

* math/libm-test.inc (NON_FINITE): New macro.
(enable_test): Do not run tests flagged NON_FINITE if TEST_FINITE.
* math/gen-libm-test.pl (show_exceptions): Add argument
$non_finite.
(parse_args): Update call to show_exceptions.
* math/test-math-finite.h: New file.
* math/test-math-no-finite.h: Likewise.
* math/test-double-finite.c: Likewise.
* math/test-float-finite.c: Likewise.
* math/test-ldouble-finite.c: Likewise.
* math/test-double.c: Include "test-math-no-finite.h".
* math/test-float.c: Include "test-math-no-finite.h".
* math/test-ldouble.c: Include "test-math-no-finite.h".
* math/test-math-inline.h (TEST_FINITE): New macro.
* math/test-math-vector.h (TEST_FINITE): Likewise.
* math/Makefile (test-longdouble-yes): Add test-ldouble-finite.
(libm-tests): Add test-float-finite and test-double-finite.
($(objpfx)test-float-finite.o): New dependency on
$(objpfx)libm-test.stmp.
($(objpfx)test-double-finite.o): Likewise.
($(objpfx)test-ldouble-finite.o): Likewise.
(libm-test-no-inline-cflags): New variable.
(libm-test-finite-cflags): Likewise.
(CFLAGS-test-float-finite.c): Likewise.
(CFLAGS-test-double-finite.c): Likewise.
(CFLAGS-test-ldouble-finite.c): Likewise.
(CFLAGS-test-float.c): Use $(libm-test-no-inline-cflags).
(CFLAGS-test-double.c): Likewise.
(CFLAGS-test-ldouble.c): Likewise.

8 years agoFix some stub prototypes missing ... after K&R conversion
Roland McGrath [Thu, 5 Nov 2015 23:00:12 +0000 (15:00 -0800)]
Fix some stub prototypes missing ... after K&R conversion

8 years agoAdd script to list fixed bugs for the NEWS file.
Joseph Myers [Thu, 5 Nov 2015 22:18:32 +0000 (22:18 +0000)]
Add script to list fixed bugs for the NEWS file.

This patch adds a script to list fixed bugs for the NEWS file, as
proposed in
<https://sourceware.org/ml/libc-alpha/2015-10/msg01043.html>, with the
bugs listed in the format proposed in
<https://sourceware.org/ml/libc-alpha/2015-11/msg00088.html>.

* scripts/list-fixed-bugs.py: New file.

8 years agoFix i386/x86_64 log* (1) zero sign for -ffinite-math-only (bug 19213).
Joseph Myers [Thu, 5 Nov 2015 21:56:31 +0000 (21:56 +0000)]
Fix i386/x86_64 log* (1) zero sign for -ffinite-math-only (bug 19213).

For the -ffinite-math-only versions of various x86_64 and x86 log*
functions, a zero result from log* (1) is returned with incorrect sign
in round-downward mode.  This patch fixes this in a similar way to the
previous fixes for the non-*_finite versions of the functions.

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

[BZ #19213]
* sysdeps/i386/fpu/e_log.S (__log_finite): Ensure +0 is always
returned for argument 1.
* sysdeps/i386/fpu/e_logf.S (__logf_finite): Likewise.
* sysdeps/i386/fpu/e_logl.S (__logl_finite): Likewise.
* sysdeps/i386/i686/fpu/e_logl.S (__logl_finite): Likewise.
* sysdeps/x86_64/fpu/e_log10l.S (__log10l_finite): Likewise.
* sysdeps/x86_64/fpu/e_log2l.S (__log2l_finite): Likewise.
* sysdeps/x86_64/fpu/e_logl.S (__logl_finite): Likewise.

8 years agoFix finite-math-only lgamma functions signgam setting (bug 19211).
Joseph Myers [Thu, 5 Nov 2015 21:23:07 +0000 (21:23 +0000)]
Fix finite-math-only lgamma functions signgam setting (bug 19211).

The lgamma inline functions in bits/math-finite.h do not set signgam
if __USE_ISOC99, even when other feature test macros mean a standard
such as XSI POSIX is selected for which it should be set.  (This is
essentially the opposite issue to bug 15421, the out-of-line versions
setting signgam even when they shouldn't.)

This patch fixes those functions to use __USE_MISC || __USE_XOPEN as
the condition for when to set signgam, since it's the condition for
when math.h declares signgam.  The legacy gamma* names are only
declared at all if __USE_MISC || __USE_XOPEN, so they just set signgam
unconditionally.

Tests for certain standards or not using _GNU_SOURCE cannot use
test-skeleton.c (this is a known issue noted on the wiki todo list).
Thus, the new tests that signgam remains not set in ISO C modes do not
use test-skeleton.c.  They also define _ISOMAC to avoid running into
declarations in the internal include/ headers that only work in
_GNU_SOURCE mode.

Tested for x86_64 and x86.

[BZ #19211]
* math/bits/math-finite.h (lgamma): Set signgam if [__USE_MISC ||
__USE_XOPEN], not if [!__USE_ISOC99].
(lgammaf): Likewise.
(lgammal): Likewise.
(gamma): Set signgam unconditionally, not if [!__USE_ISOC99].
(gammaf): Likewise.
(gammal): Likewise.
* math/test-signgam-finite-c11.c: New file.
* math/test-signgam-finite-c99.c: Likewise.
* math/test-signgam-finite.c: Likewise.
* math/Makefile (tests): Add test-signgam-finite,
test-signgam-finite-c99 and test-signgam-finite-c11.
(CFLAGS-test-signgam-finite.c): New variable.
(CFLAGS-test-signgam-finite-c99.c): Likewise.
(CFLAGS-test-signgam-finite-c11.c): Likewise.

This page took 0.107742 seconds and 5 git commands to generate.