aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2015-10-08strcoll: Add bug-strcoll2 to testsuite (Bug 18589).Carlos O'Donell3-4/+9
Adds bug-strcoll2 to the string tests, along with the generation of required locales.
2015-10-08strcoll: Remove incorrect STRDIFF-based optimization (Bug 18589).Carlos O'Donell10-67/+116
The optimization introduced in commit f13c2a8dff2329c6692a80176262ceaaf8a6f74e, 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-08Correct "inexact" expectations in lround, llround tests.Joseph Myers2-6/+10
I noticed that some of my recently added tests of lround and llround wrongly expected the "inexact" exception to be absent for certain within-range non-integer arguments. (It's unspecified whether this exception is present or not for within-range non-integer arguments; it mustn't be present for integer arguments and out-of-range arguments.) This patch corrects those expectations. Tested for x86_64 and x86. * math/libm-test.inc (lround_test_data): Do not expect the absence of "inexact" for some tests with non-integer arguments. (llround_test_data): Likewise.
2015-10-08Remove configure tests for AVX support.Joseph Myers23-279/+137
GCC added support for -mavx and -msse2avx in version 4.4. Thus the configure tests for this support are obsolete, and this patch removes them. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by this patch). * sysdeps/i386/configure.ac (libc_cv_cc_avx): Remove configure test. (libc_cv_cc_sse2avx): Likewise. * sysdeps/i386/configure: Regenerated. * sysdeps/i386/i686/multiarch/Makefile [$(subdir)$(config-cflags-avx) = mathyes]: Change conditional to [$(subdir) = math]. * sysdeps/i386/i686/multiarch/s_fma-fma.c [HAVE_AVX_SUPPORT]: Make code unconditional. * sysdeps/i386/i686/multiarch/s_fma.c [HAVE_AVX_SUPPORT]: Likewise. * sysdeps/i386/i686/multiarch/s_fmaf-fma.c [HAVE_AVX_SUPPORT]: Likewise. * sysdeps/i386/i686/multiarch/s_fmaf.c [HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/configure.ac (libc_cv_cc_avx): Remove configure test. (libc_cv_cc_sse2avx): Likewise. * sysdeps/x86_64/configure: Regenerated. * sysdeps/x86_64/Makefile [$(config-cflags-avx) = yes]: Make code unconditional. * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_profile) [HAVE_AVX_SUPPORT || HAVE_AVX512_ASM_SUPPORT]: Make code unconditional. (_dl_runtime_profile) [!(HAVE_AVX_SUPPORT || HAVE_AVX512_ASM_SUPPORT)]: Remove conditional code. * sysdeps/x86_64/fpu/multiarch/Makefile [$(config-cflags-sse2avx) = yes]: Make code unconditional. * sysdeps/x86_64/fpu/multiarch/e_atan2.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/e_exp.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/e_log.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/s_atan.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/s_fma.c [HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/s_fmaf.c [HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/s_sin.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/fpu/multiarch/s_tan.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Likewise. * sysdeps/x86_64/multiarch/strcmp.S [HAVE_AVX_SUPPORT]: Likewise. * config.h.in (HAVE_AVX_SUPPORT): Remove #undef. (HAVE_SSE2AVX_SUPPORT): Likewise.
2015-10-08Add BZ#19086 to NEWS.Carlos O'Donell1-1/+2
2015-10-07stdio-common/tst-printf-bz18872.sh: Use attribute optimize instead ofPaul Pluzhnikov2-3/+6
This fixes build problems on arm, aarch64 and s390, which failed due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884.
2015-10-07malloc: Consistently apply trim_threshold to all heaps (Bug 17195)Carlos O'Donell2-2/+14
In the per-thread arenas we apply trim_threshold-based checks to the extra space between the pad and the top_area. This isn't quite accurate and instead we should be harmonizing with the way in which trim_treshold is applied everywhere else like sysrtim and _int_free. The trimming check should be based on the size of the top chunk and only the size of the top chunk. The following patch harmonizes the trimming and make it consistent for the main arena and thread arenas. In the old code a large padding request might have meant that trimming was not triggered. Now trimming is considered first based on the chunk, then the pad is subtracted, and the remainder trimmed. This is how all the other trimmings operate. I didn't measure the performance difference of this change because it corrects what I consider to be a behavioural anomaly. We'll need some profile driven optimization to make this code better, and even there Ondrej and others have better ideas on how to speedup malloc. Tested on x86_64 with no regressions. Already reviewed by Siddhesh Poyarekar and Mel Gorman here and discussed here: https://sourceware.org/ml/libc-alpha/2015-05/msg00002.html
2015-10-08Add task_notify to mach_interface_listSamuel Thibault3-2/+6
* sysdeps/mach/configure.ac (mach_interface_list): Add task_notify.
2015-10-07Fix lround, llround missing exceptions close to overflow threshold (bug 19088).Joseph Myers9-14/+358
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 Update timezone/Makefile to use -Wno-unused-variableSteve Ellcey2-3/+12
GCC 6.0 (prelease) complains about time_t_min and time_t_max not being used. These variables are not used in glibc but are needed in other packages. * timezone/Makefile (CFLAGS-zic.c): Add -Wno-unused-variable. (CFLAGS-ialloc.c): Ditto. (CFLAGS-scheck.c): Ditto.
2015-10-07Fix manual argument order for posix_fallocate64 (Bug 19086).Carlos O'Donell2-1/+7
The argument order for posix_fallocate64 in the manual was wrong, it was listed as [fd, len, offset] when it should have been [fd, offset, len]. Verified io/fcntl.h has the right argument order, and it does. Verified generated PDF.
2015-10-07Fix ldbl-128 lrintl, lroundl missing exceptions for 32-bit long (bug 19085).Joseph Myers4-23/+30
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-07iconvdata: Add missing const to lookup table definitionsFlorian Weimer3-2/+7
2015-10-07Use dbl-64/wordsize-64 for MIPS64.Joseph Myers3-1/+5
This patch enables use of sysdeps/ieee754/dbl-64/wordsize-64 for MIPS64 (both n64 and n32), removing a #error in one case now that case has been tested and found to work. Tested for mips64 (n64 and n32). * sysdeps/mips/mips64/Implies: Use ieee754/dbl-64/wordsize-64. * sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c (__issignaling) [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Remove #error.
2015-10-07Don't use dbl-64/wordsize-64 lround based on llround for ILP32 (bug 19079).Joseph Myers6-25/+87
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-06Add more tests of lrint, llrint, lround, llround.Joseph Myers2-0/+105
This patch adds more tests of lrint, llrint, lround and llround, to cover various standard special cases not previously covered, and more tests of overflow. Tested for x86_64 and x86. * math/libm-test.inc (lrint_test_data): Add more tests. (llrint_test_data): Likewise. (lround_test_data): Likewise. (llround_test_data): Likewise.
2015-10-06Use same test inputs for lrint and llrint.Joseph Myers2-0/+122
This patch makes lrint and llrint use the same test inputs in libm-test.inc, appropriately conditioned on LONG_MAX in the lrint case. Tested for x86_64 and x86. * math/libm-test.inc (lrint_test_data): Add tests used for llrint. (llrint_test_data): Add tests used for lrint.
2015-10-06Remove configure tests for SSE4 support.Joseph Myers12-101/+23
GCC added support for -msse4 in version 4.3. Thus the configure tests for it are obsolete, and this patch removes them. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by this patch). * sysdeps/i386/configure.ac (libc_cv_cc_sse4): Remove configure test. * sysdeps/i386/configure: Regenerated. * sysdeps/i386/i686/multiarch/Makefile [$(config-cflags-sse4) = yes]: Make code unconditional. * sysdeps/i386/i686/multiarch/strcspn.S [HAVE_SSE4_SUPPORT]: Likewise. * sysdeps/i386/i686/multiarch/strspn.S [HAVE_SSE4_SUPPORT]: Likewise. * sysdeps/x86_64/configure.ac (libc_cv_cc_sse4): Remove configure test. * sysdeps/x86_64/configure: Regenerated. * sysdeps/x86_64/multiarch/Makefile [$(config-cflags-sse4) = yes]: Make code unconditional. * sysdeps/x86_64/multiarch/strcspn.S [HAVE_SSE4_SUPPORT]: Likewise. * sysdeps/x86_64/multiarch/strspn.S [HAVE_SSE4_SUPPORT]: Likewise. * config.h.in (HAVE_SSE4_SUPPORT): Remove #undef.
2015-10-06Remove scripts/rpm2dynsym.sh.Joseph Myers2-36/+4
The file scripts/rpm2dynsym.sh appears to be unused anywhere in glibc. This patch removes this script. Tested for x86_64 and x86 (testsuite, and that installed shared libraries are unchanged by the patch). * scripts/rpm2dynsym.sh: Remove file.
2015-10-06Add a test case for C++11 thread_local supportFlorian Weimer6-1/+309
This requires a C++ compiler with thread_local support, and a new configure check is needed.
2015-10-06Fix ldbl-128ibm expl overflow in non-default rounding modes (bug 19078).Joseph Myers3-6/+9
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-06Add more scalb test expectations for "inexact" exception.Joseph Myers2-45/+51
This patch adds more libm-test.inc expectations for the "inexact" exception for scalb, in all cases except those with a non-integer second argument (where results are unspecified by POSIX, so the function does not count as fully determined and the spurious "inexact" exceptions raised by the existing implementations alongside "invalid" are OK). Tested for x86_64 and x86. * math/libm-test.inc (scalb_test_data): Add more expectations for the "inexact" exception.
2015-10-06Fix ldbl-128ibm logl (1) sign of zero result (bug 19077).Joseph Myers3-1/+7
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-06Fix ldbl-128ibm log1pl (-1) sign of infinity (bug 19076).Joseph Myers3-2/+8
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-06nss_nis: Do not call malloc_usable_size [BZ #10432]Florian Weimer3-11/+16
This is a namespace violation, and interposed malloc implementations are not required to interpose malloc_usable_size.
2015-10-06Harden tls_dtor_list with pointer mangling [BZ #19018]Florian Weimer3-3/+18
2015-10-05Fix BZ #19012 -- iconv_open leaks memory on error path.Paul Pluzhnikov3-10/+39
2015-10-05Fix ldbl-96 lroundl just below powers of 2 (bug 19071).Joseph Myers4-15/+178
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-05Don't list bug 887 as fixed for glibc 2.16.Joseph Myers1-23/+23
2015-10-05Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug ↵Joseph Myers17-14/+199
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-03sysdeps/x86_64/fpu/libm-test-ulps: Regenerated on Haswell.Paul Pluzhnikov2-1/+5
2015-10-02Fix nexttoward overflow in non-default rounding modes (bug 19059).Joseph Myers13-20/+47
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-02Fix i386 build after put*ent hardening changes.Joseph Myers4-0/+10
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-02Harden putpwent, putgrent, putspent, putspent against injection [BZ #18724]Florian Weimer22-109/+1018
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-01PowerPC: Add comments to optimized strncpyGabriel F. T. Gomes2-2/+43
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Added comments to some assembly instructions.
2015-10-01PowerPC: Fix operand prefixesGabriel F. T. Gomes2-6/+11
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-01Fix ldbl-128 / ldbl-128ibm lgamma overflow handling (bug 16347, bug 19046).Joseph Myers5-15/+686
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-01Use type-specific precision when printing results in libm-test.inc.Joseph Myers2-3/+24
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-09-30Fix ldbl-128ibm exp10l spurious overflows (bug 16620).Joseph Myers3-10/+15
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-30Fix i386 acosh (-qNaN) spurious "invalid" exception.Joseph Myers5-5/+14
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-30Improve test coverage of real libm functions [a-e]*.Joseph Myers5-9/+18891
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-30Move sysdeps/unix/sysv/linux/i386/i486/*.? to i386H.J. Lu31-254/+73
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-30Refine errno / "inexact" expectations in libm-test.inc.Joseph Myers2-1564/+1645
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-29Files open O_WRONLY not supported in fallocate emulation.Carlos O'Donell2-0/+9
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-28Fix clog, clog10 inaccuracy (bug 19016).Joseph Myers19-156/+6759
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-28Let 'make check subdirs=string' succeed even when it's invokedMartin Sebor4-3/+25
immediately after glibc has been built and before 'make check' (or after 'make clean').
2015-09-26Fix BZ #18985 -- out of range data to strftime() causes a segfaultPaul Pluzhnikov4-9/+73
2015-09-26Fix powf inaccuracy (bug 18956).Joseph Myers6-11/+49
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-25Fix pow missing underflows (bug 18825).Joseph Myers15-10/+3926
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-25Fix inconsistent passwd compensation in nss/bug17079.cFlorian Weimer2-1/+15
It used to be common practice to have a statically linked shell for an alternative root account, as in: root:x:0:0:root:/root:/bin/bash toor:x:0: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.