Commit Graph

1890 Commits

Author SHA1 Message Date
Joseph Myers c643db8792 Fix j1, jn missing errno setting on underflow (bug 18611).
j1 and jn can underflow for small arguments, but fail to set errno
when underflowing to 0.  This patch fixes them to set errno in that
case.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18611]
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Set errno and
	avoid excess range and precision on underflow.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Set errno on
	underflow.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	* math/auto-libm-test-in: Do not allow missing errno setting for
	tests of j1 and jn.
	* math/auto-libm-test-out: Regenerated.
2015-10-23 21:37:33 +00:00
Joseph Myers 846d9a4a3a Fix i386 / x86_64 nearbyint exception clearing (bug 15491).
The implementations of nearbyint functions using x87 floating point
(i386 all versions, x86_64 long double only) use the fclex
instruction, which clears any exceptions that were raised before the
function was called.  These functions must not clear exceptions that
were raised before they were called.

This patch fixes these functions to save and restore the whole
floating-point environment (fnstenv / fldenv) as the way of avoiding
raising "inexact" (recall that there isn't an x87 instruction for
loading just the status word, so the whole environment has to be saved
and loaded instead - the code already saved and loaded the control
word, which is now obtained from the saved environment after this
patch, to disable traps on "inexact").  In the case of the long double
functions, any "invalid" exception from frndint (applied to a
signaling NaN) needs merging into the saved state; this issue doesn't
apply to the float and double functions because that exception would
have been raised when the argument is loaded, before the environment
is saved.

	[BZ #15491]
	* sysdeps/i386/fpu/s_nearbyint.S (__nearbyint): Save and restore
	floating-point environment instead of clearing all exceptions.
	* sysdeps/i386/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
	* sysdeps/i386/fpu/s_nearbyintl.S (__nearbyintl): Likewise,
	merging in "invalid" exceptions from frndint.
	* sysdeps/x86_64/fpu/s_nearbyintl.S (__nearbyintl): Likewise.
	* math/test-nearbyint-except.c: New file.
	* math/Makefile (tests): Add test-nearbyint-except.
2015-10-22 23:14:55 +00:00
Chris Metcalf 45ccb8346b Update NEWS to mention drive-by fix for bug 18699.
Wilco fixed this tilegx bug in commit fe8c2b33ae ("Since we
now inline isinf, isnan and isfinite in math.h, replace uses
of __isinf_ns(l/f) with isinf, and remove the unused inlines
__isinf_ns(l/f), __isnan(f) and __finite(f).")

I verified that reverting math/s_cprojf.c back to using the
sysdeps/ieee754/flt-32/math_private.h version of __isinf_nsf()
instead of isinf() brings back the bug on tilegx.
2015-10-22 13:41:54 -04:00
Joseph Myers 0a90a8f2b9 Fix ldbl-128 j0l spurious underflows (bug 19156).
My recent addition of more tests for j0 showed up that the ldbl-128
implementation of j0l produces spurious underflow exceptions for
arguments close to 0 (when the result is very close to 1).  This patch
fixes this by just returning the argument in that case.

Tested for mips64 (where it fixes the recently-added tests that were
previously failing).

	[BZ #19156]
	* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_j0l): Return 1 for
	arguments very close to 0.
2015-10-21 16:40:20 +00:00
Tulio Magno Quites Machado Filho 6ec52bf634 PowerPC: Fix a race condition when eliding a lock
The previous code used to evaluate the preprocessor token is_lock_free to
a variable before starting a transaction.  This behavior can cause an
error if another thread got the lock (without using a transaction)
between the evaluation of the token and the beginning of the transaction.

This bug can be triggered with the following order of events:
1. The lock accessed by is_lock_free is free.
2. Thread T1 evaluates is_lock_free and stores into register R1 that the
   lock is free.
3. Thread T2 acquires the same lock used in is_lock_free.
4. T1 begins the transaction, creating a memory barrier where is_lock_free
   is false, but R1 is true.
5. T1 reads R1 and doesn't abort the transaction.
6. T1 calls ELIDE_UNLOCK, which reads false from is_lock_free and decides
   to unlock a lock acquired by T2, leading to undefined behavior.

This patch delays the evaluation of is_lock_free to inside a transaction
by moving this part of the code to the macro ELIDE_LOCK.

	[BZ #18743]
	* sysdeps/powerpc/nptl/elide.h (__elide_lock): Move most of this
	code to...
	(ELIDE_LOCK): ...here.
	(__get_new_count): New function with part of the code from
	__elide_lock that updates the value of adapt_count after a
	transaction abort.
	(__elided_trylock): Moved this code to...
	(ELIDE_TRYLOCK): ...here.
2015-10-19 16:58:03 -02:00
Mike Frysinger bc148ca1b1 timezone: document new --disable-timezone-tools option
Reported-by: Joseph Myers <joseph@codesourcery.com>
2015-10-19 14:11:44 -04:00
Florian Weimer f546f87c4f The va_list pointer is unspecified after a call to vfprintf [BZ #18982]
This adjusts the documentation to the existing implementation.
2015-10-17 12:02:22 +02:00
Gunnar Hjalmarsson 213938ee8a lt_LT: change currency symbol to the euro [BZ #18953]
Lithuania switched currency to the Euro on 1st Jan 2015.
2015-10-17 00:28:13 -04:00
Egmont Koblinger c7266a2d82 hu_HU: change time separator to colon [BZ #18918]
The previous (11th) version of the Hungarian spelling rules (released
in 1984) said that the separator had to be a dot, e.g. 10.35 meaning
10 o'clock 35 minutes. glibc correctly implements this.

The brand new (12th) version, in effect since September 1, 2015 adopts
to the common use of colon (especially in the digital world) and
allows to use either separator, without even expressing a preference.

For computer systems, using colons is way more typical and probably
easier to recognize. Dot is typically used in printed materials.

It also avoids an almost ambiguous situation where a space makes a
difference, e.g. "10.15-ig" means "until 10 o'clock 15 minutes"
whereas "10. 15-ig" means "until 15th of October". So I believe using
the colon as the separator is not only more frequent in the computer
world, but is also easier and quicker to recognize for the brain that
it's about hour:minute rather than month and day. And luckily it's now
equally correct according to the official rules.

11th edition: http://helyesiras.mta.hu/helyesiras/default/akh11

12th edition: http://helyesiras.mta.hu/helyesiras/default/akh12

In both editions it's the very last (299th and 300th, respectively) rule.

Microsoft also uses and recommends a colon since at least May 2011:
http://download.microsoft.com/download/e/6/1/e61266b2-d8b4-4fe0-a553-f01dc3976675/hun-hun-StyleGuide.pdf
  The time format is different in common language and in the language of
  IT. In common texts we usually do not abbreviate, so the full forms are
  used: “7 óra 10 perckor csörgött a telefon”. However, the short format,
  consisting of numerals only, can also be used. In this case a period
  must be used between the two numbers and there must not be a space
  between them: “találkozzunk 10.45-kor”.

  However, in software mostly the short format is used, and the numbers
  are separated by a colon. An obvious example is the clock in the bottom
  right corner of your screen, thus 18:31.
2015-10-17 00:15:07 -04:00
H.J. Lu b994fd7937 Remove i386/epoll_pwait.S
Only i386 implements epoll_pwait in assembly code withot cancellation
support.  All other architectures implement epoll_pwait in epoll_pwait.c
with

int epoll_pwait (int epfd, struct epoll_event *events,
		 int maxevents, int timeout,
		 const sigset_t *set)
{
  return SYSCALL_CANCEL (epoll_pwait, epfd, events, maxevents,
			 timeout, set, _NSIG / 8);
}

Although there is no test for epoll_pwait in glibc, since SYSCALL_CANCEL
works on i386 and epoll_pwait.c works for other architectures, it is
safe to assume that epoll_pwait.c with SYSCALL_CANCEL also works on
i386.

	[BZ #19137]
	* sysdeps/unix/sysv/linux/i386/Makefile (CFLAGS-epoll_pwait.c):
	Add -fomit-frame-pointer.
	* sysdeps/unix/sysv/linux/i386/epoll_pwait.S: Remove file.
2015-10-15 06:26:50 -07:00
Florian Weimer a014cecd82 Always enable pointer guard [BZ #18928]
Honoring the LD_POINTER_GUARD environment variable in AT_SECURE mode
has security implications.  This commit enables pointer guard
unconditionally, and the environment variable is now ignored.

        [BZ #18928]
        * sysdeps/generic/ldsodefs.h (struct rtld_global_ro): Remove
        _dl_pointer_guard member.
        * elf/rtld.c (_rtld_global_ro): Remove _dl_pointer_guard
        initializer.
        (security_init): Always set up pointer guard.
        (process_envvars): Do not process LD_POINTER_GUARD.
2015-10-15 09:23:32 +02:00
Joseph Myers 0c25f5b5bb Fix powerpc32 lround, lroundf spurious exceptions (bug 19134).
The powerpc32 implementation of lround and lroundf can produce
spurious exceptions from adding 0.5 then converting to integer.  This
includes "inexact" from the conversion to integer (not allowed for
integer arguments to these functions), and, for larger integer
arguments, "inexact", and "overflow" when rounding upward, from the
addition.  In addition, "inexact" is not allowed together with
"invalid" and so inexact addition must be avoided when the integer
will be out of range of 32-bit long, whether or not the argument is an
integer.

This patch fixes these problems.  As in the powerpc64 llround
implementation, a check is added for too-large arguments; in the
powerpc64 case that means arguments at least 2^52 in magnitude (so
that 0.5 cannot be added exactly), while in this case it means
arguments for which the result would overflow "long".  In those cases
a suitable overflowing value is used for the integer conversion
without adding 0.5, while for smaller arguments it's tested whether
the argument is an integer (by adding and subtracting 2^52 to the
absolute value and comparing with the original absolute value) to
avoid adding 0.5 to integers and generating spurious "inexact".

This code is not used when the power5+ sysdeps directories are used,
as there's a separate power5+ version of these functions..

Tested for powerpc.  This gets test-float (for a default powerpc32
hard-float build without any --with-cpu) back to the point where it
should pass once powerpc ulps are regenerated; test-double still needs
another problem with exceptions fixed to get back to that point (and I
haven't looked lately at what default powerpc64 results are like).

	[BZ #19134]
	* sysdeps/powerpc/powerpc32/fpu/s_lround.S (.LC1): New object.
	(.LC2): Likewise.
	(.LC3): Likewise.
	(__lround): Do not add 0.5 to integer or out-of-range arguments.
2015-10-14 21:13:42 +00:00
Szabolcs Nagy 1fae5a6800 [BZ #19129][ARM] Fix _dl_tlsdesc_resolve_hold to save r0
_dl_tlsdesc_resolve_hold calls into a C function that clobbers r0,
but it assumes the original argument is still in r0 after the call.
This can cause crash in case of concurrent TLS access when TLSDESC
is in use (-mtls-dialect=gnu2).

Run into this while fixing BZ 18572.

Both r0 and r1 are saved/restored so the stack remains 8 byte aligned.

	[BZ #19129]
	* sysdeps/arm/dl-tlsdesc.S (_dl_tlsdesc_resolve_hold): Save and restore
	r0 and r1.
2015-10-14 17:01:12 +01:00
Florian Weimer f463c7b183 Fix double-checked locking in _res_hconf_reorder_addrs [BZ #19074]
[BZ #19074]
	* resolv/res_hconf.c (_res_hconf_reorder_addrs): Use atomics to
	load and store num_ifs.
2015-10-14 16:43:16 +02:00
H.J. Lu d3d9c95aef Support PLT and GOT references in local PIC check
Linker in binutils 2.26 and newer generate GOT references instead
PLT references when -z now is passed to linker.  We need to extend
scripts/localplt.awk to allow PLT or GOT references.

	[BZ #19007]
	* scripts/localplt.awk: Also allow GOT references.
	* sysdeps/unix/sysv/linux/i386/localplt.data: Mark
	_Unwind_Find_FDE, calloc, memalign, realloc and __libc_memalign
	with "+ REL R_386_GLOB_DAT".
	* sysdeps/x86_64/localplt.data: Mark calloc, memalign, realloc
	and __libc_memalign with "+ RELA R_X86_64_GLOB_DAT".
2015-10-14 06:00:02 -07:00
Joseph Myers d7025badd8 Fix powerpc32 llround, llroundf exceptions (bug 19125).
The powerpc32 implementations of llroundf and llround produce spurious
and missing exceptions (some arising from such exceptions from
conversions to long long, some present even when fctidz is used).

This patch fixes those problems in a similar way to the llrint /
llrintf fixes.  The spurious exceptions in the fctidz case for large
arguments arise from a converted value that saturated as LLONG_MAX
being converted back to float or double (the conversion back being
inexact, but "inexact" must not be raised together with "invalid"),
and from the subtraction x - xrf also being inexact for sufficiently
large arguments (whether the saturation was to LLONG_MAX or
LLONG_MIN); those are fixed by returning early if the argument is
large enough that no rounding is needed.

This code is not used for --with-cpu=power4 builds (I suspect the code
used in that case may also produce spurious "inexact" exceptions, but
that's something to investigate later).

Tested for powerpc.

	[BZ #19125]
	* sysdeps/powerpc/powerpc32/fpu/s_llround.c: Include <limits.h>,
	<math_private.h> and <stdint.h>.
	(__llround): Avoid conversions to and from long long int, and
	subtractions, where those might raise spurious exceptions.
	* sysdeps/powerpc/powerpc32/fpu/s_llroundf.c: Include
	<math_private.h> and <stdint.h>.
	(__llroundf): Avoid conversions to and from long long int, and
	subtractions, where those might raise spurious exceptions.
2015-10-13 23:30:20 +00:00
H.J. Lu 0a5768fe9c Support x86-64 assmebler without AVX512
When x86-64 assmebler doesn't support AVX512, we should make
_dl_runtime_resolve_avx512/_dl_runtime_profile_avx512 as aliases of
_dl_runtime_resolve_avx/_dl_runtime_profile_avx.  Tested on x86-64
using GCC 5.2 with binutils 20151008 and GCC 4.8 with binutils 20130219.
There are no differences in ld.so with binutils 20151008.  There are no
unexpected failures with binutils 20130219 and 20151008.

	[BZ #19124]
	* sysdeps/x86_64/dl-trampoline.S [!HAVE_AVX512_ASM_SUPPORT]
	(_dl_runtime_resolve_avx512): Make it a hidden alias of
	_dl_runtime_resolve_avx.
	(_dl_runtime_profile_avx512): Make it a hidden alias of
	_dl_runtime_profile_avx.
2015-10-13 10:36:27 -07:00
Joseph Myers e8dab9477f Fix powerpc32 llrint, llrintf bad exceptions (bug 16422).
The versions of llrint and llrintf for older powerpc32 processors
convert the results of __rint / __rintf to long long int, resulting in
spurious exceptions from such casts in certain cases.  This patch
makes glibc work around the problems with the libgcc conversions when
the compiler used to build glibc doesn't use the fctidz instruction
for them.

Tested for powerpc.

	[BZ #16422]
	* sysdeps/powerpc/powerpc32/fpu/configure.ac (libc_cv_ppc_fctidz):
	New configure test.
	* sysdeps/powerpc/powerpc32/fpu/configure: Regenerated.
	* config.h.in [_LIBC] (HAVE_PPC_FCTIDZ): New macro.
	* sysdeps/powerpc/powerpc32/fpu/s_llrint.c: Include <limits.h>,
	<math_private.h> and <stdint.h>.
	(__llrint): Avoid conversions to long long int where those might
	raise spurious exceptions.
	* sysdeps/powerpc/powerpc32/fpu/s_llrintf.c: Include
	<math_private.h> and <stdint.h>.
	(__llrintf): Avoid conversions to long long int where those might
	raise spurious exceptions.
2015-10-13 00:52:54 +00:00
Joseph Myers f1226a2ae3 Fix llrint, llround missing exceptions for ARM (bug 15470).
Similar to the recent fix for MIPS, ARM is also missing correct
exceptions on overflow from llrint and llround functions because casts
from floating-point types to long long do not result in correct
exceptions on overflow.  This patch enables the fix for this for ARM.

Tested for ARM.

	[BZ #15470]
	* sysdeps/arm/fix-fp-int-convert-overflow.h: New file.
2015-10-09 22:23:39 +00:00
Joseph Myers 06d97e5e61 Fix lrint, llrint, lround, llround missing exceptions for MIPS (bug 16399).
For 32-bit MIPS and some other systems, various of the lrint, llrint,
lround, llround functions can be missing exceptions on overflow
because casts do not (in current GCC) result in the proper
exceptions.  In the MIPS case there are two problems here: MIPS I code
generation uses an assembler macro that doesn't raise exceptions,
while the libgcc conversions of floating-point values to long long
also do not raise "invalid" on all overflow cases (and can raise
spurious "inexact").

This patch adds support in the generic code (only the functions for
which this problem has actually been seen) for forcing the "invalid"
exception in the problem cases, and enables that support for the
affected MIPS cases.

Tested for MIPS; also tested for x86_64 and x86 that installed
stripped shared libraries are unchanged by this patch.

	[BZ #16399]
	* sysdeps/generic/fix-fp-int-convert-overflow.h: New file.
	* sysdeps/ieee754/dbl-64/s_llrint.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llrint) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_llround.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llround) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_lrint.c: Include
	<fix-fp-int-convert-overflow.h>.
	(__lrint) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/dbl-64/s_lround.c: Include
	<fix-fp-int-convert-overflow.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_llrintf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__llrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_llroundf.c: Include <fenv.h>,
	<limits.h> and <fix-fp-int-convert-overflow.h>.
	(__llroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_lrintf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__lrintf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/ieee754/flt-32/s_lroundf.c: Include <fenv.h>, <limits.h>
	and <fix-fp-int-convert-overflow.h>.
	(__lroundf) [FE_INVALID]: Force FE_INVALID exception as needed if
	FIX_DBL_LLONG_CONVERT_OVERFLOW.
	* sysdeps/mips/mips32/fpu/fix-fp-int-convert-overflow.h: New file.
2015-10-09 21:02:19 +00:00
Joseph Myers 0e069029a8 Fix dbl-64 lrint for 64-bit long (bug 19095).
The dbl-64 implementation of lrint produces incorrect results for some
arguments with 64-bit long because a 32-bit (unsigned) low part of the
mantissa is shifted left, losing high bits in the process.  This patch
fixes this by casting to long int before shifting, as in lround (as
this case only applies for 64-bit long, there are no issues with
sign-extension).

Tested for mips64 (n64).

	[BZ #19095]
	* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Cast low part of
	mantissa to long int before shifting left.
2015-10-09 00:32:14 +00:00
Joseph Myers d0d286d32d Fix lrint, llrint missing exceptions close to overflow threshold (bug 19094).
The dbl-64, ldbl-96 and ldbl-128 implementations of lrint and llrint
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions).  (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist.  It also obviously cannot arise in
FE_TOWARDZERO mode.)

This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT, while raising FE_INEXACT explicitly in the cases where it
is needed; unlike lround and llround, FE_INEXACT is required, not
optional, for these functions for a within-range inexact result).

The fixes are conditional on FE_INVALID or FE_INEXACT being defined.
If any future architecture supports one but not both of those
exceptions, the code will fail to compile and need fixing to handle
that case (this seemed better than conditioning on both macros being
defined, resulting in code that would compile but quietly miss
exceptions on such a system).

Tested for x86_64, x86 and mips64.  Tested the ldbl-96 changes (only
relevant for ia64, it appears) on x86_64 by removing the x86_64
versions of lrintl / llrintl.

	[BZ #19094]
	* sysdeps/ieee754/dbl-64/s_lrint.c: Include <fenv.h> and
	<limits.h>.
	(__lrint) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Include <fenv.h> and
	<limits.h>.
	(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Include <fenv.h> and
	<limits.h>.
	(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c: Include <fenv.h> and
	<limits.h>.
	(__llrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c: Include <fenv.h> and
	<limits.h>.
	(__lrintl) [FE_INVALID || FE_INEXACT]: Force FE_INVALID exception
	when result overflows but exception would not result from cast.
	* math/libm-test.inc (lrint_test_data): Add more tests.
	(llrint_test_data): Likewise.
2015-10-08 22:17:45 +00:00
Carlos O'Donell 87701a58e2 strcoll: Remove incorrect STRDIFF-based optimization (Bug 18589).
The optimization introduced in commit
f13c2a8dff, causes regressions in
sorting for languages that have digraphs that change sort order, like
cs_CZ which sorts ch between h and i.

My analysis shows the fast-forwarding optimization in STRCOLL advances
through a digraph while possibly stopping in the middle which results
in a subsequent skipping of the digraph and incorrect sorting. The
optimization is incorrect as implemented and because of that I'm
removing it for 2.23, and I will also commit this fix for 2.22 where
it was originally introduced.

This patch reverts the optimization, introduces a new bug-strcoll2.c
regression test that tests both cs_CZ.UTF-8 and da_DK.ISO-8859-1 and
ensures they sort one digraph each correctly. The optimization can't be
applied without regressing this test.

Checked on x86_64, bug-strcoll2.c fails without this patch and passes
after. This will also get a fix on 2.22 which has the same bug.
2015-10-08 16:41:45 -04:00
Carlos O'Donell 104ff17183 Add BZ#19086 to NEWS. 2015-10-08 10:38:36 -04:00
Joseph Myers 8afdb7ac1e Fix lround, llround missing exceptions close to overflow threshold (bug 19088).
The dbl-64, ldbl-96 and ldbl-128 implementations of lround and llround
fail to produce "invalid" exceptions in cases where the rounded result
overflows the target type, but truncating the floating-point argument
to the next integer towards zero does not overflow it (so in
particular casts do not produce such exceptions).  (This issue cannot
arise for float, or for double with 64-bit target type, or for ldbl-96
with 64-bit target type and negative arguments, because of
insufficient precision in the floating-point type for arguments with
the relevant property to exist.)

This patch fixes these problems by inserting checks for the special
cases that can occur in each implementation, and explicitly raising
FE_INVALID (and avoiding the cast if it might raise spurious
FE_INEXACT).

Tested for x86_64, x86 and mips64.

	[BZ #19088]
	* sysdeps/ieee754/dbl-64/s_lround.c: Include <fenv.h> and
	<limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Include <fenv.h>
	and <limits.h>.
	(__lround) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Include <fenv.h> and
	<limits.h>.
	(__llroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Include <fenv.h> and
	<limits.h>.
	(__lroundl) [FE_INVALID]: Force FE_INVALID exception when result
	overflows but exception would not result from cast.
	* math/libm-test.inc (lround_test_data): Add more tests.
	(llround_test_data): Likewise.
2015-10-07 23:45:29 +00:00
Joseph Myers 119d073e33 Fix ldbl-128 lrintl, lroundl missing exceptions for 32-bit long (bug 19085).
The ldbl-128 implementations of lrintl and lroundl miss "invalid"
exceptions on systems with 32-bit long for arguments that overflow
long but have exponent below 48.  This patch fixes this by rearranging
the sequence of tests in the code so the exponent < 48 case is only
used for exponents that don't overflow long.

Tested for mips64 (n32 and n64).

	[BZ #19085]
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Move test for
	exponent below 48 inside case for non-overflowing exponent.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl): Likewise.
2015-10-07 16:10:59 +00:00
Joseph Myers b75bc69cdf Don't use dbl-64/wordsize-64 lround based on llround for ILP32 (bug 19079).
The implementation of lround in dbl-64/wordsize-64 as an alias or
wrapper for llround is always incorrect when long is not 64-bit,
because it misses required exceptions in overflow cases, as shown by
my recently added tests.  This patch removes that alias / wrapper in
the non-LP64 case, together with the REGISTER_CAST_INT32_TO_INT64
macro, restoring the previous version of lround for dbl-64/wordsize-64
(newly conditioned on !_LP64).

Tested for x86_64, and for mips64 with use of dbl-64/wordsize-64
enabled.

	[BZ #19079]
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Restore previous
	file, conditioned on [!_LP64].
	* sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
	[!_LP64] (__lround): Do not define as function or alias.
	[!_LP64] (lround): Likewise.
	[!_LP64] (__lroundl): Likewise.
	[!_LP64] (lroundl): Likewise.
	* sysdeps/tile/sysdep.h (REGISTER_CAST_INT32_TO_INT64): Remove
	macro.
	* sysdeps/x86_64/x32/sysdep.h (REGISTER_CAST_INT32_TO_INT64):
	Likewise.
2015-10-07 00:40:12 +00:00
Joseph Myers 6c9678ebd4 Fix ldbl-128ibm expl overflow in non-default rounding modes (bug 19078).
The ldbl-128ibm expl wrapper checks the argument to determine when to
call __kernel_standard_l, thereby overriding overflowing results from
__ieee754_expl that could otherwise (given appropriately patched
libgcc) be correct for the rounding mode.  This patch changes it to
check the result of __ieee754_expl instead, as other versions of this
wrapper do.

Tested for powerpc.

	[BZ #19078]
	* sysdeps/ieee754/ldbl-128ibm/w_expl.c (o_thres): Remove variable.
	(u_thres): Likewise.
	(__expl): Determine whether to call __kernel_standard_l based on
	value of result, not argument.
2015-10-06 17:37:49 +00:00
Joseph Myers 31d4459e42 Fix ldbl-128ibm logl (1) sign of zero result (bug 19077).
The ldbl-128ibm implementation of logl produces a zero with the wrong
sign for logl (1) in FE_DOWNWARD mode.  This patch makes it explicitly
return 0.0L in that case, as in e.g. the ldbl-128 implementation.

Tested for powerpc.

	[BZ #19077]
	* sysdeps/ieee754/ldbl-128ibm/e_logl.c (__ieee754_logl): Return
	0.0L for argument 1.0L.
2015-10-06 15:32:06 +00:00
Joseph Myers d79b568926 Fix ldbl-128ibm log1pl (-1) sign of infinity (bug 19076).
The ldbl-128ibm implementation of log1pl produces an infinity with the
wrong sign for log1pl (-1) in FE_DOWNWARD mode.  This patch fixes this
by changing a division (-1.0L / (x - x)) (incorrect in FE_DOWNWARD
mode) to (-1.0L / 0.0L) (correct in all rounding modes).

Tested for powerpc.

	[BZ #19076]
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Divide by
	constant 0.0L when computing infinite result.
2015-10-06 15:14:26 +00:00
Florian Weimer 3670da6bfb nss_nis: Do not call malloc_usable_size [BZ #10432]
This is a namespace violation, and interposed malloc implementations
are not required to interpose malloc_usable_size.
2015-10-06 14:03:35 +02:00
Florian Weimer f586e13286 Harden tls_dtor_list with pointer mangling [BZ #19018] 2015-10-06 13:22:56 +02:00
Paul Pluzhnikov be64c2ef2a Fix BZ #19012 -- iconv_open leaks memory on error path. 2015-10-05 20:03:48 -07:00
Joseph Myers cec7d28af8 Fix ldbl-96 lroundl just below powers of 2 (bug 19071).
The ldbl-96 version of lroundl is incorrect for systems with 64-bit
long when the argument's absolute value is just below a power of 2,
2^32 or more, and rounds up to the next integer; in such cases, it
returns 0.  The problem is incrementing the high part of the mantissa
loses the high bit of the value (which is not an issue for any other
floating-point format, and is handled specially in lround when the bit
corresponding to 0.5 was in the high part rather than the low part).

This patch fixes this in a similar way to that used in llroundl:
storing the high part in an unsigned long variable before incrementing
it, so problems cannot occur in the case when this code is reachable.
I improved test coverage for both lround and llround by making them
use the same test inputs (appropriately conditioned on the size of
long in the lround case) - complete with the same comments, to make
comparison as easy as possible.  (This test coverage improvement was
how I found the lroundl bug.)

Tested for x86_64 and x86.

	[BZ #19071]
	* sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Use unsigned
	long int variable to store possibly incremented high part of
	mantissa.
	* math/libm-test.inc (lround_test_data): Add tests used for
	llround.  Use [LONG_MAX > 0x7fffffff] consistently as condition
	for tests requiring 64-bit long.  Do not condition tests on
	[TEST_FLOAT] unnecessarily.
	(llround_test_data): Add tests used for lround.  Add another
	expectation for the "inexact" exception.  Do not condition tests
	on [TEST_FLOAT] unnecessarily.
2015-10-05 22:54:50 +00:00
Joseph Myers a8133e197e Don't list bug 887 as fixed for glibc 2.16. 2015-10-05 17:49:28 +00:00
Joseph Myers bc3753638a Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug 19050).
On powerpc32 hard-float, older processors (ones where fcfid is not
available for 32-bit code), GCC generates conversions from integers to
floating point that wrongly convert integer 0 to -0 instead of +0 in
FE_DOWNWARD mode.  This in turn results in logb and a few other
functions wrongly returning -0 when they should return +0.

This patch works around this issue in glibc as I proposed in
<https://sourceware.org/ml/libc-alpha/2015-09/msg00728.html>, so that
the affected functions can be correct and the affected tests pass in
the absence of a GCC fix for this longstanding issue (GCC bug 67771 -
if fixed, of course we can put in GCC version conditionals, and
eventually phase out the workarounds).  A new macro
FIX_INT_FP_CONVERT_ZERO is added in a new sysdeps header
fix-int-fp-convert-zero.h, and the powerpc32/fpu version of that
header defines the macro based on the results of a configure test for
whether such conversions use the fcfid instruction.

Tested for x86_64 (that installed stripped shared libraries are
unchanged by the patch) and powerpc (that HAVE_PPC_FCFID comes out to
0 as expected and that the relevant tests are fixed).  Also tested a
build with GCC configured for -mcpu=power4 and verified that
HAVE_PPC_FCFID comes out to 1 in that case.

There are still some other issues to fix to get test-float and
test-double passing cleanly for older powerpc32 processors (apart from
the need for an ulps regeneration for powerpc).  (test-ldouble will be
harder to get passing cleanly, but with a combination of selected
fixes to ldbl-128ibm code that don't involve significant performance
issues, allowing spurious underflow and inexact exceptions for that
format, and lots of XFAILing for the default case of unpatched libgcc,
it should be doable.)

	[BZ #887]
	[BZ #19049]
	[BZ #19050]
	* sysdeps/generic/fix-int-fp-convert-zero.h: New file.
	* sysdeps/ieee754/dbl-64/e_log10.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log10): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/e_log2.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log2): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/s_erf.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfc): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/dbl-64/s_logb.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logb): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/e_log10f.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log10f): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/e_log2f.c: Include
	<fix-int-fp-convert-zero.h>.
	(__ieee754_log2f): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/s_erff.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfcf): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/flt-32/s_logbf.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logbf): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include
	<fix-int-fp-convert-zero.h>.
	(__erfcl): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/ieee754/ldbl-128ibm/s_logbl.c: Include
	<fix-int-fp-convert-zero.h>.
	(__logbl): Adjust signs as needed if FIX_INT_FP_CONVERT_ZERO.
	* sysdeps/powerpc/powerpc32/fpu/configure.ac: New file.
	* sysdeps/powerpc/powerpc32/fpu/configure: New generated file.
	* sysdeps/powerpc/powerpc32/fpu/fix-int-fp-convert-zero.h: New
	file.
	* config.h.in [_LIBC] (HAVE_PPC_FCFID): New macro.
2015-10-05 17:46:50 +00:00
Joseph Myers 59a63cca11 Fix nexttoward overflow in non-default rounding modes (bug 19059).
ISO C requires overflowing results from nexttoward to be the
appropriate infinity independent of the rounding mode, but some
implementations use a rounding-mode-dependent result (this is the same
issue as was fixed for nextafter in bug 16677).  This patch fixes the
problem by making the nexttoward implementations discard the result
from the floating-point computation that forced an overflow exception
and then return the infinity previously computed with integer
arithmetic.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #19059]
	* math/s_nexttowardf.c (__nexttowardf): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
	Likewise.
	* math/libm-test.inc (nexttoward_test_data): Add more tests.
2015-10-02 17:11:13 +00:00
Florian Weimer 676599b36a Harden putpwent, putgrent, putspent, putspent against injection [BZ #18724]
This prevents injection of ':' and '\n' into output functions which
use the NSS files database syntax.  Critical fields (user/group names
and file system paths) are checked strictly.  For backwards
compatibility, the GECOS field is rewritten instead.

The getent program is adjusted to use the put*ent functions in libc,
instead of local copies.  This changes the behavior of getent if user
names start with '-' or '+'.
2015-10-02 11:34:13 +02:00
Joseph Myers 4b84e2471b Fix ldbl-128 / ldbl-128ibm lgamma overflow handling (bug 16347, bug 19046).
The ldbl-128 / ldbl-128ibm implementation of lgamma has problems with
its handling of large arguments.  It has an overflow threshold that is
correct only for ldbl-128, despite being used for both types - with
diagnostic control macros as a temporary measure to disable warnings
about that constant overflowing for ldbl-128ibm - and it has a
calculation that's roughly x * log(x) - x, resulting in overflows for
arguments that are roughly at most a factor 1/log(threshold) below the
overflow threshold.

This patch fixes both issues, using an overflow threshold appropriate
for the type in question and adding another case for large arguments
that avoids the possible intermediate overflow.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16347]
	[BZ #19046]
	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c: Do not include
	<libc-internal.h>.
	(MAXLGM): Do not use diagnostic control macros.
	[LDBL_MANT_DIG == 106] (MAXLGM): Change value to overflow
	threshold for ldbl-128ibm.
	(__ieee754_lgammal_r): For large arguments, multiply by log - 1
	instead of multiplying by log then subtracting.
	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
2015-10-01 17:15:54 +00:00
Joseph Myers 7cda516f5f Fix ldbl-128ibm exp10l spurious overflows (bug 16620).
The ldbl-128ibm implementation of exp10l uses a version of log(10)
split into high and low parts - but the low part is negative, so
causing spurious overflows from __ieee754_expl (exp_high) in cases
close to the overflow threshold (I added relevant tests close to the
overflow threshold to the testsuite earlier today).  The same issue
applies close to the underflow threshold as well (except that spurious
underflows in IBM long double arithmetic are harder to fix than the
other deficiencies, so we might end up permitting those for IBM long
double in the libm testsuite, as permitted by ISO C).

This patch fixes it to use a low part rounded downward to 48 bits
instead.  (The choice of 48 instead of 53 bits is to make it more
obviously safe even when the low part of the argument is negative.)

Tested for powerpc.  (Note that because of libgcc bugs with
multiplication very close to LDBL_MAX, libgcc also needs patching for
all the problem cases to be fixed, but this patch is still safe and
correct in the absence of such libgcc fixes.)

	[BZ #16620]
	* sysdeps/ieee754/ldbl-128ibm/e_exp10l.c (log10_high): Use value
	of log (10) rounded downward to 48 bits.
	(log10_low): Use corresponding low part of log (10).
2015-09-30 23:34:59 +00:00
Joseph Myers 8c6c923636 Fix i386 acosh (-qNaN) spurious "invalid" exception.
The i386 versions of acoshf and acosh raise a spurious "invalid"
exception for an argument that is a quiet NaN with the sign bit set.
The integer arithmetic to detect arguments < 1 also detects -NaN, and
then the computation 0 / 0 in that case raises the exception.  This
patch fixes this by using (x - x) / (x - x) as the computation in that
case instead, which will always raise the exception for non-NaN
arguments reaching that code, but not for quiet NaN arguments.

Tested for x86_64 and x86.

	[BZ #19032]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): For arguments < 1,
	compute result as (x - x) / (x - x) not as 0 / 0.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* math/libm-test.inc (acosh_test_data): Add another test of acosh.
2015-09-30 21:44:42 +00:00
Joseph Myers a5721ebc68 Fix clog, clog10 inaccuracy (bug 19016).
For arguments with X^2 + Y^2 close to 1, clog and clog10 avoid large
errors from log(hypot) by computing X^2 + Y^2 - 1 in a way that avoids
cancellation error and then using log1p.

However, the thresholds for using that approach still result in log
being used on argument as large as sqrt(13/16) > 0.9, leading to
significant errors, in some cases above the 9ulp maximum allowed in
glibc libm.  This patch arranges for the approach using log1p to be
used in any cases where |X|, |Y| < 1 and X^2 + Y^2 >= 0.5 (with the
existing allowance for cases where one of X and Y is very small),
adjusting the __x2y2m1 functions to work with the wider range of
inputs.  This way, log only gets used on arguments below sqrt(1/2) (or
substantially above 1), where the error involved is much less.

Tested for x86_64, x86, mips64 and powerpc.  For the ulps regeneration
I removed the existing clog and clog10 ulps before regenerating to
allow any reduced ulps to appear.  Tests added include those found by
random test generation to produce large ulps either before or after
the patch, and some found by trying inputs close to the (0.75, 0.5)
threshold where the potential errors from using log are largest.

	[BZ #19016]
	* sysdeps/generic/math_private.h (__x2y2m1f): Update comment to
	allow more cases with X^2 + Y^2 >= 0.5.
	* sysdeps/ieee754/dbl-64/x2y2m1.c (__x2y2m1): Likewise.  Add -1 as
	normal element in sum instead of special-casing based on values of
	arguments.
	* sysdeps/ieee754/dbl-64/x2y2m1f.c (__x2y2m1f): Update comment.
	* sysdeps/ieee754/ldbl-128/x2y2m1l.c (__x2y2m1l): Likewise.  Add
	-1 as normal element in sum instead of special-casing based on
	values of arguments.
	* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c (__x2y2m1l): Likewise.
	* sysdeps/ieee754/ldbl-96/x2y2m1.c [FLT_EVAL_METHOD != 0]
	(__x2y2m1): Update comment.
	* sysdeps/ieee754/ldbl-96/x2y2m1l.c (__x2y2m1l): Likewise.  Add -1
	as normal element in sum instead of special-casing based on values
	of arguments.
	* math/s_clog.c (__clog): Handle more cases using log1p without
	hypot.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/auto-libm-test-in: Add more tests of clog and clog10.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-09-28 22:11:22 +00:00
Martin Sebor 60cf80f09d Let 'make check subdirs=string' succeed even when it's invoked
immediately after glibc has been built and before 'make check'
(or after 'make clean').
2015-09-28 16:55:57 -04:00
Paul Pluzhnikov d36c75fc0d Fix BZ #18985 -- out of range data to strftime() causes a segfault 2015-09-26 13:27:48 -07:00
Joseph Myers fa752c6981 Fix powf inaccuracy (bug 18956).
The flt-32 version of powf can be inaccurate because of bugs in the
extra-precision calculation of (x-1)/(x+1) or (x-1.5)/(x+1.5) as part
of calculating log(x) with extra precision: a constant used (as part
of adding 1 or 1.5 through integer arithmetic) is incorrect, and then
the code fails to mask a computed high part before using it in
arithmetic that relies on s_h*t_h being exactly representable.  This
patch fixes these bugs.

Tested for x86_64 and x86.  x86_64 ulps for powf removed and
regenerated to reflect reduced ulps from the increased accuracy for
existing tests.

	[BZ #18956]
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Add 0x00400000
	not 0x0040000 for high bit of mantissa.  Mask with 0xfffff000 when
	extracting high part.
	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-09-26 00:27:06 +00:00
Joseph Myers 6ace393821 Fix pow missing underflows (bug 18825).
Similar to various other bugs in this area, pow functions can fail to
raise the underflow exception when the result is tiny and inexact but
one or more low bits of the intermediate result that is scaled down
(or, in the i386 case, converted from a wider evaluation format) are
zero.  This patch forces the exception in a similar way to previous
fixes, thereby concluding the fixes for known bugs with missing
underflow exceptions currently filed in Bugzilla.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18825]
	* sysdeps/i386/fpu/i386-math-asm.h (FLT_NARROW_EVAL_UFLOW_NONNAN):
	New macro.
	(DBL_NARROW_EVAL_UFLOW_NONNAN): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	* sysdeps/i386/fpu/e_pow.S: Use DEFINE_DBL_MIN.
	(__ieee754_pow): Use DBL_NARROW_EVAL_UFLOW_NONNAN instead of
	DBL_NARROW_EVAL, reloading the PIC register as needed.
	* sysdeps/i386/fpu/e_powf.S: Use DEFINE_FLT_MIN.
	(__ieee754_powf): Use FLT_NARROW_EVAL_UFLOW_NONNAN instead of
	FLT_NARROW_EVAL.  Use separate return path for case when first
	argument is NaN.
	* sysdeps/i386/fpu/e_powl.S: Include <i386-math-asm.h>.  Use
	DEFINE_LDBL_MIN.
	(__ieee754_powl): Use LDBL_CHECK_FORCE_UFLOW_NONNAN, reloading the
	PIC register.
	* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Force
	underflow for subnormal result.
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/x86/fpu/powl_helper.c (__powl_helper): Use
	math_check_force_underflow.
	* sysdeps/x86_64/fpu/x86_64-math-asm.h
	(LDBL_CHECK_FORCE_UFLOW_NONNAN): New macro.
	* sysdeps/x86_64/fpu/e_powl.S: Include <x86_64-math-asm.h>.  Use
	DEFINE_LDBL_MIN.
	(__ieee754_powl): Use LDBL_CHECK_FORCE_UFLOW_NONNAN.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
2015-09-25 22:29:10 +00:00
Maciej W. Rozycki 93bad7c97c [BZ #17250] Fix static dlopen default library search path
Fix a regression introduced with commit 0d23a5c1 [Static dlopen
correction fallout fixes] that caused the default library search path to
be ignored for modules loaded with dlopen from static executables.

	[BZ #17250]
	* elf/dl-support.c (_dl_main_map): Don't initialize l_flags_1
	member.
2015-09-25 09:37:12 +01:00
Joseph Myers f6987f5aa4 Fix hypot missing underflows (bug 18803).
Similar to various other bugs in this area, hypot functions can fail
to raise the underflow exception when the result is tiny and inexact
but one or more low bits of the intermediate result that is scaled
down (or, in the i386 case, converted from a wider evaluation format)
are zero.  This patch forces the exception in a similar way to
previous fixes.

Note that this issue cannot arise for implementations of hypotf using
double (or wider) for intermediate evaluation (if hypotf should
underflow, that means the double square root is being computed of some
number of the form N*2^-298, for 0 < N < 2^46, which is exactly
represented as a double, and whatever the rounding mode such a square
root cannot have a mantissa with all zeroes after the initial 23
bits).  Thus no changes are made to hypotf implementations in this
patch, only to hypot and hypotl.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18803]
	* sysdeps/i386/fpu/e_hypot.S: Use DEFINE_DBL_MIN.
	(MO): New macro.
	(__ieee754_hypot) [PIC]: Load PIC register.
	(__ieee754_hypot): Use DBL_NARROW_EVAL_UFLOW_NONNEG instead of
	DBL_NARROW_EVAL.
	* sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Use
	math_check_force_underflow_nonneg in case where result might be
	tiny.
	* sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_hypotl.c (__ieee754_hypotl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise.
	* sysdeps/powerpc/fpu/e_hypot.c (__ieee754_hypot): Likewise.
	* math/auto-libm-test-in: Add more tests of hypot.
	* math/auto-libm-test-out: Regenerated.
2015-09-24 23:43:57 +00:00
Joseph Myers 51df260506 Fix x86_64 fma4 pow inappropriate contraction (bug 19003).
The x86_64 fma4 version of pow fails to disable contraction of
operations other than those explicitly intended to use fma
instructions, so resulting in large ulps errors on processors with
fma4 instructions, as in bug 18104 (165ulp for the test added for that
bug; error originally reported by "blaaa" on #glibc).  This patch adds
$(config-cflags-nofma) for e_pow-fma4.c, corresponding to the use for
e_pow.c in sysdeps/ieee754/dbl-64/Makefile.

Tested for x86_64 on a processor with fma4.

	[BZ #19003]
	* sysdeps/x86_64/fpu/multiarch/Makefile (CFLAGS-e_pow-fma4.c): Add
	$(config-cflags-nofma).
2015-09-24 16:48:32 +00:00
Joseph Myers 6f0f237bf5 Avoid excess range in results from i386 exp, hypot, pow functions (bug 18980).
i386 exp, hypot and pow functions can return overflowing and
underflowing values with excess range and precision; ; Wilco
Dijkstra's patches to make isfinite etc. expand inline cause this
pre-existing issue to result in test failures.

This patch fixes those functions to avoid excess range and precision
in their return values.  Appropriate macros are added for the repeated
code sequences; in future I'll add more such macros and refactor
existing code forcing underflow (with or without also eliminating
excess range and precision from the return value) to use such macros.

Tested for x86.  If, after this patch, you still see x86 libm test
failures with excess range or precision, please file bugs in Bugzilla.

	[BZ #18980]
	* sysdeps/i386/fpu/i386-math-asm.h (DEFINE_FLT_MIN): New macro.
	(DEFINE_DBL_MIN): Likewise.
	(FLT_NARROW_EVAL_UFLOW_NONNEG_NAN): Likewise.
	(DBL_NARROW_EVAL_UFLOW_NONNEG_NAN): Likewise.
	(FLT_NARROW_EVAL_UFLOW_NONNEG): Likewise.
	(DBL_NARROW_EVAL_UFLOW_NONNEG): Likewise.
	* sysdeps/i386/fpu/e_exp.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_exp): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
	(__exp_finite): Use DBL_NARROW_EVAL_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_exp10.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_exp10): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_exp10f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_exp10f): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_exp2.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_exp2): Use DBL_NARROW_EVAL_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_exp2f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_exp2f): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_expf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_expf): Use FLT_NARROW_EVAL_UFLOW_NONNEG_NAN.
	(__expf_finite): Use FLT_NARROW_EVAL_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_hypot.S: Include <i386-math-asm.h>.
	(__ieee754_hypot): Use DBL_NARROW_EVAL.
	* sysdeps/i386/fpu/e_hypotf.S: Include <i386-math-asm.h>.
	(__ieee754_hypotf): Use FLT_NARROW_EVAL.
	* sysdeps/i386/fpu/e_pow.S: Include <i386-math-asm.h>.
	(__ieee754_pow): Use DBL_NARROW_EVAL.
	* sysdeps/i386/fpu/e_powf.S: Include <i386-math-asm.h>.
	(__ieee754_powf): Use FLT_NARROW_EVAL.
	* sysdeps/i386/i686/fpu/multiarch/e_expf-sse2.S
	(__ieee754_expf_sse2): Convert double-precision result to single
	precision.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-09-18 21:53:22 +00:00
Joseph Myers 94ced920a9 Avoid excess range in results from i386 scalb functions (bug 18981).
i386 scalb / scalbn / scalbln (and thus ldexp) functions for float and
double can return results with excess range (and consequently excess
precision for subnormal results).  As the results of these functions
are fully determined by reference to IEEE 754 operations, this is
unambiguously a bug, apart from the testsuite failures it causes.

This patch makes those functions store their results on the stack and
load them back to eliminate the excess range.  Double rounding is not
a problem, as the only cases where it could occur are when the result
overflows or underflows for extended precision, and then the
double-rounded results are the same as the single-rounded results.

The new macros will be used for more functions, more such macros
added, and existing code refactored to use such macros, in subsequent
patches.

Tested for x86.  Committed.

	[BZ #18981]
	* sysdeps/i386/fpu/i386-math-asm.h: New file.
	* sysdeps/i386/fpu/e_scalb.S: Include <i386-math-asm.h>.
	(__ieee754_scalb): Use DBL_NARROW_EVAL.
	* sysdeps/i386/fpu/e_scalbf.S: Include <i386-math-asm.h>.
	(__ieee754_scalbf): Use FLT_NARROW_EVAL.
	* sysdeps/i386/fpu/s_scalbn.S: Include <i386-math-asm.h>.
	(__scalbn): Use DBL_NARROW_EVAL.
	* sysdeps/i386/fpu/s_scalbnf.S: Include <i386-math-asm.h>.
	(__scalbnf): Use FLT_NARROW_EVAL.
2015-09-18 20:34:59 +00:00
Wilco Dijkstra 8df4e219e4 Add inlining of the C99 math functions isinf/isnan/signbit/isfinite/isnormal/fpclassify using GCC
built-ins when available. Since going through the PLT is expensive for these small functions,
inlining results in major speedups (about 7x on Cortex-A57 for isinf). The GCC built-ins are not
correct if signalling NaN support is required, and thus are turned off in that case (see GCC bug
66462). The test-snan.c tests sNaNs and so must be explicitly built with -fsignaling-nans.

2015-09-18  Wilco Dijkstra  <wdijkstr@arm.com>

        [BZ #15367]
        [BZ #17441]

        * math/Makefile: Build test-snan.c with -fsignaling-nans.
        * math/math.h (fpclassify): Use __builtin_fpclassify when
        available.  (signbit): Use __builtin_signbit(f/l).
        (isfinite): Use__builtin_isfinite.  (isnormal): Use
        __builtin_isnormal.  (isnan): Use __builtin_isnan.
        (isinf): Use __builtin_isinf_sign.
2015-09-18 16:34:45 +01:00
Vincent Bernat e952e1dfeb time: in strptime(), make %z accept [+-]HH:MM tz [BZ #17887]
In ISO 8601, +03:30 is a valid time zone. Currently, strptime() only
parses it as a 2-digit time zone an believes this is +03:00. This change
makes it accept a single colon.
2015-09-18 01:17:15 -04:00
Vincent Bernat 900f33e23e time: in strptime(), make %z accept Z as a time zone [BZ #17886]
In ISO 8601, the timezone can be 'Z' instead of using
digits. 2014-08-17T12:33:12+0000 is often expressed as
2014-08-17T12:33:12Z.
2015-09-18 01:15:45 -04:00
H.J. Lu e5d19c08d1 Use __pthread_setcancelstate in libc.a
This patch references __pthread_setcancelstate instead of
pthread_setcancelstate in libc.a.

	[BZ #18970]
	* misc/error.c (error): Replace pthread_setcancelstate with
	__pthread_setcancelstate.
	(error_at_line): Likewise.
	* posix/wordexp.c (parse_comm): Likewise.
	* stdlib/fmtmsg.c (fmtmsg): Likewise.
	* nptl/forward.c (pthread_setcancelstate): Renamed to ...
	(__pthread_setcancelstate): This.
	(pthread_setcancelstate): Add an alias.
	* nptl/nptl-init.c (pthread_functions): Replace
	ptr_pthread_setcancelstate with ptr___pthread_setcancelstate.
	* sysdeps/nptl/pthread-functions.h (pthread_functions): Likewise.
	* nptl/pthreadP.h (__pthread_setcancelstate): Mark it with
	hidden_proto.
	* nptl/pthread_setcancelstate.c (__pthread_setcancelstate): Mark
	it with hidden_def.
	* sysdeps/nptl/libc-lockP.h (__pthread_setcancelstate): New.
	(pthread_setcancelstate): Renamed to ...
	(__pthread_setcancelstate): This.
	* sysdeps/unix/sysv/linux/fatal-prepare.h (FATAL_PREPARE): Use
	__libc_ptf_call with __pthread_setcancelstate.
2015-09-17 16:38:54 -07:00
Joseph Myers 61f8937898 Fix sign of zero part from ctan / ctanh when argument infinite (bug 17118).
C99/C11 Annex G specifies the sign of the zero part of the result of
ctan (x +/- i * Inf) and ctanh (+/-Inf + i * y).  This patch fixes glibc
to follow that specification, along the lines I described in my review
of Andreas's previous patch for this issue
<https://sourceware.org/ml/libc-alpha/2014-08/msg00142.html>.

Tested for x86_64.

2015-09-17  Joseph Myers  <joseph@codesourcery.com>
	    Andreas Schwab  <schwab@suse.de>

	[BZ #17118]
	* math/s_ctan.c (__ctan): Determine sign of zero real part of
	result when imaginary part of argument is infinite using sine and
	cosine.
	* math/s_ctanf.c (__ctanf): Likewise.
	* math/s_ctanl.c (__ctanl): Likewise.
	* math/s_ctanh.c (__ctanh): Determine sign of zero imaginary part
	of result when real part of argument is infinite using sine and
	cosine.
	* math/s_ctanhf.c (__ctanhf): Likewise.
	* math/s_ctanhl.c (__ctanhl): Likewise.
	* math/libm-test.inc (ctan_test_data): Add more tests of ctan.
	(ctanh_test_data): Add more tests of ctanh.
2015-09-17 21:21:39 +00:00
Joseph Myers b8682397ab Reduce number of constants in __finite* (bug 15384).
Bug 15384 notes that in __finite, two different constants are used
that could be the same constant (the result only depends on the
exponent of the floating-point representation), and that using the
same constant is better for architectures where constants need loading
from a constant pool.  This patch implements that change.

Tested for x86_64, mips64 and powerpc.

	[BZ #15384]
	* sysdeps/ieee754/dbl-64/s_finite.c (FINITE): Use same constant as
	bit-mask as in subtraction.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c (__finite):
	Likewise.
	* sysdeps/ieee754/flt-32/s_finitef.c (FINITEF): Likewise.
	* sysdeps/ieee754/ldbl-128/s_finitel.c (__finitel): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_finitel.c (__finitel): Likewise.
2015-09-17 16:47:14 +00:00
Joseph Myers 46f74e1dee Fix tgamma missing underflows (bug 18951).
Similar to various other bugs in this area, tgamma functions can fail
to raise the underflow exception when the result is tiny and inexact
but one or more low bits of the intermediate result that is scaled
down are zero.  This patch forces the exception in a similar way to
previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #18951]
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Force
	underflow exception for small results.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* math/auto-libm-test-in: Add more tests of tgamma.
	* math/auto-libm-test-out: Regenerated.
2015-09-17 15:51:54 +00:00
Joseph Myers 1f11365a75 Don't declare float / long double Bessel functions for XSI POSIX (bug 18977).
The float and long double versions of Bessel function (j0f, y1l, etc.)
are not in POSIX; only the double versions are.  This patch
accordingly limits the declarations of those functions to __USE_MISC,
and fixes the conform/ test expectations which matched the previous
incorrect declarations.

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

	[BZ #18977]
	* math/bits/mathcalls.h
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (j0): Do
	not declare.
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (j1):
	Likewise.
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (jn):
	Likewise.
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (y0):
	Likewise.
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (y1):
	Likewise.
	[!__USE_MISC && __USE_XOPEN && !__MATH_DECLARING_DOUBLE] (yn):
	Likewise.
	* conform/data/math.h-data
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (j0f): Do not expect
	function.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (j1f): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (jnf): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (y0f): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (y1f): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (ynf): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (j0l): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (j1l): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (jnl): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (y0l): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (y1l): Likewise.
	[!ISO99 && !ISO11 && !POSIX && !POSIX2008] (ynl): Likewise.
2015-09-16 22:04:40 +00:00
Joseph Myers da2f4f2dd5 Make scalbn set errno (bug 6803).
As noted in bug 6803, scalbn fails to set errno on overflow and
underflow.  This patch fixes this by making scalbn an alias of ldexp,
which has exactly the same semantics (for floating-point types with
radix 2) and already has wrappers that deal with setting errno,
instead of an alias of the internal __scalbn (which ldexp calls).

Notes:

* Where compat symbols were defined for scalbn functions, I didn't
  change what they point to (to keep the patch minimal), so such
  compat symbols continue to go directly to the non-errno-setting
  functions.

* Mike, I didn't do anything with the IA64 versions of these
  functions, where I think both the ldexp and scalbn functions already
  deal with setting errno.  As a cleanup (not needed to fix this bug)
  however you might want to make those functions into aliases for
  IA64; there is no need for them to be separate function
  implementations at all.

* This concludes the fix for bug 6803 since the scalb and scalbln
  cases of that bug were fixed some time ago.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #6803]
	* math/s_ldexp.c (scalbn): Define as weak alias of __ldexp.
	[NO_LONG_DOUBLE] (scalbnl): Define as weak alias of __ldexp.
	* math/s_ldexpf.c (scalbnf): Define as weak alias of __ldexpf.
	* math/s_ldexpl.c (scalbnl): Define as weak alias of __ldexpl.
	* sysdeps/i386/fpu/s_scalbn.S (scalbn): Remove alias.
	* sysdeps/i386/fpu/s_scalbnf.S (scalbnf): Likewise.
	* sysdeps/i386/fpu/s_scalbnl.S (scalbnl): Likewise.
	* sysdeps/ieee754/dbl-64/s_scalbn.c (scalbn): Likewise.
	[NO_LONG_DOUBLE] (scalbnl): Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c (scalbn):
	Likewise.
	[NO_LONG_DOUBLE] (scalbnl): Likewise.
	* sysdeps/ieee754/flt-32/s_scalbnf.c (scalbnf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_scalbnl.c (scalbnl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c (scalbnl): Remove
	long_double_symbol calls.
	* sysdeps/ieee754/ldbl-64-128/s_scalbnl.c (scalbnl): Likewise.
	* sysdeps/ieee754/ldbl-opt/s_ldexpl.c (__ldexpl_2): Define as
	strong alias of __ldexpl.
	(scalbnl): Define using long_double_symbol.
	* sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(scalbn,suffix)):
	Remove alias.
	* sysdeps/sparc/sparc64/soft-fp/s_scalbnl.c (scalbnl): Likewise.
	* sysdeps/x86_64/fpu/s_scalbnl.S (scalbnl): Likewise.
	* math/libm-test.inc (scalbn_test_data): Add errno expectations.
	(scalbln_test_data): Add more errno expectations.
2015-09-16 21:11:00 +00:00
Joseph Myers c88b3da93e Update de.po from Translation Project (bug 4404).
[BZ #4404]
	* po/de.po: Update from Translation Project.
2015-09-16 16:51:28 +00:00
Joseph Myers 8124ac3e73 Clean up ldbl-128 / ldbl-128ibm expm1l dead code (bug 16415).
The ldbl-128 and ldbl-128ibm expm1l implementations have code to
handle +Inf and finite arguments above an overflow threshold.  Since
they now use __expl for large positive arguments to fix other
problems, this code is unreachable; this patch removes it.

Tested for mips64 and powerpc.

	[BZ #16415]
	* sysdeps/ieee754/ldbl-128/s_expm1l.c (maxlog): Remove variable.
	(__expm1l): Remove code to handle positive infinity and overflow.
	* sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (maxlog): Remove
	variable.
	(__expm1l): Remove code to handle positive infinity and overflow.
2015-09-16 16:42:46 +00:00
Paul Pluzhnikov 560b04462f Fix BZ #18872 -- memory leak in printf_positional. 2015-09-16 09:16:11 -07:00
Andreas Schwab 1f60740e5f Remove extra va_start/va_end calls (bug 17244) 2015-09-16 14:51:28 +02:00
Andreas Schwab a6d9312c4d Add missing va_end calls (bug 17243) 2015-09-16 14:51:28 +02:00
Joseph Myers de20571d40 Fix math.h, tgmath.h XSI POSIX namespace (gamma, isnan, scalb) (bug 18967).
math.h incorrectly declares various functions for XSI POSIX 2001 and
2008 editions.  gamma was removed in the 2001 edition but is still
declared, along with gammaf and gammal which were never standard
functions.  isnan is still declared as a function, along with isnanf
and isnanl which were never standard functions, although in 2001 the
function was replaced by the type-generic macro.  scalbf and scalbl
are declared although never standard, and scalb was removed in the
2008 edition but is still declared.  The scalb type-generic macro in
tgmath.h shouldn't be present for any POSIX version, since POSIX never
had such a type-generic macro.

This patch disables all those declarations in the relevant cases (as a
minimal fix, it leaves them enabled for __USE_MISC).  For the matter
of declaring scalb but not scalbf or scalbl for the 2001 edition, a
new macro __MATH_DECLARING_DOUBLE is added, defined by math.h around
includes of bits/mathcalls.h, for bits/mathcalls.h to use to test
which type's functions are being declared.

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

	[BZ #18967]
	* math/math.h (__MATH_DECLARING_DOUBLE): New macro.  Define and
	undefine around includes of <bits/mathcalls.h>.
	* math/bits/mathcalls.h [!__USE_MISC && __USE_XOPEN2K] (isnan): Do
	not declare function.
	[!__USE_MISC && __USE_XOPEN2K] (gamma): Likewise.
	[!__USE_MISC && (!__MATH_DECLARING_DOUBLE || __USE_XOPEN2K8)]
	(scalb): Likewise.
	* math/tgmath.h [!__USE_MISC && __USE_XOPEN_EXTENDED] (scalb): Do
	not define macro.
	* conform/Makefile (test-xfail-XOPEN2K/math.h/conform): Remove
	variable.
	(test-xfail-XOPEN2K/tgmath.h/conform): Likewise.
	(test-xfail-XOPEN2K8/math.h/conform): Likewise.
	(test-xfail-XOPEN2K8/tgmath.h/conform): Likewise.
2015-09-15 22:12:40 +00:00
Joseph Myers dfa0f62011 Fix ldbl-128ibm nearbyintl use of signaling comparisons on NaNs (bug 18857).
The ldbl-128ibm implementation of nearbyintl wrongly uses signaling
comparisons such as "if (fabs (u.d[0].d) < TWO52)" on arguments that
might be NaNs, when "invalid" exceptions should not be raised.  (For
hard float, this issue may be hidden by
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, powerpc GCC
wrongly only using unordered comparison instructions.)  This patch
fixes this by just returning the argument if it is not finite (because
of the arbitrary value of the low part of a NaN in IBM long double,
there are quite a lot of comparisons that could end up involving a NaN
when the argument to nearbyintl is a NaN, so excluding NaN arguments
at the start is the simplest and safest fix).

Tested for powerpc-nofpu, where it removes failures for spurious
"invalid" exceptions from nearbyintl.

	[BZ #18857]
	* sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c (__nearbyintl): Just
	return non-finite argument without doing ordered comparisons on
	it.
2015-09-15 20:48:05 +00:00
Joseph Myers 223d1cacc5 Mark fegetround pure (bug 16296).
Bug 16296 notes that fegetround is a pure function and should be
marked as such in fenv.h.  This patch implements that.

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

	[BZ #16296]
	* math/fenv.h (fegetround): Use __attribute_pure__.
	* include/fenv.h (__fegetround): Likewise.
2015-09-15 20:36:50 +00:00
Joseph Myers 0b87419b69 Fix ctan, ctanh missing underflows (bug 18595).
Similar to various other bugs in this area, ctan and ctanh can fail to
raise the underflow exception for some cases of results that are tiny
and inexact.  This patch forces the exception in a similar way to
previous fixes.

Tested for x86_64 and x86.

	[BZ #18595]
	* math/s_ctan.c (__ctan): Force underflow exception for results
	whose real or imaginary part has small absolute value.
	* math/s_ctanf.c (__ctanf): Likewise.
	* math/s_ctanh.c (__ctanh): Likewise.
	* math/s_ctanhf.c (__ctanhf): Likewise.
	* math/s_ctanhl.c (__ctanhl): Likewise.
	* math/s_ctanl.c (__ctanl): Likewise.
	* math/auto-libm-test-in: Do not allow missing underflow for ctan
	and ctanh.  Add more tests of ctan and ctanh.
2015-09-15 17:46:08 +00:00
Joseph Myers 694aabefd2 Simplify hypotf infinity handling (bug 15918).
Bug 15918 points out that the handling of infinities in hypotf can be
simplified: it's enough to return the absolute value of the infinite
argument without first comparing it to the other argument and possibly
returning that other argument's absolute value.  This patch makes that
cleanup (which should not change how hypotf behaves on any input).

Tested for x86_64.

	[BZ #15918]
	* sysdeps/ieee754/flt-32/e_hypotf.c (__ieee754_hypotf): Simplify
	handling of cases where one argument is an infinity.
2015-09-15 17:24:23 +00:00
Joseph Myers 828bf6828b Fix i386 exp10 missing underflows (bug 18966).
On i386, the double version of exp10 can miss underflow exceptions if
the result is in the subnormal range for double but the last 11 bits
of the 64-bit extended-precision mantissa happen to be zero.  This
patch forces the exception in a similar way to previous fixes.

As with the exp2 and exp fixes, the exp10f changes may in fact not be
needed to ensure underflow exceptions, but are included for
consistency and to fix the exp10 part of bug 18875 by ensuring that
excess range and precision is removed from underflowing return values.

Tested for x86_64 and x86.

	[BZ #18875]
	[BZ #18966]
	* sysdeps/i386/fpu/e_exp10.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_exp10): For small results, force underflow exception
	and remove excess range and precision from return value.
	* sysdeps/i386/fpu/e_exp10f.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_exp10f): For small results, force underflow exception
	and remove excess range and precision from return value.
	* math/auto-libm-test-in: Add more tests of exp10.
	* math/auto-libm-test-out: Regenerated.
2015-09-15 16:50:02 +00:00
Joseph Myers de5e81691c Fix i386 exp missing underflows (bug 18961).
On i386, the double version of exp can miss underflow exceptions if
the result is in the subnormal range for double but the last 11 bits
of the 64-bit extended-precision mantissa happen to be zero.  This
patch forces the exception in a similar way to previous fixes.

As with the exp2 fixes, the expf changes may in fact not be needed to
ensure underflow exceptions, but are included for consistency and to
fix the exp part of bug 18875 by ensuring that excess range and
precision is removed from underflowing return values.

Tested for x86_64 and x86.

	[BZ #18875]
	[BZ #18961]
	* sysdeps/i386/fpu/e_exp.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_exp): For small results, force underflow exception and
	remove excess range and precision from return value.
	(__exp_finite): Likewise.
	* sysdeps/i386/fpu/e_expf.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_expf): For small results, force underflow exception and
	remove excess range and precision from return value.
	(__expf_finite): Likewise.
	* math/auto-libm-test-in: Add more tests of exp.
	* math/auto-libm-test-out: Regenerated.
2015-09-14 22:40:05 +00:00
Joseph Myers 903af5af9a Fix exp2 missing underflows (bug 16521).
Various exp2 implementations in glibc can miss underflow exceptions
when the scaling down part of the calculation is exact (or, in the x86
case, when the conversion from extended precision to the target
precision is exact).  This patch forces the exception in a similar way
to previous fixes.

The x86 exp2f changes may in fact not be needed for this purpose -
it's likely to be the case that no argument of type float has an exp2
result so close to an exact subnormal float value that it equals that
value when rounded to 64 bits (even taking account of variation
between different x86 implementations).  However, they are included
for consistency with the changes to exp2 and so as to fix the exp2f
part of bug 18875 by ensuring that excess range and precision is
removed from underflowing return values.

Tested for x86_64, x86 and mips64.

	[BZ #16521]
	[BZ #18875]
	* math/e_exp2l.c (__ieee754_exp2l): Force underflow exception for
	small results.
	* sysdeps/i386/fpu/e_exp2.S (dbl_min): New object.
	(MO): New macro.
	(__ieee754_exp2): For small results, force underflow exception and
	remove excess range and precision from return value.
	* sysdeps/i386/fpu/e_exp2f.S (flt_min): New object.
	(MO): New macro.
	(__ieee754_exp2f): For small results, force underflow exception
	and remove excess range and precision from return value.
	* sysdeps/i386/fpu/e_exp2l.S (ldbl_min): New object.
	(MO): New macro.
	(__ieee754_exp2l): Force underflow exception for small results.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Likewise.
	* sysdeps/x86_64/fpu/e_exp2l.S (ldbl_min): New object.
	(MO): New macro.
	(__ieee754_exp2l): Force underflow exception for small results.
	* math/auto-libm-test-in: Add more tests or exp2.
	* math/auto-libm-test-out: Regenerated.
2015-09-14 22:00:12 +00:00
Mike Frysinger b482d0364e localedef: improve error message [BZ #16985]
If you pass in a path that fails to be opened, then output_path is set to
NULL, and an error is flagged.  Then at the end, we use both of those:
	cannot write output files to `(null)': No such file or directory

Tweak the message to use the user's input when output_path is NULL.
2015-09-11 23:25:06 -04:00
Joseph Myers de071d199a Move bits/atomic.h to atomic-machine.h (bug 14912).
It was noted in
<https://sourceware.org/ml/libc-alpha/2012-09/msg00305.html> that the
bits/*.h naming scheme should only be used for installed headers.
This patch renames bits/atomic.h to atomic-machine.h to follow that
convention.

This is the only change in this series that needs to change the
filename rather than simply removing a directory level (because both
atomic.h and bits/atomic.h exist at present).

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

	[BZ #14912]
	* sysdeps/aarch64/bits/atomic.h: Move to ...
	* sysdeps/aarch64/atomic-machine.h: ...here.
	(_AARCH64_BITS_ATOMIC_H): Rename macro to
	_AARCH64_ATOMIC_MACHINE_H.
	* sysdeps/alpha/bits/atomic.h: Move to ...
	* sysdeps/alpha/atomic-machine.h: ...here.
	* sysdeps/arm/bits/atomic.h: Move to ...
	* sysdeps/arm/atomic-machine.h: ...here.  Update comments.
	* bits/atomic.h: Move to ...
	* sysdeps/generic/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/i386/bits/atomic.h: Move to ...
	* sysdeps/i386/atomic-machine.h: ...here.
	* sysdeps/ia64/bits/atomic.h: Move to ...
	* sysdeps/ia64/atomic-machine.h: ...here.
	* sysdeps/m68k/coldfire/bits/atomic.h: Move to ...
	* sysdeps/m68k/coldfire/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/m68k/m680x0/m68020/bits/atomic.h: Move to ...
	* sysdeps/m68k/m680x0/m68020/atomic-machine.h: ...here.
	* sysdeps/microblaze/bits/atomic.h: Move to ...
	* sysdeps/microblaze/atomic-machine.h: ...here.
	* sysdeps/mips/bits/atomic.h: Move to ...
	* sysdeps/mips/atomic-machine.h: ...here.
	(_MIPS_BITS_ATOMIC_H): Rename macro to _MIPS_ATOMIC_MACHINE_H.
	* sysdeps/powerpc/bits/atomic.h: Move to ...
	* sysdeps/powerpc/atomic-machine.h: ...here.  Update comments.
	* sysdeps/powerpc/powerpc32/bits/atomic.h: Move to ...
	* sysdeps/powerpc/powerpc32/atomic-machine.h: ...here.  Update
	comments.  Include <atomic-machine.h> instead of <bits/atomic.h>.
	* sysdeps/powerpc/powerpc64/bits/atomic.h: Move to ...
	* sysdeps/powerpc/powerpc64/atomic-machine.h: ...here.  Include
	<atomic-machine.h> instead of <bits/atomic.h>.
	* sysdeps/s390/bits/atomic.h: Move to ...
	* sysdeps/s390/atomic-machine.h: ...here.
	* sysdeps/sparc/sparc32/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc32/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/sparc/sparc32/sparcv9/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: ...here.
	* sysdeps/sparc/sparc64/bits/atomic.h: Move to ...
	* sysdeps/sparc/sparc64/atomic-machine.h: ...here.
	* sysdeps/tile/bits/atomic.h: Move to ...
	* sysdeps/tile/atomic-machine.h: ...here.
	* sysdeps/tile/tilegx/bits/atomic.h: Move to ...
	* sysdeps/tile/tilegx/atomic-machine.h: ...here.  Include
	<sysdeps/tile/atomic-machine.h> instead of
	<sysdeps/tile/bits/atomic.h>.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/tile/tilepro/bits/atomic.h: Move to ...
	* sysdeps/tile/tilepro/atomic-machine.h: ...here.  Include
	<sysdeps/tile/atomic-machine.h> instead of
	<sysdeps/tile/bits/atomic.h>.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/arm/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/arm/atomic-machine.h: ...here.  Include
	<sysdeps/arm/atomic-machine.h> instead of
	<sysdeps/arm/bits/atomic.h>.
	* sysdeps/unix/sysv/linux/hppa/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/hppa/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/m68k/coldfire/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: ...here.
	(_BITS_ATOMIC_H): Rename macro to _ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/nios2/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/nios2/atomic-machine.h: ...here.
	(_NIOS2_BITS_ATOMIC_H): Rename macro to _NIOS2_ATOMIC_MACHINE_H.
	* sysdeps/unix/sysv/linux/sh/bits/atomic.h: Move to ...
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h: ...here.
	* sysdeps/x86_64/bits/atomic.h: Move to ...
	* sysdeps/x86_64/atomic-machine.h: ...here.
	* include/atomic.h: Include <atomic-machine.h> instead of
	<bits/atomic.h>.
2015-09-11 20:00:19 +00:00
Joseph Myers 9bb69b60fa Fix ldbl-128/ldbl-128ibm lgamma spurious "invalid", incorrect signgam (bug 18952).
The ldbl-128 / ldbl-128ibm implementation of lgammal converts (the
floor of minus) non-integer negative arguments to int to determine the
value of signgam.  When those values are outside the range of int,
this produces spurious "invalid" exceptions and incorrect values of
signgam.  This patch fixes this by instead determining signgam through
comparing half the integer in question to floor of half the integer.

Tested for mips64, x86_64 and x86.

	[BZ #18952]
	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Do
	not convert non-integer negative arguments to int to determine the
	value of signgam.
	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
2015-09-11 15:34:25 +00:00
Joseph Myers 050f29c188 Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558).
The existing implementations of lgamma functions (except for the ia64
versions) use the reflection formula for negative arguments.  This
suffers large inaccuracy from cancellation near zeros of lgamma (near
where the gamma function is +/- 1).

This patch fixes this inaccuracy.  For arguments above -2, there are
no zeros and no large cancellation, while for sufficiently large
negative arguments the zeros are so close to integers that even for
integers +/- 1ulp the log(gamma(1-x)) term dominates and cancellation
is not significant.  Thus, it is only necessary to take special care
about cancellation for arguments around a limited number of zeros.

Accordingly, this patch uses precomputed tables of relevant zeros,
expressed as the sum of two floating-point values.  The log of the
ratio of two sines can be computed accurately using log1p in cases
where log would lose accuracy.  The log of the ratio of two gamma(1-x)
values can be computed using Stirling's approximation (the difference
between two values of that approximation to lgamma being computable
without computing the two values and then subtracting), with
appropriate adjustments (which don't reduce accuracy too much) in
cases where 1-x is too small to use Stirling's approximation directly.

In the interval from -3 to -2, using the ratios of sines and of
gamma(1-x) can still produce too much cancellation between those two
parts of the computation (and that interval is also the worst interval
for computing the ratio between gamma(1-x) values, which computation
becomes more accurate, while being less critical for the final result,
for larger 1-x).  Because this can result in errors slightly above
those accepted in glibc, this interval is instead dealt with by
polynomial approximations.  Separate polynomial approximations to
(|gamma(x)|-1)(x-n)/(x-x0) are used for each interval of length 1/8
from -3 to -2, where n (-3 or -2) is the nearest integer to the
1/8-interval and x0 is the zero of lgamma in the relevant half-integer
interval (-3 to -2.5 or -2.5 to -2).

Together, the two approaches are intended to give sufficient accuracy
for all negative arguments in the problem range.  Outside that range,
the previous implementation continues to be used.

Tested for x86_64, x86, mips64 and powerpc.  The mips64 and powerpc
testing shows up pre-existing problems for ldbl-128 and ldbl-128ibm
with large negative arguments giving spurious "invalid" exceptions
(exposed by newly added tests for cases this patch doesn't affect the
logic for); I'll address those problems separately.

	[BZ #2542]
	[BZ #2543]
	[BZ #2558]
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Call
	__lgamma_neg for arguments from -28.0 to -2.0.
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Call
	__lgamma_negf for arguments from -15.0 to -2.0.
	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r):
	Call __lgamma_negl for arguments from -48.0 or -50.0 to -2.0.
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c (__ieee754_lgammal_r):
	Call __lgamma_negl for arguments from -33.0 to -2.0.
	* sysdeps/ieee754/dbl-64/lgamma_neg.c: New file.
	* sysdeps/ieee754/dbl-64/lgamma_product.c: Likewise.
	* sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise.
	* sysdeps/ieee754/flt-32/lgamma_productf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/lgamma_productl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/lgamma_product.c: Likewise.
	* sysdeps/ieee754/ldbl-96/lgamma_productl.c: Likewise.
	* sysdeps/generic/math_private.h (__lgamma_negf): New prototype.
	(__lgamma_neg): Likewise.
	(__lgamma_negl): Likewise.
	(__lgamma_product): Likewise.
	(__lgamma_productl): Likewise.
	* math/Makefile (libm-calls): Add lgamma_neg and lgamma_product.
	* math/auto-libm-test-in: Add more tests of lgamma.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2015-09-10 22:27:58 +00:00
Paul Pluzhnikov d18c36e600 To fix BZ #18675, use __fstatvfs64 in __fpathconf. 2015-09-09 18:41:25 -07:00
Roland McGrath baeb80a026 BZ#18921: Mark fixed in NEWS. 2015-09-08 14:03:07 -07:00
Paul Pluzhnikov 2d8e36e691 Fix BZ #18757. 2015-09-01 08:48:15 -07:00
Brett Neumeier 3f512ca79f Fix non-v9 32-bit sparc build.
[BZ #18870]
	* sysdeps/sparc/sparc32/sem_open.c: Add missing #include
2015-08-31 15:27:47 -07:00
Paul Eggert 543ef578c3 Fix broken overflow check in posix_fallocate [BZ 18873]
* sysdeps/posix/posix_fallocate.c (posix_fallocate):
* sysdeps/posix/posix_fallocate64.c (__posix_fallocate64_l64):
Fix parenthesization typo.
2015-08-31 17:47:42 +02:00
Mike Frysinger 3f563e90e8 NEWS: add #18887 2015-08-29 18:10:50 -04:00
James Perkins cccc95f28a strptime %z: fix rounding, extend range to +/-9959 [BZ #16141]
Topic: strptime supports a %z input field descriptor, which parses a
time zone offset from UTC time into the broken-out time field tm_gmtoff.

Problems:

1) In the current implementation, the minutes portion calculation is
correct only for minutes evenly divisible by 3. This is because the
minutes value is converted to decimal time, but inadequate precision
leads to rounding which calculates results that are too low for
some values.

For example, due to rounding, a +1159 offset string results in an
incorrect tm_gmtoff of 43128 (== 11 * 3600 + 58.8 * 60) seconds,
instead of 43140 (== 11 * 3600 + 59 * 60) seconds. In contrast,
a +1157 offset (minutes divisible by 3) does not cause the bug,
and results in a correct tm_gmtoff of 43020.

2) strptime's %z specifier will not parse time offsets less than
-1200 or greater than +1200, or if only hour digits are present, less
than -12 or greater than +12. It will return NULL for offsets outside
that range. These limits do not meet historical and modern use cases:

  * Present day exceeds the +1200 limit:
    - Pacific/Auckland (New Zealand) summer time is +1300.
    - Pacific/Kiritimati (Christmas Island) is +1400.
    - Pacific/Apia (Samoa) summer time is +1400.
  * Historical offsets exceeded +1500/-1500.
  * POSIX supports -2459 to +2559.
  * Offsets up to +/-9959 may occasionally be useful.
  * Paul Eggert's notes provide additional detail:
    - https://sourceware.org/ml/libc-alpha/2014-12/msg00068.html
    - https://sourceware.org/ml/libc-alpha/2014-12/msg00072.html

3) tst-strptime2, part of the 'make check' test suite, does not test
for the above problems.

Corrective actions:

1) In time/strptime_l.c, calculate the offset from the hour and
minute portions directly, without the rounding errors introduced by
decimal time.

2) Remove the +/-1200 range limit, permitting strptime to parse offsets
from -9959 through +9959.

3) Add zone offset values to time/tst-strptime2.c.

  * Test minutes evenly divisible by three (+1157) and not evenly
    divisible by three (+1158 and +1159).
  * Test offsets near the old and new range limits (-1201, -1330, -2459,
    -2500, -99, -9959, +1201, +1330, +1400, +1401, +2559, +2600, +99,
    and +9959)

The revised strptime passes all old and new tst-strptime2 tests.
2015-08-28 23:45:51 -04:00
H.J. Lu 315267abcd Mention 15786 in NEWS
commit f3dcae82d5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Aug 25 04:33:54 2015 -0700

    Save and restore vector registers in x86-64 ld.so

also fixed

https://sourceware.org/bugzilla/show_bug.cgi?id=15786
2015-08-28 12:54:49 -07:00
Adhemerval Zanella d3573f61ac Fix wordsize-32 mmap offset for negative value (BZ#18877)
This patch fixes the default wordsize-32 mmap implementation offset
calculation for negative values.  Current code uses signed shift
operation to calculate the multiple size to use with syscall and
it is implementation defined.  Change it to use a division base
on mmap page size (default being as before, 4096).

Tested on armv7hf.

	[BZ #18877]
	* posix/Makefile (tests): Add tst-mmap-offset.
	* posix/tst-mmap.c: New file.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c (__mmap): Fix
	offset calculation for negative values.
2015-08-28 10:42:07 -03:00
Joseph Myers 8c17cb1f64 Note bug 14941 as having been fixed in 2.18. 2015-08-27 22:37:51 +00:00
Gleb Fotengauer-Malinovskiy 64d9cfd90e Mention mkdtemp as another secure alternative to mktemp
[BZ #2898]
* misc/mktemp.c: Add mkdtemp to the link_warning message.
Based on patch by Aurelien Jarno.
2015-08-27 12:43:45 +00:00
Mike Frysinger a2ab38c9b8 mips: siginfo.h: add SIGSYS details [BZ #18863]
Linux 3.13 added SIGSYS details to siginfo_t; update glibc's copy to
keep in sync with it.
2015-08-26 13:33:54 -04:00
Stefan Liebler 1efad39b22 S390: Optimize string, wcsmbs and memory functions.
This patch set introduces optimized string, wcsmbs and memory functions for
S390/S390x. The functions are accelerated by the usage of the new z13 vector
instructions.

The Principles of Operations manual for IBM z13 is publically available:
http://publibfi.boulder.ibm.com/epubs/pdf/dz9zr010.pdf

The support for these instructions in assembler was introduced by commits:
-"[Committed] S/390: Add support for IBM z13."
 (https://sourceware.org/ml/binutils/2015-01/msg00197.html)
-"[Committed] S/390: Add more IBM z13 instructions"
 (https://sourceware.org/ml/binutils/2015-03/msg00088.html)

The first patches do preparation for the latter optimization patches.
The floating point exception handling - fetestexcept(), ... - is fixed and
the platform and hwcap strings are extended.
The current ifunc routines memset, memcpy and memcmp are refactored and the
ifunc test-framework is now enabled.
A S390 specific configure-check tests if the used binutils supports the new
vector instructions. The optimized functions are provided via ifunc if the
binutils supports the vector instructions. Otherwise a message is dumped to
configure output and only the currently used common code functions are
available.

The optimized functions are implemented in common for s390-32 and s390-64
and the few differences are handled via #ifdef.

The ifunc-resolvers are defined in files sysdeps/s390/multiarch/<func>.c,
which choose either the current implementation __<func>_c() or the vector
implementation __<func>_vx() depending on the HWCAP_S390_VX flag bit in
AT_HWCAP field. If the bit is set, the hardware and the kernel are supporting
vector registers and instructions. If the used binutils lacks vector-support,
then the default implementation in string or wcsmbs directory is included
here instead.
The file sysdeps/s390/multiarch/<func>-c.c includes the current implementation
and defines the function name __<func>_c.
The assembler files sysdeps/s390/multiarch/<func>-vx.S with the vector
instructions are using the directive '.machine "z13"' to allow building glibc
without option '-march=z13'. Additionally the directive '.machinemode
"zarch_nohighgprs"' is needed for the 31bit glibc. This mode does not set the
highgprs flag in ELF header, which would lead to an unloadable libc on a 31bit
kernel.

The most optimized string functions are structured in the same way:
The first 16 bytes of the string is loaded unaligned via vlbb - vector load
to block boundary (e.g. 4k). This instruction loads 16 bytes if possible.
In case of a page cross, it only loads the last bytes of the current page
without a segmentation fault.
Afterwards these first part of string is processed. If e.g. for strlen the end
of string is reached within this first part, the function returns. Otherwise
the pointer is aligned to 16 byte, so i can load a full vector register with vl
without checking for a page cross. Afterwards the first part of string is
processed. If e.g. for strlen the end of string is reached within this first
part, the function returns. Otherwise the pointer is aligned to 16 byte, so
a full vector register can be loaded with vl - vector load - without checking
for a page cross. The remaining string is processed in a four times unrolled
loop, because benchmark results measured improvements compared to a non
unrolled loop.

The optimized wide string functions can only handle 4byte aligned string
pointers. Although a wchar_t pointer should always be 4byte aligned, the most
current common code wide string functions can handle non aligned strings.
Thus the optimized functions will fall back to the common code functions in
case of a non aligned wide string to behave the same as before this patch.

Some string tests can test the string and the wide string version of a function.
The remaining ones are extended and new wide string tests are added.
This is the same in case of the benchtests.

ChangeLog:

	* NEWS: New item for IBM z13 string optimizations.
2015-08-26 10:26:26 +02:00
Ondřej Bílka 4bd228c8a6 add bug 18240 to news. 2015-08-25 16:05:13 +02:00
Joseph Myers 2d02fd0737 Note bug 10882 as having been fixed in 2.16. 2015-08-24 14:45:32 +00:00
Ondřej Bílka 9ceeb27931 Fix exponents in manual.
* manual/macros.texi: Add twoexp macro.
	* manual/filesys.texi: Fix exponents.
	* manual/llio.texi: Likewise.
	* manual/stdio.texi: Likewise.
2015-08-20 09:43:50 +02:00
Joseph Myers 948e12a238 Fix csqrt missing underflows (bug 18370).
The csqrt implementations in glibc can miss underflow exceptions when
the real or imaginary part of the result becomes tiny in the course of
scaling down (in particular, multiplication by 0.5) and that scaling
is exact although the relevant part of the mathematical result isn't.
This patch forces the exception in a similar way to previous fixes.

Tested for x86_64 and x86.

	[BZ #18370]
	* math/s_csqrt.c (__csqrt): Force underflow exception for results
	whose real or imaginary part has small absolute value.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-08-19 22:42:01 +00:00
Andrew Senkevich 1f3be1988b Mention BZ #18796 fix in NEWS. 2015-08-19 19:48:52 +03:00
H.J. Lu 9b9d20faf6 Add BZ #14341 to NEWS 2015-08-19 06:01:58 -07:00
Marko Myllynen 441c3b59d1 Fix lang_lib/lang_term as per ISO 639-2 [BZ #16973]
lang_lib (which reflects ISO 639-2/B (bibliographic) codes) and
lang_term (which reflects ISO 639-2/T (terminology) codes) should be
identical except for those languages for which ISO 639-2 specifies
separate bibliographic/terminology values.

I used this Library of Congress page as the source:
	http://www.loc.gov/standards/iso639-2/php/code_list.php
2015-08-18 10:15:04 -04:00
Mike Frysinger 41aff137cb NEWS: note fixed bug 2015-08-18 02:59:37 -04:00
Joseph Myers 3fb4cfaf1f Fix csqrt spurious underflows (bug 18823).
The csqrt functions scale up small arguments to avoid underflows when
calling hypot functions.  However, even when hypot does not underflow,
a subsequent calculation of 0.5 * hypot can underflow.  This patch
duly increases the threshold and scale factor to avoid such underflows
as well.

Tested for x86_64, x86 and mips64.

	[BZ #18823]
	* math/s_csqrt.c (__csqrt): Increase threshold and scale factor
	for scaling up small arguments.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/auto-libm-test-in: Add more tests of csqrt.
	* math/auto-libm-test-out: Regenerated.
2015-08-17 23:02:54 +00:00
Zack Weinberg 1c70b6f155 Desupport regexp.h (bug 18681) 2015-08-16 17:34:35 +02:00
Paul Pluzhnikov d5dff793af Fix BZ #18084 -- backtrace (..., 0) dumps core on x86.
Other architectures also had bugs, or did unnecessary work.
2015-08-15 11:42:43 -07:00
Mike Frysinger 3cda1b6d56 stpncpy: fix bug number [BZ #18795]
The previous commit used 18975 instead of 18795.
2015-08-14 22:43:52 -04:00
Zack Weinberg 8ff5e0ec49 stpncpy: fix size checking [BZ #18975]
I think the last clause of the conditional,

	|| __n <= __bos (__dest)

may be backward.  The code should call the runtime-checking function
if __n is not constant, or if __n is known to be LARGER than the size
of the destination.
2015-08-14 22:40:19 -04:00
Joseph Myers 739babd775 Fix fma spurious underflows (bug 18824).
Various fma implementations have logic that, when computing fma (x, y,
z) where z is large (so care needs taking to avoid internal overflow)
but x * y is small, scale x * y up instead of down to avoid internal
underflows resulting from scaling down.  (In these cases, x * y is
small enough that only its sign actually matters rather than the exact
value.)

The threshold for scaling up instead of down was correct for "if the
unscaled values were multiplied, the low part of the multiplication
could underflow", and the scaling was sufficient to ensure that the
low part of the multiplication did not underflow (given that cases of
very small x * y - less than half the least subnormal - were
previously dealt with).  However, the choice in the functions wasn't
between scaling up or no scaling, but between scaling up and scaling
down (scaling down actually being needed when x * y isn't so small
compared to z and so the exact value does matter).  Thus a larger
threshold is needed to ensure that scaling down doesn't produce values
the multiplication of whose low parts underflows.  This patch
increases the thresholds accordingly.

Tested for x86_64, x86 and mips64 (with the MIPS version of s_fmal.c
removed so that the ldbl-128 version gets tested instead of the
soft-fp one).

	[BZ #18824]
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Increase threshold for
	scaling x * y up instead of down.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Likewise.
	* math/auto-libm-test-in: Add more tests of fma.
	* math/auto-libm-test-out: Regenerated.
2015-08-14 17:15:06 +00:00
Joseph Myers 37d83a089d Fix tanh missing underflows (bug 16520).
Similar to various other bugs in this area, some tanh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16520]
	* sysdeps/ieee754/dbl-64/s_tanh.c: Include <float.h>.
	(__tanh): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/flt-32/s_tanhf.c: Include <float.h>.
	(__tanhf): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128/s_tanhl.c: Include <float.h>.
	(__tanhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c: Include <float.h>.
	(__tanhl): Force underflow exception for arguments with small
	absolute value.
	* sysdeps/ieee754/ldbl-96/s_tanhl.c: Include <float.h>.
	(__tanhl): Force underflow exception for arguments with small
	absolute value.
	* math/auto-libm-test-in: Add more tests of tanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-08-13 16:40:39 +00:00
Paul Pluzhnikov 63e952d9be Fix BZ #18820 -- fmemopen may leak memory on failure. 2015-08-12 23:51:04 -07:00
Paul Pluzhnikov 8a29509dd9 Fix BZ #16734 -- fopen calls mmap to allocate its buffer 2015-08-12 18:56:08 -07:00
Paul Pluzhnikov 84895dca70 Fix BZ #18086 -- nice resets errno to 0. 2015-08-11 23:40:00 -07:00
Maxim Ostapenko f25238ffe0 Clear DF_1_NODELETE flag only for failed to load library.
https://sourceware.org/bugzilla/show_bug.cgi?id=18778

If dlopen fails to load an object that has triggered loading libpthread it
causes ld.so to unload libpthread because its DF_1_NODELETE flags has been
forcefully cleared. The next call to __rtdl_unlock_lock_recursive will crash
since pthread_mutex_unlock no longer exists.

This patch moves l->l_flags_1 &= ~DF_1_NODELETE out of loop through all loaded
libraries and performs the action only on inconsistent one.

	[BZ #18778]
	* elf/Makefile (tests): Add Add tst-nodelete2.
	(modules-names): Add tst-nodelete2mod.
	(tst-nodelete2mod.so-no-z-defs): New.
	($(objpfx)tst-nodelete2): Likewise.
	($(objpfx)tst-nodelete2.out): Likewise.
	(LDFLAGS-tst-nodelete2): Likewise.
	* elf/dl-close.c (_dl_close_worker): Move DF_1_NODELETE clearing
	out of loop through all loaded libraries.
	* elf/tst-nodelete2.c: New file.
	* elf/tst-nodelete2mod.c: Likewise.
2015-08-11 10:13:22 +02:00
Joseph Myers 7ee06ef158 Fix ldbl-128ibm tanhl inaccuracy (bug 18790).
ldbl-128ibm tanhl uses a too-small threshold to decide when to return
+/-1, resulting in large errors.  This patch changes it to a more
appropriate threshold (the requirement is for 2*exp(-2|x|) to be small
in terms of ulps of 1).

Tested for x86_64, x86 and powerpc.

	[BZ #18790]
	* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Increase
	threshold for returning +/- 1.
	* math/auto-libm-test-in: Add more tests of tanh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-08-10 20:35:30 +00:00
Andreas Schwab eb32b0d403 Readd O_LARGEFILE flag for openat64 (bug 18781) 2015-08-10 18:10:19 +02:00
Joseph Myers d0649b2d8e Fix ldbl-128ibm sinhl inaccuracy near 0 (bug 18789).
ldbl-128ibm sinhl uses a too-big threshold to decide when to return
the argument, resulting in large errors.  This patch fixes it to use a
more appropriate threshold.

Tested for x86_64, x86 and powerpc.

	[BZ #18789]
	* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl): Use
	smaller threshold for returning the argument.
	* math/auto-libm-test-in: Add more tests of sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-08-10 15:25:10 +00:00
H.J. Lu d2ff039fa1 Add a missing break in tst-auditmod3b.c
[BZ #18674]
	* sysdeps/i386/tst-auditmod3b.c (la_objsearch): Add a missing
	break.
2015-08-09 08:06:50 -07:00
Joseph Myers d903454267 Resort bug numbers in NEWS into ascending order. 2015-08-09 14:35:43 +00:00
John David Anglin 04ece7d2de hppa: Fix miscompilation of sched_setaffinity() [BZ #18480]
The attached change fixes the miscompilation of sched_setaffinity() on
hppa.  This is an old problem that was fixed on other architectures using
a similar approach to the attached change.  See:
https://sourceware.org/ml/libc-hacker/2004-04/msg00016.html

Build tested on trunk.  Patch has been applied to debian glibc for some time.
2015-08-08 22:56:01 -04:00
Paul Pluzhnikov 0f58539030 Fix BZ #17905 2015-08-08 15:53:03 -07:00
John David Anglin 74bc0c3a16 hppa: Fix reload error with atomic code [BZ #18787]
As noted in the bug, the asm operands need to be copied to register
variables to avoid operand reloads in the principal asm of the macro.
See the arm implementation for reference.  Otherwise we get:
../sysdeps/unix/sysv/linux/hppa/bits/atomic.h:68:6: error:
	can't find a register in class 'R1_REGS' while reloading 'asm'

Build tested on trunk with gcc-4.8.  Similar patch has been tested
with 2.19 on Debian hppa-unknown-linux-gnu.
2015-08-08 01:11:44 -04:00
Joseph Myers 37550cb3d6 Fix tan missing underflows (bug 16517).
Similar to various other bugs in this area, some tan implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16517]
	* sysdeps/ieee754/dbl-64/s_tan.c: Include <float.h>.
	(tan): Force underflow exception for arguments with small absolute
	value.
	* sysdeps/ieee754/flt-32/k_tanf.c: Include <float.h>.
	(__kernel_tanf): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/k_tanl.c: Include <float.h>.
	(__kernel_tanl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c: Include <float.h>.
	(__kernel_tanl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/k_tanl.c: Include <float.h>.
	(__kernel_tanl): Force underflow exception for arguments with
	small absolute value.
	* math/auto-libm-test-in: Add more tests of tan.
	* math/auto-libm-test-out: Regenerated.
2015-08-07 23:10:35 +00:00
Arslanbek Astemirov db2bcbcb63 locales/ce_RU: sync with other *_RU locales
[BZ #18618]
* locales/ce_RU (LC_IDENTIFICATION): Fix language.
(LC_TIME): Set first_weekday and first_workday.
(LC_NUMERIC): Copy ru_RU.
2015-08-07 11:10:23 +00:00
Joseph Myers 5e29dd5737 Fix sinh missing underflows (bug 16519).
Similar to various other bugs in this area, some sinh implementations
do not raise the underflow exception for subnormal arguments, when the
result is tiny and inexact.  This patch forces the exception in a
similar way to previous fixes.

Tested for x86_64, x86, mips64 and powerpc.

	[BZ #16519]
	* sysdeps/ieee754/dbl-64/e_sinh.c: Include <float.h>.
	(__ieee754_sinh): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/flt-32/e_sinhf.c: Include <float.h>.
	(__ieee754_sinhf): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128/e_sinhl.c: Include <float.h>.
	(__ieee754_sinhl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c: Include <float.h>.
	(__ieee754_sinhl): Force underflow exception for arguments with
	small absolute value.
	* sysdeps/ieee754/ldbl-96/e_sinhl.c: Include <float.h>.
	(__ieee754_sinhl): Force underflow exception for arguments with
	small absolute value.
	* math/auto-libm-test-in: Add more tests of sinh.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2015-08-06 23:01:09 +00:00
Zack Weinberg a03ba36305 Correct comments about the history of <regexp.h>
In the "Kill regexp.h" thread, Joseph dug up more accurate information
about exactly which editions of the Single Unix Standard included and
deprecated this header.
2015-08-05 22:38:22 -04:00
H.J. Lu 72354ab5e1 Align stack to 16 bytes when calling __errno_location
We should align stack to 16 bytes when calling __errno_location.

	[BZ #18661]
	* sysdeps/x86_64/fpu/s_cosf.S (__cosf): Align stack to 16 bytes
	when calling __errno_location.
	* sysdeps/x86_64/fpu/s_sincosf.S (__sincosf): Likewise.
	* sysdeps/x86_64/fpu/s_sinf.S (__sinf): Likewise.
2015-08-05 08:36:27 -07:00
Joseph Myers cf36e5034f Fix powf (close to -1, large) (bug 18647).
The flt-32 implementation of powf wrongly uses x-1 instead of |x|-1
when computing log (x) for the case where |x| is close to 1 and y is
large.  This patch fixes the logic accordingly.  Relevant tests
existed for x close to 1, and corresponding tests are added for x
close to -1, as well as for some new variant cases.

Tested for x86_64 and x86.

	[BZ #18647]
	* sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): For large y
	and |x| close to 1, use absolute value of x when computing log.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
2015-08-05 15:01:58 +00:00
Marko Myllynen 42eaa27fac localedata: remove timezone information [BZ #18525]
as discussed in the thread starting at

https://sourceware.org/ml/libc-alpha/2015-06/msg00098.html

it looks like the best options is to remove locale timezone information
from locales which currently provide it (in incomplete or incorrect
fashion) rather than to start duplicating tzdata info in glibc.
2015-08-05 05:02:18 -04:00
Daniel Marjamäki aeb47bbc06 Updated __nonnull annotations for wcscat, wcsncat, wcscmp and wcsncmp [BZ #18265]
This patch adds __nonnull annotations for wcscat, wcsncat, wcscmp and wcsncmp.

These added annotations match the annoations for strcat, strncat, strcmp, strncmp in glibc.
2015-08-05 04:43:42 -04:00
Andreas Schwab bbab82c25d Properly terminate FDE in makecontext for ix86 (bug 18635) 2015-08-04 17:46:56 +02:00
Zack Weinberg 2ec11c2b6e Deprecate the use of regexp.h
<regexp.h> (not to be confused with <regex.h>) is an obsolete and
frankly horrible regular expression-matching API.  It was part of SVID
but was withdrawn in Issue 5 (for reference, we're on Issue 7 now).
It doesn't do anything you can't do with <regex.h>, and using it
involves defining a bunch of macros before including the header.
Moreover, the code in regexp.h that uses those macros has been buggy
since its creation (in 1996) and no one has noticed, which indicates
to me that there are no users.  (Specifically, RETURN() is used in a
whole bunch of cases where it should have been ERROR().)

The header is given a warning and marked deprecated for 2.22.

See:
https://sourceware.org/ml/libc-alpha/2015-07/msg00862.html and
https://sourceware.org/ml/libc-alpha/2015-07/msg00871.html.
2015-08-01 14:38:05 -04:00
Mike Frysinger 0e569d30e3 hppa: add bz entry for pthreadtypes.h fix 2015-07-30 10:08:35 -04:00
H.J. Lu 9637d8a253 Extend local PLT reference check
On x86, linker in binutils 2.26 and newer consolidates R_*_JUMP_SLOT with
R_*_GLOB_DAT relocation against the same symbol.  This patch extends
local PLT reference check to support alternate relocations.

	[BZ #18078]
	* scripts/check-localplt.awk: Support alternate relocations.
	* scripts/localplt.awk: Also check relocations in DT_RELA/DT_REL
	sections.
	* sysdeps/unix/sysv/linux/i386/localplt.data: Mark free and
	malloc entries with + REL R_386_GLOB_DAT.
	* sysdeps/x86_64/localplt.data: New file.
2015-07-29 11:58:06 -07:00
Joseph Myers 3df5cd9837 Mark bug 2981 (elf/tst-audit* fail on MIPS) as fixed.
Changes in support of -fno-plt also cause the elf/tst-audit* tests to
start passing on MIPS.  This patch duly marks the relevant bug as
fixed in ChangeLog and NEWS.
2015-07-27 23:59:08 +00:00
Siddhesh Poyarekar e400f3ccd3 Use IE model for static variables in libc.so, libpthread.so and rtld
The recently introduced TLS variables in the thread-local destructor
implementation (__cxa_thread_atexit_impl) used the default GD access
model, resulting in a call to __tls_get_addr.  This causes a deadlock
with recent changes to the way TLS is initialized because DTV
allocations are delayed and hence despite knowing the offset to the
variable inside its TLS block, the thread has to take the global rtld
lock to safely update the TLS offset.

This causes deadlocks when a thread is instantiated and joined inside
a destructor of a dlopen'd DSO.  The correct long term fix is to
somehow not take the lock, but that will need a lot deeper change set
to alter the way in which the big rtld lock is used.

Instead, this patch just eliminates the call to __tls_get_addr for the
thread-local variables inside libc.so, libpthread.so and rtld by
building all of their units with -mtls-model=initial-exec.

There were concerns that the static storage for TLS is limited and
hence we should not be using it.  Additionally, dynamically loaded
modules may result in libc.so looking for this static storage pretty
late in static binaries.  Both concerns are valid when using TLSDESC
since that is where one may attempt to allocate a TLS block from
static storage for even those variables that are not IE.  They're not
very strong arguments for the traditional TLS model though, since it
assumes that the static storage would be used sparingly and definitely
not by default.  Hence, for now this would only theoretically affect
ARM architectures.

The impact is hence limited to statically linked binaries that dlopen
modules that in turn load libc.so, all that on arm hardware.  It seems
like a small enough impact to justify fixing the larger problem that
currently affects everything everywhere.

This still does not solve the original problem completely.  That is,
it is still possible to deadlock on the big rtld lock with a small
tweak to the test case attached to this patch.  That problem is
however not a regression in 2.22 and hence could be tackled as a
separate project.  The test case is picked up as is from Alex's patch.

This change has been tested to verify that it does not cause any
issues on x86_64.

ChangeLog:

	[BZ #18457]
	* nptl/Makefile (tests): New test case tst-join7.
	(modules-names): New test case module tst-join7mod.
	* nptl/tst-join7.c: New file.
	* nptl/tst-join7mod.c: New file.
	* Makeconfig (tls-model): Pass -ftls-model=initial-exec for
	all translation units in libc.so, libpthread.so and rtld.
2015-07-24 19:13:38 +05:30
Siddhesh Poyarekar 90b37cac8b Also use l_tls_dtor_count to decide on object unload (BZ #18657)
When an TLS destructor is registered, we set the DF_1_NODELETE flag to
signal that the object should not be destroyed.  We then clear the
DF_1_NODELETE flag when all destructors are called, which is wrong -
the flag could have been set by other means too.

This patch replaces this use of the flag by using l_tls_dtor_count
directly to determine whether it is safe to unload the object.  This
change has the added advantage of eliminating the lock taking when
calling the destructors, which could result in a deadlock.  The patch
also fixes the test case tst-tls-atexit - it was making an invalid
dlclose call, which would just return an error silently.

I have also added a detailed note on concurrency which also aims to
justify why I chose the semantics I chose for accesses to
l_tls_dtor_count.  Thanks to Torvald for his help in getting me
started on this and (literally) teaching my how to approach the
problem.

Change verified on x86_64; the test suite does not show any
regressions due to the patch.

ChangeLog:

	[BZ #18657]
	* elf/dl-close.c (_dl_close_worker): Don't unload DSO if there
	are pending TLS destructor calls.
	* include/link.h (struct link_map): Add concurrency note for
	L_TLS_DTOR_COUNT.
	* stdlib/cxa_thread_atexit_impl.c (__cxa_thread_atexit_impl):
	Don't touch the link map flag.  Atomically increment
	l_tls_dtor_count.
	(__call_tls_dtors): Atomically decrement l_tls_dtor_count.
	Avoid taking the load lock and don't touch the link map flag.
	* stdlib/tst-tls-atexit-nodelete.c: New test case.
	* stdlib/Makefile (tests): Use it.
	* stdlib/tst-tls-atexit.c (do_test): dlopen
	tst-tls-atexit-lib.so again before dlclose.  Add conditionals
	to allow tst-tls-atexit-nodelete test case to use it.
2015-07-23 11:16:18 +05:30
Roland McGrath 7493ab257e Add abilist files and NEWS item for arm-nacl port. 2015-07-21 13:31:21 -07:00
Mike Frysinger 7fde904c73 sparc: fix sigaction for 32bit builds [BZ #18694]
Commit a059d359d8 changed the sigaction
struct to pass conform tests, but it ended up also changing the ABI for
32 bit builds.  For 64 bit builds, changing the long to two ints works,
but for 32 bit builds, it inserts 4 extra bytes.  This leads to many
packages randomly failing like bash that spews things like:
	configure: line 471: wait_for: No record of process 0

Bracket the new member by a wordsize check to fix the ABI for 32bit.
2015-07-20 21:53:47 -04:00
H.J. Lu d4358b51c2 Add si_addr_bnd to _sigfault in x86 struct siginfo
X86 struct siginfo in kernel 3.19 has been changed by

commit ee1b58d36aa1b5a79eaba11f5c3633c88231da83
Author: Qiaowei Ren <qiaowei.ren@intel.com>
Date:   Fri Nov 14 07:18:19 2014 -0800

    mpx: Extend siginfo structure to include bound violation information

    This patch adds new fields about bound violation into siginfo
    structure. si_lower and si_upper are respectively lower bound
    and upper bound when bound violation is caused.

This patch updates x86 struct siginfo to enable GDB with MPX support.

	[BZ #18696]
	* sysdeps/unix/sysv/linux/x86/bits/siginfo.h (_sigfault): Add
	si_addr_bnd.
	(si_lower): New.
	(si_upper): Likewise.
2015-07-20 11:54:53 -07:00
Siddhesh Poyarekar b632bdd3f7 Set NODELETE flag when opening already open objects with RTLD_NODELETE
The DF_1_NODELETE flag is set too late when opening a DSO, due to
which, if a DSO is already open, subsequently opening it with
RTLD_NODELETE fails to set the DF_1_NODELETE flag.  This patch fixes
this by setting the flag immediately after bumping the opencount.

Verified on x86_64.

	[BZ #18676]
	* elf/tst-nodelete-opened.c: New test case.
	* elf/tst-nodelete-opened-lib.c: New test case module.
	* elf/Makefile (tests, modules-names): Use them.
	* elf/dl-open.c (dl_open_worker): Set DF_1_NODELETE flag
	early.
2015-07-16 08:53:28 +05:30
H.J. Lu c9328a5c4c Sort NEWS 2015-07-15 05:38:01 -07:00
Pravin Satpute 032c510db0 Correcting language code for Bhili and Tulu locales (bug 17475)
Bhili [1] and Tulu [2] language does not have iso-639-1 codes. Patch
moves locale file with correct code and also fix iso-639.def.

1. http://www-01.sil.org/iso639-3/documentation.asp?id=bhb
2. http://www-01.sil.org/iso639-3/documentation.asp?id=tcy

localedata/ChangeLog:

2015-07-02  Pravin Satpute  <psatpute@redhat.com>

	[BZ #17475]
        * locales/tu_IN: renamed to tcy_IN
	* locales/bh_IN: renamed to bhb_IN

Changelog:

2015-03-05  Pravin Satpute  <psatpute@redhat.com>

	[BZ #17475]
	* locale/iso-639.def: Update Bhili and Tulu language codes as
	per iso639-3.
2015-07-15 16:06:18 +05:30
Martin Sebor 203c1a898d The patch committed to fix bug #18435 caused regressions on aarch64
and also powerpc64 and powerpc64le. See the discussion in the thread
below for details. This change reverts the problematic bits leaving
the added test in place and marking XFAIL in anticipation of fixing
the bug in the near future.
https://sourceware.org/ml/libc-alpha/2015-07/msg00141.html

	[BZ #18435]
	* nptl/pthreadP.h (pthread_cleanup_push, pthread_cleanup_pop):
	Revert commit ed225df3ad.
	* nptl/Makefile (test-xfail-tst-once5): Define.
2015-07-09 19:27:06 -04:00
Igor Zamyatin 14c5cbabc2 Preserve bound registers for pointer pass/return
We need to save/restore bound registers and add a BND prefix before
branches in _dl_runtime_profile so that bound registers for pointer
pass and return are preserved when LD_AUDIT is used.

	[BZ #18134]
	* sysdeps/i386/configure.ac: Set HAVE_MPX_SUPPORT.
	* sysdeps/i386/configure: Regenerated.
	* sysdeps/i386/dl-trampoline.S (PRESERVE_BND_REGS_PREFIX): New.
	(_dl_runtime_profile): Save and restore Intel MPX return bound
	registers when calling _dl_call_pltexit.  Add
	PRESERVE_BND_REGS_PREFIX before return.
	* sysdeps/i386/link-defines.sym (LRV_BND0_OFFSET): New.
	(LRV_BND1_OFFSET): Likewise.
	* sysdeps/x86/bits/link.h (La_i86_retval): Add lrv_bnd0 and
	lrv_bnd1.
	* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Fix
	typo in bndmov encoding.
	* sysdeps/x86_64/dl-trampoline.h: Properly save and restore
	Intel MPX bound registers.  Add PRESERVE_BND_REGS_PREFIX before
	branch instructions to preserve bounds.
2015-07-09 06:50:12 -07:00
Szabolcs Nagy b8528e771c [AArch64][BZ 18648] change greg_t definition in ucontext.h
This is an ABI breaking change, but

	typedef int greg_t;

is not a useful definition on aarch64.

greg_t is usually used for defining gregset_t which is used
in mcontext_t.  The general registers in mcontext_t can only
be accessed by target specific code and on aarch64 greg_t
is not needed for that so this change is not supposed to break
existing code, just fix the definition.

	[BZ #18648]
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h (greg_t): Change the
	definition to elf_greg_t.

(Added another BZ entry that was missed in the previous commit).
2015-07-09 09:53:30 +01:00
Roland McGrath 95af4cffdb BZ#18383: Conditionalize test-xfail-tst-tlsalign{,-static} on ARM assembler bug. 2015-07-08 15:00:43 -07:00
Adhemerval Zanella fdb7d390dd libio: fmemopen rewrite to POSIX compliance
This patch added a new fmemopen version, for glibc 2.22, that aims to be
POSIX complaint.  It fixes some long-stading glibc fmemopen issues, such
as:

* it changes the way fseek with SEEK_END works on fmemopen to seek
  relative to buffer size instead of first '\0'.  This is default mode and
  'b' opening mode does not change internal behavior (bz#6544).

* fix apending opening mode to use as start position either first null
  byte of len specified in function call (bz#13152 and #13151).

* remove binary option 'b' and internal different handling (bz#12836)

* fix seek/SEE_END with negative values (bz#14292).

A compatibility symbol is provided to with old behavior for older symbols
version (2.2.5).

	* include/stdio.h (fmemopen): Remove hidden prototype.
	(__fmemopen): Add new hidden prototype.
	* libio/Makefile: Add oldfmemopen object.
	* libio/Versions [GLIBC_2.22]: Add new fmemopen symbol.
	* libio/fmemopen.c (__fmemopen): Function rewrite to be POSIX
	compliance.
	* libio/oldfmemopen.c: New file: old fmemopen implementation for
	symbol compatibility.
	* stdio-common/Makefile [tests]: Add new tst-fmemopen3.
	* stdio-common/psiginfo.c [psiginfo]: Call __fmemopen instead of
	fmemopen.
	* stdio-common/tst-fmemopen3.c: New file: more fmemopen tests, focus
	on append and read mode.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.22]: Add
	fmemopen.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist [GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist [GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist [GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist [GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
	[GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist [GLIBC_2.22]:
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist [GLIBC_2.22]: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist [GLIBC_2.22]: Likewise.
2015-07-08 12:07:21 -03:00
Carlos O'Donell 1c1e312520 Add missing Advanced API (RFC3542) (1) defines.
Fixes bug 18643.

Defines IPV6_RECVPATHMTU, IPV6_PATHMTU, and IPV6_DONTFRAG for Linux.
2015-07-08 10:58:23 -04:00
Mike Frysinger 61d95397de pwd.h: add __nonnull markings [BZ #18641]
Mark all the functions that don't handle NULL pointers as __nonnull.
POSIX does not require either behavior, so the prototypes should match
the reality of the codebase.
2015-07-08 03:18:27 -04:00
Carlos O'Donell 8b59c73386 Fix ruserok scalability with large ~/.rhosts file.
Fixes bug 18557.

The ruserok API does hosts checks first while it walks the
user's ~/.rhosts file. This results in lots of DNS queries
that could have been skipped if we short-circuit test the
user portion first to see if would have had a failed match.

This supports configurations where rlogin is used on internal
secure networks with large numbers of users and machines.

The Red Hat QE team did extensive testing on various rlogin
combinations to validate this change, and in fact we found
a defect in the first version which is fixed in this version.
2015-07-08 02:42:11 -04:00
Pavel Kopyl 02d5e5d94a Add forced deletion support to _dl_close_worker
https://sourceware.org/bugzilla/show_bug.cgi?id=17833

I've a shared library that contains both undefined and unique symbols.
Then I try to call the following sequence of dlopen:

1. dlopen("./libfoo.so", RTLD_NOW)
2. dlopen("./libfoo.so", RTLD_LAZY | RTLD_GLOBAL)

First dlopen call terminates with error because of undefined symbols,
but STB_GNU_UNIQUE ones set DF_1_NODELETE flag and hence block library
in the memory.

The library goes into inconsistent state as several structures remain
uninitialized. For instance, relocations for GOT table were not performed.

By the time of second dlopen call this library looks like as it would be
fully initialized but this is not true: any call through incorrect GOT
table leads to segmentation fault.  On some systems this inconsistency
triggers assertions in the dynamic linker.

This patch adds a parameter to _dl_close_worker to implement forced object
deletion in case of dlopen() failure:

1. Clears DF_1_NODELETE bit if forced, to allow library to be removed from
memory.
2. For each unique symbol that is defined in this object clears
appropriate entry in _ns_unique_sym_table.

	[BZ #17833]
	* elf/Makefile (tests): Add tst-nodelete.
	(modules-names): Add tst-nodelete-uniquemod.
	(tst-nodelete-uniquemod.so-no-z-defs): New.
	(tst-nodelete-rtldmod.so-no-z-defs): Likewise.
	(tst-nodelete-zmod.so-no-z-defs): Likewise.
	($(objpfx)tst-nodelete): Likewise.
	($(objpfx)tst-nodelete.out): Likewise.
	(LDFLAGS-tst-nodelete): Likewise.
	(LDFLAGS-tst-nodelete-zmod.so): Likewise.
	* elf/dl-close.c (_dl_close_worker): Add a parameter to
	implement forced object deletion.
	(_dl_close): Pass false to _dl_close_worker.
	* elf/dl-open.c (_dl_open): Pass true to _dl_close_worker.
	* elf/tst-nodelete.cc: New file.
	* elf/tst-nodeletelib.cc: Likewise.
	* elf/tst-znodeletelib.cc: Likewise.
	* include/dlfcn.h (_dl_close_worker): Add a new parameter.
2015-07-07 11:06:56 -07:00
Stefan Liebler 890b7a4b33 S390: Fix "backtrace() returns infinitely deep stack frames with makecontext()" [BZ #18508].
On s390/s390x backtrace(buffer, size) returns the series of called functions until
"makecontext_ret" and additional entries (up to "size") with "makecontext_ret".
GDB-backtrace is also warning:
"Backtrace stopped: previous frame identical to this frame (corrupt stack?)"

To reproduce this scenario you have to setup a new context with makecontext()
and activate it with setcontext(). See e.g. cf() function in testcase stdlib/tst-makecontext.c.
Or see bug in libgo "Bug 66303 - runtime.Caller() returns infinitely deep stack frames
on s390x " (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66303).

This patch omits the cfi_startproc/cfi_endproc directives in ENTRY/END macro of
__makecontext_ret. Thus no frame information is generated in .eh_frame and backtrace
stops after __makecontext_ret. There is also no .eh_frame info for _start or
thread_start functions.

ChangeLog:

	[BZ #18508]
	* stdlib/Makefile ($(objpfx)tst-makecontext3):
	Depend on $(libdl).
	* stdlib/tst-makecontext.c (cf): Test if _Unwind_Backtrace
	is not called infinitely times.
	(backtrace_helper): New function.
	(trace_arg): New struct.
	(st1): Enlarge stack size.
	* sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S:
	(__makecontext_ret): Omit cfi_startproc and cfi_endproc.
	* sysdeps/unix/sysv/linux/s390/s390-64/__makecontext_ret.S:
	Likewise.
2015-07-07 16:11:14 +02:00
Torvald Riegel 213a2be7b4 Do not create invalid pointers in C code of string functions.
Some of the x86 string functions create pointers based on input strings
that may be outside of the input strings.  When this happens in C code,
the compiler can potentially detect this, leading to warnings in
application code when those string functions are inlined.  Perform those
operations in the assembly code instead of the C code to fix this.
2015-07-07 13:40:12 +02:00
Andreas Schwab 01964dd663 Update NEWS 2015-07-07 12:29:14 +02:00