Commit Graph

29573 Commits

Author SHA1 Message Date
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
Paul Pluzhnikov 57352c2201 sysdeps/x86_64/fpu/libm-test-ulps: Regenerated on Haswell. 2015-10-03 11:31:21 -07: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
Joseph Myers ef6b619f73 Fix i386 build after put*ent hardening changes.
The recent put*ent hardening changes broke the build for i386.  i386
defines internal_function to __attribute__ ((regparm (3), stdcall)),
which affects type compatibility, so requiring internal_function to be
used consistently on declarations and definitions.  This patch adds
internal_function to the definitions of the new functions using it on
their declarations.

Tested for i386 that this fixes the build.

	* nss/rewrite_field.c (__nss_rewrite_field): Use
	internal_function.
	* nss/valid_field.c (__nss_valid_field): Likewise.
	* nss/valid_list_field.c (__nss_valid_list_field): Likewise.
2015-10-02 11:14:19 +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
Gabriel F. T. Gomes b0f81637d5 PowerPC: Add comments to optimized strncpy
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Added comments to some
	assembly instructions.
2015-10-01 17:36:55 -03:00
Gabriel F. T. Gomes 850713336e PowerPC: Fix operand prefixes
The file sysdeps/powerpc/sysdeps.h defines aliases for register operands,
which add the letter 'r' as a prefix to a register name.  E.g.: register 20
can be written as 'r20', instead of '20'.  On the one hand, this increases
readability, as it makes it easier for readers to know whether the operand is a
register or an immediate.  On the other hand, this permits that immediate
operands be written as if they were registers, and vice-versa, thus reducing
the readability of the code.

This commit removes some of these unintentional misuses.

This commit also increases readability of the code by adding the prefix 'cr' to
some uses of the control register.

Both changes have no effect on the final code.  Checked with objdump.

	* sysdeps/powerpc/powerpc64/power8/strncpy.S: Remove or add register
	prefix from operands.
2015-10-01 17:36:46 -03: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 e27fcd027c Use type-specific precision when printing results in libm-test.inc.
When libm-test.inc prints the results of failing tests, the output can
be unhelpful for ldbl-128 and ldbl-128ibm because the precision used
is insufficient to distinguish values of those types, resulting in
reported values that look identical but differ by a large number of
ulps.

This patch changes it to use a precision appropriate for the type, for
both decimal and hex output (so output for float is more compact,
output for ldbl-128 and ldbl-128ibm is substantially wider).  The
natural precision to use for decimal is given by the C11 <float.h>
macros such as FLT_DECIMAL_DIG.  GCC's <float.h> only defines those in
C11 mode, so this patch uses the predefines such as
__FLT_DECIMAL_DIG__ (added in GCC 4.6) instead; if we move to building
with -std=gnu11 (or -std=gnu1x if we can't get rid of 4.6 support).

Tested for powerpc and mips64.

	* math/libm-test.inc (TYPE_DECIMAL_DIG): New macro.
	(TYPE_HEX_DIG): Likewise.
	(print_float): Use TYPE_DECIMAL_DIG - 1 and TYPE_HEX_DIG - 1 as
	precisions when printing floating-point numbers.
	(check_float_internal): Likewise.
2015-10-01 15:24: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 93e448cbed Improve test coverage of real libm functions [a-e]*.
This patch improves test coverage of the real libm functions [a-e]*,
ensuring that special cases and ranges of input values of potential
significance (such as close to overflow and underflow thresholds) are
more systematically covered.

This is a followup to
<https://sourceware.org/ml/libc-alpha/2013-12/msg00757.html> which
covered [a-c]* (however, I found more weaknesses in the coverage of
those functions when preparing this patch, hence the additional tests
being added for them here).

Addition of a test for acosh (-qNaN) is temporarily deferred, to be
included as part of a fix for bug 19032 which was discovered in the
course of adding these tests (and which illustrates the use of testing
-qNaN as well as +qNaN as input even to functions for which the sign
of a NaN isn't meant to be significant).

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Add more tests of acos, acosh, asin,
	atan, atan2, atanh, cbrt, cos, cosh, erf, erfc, exp, exp10, exp2
	and expm1.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (acos_test_data): Add more tests.
	(asin_test_data): Likewise.
	(asinh_test_data): Likewise.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Likewise.
	(cbrt_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	(cos_test_data): Likewise.
	(cosh_test_data): Likewise.
	(erf_test_data): Likewise.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp10_test_data): Likewise.
	(exp2_test_data): Likewise.
	(expm1_test_data): Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.
2015-09-30 18:06:02 +00:00
H.J. Lu f6d1d86d0c Move sysdeps/unix/sysv/linux/i386/i486/*.? to i386
Since glibc doesn't support i386 any more, we can move
sysdeps/unix/sysv/linux/i386/i486/*.? to i386.

	[BZ #19006]
	* sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/libc-lowlevellock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lll_timedlock_wait.c: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lll_timedlock_wait.c: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lll_timedwait_tid.c: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lll_timedwait_tid.c: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Moved to ...
	* sysdeps/unix/sysv/linux/i386/lowlevellock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/lowlevelrobustlock.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_barrier_wait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_broadcast.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_signal.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S:
	Moved to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_timedwait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Moved
	to ...
	* sysdeps/unix/sysv/linux/i386/pthread_cond_wait.S: Here.
	* sysdeps/unix/sysv/linux/i386/i586/libc-lowlevellock.S:
	Removed.
	* sysdeps/unix/sysv/linux/i386/i586/lll_timedlock_wait.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lll_timedwait_tid.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/lowlevelrobustlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_barrier_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/libc-lowlevellock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lll_timedlock_wait.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lll_timedwait_tid.c:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lowlevellock.S: Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/lowlevelrobustlock.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_barrier_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S:
	Likewise.
	* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S:
	Replace ../i486/pthread_cond_timedwait.S with
	../pthread_cond_timedwait.S.
2015-09-30 10:12:44 -07:00
Joseph Myers 629d220d49 Refine errno / "inexact" expectations in libm-test.inc.
This patch makes math/libm-test.inc more consistent regarding
including expectations for errno setting and "inexact" exceptions
where expected test results are given manually.  Mostly this is a
matter of including ERRNO_UNCHANGED in expectations, but there are
also some cases where expectations regarding "inexact" were missing
for exactly determined functions (especially in cases where some other
exception was expected and it should also have been expected that
"inexact" was not set with that other exception), and one case for pow
where the NO_INEXACT_EXCEPTION expectation should not have been there
(the rule about not having "inexact" exceptions for NaN arguments is
only when those NaN arguments produce NaN results).

I deferred making such changes for complex functions and scalb.

Tested for x86_64 and x86.

	* math/libm-test.inc (acos_test_data): Refine expectations for
	errno and "inexact" exceptions.
	(acosh_test_data): Likewise.
	(asin_test_data): Likewise.
	(asinh_test_data): Likewise.
	(atan_test_data): Likewise.
	(atanh_test_data): Likewise.
	(atan2_test_data): Likewise.
	(cbrt_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	(cosh_test_data): Likewise.
	(erf_test_data): Likewise.
	(erfc_test_data): Likewise.
	(exp_test_data): Likewise.
	(exp10_test_data): Likewise.
	(exp2_test_data): Likewise.
	(expm1_test_data): Likewise.
	(fabs_test_data): Likewise.
	(floor_test_data): Likewise.
	(fma_test_data): Likewise.
	(fmax_test_data): Likewise.
	(fmin_test_data): Likewise.
	(fmod_test_data): Likewise.
	(fpclassify_test_data): Likewise.
	(frexp_test_data): Likewise.
	(hypot_test_data): Likewise.
	(ilogb_test_data): Likewise.
	(isgreater_test_data): Likewise.
	(isgreaterequal_test_data): Likewise.
	(isinf_test_data): Likewise.
	(isless_test_data): Likewise.
	(islessequal_test_data): Likewise.
	(islessgreater_test_data): Likewise.
	(isnan_test_data): Likewise.
	(isnormal_test_data): Likewise.
	(issignaling_test_data): Likewise.
	(isunordered_test_data): Likewise.
	(j0_test_data): Likewise.
	(j1_test_data): Likewise.
	(jn_test_data): Likewise.
	(lgamma_test_data): Likewise.
	(lrint_test_data): Likewise.
	(llrint_test_data): Likewise.
	(log_test_data): Likewise.
	(log10_test_data): Likewise.
	(log1p_test_data): Likewise.
	(log2_test_data): Likewise.
	(logb_test_data): Likewise.
	(lround_test_data): Likewise.
	(llround_test_data): Likewise.
	(modf_test_data): Likewise.
	(nearbyint_test_data): Likewise.
	(nextafter_test_data): Likewise.
	(nexttoward_test_data): Likewise.
	(pow_test_data): Likewise.
	(remainder_test_data): Likewise.
	(remquo_test_data): Likewise.
	(rint_test_data): Likewise.
	(round_test_data): Likewise.
	(signbit_test_data): Likewise.
	(sinh_test_data): Likewise.
	(sqrt_test_data): Likewise.
	(tanh_test_data): Likewise.
	(tgamma_test_data): Likewise.
	(trunc_test_data): Likewise.
	(y0_test_data): Likewise.
	(y1_test_data): Likewise.
	(yn_test_data): Likewise.
	(significand_test_data): Likewise.
2015-09-30 15:30:41 +00:00
Carlos O'Donell 032f225008 Files open O_WRONLY not supported in fallocate emulation.
In the posix_fallocate description in the manual we list various
drawbacks with the emulation, including the fact that a file opened
with O_APPEND fails with EBADF. Similarly a file opened with O_WRONLY
fails with EBADF. We must be able to emulate a compare-and-swap via
pread/compare/pwrite in order to make the emulation as safe as possible.
It is not acceptable to ignore the read failure because it could result
in significant data loss across all of the blocks. There is no other way
to make this work without a true atomic CAS and SIGBUS handler (which
is looking more attractive as a way to remove the race condition).

This patch adds O_WRONLY to the manual as another bullet to clarify the
limits of the emulation.

Manual looks good in PDF.
2015-09-29 11:32:36 -04: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
Florian Weimer 5a9af6376d Fix inconsistent passwd compensation in nss/bug17079.c
It used to be common practice to have a statically linked shell for an
alternative root account, as in:

root0:0:root:/root:/bin/bash
toor0:0:root recovery account:/root:/sbin/sash

This causes problems with passwd NSS tests because a UID-based lookup
will only retrieve one of those entries.  The original version of
nss/bug17079.c detected this, but failed to use this information later
on.
2015-09-25 20:20:33 +02:00
Joseph Myers 775e99641e Use soft-fp fma for no-FPU ColdFire (bug 13304).
Systems without floating-point exceptions and rounding modes should
use the soft-fp versions of fmaf and fma, not the sysdeps/ieee754
versions that rely on setting rounding to zero and testing for the
"inexact" exception; this has been noted on
<https://sourceware.org/glibc/wiki/PortStatus> for some time.  This
patch makes no-FPU ColdFire use the soft-fp files; sfp-machine.h is
made to include the nios2 version of sfp-machine.h which seems
sufficiently generic for 32-bit systems.

	[BZ #13304]
	* sysdeps/m68k/coldfire/nofpu/s_fma.c: New file.
	* sysdeps/m68k/coldfire/nofpu/s_fmaf.c: Likewise.
	* sysdeps/m68k/coldfire/nofpu/sfp-machine.h: Likewise.
2015-09-25 17:30:56 +00:00
Joseph Myers 02c48b21b5 Use soft-fp fma for MicroBlaze (bug 13304).
Systems without floating-point exceptions and rounding modes should
use the soft-fp versions of fmaf and fma, not the sysdeps/ieee754
versions that rely on setting rounding to zero and testing for the
"inexact" exception; this has been noted on
<https://sourceware.org/glibc/wiki/PortStatus> for some time.  This
patch makes MicroBlaze use the soft-fp files; sfp-machine.h is made to
include the nios2 version of sfp-machine.h which seems sufficiently
generic for 32-bit systems.

	[BZ #13304]
	* sysdeps/microblaze/s_fma.c: New file.
	* sysdeps/microblaze/s_fmaf.c: Likewise.
	* sysdeps/microblaze/sfp-machine.h: Likewise.
2015-09-25 17:29:19 +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
Steve Ellcey 2fd9177c92 Add missing ChangeLog entry.
I forgot the ChangeLog entry with my patch to sysdeps/mips/math_private.h.
2015-09-24 16:38:43 -07:00
Steve Ellcey 35e977b003 Add unused attribute to declaration for mips16 builds.
2015-09-24  Steve Ellcey  <sellcey@imgtec.com>

 	* sysdeps/mips/math_private.h (libc_fesetenv_mips): Mark cw as unused.
2015-09-24 16:12:49 -07:00
Joseph Myers b2a64460ba Refactor x86_64 libm code forcing underflow exceptions.
This patch refactors code in sysdeps/x86_64/fpu that forces underflow
exceptions and closely follows corresponding i386 code to use common
macros in x86_64-math-asm.h for that purpose.  This is mainly about
keeping the code similar to the i386 code as far as possible, since
each macro apart from DEFINE_LDBL_MIN ends up used only once.  It
would be possible to do a further refactoring to share these macros
between i386 and x86_64 (with i386 using the fcomip / fucomip versions
when building for i686 and above), but I have no immediate plans to do
so.

Tested for x86_64.

	* sysdeps/x86_64/fpu/x86_64-math-asm.h: New file.
	* sysdeps/x86_64/fpu/e_exp2l.S: Include <x86_64-math-asm.h>.
	(ldbl_min): Replace with use of DEFINE_LDBL_MIN.
	(__ieee754_exp2l): Use LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN.
	* sysdeps/x86_64/fpu/e_expl.S: Include <x86_64-math-asm.h>.
	[!USE_AS_EXPM1L] (cmin): Replace with use of DEFINE_LDBL_MIN.
	(IEEE754_EXPL): Use LDBL_CHECK_FORCE_UFLOW_NONNEG.
2015-09-24 22:25:30 +00:00
Joseph Myers 1a19b8894f Use LOAD_PIC_REG in i386 atanh.
sysdeps/i386/fpu/e_atanh.S, unlike all other functions in that
directory, loads the PIC register with its own code using
_GLOBAL_OFFSET_TABLE_, rather than with the LOAD_PIC_REG macro.  I see
no good reason for the difference; this patch makes it use the common
macro.

Tested for x86.

	* sysdeps/i386/fpu/e_atanh.S (__ieee754_atanh) [PIC]: Use
	LOAD_PIC_REG.
2015-09-24 21:48:22 +00:00
Joseph Myers 37825319ee Refactor i386 libm code forcing underflow exceptions.
This patch refactors code in sysdeps/i386/fpu that forces underflow
exceptions to use common macros for that purpose as far as possible.
(Although some of the macros end up used in only one place, I think
it's cleanest to define all these macros together so that all the code
forcing underflow uses such macros.  Some more uses of such macros
will also be introduced when fixing remaining bugs about missing
underflow exceptions, and it would be possible to do further
refactoring of the macros in i386-math-asm.h to share more code by
using other macros internally.  Places that test for underflow by
examining the representation of the argument with integer operations,
rather that using floating-point comparisons on the argument or
result, are unchanged by this patch.)

Most of this code uses a macro MO to abstract away the differences
between PIC and non-PIC memory references to constants.  log1p
functions, however, hardcoded PIC conditionals for this.  Because the
common macros rely on the use of MO, I changed the log1p functions to
use the normal style here, and, for consistency, also made that change
to log1pl which is otherwise unaffected by this patch.

Tested for x86.

	* sysdeps/i386/fpu/i386-math-asm.h (DEFINE_LDBL_MIN): New macro.
	(FLT_CHECK_FORCE_UFLOW): Likewise.
	(DBL_CHECK_FORCE_UFLOW): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NARROW): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NARROW): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NONNAN): Likewise.
	(FLT_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	(DBL_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	(LDBL_CHECK_FORCE_UFLOW_NONNEG): Likewise.
	* sysdeps/i386/fpu/e_asin.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_asin): Use DBL_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/e_asinf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_asinf): Use FLT_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/e_atan2.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_atan2): Use DBL_CHECK_FORCE_UFLOW_NARROW.
	* sysdeps/i386/fpu/e_atan2f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_atan2f): Use FLT_CHECK_FORCE_UFLOW_NARROW.
	* sysdeps/i386/fpu/e_atanh.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__ieee754_atanh): Use DBL_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_atanhf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__ieee754_atanhf): Use FLT_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/e_exp2l.S: Include <i386-math-asm.h>.
	(ldbl_min): Replace with use of DEFINE_LDBL_MIN.
	(__ieee754_exp2l): Use LDBL_CHECK_FORCE_UFLOW_NONNEG_NAN.
	* sysdeps/i386/fpu/e_expl.S: Include <i386-math-asm.h>.
	[!USE_AS_EXPM1L] (cmin): Replace with use of DEFINE_LDBL_MIN.
	(IEEE754_EXPL): Use LDBL_CHECK_FORCE_UFLOW_NONNEG.
	* sysdeps/i386/fpu/s_atan.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__atan): Use DBL_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/s_atanf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__atanf): Use FLT_CHECK_FORCE_UFLOW.
	* sysdeps/i386/fpu/s_expm1.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(__expm1): Use DBL_CHECK_FORCE_UFLOW.  Move underflow check after
	main computation.
	* sysdeps/i386/fpu/s_expm1f.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(__expm1f): Use FLT_CHECK_FORCE_UFLOW.  Move underflow check after
	main computation.
	* sysdeps/i386/fpu/s_log1p.S: Include <i386-math-asm.h>.
	(dbl_min): Replace with use of DEFINE_DBL_MIN.
	(MO): New macro.
	(__log1p): Use MO.  Use DBL_CHECK_FORCE_UFLOW_NONNAN.
	* sysdeps/i386/fpu/s_log1pf.S: Include <i386-math-asm.h>.
	(flt_min): Replace with use of DEFINE_FLT_MIN.
	(MO): New macro.
	(__log1pf): Use MO.  Use FLT_CHECK_FORCE_UFLOW_NONNAN.
	* sysdeps/i386/fpu/s_log1pl.S (MO): New macro.
	(__log1pl): Use MO.
2015-09-24 21:41:00 +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
Szabolcs Nagy 24ffcbfc24 Regenerate aarch64 libm-test-ulps
* sysdeps/aarch64/libm-test-ulps: Regenerated.
2015-09-24 14:22:31 +01:00
Joseph Myers cfcbebf7ac Don't use volatile in exp2f.
sysdeps/ieee754/flt-32/e_exp2f.c declares two variable as "static
const volatile float".  Maybe this use of "volatile" was originally
intended to inhibit optimization of underflowing / overflowing
operations such as TWOM100 * TWOM100; in any case, it's not currently
needed, as given -frounding-math constant folding of such expressions
is properly disabled when it would be unsafe.  This patch removes the
unnecessary use of "volatile".

Tested for x86_64.

	* sysdeps/ieee754/flt-32/e_exp2f.c (TWOM100): Remove volatile.
	(TWO127): Likewise.
2015-09-23 22:52:13 +00:00
Joseph Myers d96164c330 Refactor code forcing underflow exceptions.
Various floating-point functions have code to force underflow
exceptions if a tiny result was computed in a way that might not have
resulted in such exceptions even though the result is inexact.  This
typically uses math_force_eval to ensure that the underflowing
expression is evaluated, but sometimes uses volatile.

This patch refactors such code to use three new macros
math_check_force_underflow, math_check_force_underflow_nonneg and
math_check_force_underflow_complex (which in turn use
math_force_eval).  In the limited number of cases not suited to a
simple conversion to these macros, existing uses of volatile are
changed to use math_force_eval instead.  The converted code does not
always execute exactly the same sequence of operations as the original
code, but the overall effects should be the same.

Tested for x86_64, x86, mips64 and powerpc.

	* sysdeps/generic/math_private.h (fabs_tg): New macro.
	(min_of_type): Likewise.
	(math_check_force_underflow): Likewise.
	(math_check_force_underflow_nonneg): Likewise.
	(math_check_force_underflow_complex): Likewise.
	* math/e_exp2l.c (__ieee754_exp2l): Use
	math_check_force_underflow_nonneg.
	* math/k_casinh.c (__kernel_casinh): Likewise.
	* math/k_casinhf.c (__kernel_casinhf): Likewise.
	* math/k_casinhl.c (__kernel_casinhl): Likewise.
	* math/s_catan.c (__catan): Use
	math_check_force_underflow_complex.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* math/s_ccosh.c (__ccosh): Likewise.
	* math/s_ccoshf.c (__ccoshf): Likewise.
	* math/s_ccoshl.c (__ccoshl): Likewise.
	* math/s_cexp.c (__cexp): Likewise.
	* math/s_cexpf.c (__cexpf): Likewise.
	* math/s_cexpl.c (__cexpl): Likewise.
	* math/s_clog.c (__clog): Use math_check_force_underflow_nonneg.
	* 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/s_csin.c (__csin): Use math_check_force_underflow_complex.
	* math/s_csinf.c (__csinf): Likewise.
	* math/s_csinh.c (__csinh): Likewise.
	* math/s_csinhf.c (__csinhf): Likewise.
	* math/s_csinhl.c (__csinhl): Likewise.
	* math/s_csinl.c (__csinl): Likewise.
	* math/s_csqrt.c (__csqrt): Use math_check_force_underflow.
	* math/s_csqrtf.c (__csqrtf): Likewise.
	* math/s_csqrtl.c (__csqrtl): Likewise.
	* math/s_ctan.c (__ctan): Use math_check_force_underflow_complex.
	* 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.
	* stdlib/strtod_l.c (round_and_return): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/dbl-64/e_asin.c (__ieee754_asin): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/e_atanh.c (__ieee754_atanh): Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Do not use
	volatile when forcing underflow.
	* sysdeps/ieee754/dbl-64/e_exp2.c (__ieee754_exp2): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
	Likewise.
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
	* sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise.
	* sysdeps/ieee754/dbl-64/s_atan.c (atan): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/s_erf.c (__erf): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/s_expm1.c (__expm1): Likewise.
	* sysdeps/ieee754/dbl-64/s_fma.c (__fma): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/dbl-64/s_log1p.c (__log1p): Use
	math_check_force_underflow.
	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Likewise.
	* sysdeps/ieee754/dbl-64/s_tan.c (tan): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/dbl-64/s_tanh.c (__tanh): Use
	math_check_force_underflow.
	* sysdeps/ieee754/flt-32/e_asinf.c (__ieee754_asinf): Likewise.
	* sysdeps/ieee754/flt-32/e_atanhf.c (__ieee754_atanhf): Likewise.
	* sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
	Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Use
	math_check_force_underflow.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
	* sysdeps/ieee754/flt-32/e_sinhf.c (__ieee754_sinhf): Likewise.
	* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.
	* sysdeps/ieee754/flt-32/k_tanf.c (__kernel_tanf): Likewise.
	* sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise.
	* sysdeps/ieee754/flt-32/s_atanf.c (__atanf): Likewise.
	* sysdeps/ieee754/flt-32/s_erff.c (__erff): Likewise.
	* sysdeps/ieee754/flt-32/s_expm1f.c (__expm1f): Likewise.
	* sysdeps/ieee754/flt-32/s_log1pf.c (__log1pf): Likewise.
	* sysdeps/ieee754/flt-32/s_tanhf.c (__tanhf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_atanhl.c (__ieee754_atanhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_expl.c (__ieee754_expl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
	Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-128/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_sincosl.c (__kernel_sincosl):
	Likewise.
	* sysdeps/ieee754/ldbl-128/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128/k_tanl.c (__kernel_tanl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_asinhl.c (__asinhl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_atanl.c (__atanl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Likewise.
	* sysdeps/ieee754/ldbl-128/s_fmal.c (__fmal): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128ibm/e_atanhl.c (__ieee754_atanhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
	Use math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_sincosl.c (__kernel_sincosl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c (__kernel_tanl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_atanl.c (__atanl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_asinl.c (__ieee754_asinl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_sinhl.c (__ieee754_sinhl): Likewise.
	* sysdeps/ieee754/ldbl-96/k_sinl.c (__kernel_sinl): Likewise.
	* sysdeps/ieee754/ldbl-96/k_tanl.c (__kernel_tanl): Use
	math_check_force_underflow_nonneg.
	* sysdeps/ieee754/ldbl-96/s_asinhl.c (__asinhl): Use
	math_check_force_underflow.
	* sysdeps/ieee754/ldbl-96/s_erfl.c (__erfl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c (__fmal): Use math_force_eval
	instead of volatile.
	* sysdeps/ieee754/ldbl-96/s_tanhl.c (__tanhl): Use
	math_check_force_underflow.
2015-09-23 22:42:30 +00:00
Joseph Myers 54142c44e9 Use math_narrow_eval more consistently.
Where glibc code needs to avoid excess range and precision in
floating-point arithmetic, code variously uses either asms or volatile
to force the results of that arithmetic to memory; mostly this is
conditional on FLT_EVAL_METHOD, but in the case of lrint / llrint
functions some use of volatile is unconditional (and is present
unnecessarily in versions for long double).  This patch make such code
use the recently-added math_narrow_eval macro consistently, removing
the unnecessary uses of volatile in long double lrint / llrint
implementations completely.

Tested for x86_64, x86, mips64 and powerpc.

	* math/s_nexttowardf.c (__nexttowardf): Use math_narrow_eval.
	* stdlib/strtod_l.c: Include <math_private.h>.
	(overflow_value): Use math_narrow_eval.
	(underflow_value): Likewise.
	* sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise.
	* sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Likewise.
	(__ieee754_gamma_r): Likewise.
	* sysdeps/ieee754/dbl-64/gamma_productf.c (__gamma_productf):
	Likewise.
	* sysdeps/ieee754/dbl-64/k_rem_pio2.c (__kernel_rem_pio2):
	Likewise.
	* sysdeps/ieee754/dbl-64/lgamma_neg.c (__lgamma_neg): Likewise.
	* sysdeps/ieee754/dbl-64/s_erf.c (__erfc): Likewise.
	* sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise.
	* sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
	(__ieee754_gammaf_r): Likewise.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c (__kernel_rem_pio2f):
	Likewise.
	* sysdeps/ieee754/flt-32/lgamma_negf.c (__lgamma_negf): Likewise.
	* sysdeps/ieee754/flt-32/s_erff.c (__erfcf): Likewise.
	* sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise.
	* sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Do not use
	volatile.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward): Use
	math_narrow_eval.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c (__nexttoward):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-96/gamma_product.c (__gamma_product):
	Likewise.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Do not use
	volatile.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise.
	* sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Use
	math_narrow_eval.
	* sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf):
	Likewise.
	* sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf):
	Likewise.
2015-09-23 18:14:57 +00:00
H.J. Lu 5df386a549 Remove ignored symbols from nptl/Versions
Those ignored symbols are listed a few lines below.

	* nptl/Versions: Remove ignored symbols.
2015-09-22 09:32:38 -07:00
Florian Weimer 90fa42a1d7 Test in commit e07aabba73 is for bug 17079 2015-09-22 13:40:17 +02:00
Florian Weimer e07aabba73 Add test case for bug 18287 2015-09-22 13:20:18 +02:00
Samuel Thibault c77dd7eb9b Add missing __mach_host_self_ symbol in Versions
* mach/Versions (__mach_host_self_): Add symbol.
2015-09-22 02:02:20 +02:00
Samuel Thibault 51a3985d97 Fix vm_page_size visibility
* sysdeps/mach/hurd/mmap.c (__mmap): Use __vm_page_size instead of
	vm_page_size.
2015-09-21 00:08:51 +02:00
Samuel Thibault b0b64e1b5e Really fix sysdeps/i386/fpu/s_scalbn.S build
* math/Versions (libc: GLIBC_2_20): New (empty) version set.
	(libc: GLIBC_2_22): Remove unused version set.
2015-09-19 14:23:16 +02:00
Mike Frysinger 1cba4036b6 timezone: add a configure flag to disable program install
Some distros build+install the timezone tools (zic/zdump/tzselect) outside
of glibc and use the upstream package directly.  Add a configure flag to
glibc so they can disable install of those tools.

This allows tests to run & pass regardless of the configure flag.  Only
the install of them is impacted.
2015-09-18 19:39:46 -04:00
Joseph Myers 36546ffbef Revert timezone/Makefile change.
This change breaks the build with all released versions of GCC.

	* timezone/Makefile: Revert previous change.
2015-09-18 22:02: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
Wilco Dijkstra 1344384b52 Undo build error fixes to timezone/private.h, change makefile instead to
ignore the errors.

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

        * timezone/Makefile: Ignore unused variable errors due to private.h
        (time_t_min) and (time_t_max).
        * timezone/private.h (time_t_min): Revert removal.  (time_t_max):
        Likewise.
2015-09-18 21:43:43 +01: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