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

8 years agoFix features.h for -Wundef (bug 19212).
Joseph Myers [Thu, 5 Nov 2015 21:19:37 +0000 (21:19 +0000)]
Fix features.h for -Wundef (bug 19212).

features.h is not clean with -Wundef (for the installed header, of
course this only appears with -Wsystem-headers).  In ISO C standards
modes, you get a series of warnings / errors relating to
_POSIX_C_SOURCE and _XOPEN_SOURCE not being defined when tested in
standards mode and uses #undef _GNU_SOURCE to avoid the default
_GNU_SOURCE from libc-symbols.h.  This patch changes the relevant #if
conditionals to avoid these warnings / errors.

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

[BZ #19212]
* include/features.h [(_XOPEN_SOURCE - 0) >= 500]: Change
conditional to [defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >=
500].
[_POSIX_C_SOURCE >= 1]: Change conditional to [defined
_POSIX_C_SOURCE && _POSIX_C_SOURCE >= 1].
[(_POSIX_C_SOURCE - 0) >= 199309L]: Change conditional to [defined
_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199309L].
[(_POSIX_C_SOURCE - 0) >= 199506L]: Change conditional to [defined
_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 199506L].
[(_POSIX_C_SOURCE - 0) >= 200112L]: Change conditional to [defined
_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200112L].
[(_POSIX_C_SOURCE - 0) >= 200809L]: Change conditional to [defined
_POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L].

8 years agoDon't redirect ldexp to scalbn in bits/math-finite.h (bug 19209).
Joseph Myers [Thu, 5 Nov 2015 17:00:31 +0000 (17:00 +0000)]
Don't redirect ldexp to scalbn in bits/math-finite.h (bug 19209).

bits/math-finite.h maps ldexp functions to corresponding scalbn
functions.  This is (a) a namespace bug for C90, which has ldexp but
not scalbn, and (b) in any case useless, since the ldexp and scalbn
functions have identical semantics (for floating-point types with
radix 2), and since the fix for bug 6803 are actually aliases
(presumably the mapping was based around the old bug of scalbn not
setting errno).  This patch removes the bogus redirections.

Tested for x86_64 and x86.

[BZ #19209]
* math/bits/math-finite.h (ldexp): Remove declaration.
(ldexpf): Likewise.
(ldexpl): Likewise.

8 years agoMake bits/math-finite.h conditions match other headers (bug 19205).
Joseph Myers [Thu, 5 Nov 2015 00:48:57 +0000 (00:48 +0000)]
Make bits/math-finite.h conditions match other headers (bug 19205).

bits/math-finite.h declares -ffinite-math-only variants of various
functions under conditions not matching those under which the normal
versions are declared.

* math.h only ever includes bits/mathcalls.h to declare float and long
  double functions if __USE_ISOC99, but bits/math-finite.h declares
  some float functions regardless (long double ones are conditioned on
  __MATH_DECLARE_LDOUBLE).  (For C90 functions this isn't a
  conformance bug because C90 reserves the float and long double
  names, but is still contrary to good glibc practice.  For some other
  functions in older XSI standards it *is* a conformance bug.)

* Some functions are defined as inlines using lgamma_r functions under
  conditions where those lgamma_r functions are not themselves
  declared.

* hypot is declared under __USE_XOPEN || __USE_ISOC99 in
  bits/mathcalls.h, __USE_ISOC99 only in bits/math-finite.h.

* float and long double versions of Bessel functions should be limited
  to __USE_MISC (as in bug 18977).

* gamma should not be declared for __USE_XOPEN2K (as in bug 18967).

* remainder should be restricted to __USE_XOPEN_EXTENDED ||
  __USE_ISOC99, not unconditional.

* scalb should not be declared for __USE_XOPEN2K8, and scalbf and
  scalbl are non-POSIX (as in bug 18967).

This patch fixes all these issues (it doesn't seem worth splitting
them into separate patches or bugs).  I put __USE_ISOC99 conditionals,
where needed, around both float and long double declarations, even
though formally redundant around the long double declarations because
__MATH_DECLARE_LDOUBLE isn't defined without __USE_ISOC99; it seemed
clearer that way.  The missing declarations of lgamma_r functions are
dealt with by directly using declarations of __lgamma*_r_finite, in
the implementation namespace, rather than having the inlines rely on
asm redirection of lgamma*_r.

After this patch, there are some apparently redundant nested
__USE_ISOC99 conditionals in lgamma / gamma definitions.  These
actually reflect a separate bug (the correct condition for the lgamma
inline functions to set signgam is __USE_MISC || __USE_XOPEN, the
condition under which signgam is declared, rather than disabling
setting it if __USE_ISOC99, which includes XSI POSIX versions for
which signgam *should* be set).  They'll be fixed as part of a fix for
that bug, which will also add tests for these inlines.  I've put a
note about more general conform/ test coverage for -ffinite-math-only
on
<https://sourceware.org/glibc/wiki/Development_Todo/Master#conformtest_improvements>,
alongside other options for which this is also relevant (some of which
have also had such bugs in the past relating to mismatched
conditionals).

I also intend to enable the main libm-test.inc tests for the
math-finite.h functions, but some other bugs in __*_finite need fixing
first.

[BZ #19205]
* math/bits/math-finite.h (acosf): Condition declaration on
[__USE_ISOC99].
(acosl): Likewise.
(acoshf): Likewise.
(acoshl): Likewise.
(asinf): Likewise.
(asinl): Likewise.
(atan2f): Likewise.
(atan2l): Likewise.
(atanhf): Likewise.
(atanhl): Likewise.
(coshf): Likewise.
(coshl): Likewise.
(expf): Likewise.
(expl): Likewise.
(fmodf): Likewise.
(fmodl): Likewise.
(hypot): Change condition to [__USE_XOPEN || __USE_ISOC99].
(j0f): Change condition to [__USE_MISC && __USE_ISOC99].
(j0l): Likewise.
(y0f): Likewise.
(y0l): Likewise.
(j1f): Likewise.
(j1l): Likewise.
(y1f): Likewise.
(y1l): Likewise.
(jnf): Likewise.
(jnl): Likewise.
(ynf): Likewise.
(ynl): Likewise.
(lgammaf_r): Condition declaration on [__USE_ISOC99].
(lgammal_r): Likewise.
(__lgamma_r_finite): New declaration.
(__lgammaf_r_finite): Likewise.
(__lgammal_r_finite): Likewise.
(lgamma): Use __lgamma_r_finite.
(lgammaf): Condition definition on [__USE_ISOC99].  Use
__lgammaf_r_finite.
(lgammal): Condition definition on [__USE_ISOC99].  Use
__lgammal_r_finite.
(gamma): Do not define for [!__USE_MISC && __USE_XOPEN2K].  Use
__lgamma_r_finite.
(gammaf): Condition definition on [__USE_ISOC99].  Use
__lgammaf_r_finite.
(gammal): Condition definition on [__USE_ISOC99].  Use
__lgammal_r_finite.
(logf): Condition declaration on [__USE_ISOC99].
(logl): Likewise.
(log10f): Likewise.
(log10l): Likewise.
(ldexpf): Likewise.
(ldexpl): Likewise.
(powf): Likewise.
(powl): Likewise.
(remainder): Condition declaration on [__USE_XOPEN_EXTENDED ||
__USE_ISOC99].
(remainderf): Condition declaration on [__USE_ISOC99].
(remainderl): Likewise.
(scalb): Do not declare for [!__USE_MISC && __USE_XOPEN2K8].
(scalbf): Change condition to [__USE_MISC && __USE_ISOC99].
(scalbl): Likewise.
(sinhf): Condition declaration on [__USE_ISOC99].
(sinhl): Likewise.
(sqrtf): Likewise.
(sqrtl): Likewise.

8 years agoRemove miscellaneous GCC >= 4.7 version conditionals.
Joseph Myers [Wed, 4 Nov 2015 21:34:36 +0000 (21:34 +0000)]
Remove miscellaneous GCC >= 4.7 version conditionals.

This patch removes miscellaneous __GNUC_PREREQ (4, 7) conditionals
that are now dead.

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

* sysdeps/arm/atomic-machine.h
[__GNUC_PREREQ (4, 7) && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4]:
Change conditional to [__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4].
[__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 && !__GNUC_PREREQ (4, 7)]:
Remove conditional code.
[!__GNUC_PREREQ (4, 7) || !__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4]:
Change conditional to [!__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4].
* sysdeps/i386/sysdep.h [__ASSEMBLER__ && __GNUC_PREREQ (4, 7)]:
Change conditional to [__ASSEMBLER__].
[__ASSEMBLER__ && !__GNUC_PREREQ (4, 7)]: Remove conditional code.
[!__ASSEMBLER__ && __GNUC_PREREQ (4, 7)]: Change conditional to
[!__ASSEMBLER__].
[!__ASSEMBLER__ && !__GNUC_PREREQ (4, 7)]: Remove conditional
code.
* sysdeps/unix/sysv/linux/sh/atomic-machine.h (rNOSP): Remove
conditional macro definitions.
(__arch_compare_and_exchange_val_8_acq): Use "u" instead of rNOSP.
(__arch_compare_and_exchange_val_16_acq): Likewise.
(__arch_compare_and_exchange_val_32_acq): Likewise.
(atomic_exchange_and_add): Likewise.
(atomic_add): Likewise.
(atomic_add_negative): Likewise.
(atomic_add_zero): Likewise.
(atomic_bit_set): Likewise.
(atomic_bit_test_set): Likewise.
* sysdeps/x86_64/atomic-machine.h [__GNUC_PREREQ (4, 7)]: Make
code unconditional.
[!__GNUC_PREREQ (4, 7)]: Remove conditional code.

8 years agoRefactor libm-test inline tests disabling.
Joseph Myers [Wed, 4 Nov 2015 21:30:26 +0000 (21:30 +0000)]
Refactor libm-test inline tests disabling.

This patch refactors how libm-test.inc handles disabling
errno/exception handling tests, and some other tests, for
__FAST_MATH__ inline function tests.

The macro TEST_INLINE is changed from being defined/undefined to being
defined to 1 or 0, so that it can be tested in "if" conditionals
instead of #if.  For tests of errno and exception setting, separate
macros TEST_ERRNO and TEST_EXCEPTIONS are added, and TEST_ERRNO is
also used in the disabling of errno testing for vector function
tests.  The relevant conditionals are moved up a function, so that
they take effect before the code that counts the number of tests, so
the inline function tests now accurately report that 0 tests for
exceptions and errno were executed (whereas they previously reported a
large number desipte not running any such tests).

Tested for x86_64 and x86.

* math/test-math-errno.h: New file.
* math/test-math-inline.h (TEST_INLINE): Define to 1 instead of
empty.
(TEST_ERRNO): New macro.
(TEST_EXCEPTIONS): Likewise.
* math/test-math-no-inline.h (TEST_INLINE): Likewise.
(TEST_EXCEPTIONS): Likewise.
* math/test-math-vector.h (TEST_ERRNO): Likewise.
* math/test-double.c: Include "test-math-errno.h".
* math/test-float.c: Likewise.
* math/test-ldouble.c: Likewise.
* math/libm-test.inc (test_single_exception) [!TEST_INLINE]: Make
code unconditional.
(test_exceptions): Only run code if TEST_EXCEPTIONS.
(test_single_errno) [!TEST_INLINE && !TEST_MATHVEC]: Make code
unconditional.
(test_errno): Only run code if TEST_ERRNO.
(enable_test): Use "if" conditional on TEST_INLINE, not #ifdef.

8 years agoAdd bug 18604 to the correct section
Florian Weimer [Wed, 4 Nov 2015 16:48:40 +0000 (17:48 +0100)]
Add bug 18604 to the correct section

8 years agoRemove a spurious attribution
Florian Weimer [Wed, 4 Nov 2015 10:32:36 +0000 (11:32 +0100)]
Remove a spurious attribution

Martin Sebor confirmed that this attribution was inserted by mistake.

8 years agoAdd bug 18604 to NEWS
Florian Weimer [Wed, 4 Nov 2015 07:09:06 +0000 (08:09 +0100)]
Add bug 18604 to NEWS

8 years agoAdd more libm tests (scalb*, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma...
Joseph Myers [Wed, 4 Nov 2015 00:45:23 +0000 (00:45 +0000)]
Add more libm tests (scalb*, signbit, sin, sincos, sinh, sqrt, tan, tanh, tgamma, y0, y1, yn, significand).

This patch improves the libm test coverage for a few more functions.

Tested for x86_64 and x86.

* math/auto-libm-test-in: Add more tests of sin, sincos, sinh,
sqrt, tan, tanh, y0, y1 and yn.
* math/auto-libm-test-out: Regenerated.
* math/libm-test.inc (scalb_test_data): Add more tests.
(scalbn_test_data): Likewise.
(scalbln_test_data): Likewise.
(signbit_test_data): Likewise.
(sin_test_data): Likewise.
(sincos_test_data): Likewise.
(sinh_test_data): Likewise.
(sqrt_test_data): Likewise.
(tan_test_data): Likewise.
(tanh_test_data): Likewise.
(tgamma_test_data): Likewise.
(y0_test_data): Likewise.
(y1_test_data): Likewise.
(yn_test_data): Likewise.
(significand_test_data): Likewise.
* sysdeps/i386/fpu/libm-test-ulps: Update.

8 years agoDon't macro-expand failed assertion expression [BZ #18604]
David Kastrup [Tue, 3 Nov 2015 22:08:54 +0000 (23:08 +0100)]
Don't macro-expand failed assertion expression [BZ #18604]

[BZ #18604]
* assert/assert.h (assert): Don't macro-expand failed assertion
expression in error message.
* malloc/malloc.c (assert): Likewise.

8 years agoRemove --no-whole-archive configure test.
Joseph Myers [Tue, 3 Nov 2015 13:03:52 +0000 (13:03 +0000)]
Remove --no-whole-archive configure test.

There is a configure test for the --no-whole-archive linker option.
This option was added in binutils 2.7, so the test is obsolete; this
patch removes it.

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

* configure.ac (libc_cv_ld_no_whole_archive): Remove configure
test.
* configure: Regenerated.

8 years agoAdd more libm tests (modf, nearbyint, nextafter, nexttoward, pow, remainder, remquo...
Joseph Myers [Tue, 3 Nov 2015 00:20:29 +0000 (00:20 +0000)]
Add more libm tests (modf, nearbyint, nextafter, nexttoward, pow, remainder, remquo, rint).

This patch improves the libm test coverage for a few more functions.

Tested for x86_64 and x86.

* math/libm-test.inc (modf_test_data): Add more tests.
(nearbyint_test_data): Likewise.
(nextafter_test_data): Likewise.
(nexttoward_test_data): Likewise.
(pow_test_data): Likewise.
(remainder_test_data): Likewise.
(remquo_test_data): Likewise.
(rint_test_data): Likewise.

8 years agoFix dbl-64 remainder sign of zero result (bug 19201).
Joseph Myers [Tue, 3 Nov 2015 00:11:49 +0000 (00:11 +0000)]
Fix dbl-64 remainder sign of zero result (bug 19201).

For some large arguments, the dbl-64 implementation of remainder gives
zero results with the wrong sign, resulting from a subtraction that is
mathematically correct but does not guarantee that a zero result has
the sign of the first argument to remainder.  This patch adds an
appropriate check for this case, similar to other implementations of
remainder in the case of equality, and adds tests of remainder on
inputs already used to test remquo.

Tested for x86_64 and x86.

[BZ #19201]
* sysdeps/ieee754/dbl-64/e_remainder.c (__ieee754_remainder):
Check for zero remainder in case of large exponents and ensure
correct sign of result in that case.
* math/libm-test.inc (remainder_test_data): Add more tests.

8 years agoMake nextafter, nexttoward set errno (bug 6799).
Joseph Myers [Mon, 2 Nov 2015 18:54:19 +0000 (18:54 +0000)]
Make nextafter, nexttoward set errno (bug 6799).

nextafter and nexttoward fail to set errno on overflow and underflow.
This patch makes them do so in cases that should include all the cases
where such errno setting is required by glibc's goals for when to set
errno (but not all cases of underflow where the result is nonzero and
so glibc's goals do not require errno setting).

Tested for x86_64, x86, mips64 and powerpc.

[BZ #6799]
* math/s_nextafter.c: Include <errno.h>.
(__nextafter): Set errno on overflow and underflow.
* math/s_nexttowardf.c: Include <errno.h>.
(__nexttowardf): Set errno on overflow and underflow.
* sysdeps/i386/fpu/s_nextafterl.c: Include <errno.h>.
(__nextafterl): Set errno on overflow and underflow.
* sysdeps/i386/fpu/s_nexttoward.c: Include <errno.h>.
(__nexttoward): Set errno on overflow and underflow.
* sysdeps/i386/fpu/s_nexttowardf.c: Include <errno.h>.
(__nexttowardf): Set errno on overflow and underflow.
* sysdeps/ieee754/flt-32/s_nextafterf.c: Include <errno.h>.
(__nextafterf): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128/s_nextafterl.c: Include <errno.h>.
(__nextafterl): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128/s_nexttoward.c: Include <errno.h>.
(__nexttoward): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128/s_nexttowardf.c: Include <errno.h>.
(__nexttowardf): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c: Include <errno.h>.
(__nextafterl): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c: Include <errno.h>.
(__nexttoward): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c: Include <errno.h>.
(__nexttowardf): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-96/s_nexttoward.c: Include <errno.h>.
(__nexttoward): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-96/s_nexttowardf.c: Include <errno.h>.
(__nexttowardf): Set errno on overflow and underflow.
* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c: Include <errno.h>.
(__nldbl_nexttowardf): Set errno on overflow and underflow.
* sysdeps/m68k/m680x0/fpu/s_nextafterl.c: Include <errno.h>.
(__nextafterl): Set errno on overflow and underflow.
* math/libm-test.inc (nextafter_test_data): Do not allow errno
setting to be missing on overflow.  Add more tests.
(nexttoward_test_data): Likewise.

8 years agoRemove init_array / fini_array configure test.
Joseph Myers [Mon, 2 Nov 2015 15:08:25 +0000 (15:08 +0000)]
Remove init_array / fini_array configure test.

There is a configure test "for .preinit_array/.init_array/.fini_array
support".  Support for this feature was added in binutils 2.13, so the
configure test is obsolete; this patch removes it.

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

* configure.ac (libc_cv_initfini_array): Remove configure test.
* configure: Regenerated.

8 years agoFix ldbl-128 log1pl (-qNaN) spurious "invalid" exception (bug 19189).
Joseph Myers [Thu, 29 Oct 2015 23:09:51 +0000 (23:09 +0000)]
Fix ldbl-128 log1pl (-qNaN) spurious "invalid" exception (bug 19189).

The ldbl-128 version of log1pl raises a spurious "invalid" exception
for a -qNaN argument.  This patch fixes this by making the initial
check for infinities and NaNs handle arguments of both signs in such a
way that NaNs result in a NaN being returned (quietly if the input NaN
was quiet) while +Inf results in +Inf being returned and -Inf results
in a qNaN being returned with "invalid" exception raised.

Tested for mips64.

[BZ #19189]
* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Make check for
non-finite argument handle arguments with negative sign.

8 years agoDo not test sign of zero result from infinite argument to Bessel functions.
Joseph Myers [Thu, 29 Oct 2015 22:45:47 +0000 (22:45 +0000)]
Do not test sign of zero result from infinite argument to Bessel functions.

When Bessel functions return a zero result from an infinite argument,
the function oscillates as it approaches 0, so the sign of that zero
result should be indeterminate.  This patch weakens the expectations
accordingly not to check the sign of such results (the tests were
causing spurious failures for j1 (-Inf) for ldbl-128).

Tested for x86_64 and x86.

* math/libm-test.inc (j0_test_data): Do not test sign of zero
result from infinite argument.
(j1_test_data): Likewise.
(jn_test_data): Likewise.
(y0_test_data): Likewise.
(y1_test_data): Likewise.
(yn_test_data): Likewise.

8 years agoMake drem an alias of remainder (bug 16171).
Joseph Myers [Thu, 29 Oct 2015 22:29:21 +0000 (22:29 +0000)]
Make drem an alias of remainder (bug 16171).

The libm drem functions just call the corresponding __remainder
functions.  This patch removes the unnecessary wrappers by making them
into weak aliases at the ELF level.

Tested for x86_64, x86, mips64 and powerpc.

[BZ #16171]
* math/w_remainder.c (drem): Define as weak alias of __remainder.
[NO_LONG_DOUBLE] (dreml): Define as weak alias of __remainder.
* math/w_remainderf.c (dremf): Define as weak alias of
__remainderf.
* math/w_remainderl.c (dreml): Define as weak alias of
__remainderl.
* sysdeps/ia64/fpu/e_remainder.S (drem): Define as weak alias of
__remainder.
* sysdeps/ia64/fpu/e_remainderf.S (dremf): Define as weak alias of
__remainderf.
* sysdeps/ia64/fpu/e_remainderl.S (dreml): Define as weak alias of
__remainderl.
* sysdeps/ieee754/ldbl-opt/nldbl-remainder.c (dreml): Define as
weak alias of remainderl.
* sysdeps/ieee754/ldbl-opt/w_remainder.c
[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (__drem): Define as strong
alias of __remainder.
[LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (dreml): Use compat_symbol.
* sysdeps/ieee754/ldbl-opt/w_remainderl.c (__dreml): Define as
strong alias of __remainderl.
(dreml): Use long_double_symbol.
* math/Makefile (libm-calls): Remove w_drem.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Remove drem.
(CFLAGS-nldbl-drem.c): Remove variable.
(CFLAGS-nldbl-remainder.c): Add -fno-builtin-dreml.
* math/w_drem.c: Remove file.
* math/w_dremf.c: Likewise.
* math/w_dreml.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-drem.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_drem.c: Likewise.
* sysdeps/ieee754/ldbl-opt/w_dreml.c: Likewise.

8 years agoRemove cpuid.h configure tests.
Joseph Myers [Thu, 29 Oct 2015 14:43:46 +0000 (14:43 +0000)]
Remove cpuid.h configure tests.

There are configure tests for the cpuid.h header for x86 / x86_64.
GCC 4.3 and later install this header, so those tests are obsolete.
This patch removes them.

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

* sysdeps/i386/configure.ac (cpuid.h): Do not test for header.
* sysdeps/i386/configure: Regenerated.
* sysdeps/x86_64/configure.ac (cpuid.h): Do not test for header.
* sysdeps/x86_64/configure: Regenerated.

8 years agoRemove configure tests for visibility support.
Joseph Myers [Thu, 29 Oct 2015 12:48:24 +0000 (12:48 +0000)]
Remove configure tests for visibility support.

There are various configure tests for visibility support in the
compiler and assember.

GCC support for visibility attributes was added in GCC 3.3.  I don't
know what specific fix was intended by the test "for broken
__attribute__((visibility())", but it was added by
<https://sourceware.org/ml/libc-hacker/2002-08/msg00030.html>, and GCC
3.3 appears not to have that breakage, so I suspect it was only ever
in development versions before 3.3 was released.  The assembler
support was added in binutils 2.10.

This patch removes the tests in question as obsolete.  Two tests that
were formerly conditional on "if test $libc_cv_visibility_attribute =
yes", including the one for linker support for protected data, are now
unconditional.

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

* configure.ac (libc_cv_asm_protected_directive): Remove configure
test.
(libc_cv_visibility_attribute): Likewise.
(libc_cv_protected_data): Test unconditionally.
(libc_cv_broken_visibility_attribute): Remove configure test.
(libc_cv_have_sdata_section): Test unconditionally.
* configure: Regenerated.

8 years agoUse max_align_t from <stddef.h>.
Joseph Myers [Thu, 29 Oct 2015 12:46:22 +0000 (12:46 +0000)]
Use max_align_t from <stddef.h>.

Now that we build with -std=gnu11 and can rely on a compiler providing
max_align_t in <stddef.h>, we no longer need our own version
libc_max_align_t.  This patch removes it and replaces the single user
with a use of max_align_t.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch for x86_64; for x86, I see
some code reordering of no significance).

* include/libc-internal.h (libc_max_align_t): Remove typedef.
* include/scratch_buffer.h: Include <stddef.h> instead of
<libc-internal.h>.
(struct scratch_buffer): Use max_align_t instead of
libc_max_align_t.

8 years ago_dl_fini: Rewrite to use VLA instead of extend_alloca
Florian Weimer [Thu, 29 Oct 2015 08:26:03 +0000 (09:26 +0100)]
_dl_fini: Rewrite to use VLA instead of extend_alloca

In this case, extend_alloca is used to work around the lack of
deallocation on scope exit.  A VLA is automatically deallocated in this
way, so it is the more fitting approach.

To implement this, it is necessary to eliminate the goto.  In addition,
this change eliminates the trivially-true assert; the assert is always
skipped if nloaded > 0.

* elf/dl-fini.c (_dl_fini): Rewrite to use variable-length array
instead of extend_alloca.  Change control flow to avoid a goto.
Remove assert which is trivially always true.

8 years agoHandle more state in i386/x86_64 fesetenv (bug 16068).
Joseph Myers [Wed, 28 Oct 2015 22:58:29 +0000 (22:58 +0000)]
Handle more state in i386/x86_64 fesetenv (bug 16068).

fenv_t should include architecture-specific floating-point modes and
status flags.  i386 and x86_64 fesetenv limit which bits they use from
the x87 status and control words, when using saved state, and limit
which parts of the state they set to fixed values, when using
FE_DFL_ENV / FE_NOMASK_ENV.  The following should be included but are
excluded in at least some cases: status and masking for the "denormal
operand" exception (which isn't part of FE_ALL_EXCEPT); precision
control (explicitly mentioned in Annex F as something that counts as
part of the floating-point environment); MXCSR FZ and DAZ bits (for
FE_DFL_ENV and FE_NOMASK_ENV).  This patch arranges for this extra
state to be handled by fesetenv (and thereby by feupdateenv, which
calls fesetenv).

(Note that glibc functions using floating point are not generally
expected to work correctly with non-default values of this state,
especially precision control, but it is still logically part of the
floating-point environment and should be handled as such by fesetenv.
Changes to the state relating to subnormals ought generally to work
with libm functions when the arguments aren't subnormal and neither
are the expected results; that's a consequence of functions avoiding
spurious internal underflows.)

A question arising from this is whether FE_NOMASK_ENV should or should
not mask the "denormal operand" exception.  I decided it should mask
that exception.  This is the status quo - previously that exception
could only be unmasked by direct manipulation of control registers
(possibly via <fpu_control.h>).  In addition, it means that use of
FE_NOMASK_ENV leaves a floating-point environment the same as could be
obtained by fesetenv (FE_DFL_ENV); feenableexcept (FE_ALL_EXCEPT);,
rather than an environment in which an exception is unmasked that
could only be masked again by using fesetenv with FE_DFL_ENV (or a
previously saved environment) - this exception not being usable with
other <fenv.h> functions because it's outside FE_ALL_EXCEPT.

Tested for x86_64 and x86.

[BZ #16068]
* sysdeps/i386/fpu/fesetenv.c: Include <fpu_control.h>.
(FE_ALL_EXCEPT_X86): New macro.
(__fesetenv): Use FE_ALL_EXCEPT_X86 in most places instead of
FE_ALL_EXCEPT.  Ensure precision control is included in
floating-point state.  Ensure that FE_DFL_ENV and FE_NOMASK_ENV
handle "denormal operand exception" and clear FZ and DAZ bits.
* sysdeps/x86_64/fpu/fesetenv.c: Include <fpu_control.h>.
(FE_ALL_EXCEPT_X86): New macro.
(__fesetenv): Use FE_ALL_EXCEPT_X86 in most places instead of
FE_ALL_EXCEPT.  Ensure precision control is included in
floating-point state.  Ensure that FE_DFL_ENV and FE_NOMASK_ENV
handle "denormal operand exception" and clear FZ and DAZ bits.
* sysdeps/x86/fpu/test-fenv-sse-2.c: New file.
* sysdeps/x86/fpu/test-fenv-x87.c: Likewise.
* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
test-fenv-x87 and test-fenv-sse-2.
[$(subdir) = math] (CFLAGS-test-fenv-sse-2.c): New variable.

8 years agoUse C11 CMPLX* macros in libm tests.
Joseph Myers [Wed, 28 Oct 2015 21:57:10 +0000 (21:57 +0000)]
Use C11 CMPLX* macros in libm tests.

libm-test.inc has a macro BUILD_COMPLEX to construct a complex number
with given real and imaginary parts while allowing properly for signed
zeroes, infinities and NaNs (which don't work properly with a simple
real + I * imag, in the absence of compiler support for imaginary
types), using assignment to __real__ and __imag__ parts of the number.
C11 defines CMPLX* macros for this purpose, which GCC 4.7 and above
provide suitable built-in functions for.  This patch redefines
BUILD_COMPLEX in terms of the standard macros.

Tested for x86_64 and x86.

* math/libm-test.inc (BUILD_COMPLEX): Remove macro.
* math/test-double.h (BUILD_COMPLEX): New macro.
* math/test-float.h (BUILD_COMPLEX): Likewise.
* math/test-ldouble.h (BUILD_COMPLEX): Likewise.