about summary refs log tree commit diff
path: root/sysdeps/ieee754/flt-32/e_lgammaf_r.c
Commit message (Collapse)AuthorAgeFilesLines
* Narrowing the visibility of libc-internal.h even further.Zack Weinberg2017-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; similar to what was done with libc-diag.h, I have split the definitions of cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN to a new header, libc-pointer-arith.h. It then occurred to me that the remaining declarations in libc-internal.h are mostly to do with early initialization, and probably most of the files including it, even in the core code, don't need it anymore. Indeed, only 19 files actually need what remains of libc-internal.h. 23 others need libc-diag.h instead, and 12 need libc-pointer-arith.h instead. No file needs more than one of them, and 16 don't need any of them! So, with this patch, libc-internal.h stops including libc-diag.h as well as losing the pointer arithmetic macros, and all including files are adjusted. * include/libc-pointer-arith.h: New file. Define cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN here. * include/libc-internal.h: Definitions of above macros moved from here. Don't include libc-diag.h anymore either. * posix/wordexp-test.c: Include stdint.h and libc-pointer-arith.h. Don't include libc-internal.h. * debug/pcprofile.c, elf/dl-tunables.c, elf/soinit.c, io/openat.c * io/openat64.c, misc/ptrace.c, nptl/pthread_clock_gettime.c * nptl/pthread_clock_settime.c, nptl/pthread_cond_common.c * string/strcoll_l.c, sysdeps/nacl/brk.c * sysdeps/unix/clock_settime.c * sysdeps/unix/sysv/linux/i386/get_clockfreq.c * sysdeps/unix/sysv/linux/ia64/get_clockfreq.c * sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c * sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c: Don't include libc-internal.h. * elf/get-dynamic-info.h, iconv/loop.c * iconvdata/iso-2022-cn-ext.c, locale/weight.h, locale/weightwc.h * misc/reboot.c, nis/nis_table.c, nptl_db/thread_dbP.h * nscd/connections.c, resolv/res_send.c, soft-fp/fmadf4.c * soft-fp/fmasf4.c, soft-fp/fmatf4.c, stdio-common/vfscanf.c * sysdeps/ieee754/dbl-64/e_lgamma_r.c * sysdeps/ieee754/dbl-64/k_rem_pio2.c * sysdeps/ieee754/flt-32/e_lgammaf_r.c * sysdeps/ieee754/flt-32/k_rem_pio2f.c * sysdeps/ieee754/ldbl-128/k_tanl.c * sysdeps/ieee754/ldbl-128ibm/k_tanl.c * sysdeps/ieee754/ldbl-96/e_lgammal_r.c * sysdeps/ieee754/ldbl-96/k_tanl.c, sysdeps/nptl/futex-internal.h: Include libc-diag.h instead of libc-internal.h. * elf/dl-load.c, elf/dl-reloc.c, locale/programs/locarchive.c * nptl/nptl-init.c, string/strcspn.c, string/strspn.c * malloc/malloc.c, sysdeps/i386/nptl/tls.h * sysdeps/nacl/dl-map-segments.h, sysdeps/x86_64/atomic-machine.h * sysdeps/unix/sysv/linux/spawni.c * sysdeps/x86_64/nptl/tls.h: Include libc-pointer-arith.h instead of libc-internal.h. * elf/get-dynamic-info.h, sysdeps/nacl/dl-map-segments.h * sysdeps/x86_64/atomic-machine.h: Add multiple include guard.
* Fix lgamma*, log10* and log2* results [BZ #21171]Tulio Magno Quites Machado Filho2017-02-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | lgamma(-x) should return +Inf and raise divide-by-zero. log10(+-0) and log2(+-0) should return -Inf and raise divide-by-zero. Tested on powerpc, powerpc64, powerpc64le and x86_64. [BZ #21171] * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Return +Inf and raise divide-by-zero when x is negative. * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Likewise. * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Likewise. * sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Return -Inf and raise divide-by-zero when x = +-0. * sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise. * sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f): Likewise. * sysdeps/ieee754/flt-32/e_log2f.c (__ieee754_log2f): Likewise. * sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Likewise. * sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l): Likewise.
* Remove GCC version conditionals on -Wmaybe-uninitialized pragmas.Joseph Myers2015-10-271-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One common case of __GNUC_PREREQ (4, 7) conditionals is use of diagnostic control pragmas for -Wmaybe-uninitialized, an option introduced in GCC 4.7 where older GCC needed -Wuninitialized to be controlled instead if the warning appeared with older GCC. This patch removes such conditionals. (There remain several older uses of -Wno-uninitialized in makefiles that still need to be converted to diagnostic control pragmas if the issue is still present with current sources and supported GCC versions, and it's likely that in most cases those pragmas also will end up controlling -Wmaybe-uninitialized.) Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch, except for libresolv since res_send.c contains assertions whose line numbers are changed by the patch). * resolv/res_send.c (send_vc) [__GNUC_PREREQ (4, 7)]: Make code unconditional. * soft-fp/fmadf4.c [__GNUC_PREREQ (4, 7)]: Likewise. [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * soft-fp/fmasf4.c [__GNUC_PREREQ (4, 7)]: Make code unconditional. [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * soft-fp/fmatf4.c [__GNUC_PREREQ (4, 7)]: Make code unconditional. [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * stdlib/setenv.c [((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7)]: Make code unconditional. [!(((__GNUC__ << 16) + __GNUC_MINOR__) >= ((4 << 16) + 7))]: Remove conditional code. * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__ieee754_lgamma_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__ieee754_lgammaf_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * sysdeps/ieee754/ldbl-128/k_tanl.c (__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c (__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * sysdeps/ieee754/ldbl-96/e_lgammal_r.c (__ieee754_lgammal_r) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__ieee754_lgammal_r) [!__GNUC_PREREQ (4, 7)]: Remove conditional code. * sysdeps/ieee754/ldbl-96/k_tanl.c (__kernel_tanl) [__GNUC_PREREQ (4, 7)]: Make code unconditional. (__kernel_tanl) [!__GNUC_PREREQ (4, 7)]: Remove conditional code.
* Avoid excess range overflowing results from cosh, sinh, lgamma (bug 18980).Joseph Myers2015-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various i386 libm functions return 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 (when e.g. a result that overflows float but not long double gets counted as overflowing for some purposes but not others). This patch addresses those cases arising from functions defined in C, adding a math_narrow_eval macro that forces values to memory to eliminate excess precision if FLT_EVAL_METHOD indicates this is needed, and is a no-op otherwise. I'll convert existing uses of volatile and asm for this purpose to use the new macro later, once i386 has clean test results again (which requires fixes for .S files as well). Tested for x86_64 and x86. Committed. [BZ #18980] * sysdeps/generic/math_private.h: Include <float.h>. (math_narrow_eval): New macro. [FLT_EVAL_METHOD != 0] (excess_precision): Likewise. * sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Use math_narrow_eval on overflowing return value. * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Likewise. * sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise. * sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Likewise. * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Likewise. * sysdeps/ieee754/flt-32/e_sinhf.c (__ieee754_sinhf): Likewise.
* Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558).Joseph Myers2015-09-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing implementations of lgamma functions (except for the ia64 versions) use the reflection formula for negative arguments. This suffers large inaccuracy from cancellation near zeros of lgamma (near where the gamma function is +/- 1). This patch fixes this inaccuracy. For arguments above -2, there are no zeros and no large cancellation, while for sufficiently large negative arguments the zeros are so close to integers that even for integers +/- 1ulp the log(gamma(1-x)) term dominates and cancellation is not significant. Thus, it is only necessary to take special care about cancellation for arguments around a limited number of zeros. Accordingly, this patch uses precomputed tables of relevant zeros, expressed as the sum of two floating-point values. The log of the ratio of two sines can be computed accurately using log1p in cases where log would lose accuracy. The log of the ratio of two gamma(1-x) values can be computed using Stirling's approximation (the difference between two values of that approximation to lgamma being computable without computing the two values and then subtracting), with appropriate adjustments (which don't reduce accuracy too much) in cases where 1-x is too small to use Stirling's approximation directly. In the interval from -3 to -2, using the ratios of sines and of gamma(1-x) can still produce too much cancellation between those two parts of the computation (and that interval is also the worst interval for computing the ratio between gamma(1-x) values, which computation becomes more accurate, while being less critical for the final result, for larger 1-x). Because this can result in errors slightly above those accepted in glibc, this interval is instead dealt with by polynomial approximations. Separate polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0) are used for each interval of length 1/8 from -3 to -2, where n (-3 or -2) is the nearest integer to the 1/8-interval and x0 is the zero of lgamma in the relevant half-integer interval (-3 to -2.5 or -2.5 to -2). Together, the two approaches are intended to give sufficient accuracy for all negative arguments in the problem range. Outside that range, the previous implementation continues to be used. Tested for x86_64, x86, mips64 and powerpc. The mips64 and powerpc testing shows up pre-existing problems for ldbl-128 and ldbl-128ibm with large negative arguments giving spurious "invalid" exceptions (exposed by newly added tests for cases this patch doesn't affect the logic for); I'll address those problems separately. [BZ #2542] [BZ #2543] [BZ #2558] * sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Call __lgamma_neg for arguments from -28.0 to -2.0. * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Call __lgamma_negf for arguments from -15.0 to -2.0. * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Call __lgamma_negl for arguments from -48.0 or -50.0 to -2.0. * sysdeps/ieee754/ldbl-96/e_lgammal_r.c (__ieee754_lgammal_r): Call __lgamma_negl for arguments from -33.0 to -2.0. * sysdeps/ieee754/dbl-64/lgamma_neg.c: New file. * sysdeps/ieee754/dbl-64/lgamma_product.c: Likewise. * sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise. * sysdeps/ieee754/flt-32/lgamma_productf.c: Likewise. * sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise. * sysdeps/ieee754/ldbl-128/lgamma_productl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c: Likewise. * sysdeps/ieee754/ldbl-96/lgamma_negl.c: Likewise. * sysdeps/ieee754/ldbl-96/lgamma_product.c: Likewise. * sysdeps/ieee754/ldbl-96/lgamma_productl.c: Likewise. * sysdeps/generic/math_private.h (__lgamma_negf): New prototype. (__lgamma_neg): Likewise. (__lgamma_negl): Likewise. (__lgamma_product): Likewise. (__lgamma_productl): Likewise. * math/Makefile (libm-calls): Add lgamma_neg and lgamma_product. * math/auto-libm-test-in: Add more tests of lgamma. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Fix lgamma implementations for -Wuninitialized.Joseph Myers2015-05-211-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If you remove the "override CFLAGS += -Wno-uninitialized" in math/Makefile, you get errors from lgamma implementations of the form: ../sysdeps/ieee754/dbl-64/e_lgamma_r.c: In function '__ieee754_lgamma_r': ../sysdeps/ieee754/dbl-64/e_lgamma_r.c:297:13: error: 'nadj' may be used uninitialized in this function [-Werror=maybe-uninitialized] if(hx<0) r = nadj - r; This is one of the standard kinds of false positive uninitialized warnings: nadj is set under a certain condition, and then later used under the same condition. This patch uses DIAG_* macros to suppress the warning on the use of nadj. The ldbl-128 / ldbl-128ibm implementation has a substantially different structure that avoids this issue. Tested for x86_64. (In fact this patch eliminates the need for that -Wno-uninitialized on x86_64, but I want to test on more architectures before removing it.) * sysdeps/ieee754/dbl-64/e_lgamma_r.c: Include <libc-internal.h>. (__ieee754_lgamma_r): Ignore uninitialized warnings around use of NADJ. * sysdeps/ieee754/flt-32/e_lgammaf_r.c: Include <libc-internal.h>. (__ieee754_lgammaf_r): Ignore uninitialized warnings around use of NADJ. * sysdeps/ieee754/ldbl-96/e_lgammal_r.c: Include <libc-internal.h>. (__ieee754_lgammal_r): Ignore uninitialized warnings around use of NADJ.
* Fix lgammaf spurious underflows (bug 18220).Joseph Myers2015-05-151-3/+3
| | | | | | | | | | | | | | | | | The flt-32 implementation of lgammaf produces spurious underflow exceptions for some large arguments, because of calculations involving x^-2 multiplied by small constants. This patch fixes this by adjusting the threshold for a simpler computation to 2**26 (the error in the simpler computation is on the order of 0.5 * log (x), for a result on the order of x * log (x)). Tested for x86_64 and x86. [BZ #18220] * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Use 2**26 not 2**58 as threshold for returning x * (log (x) - 1). * math/auto-libm-test-in: Add another test of lgamma. * math/auto-libm-test-out: Regenerated.
* Fix lgammaf spurious underflow (bug 15427).Joseph Myers2013-09-031-2/+2
|
* Use <> for math.h and math_private.h everywhere.Richard Henderson2012-03-091-2/+2
| | | | Entire tree edited via find | grep | sed.
* Optimize libmUlrich Drepper2011-10-121-44/+26
| | | | | libm is now somewhat integrated with gcc's -ffinite-math-only option and lots of the wrapper functions have been optimized.
* [BZ #4407]Ulrich Drepper2007-10-061-1/+6
| | | | | | | | | * sysdeps/ieee754/dbl-64/e_lgamma_r.c: Fix *signgamp for -0.0. * sysdeps/ieee754/flt-32/e_lgammaf_r.c: Likewise. * sysdeps/ieee754/ldbl-96/e_lgammal_r.c: Likewise. * math/libm-test.inc: Add test for this case. Half the patch by Christian Iseli <christian.iseli@licr.org>.
* Update.Ulrich Drepper1999-10-201-2/+0
| | | | | | | | | | | | | | | | | | | | 1999-10-19 Ulrich Drepper <drepper@cygnus.com> * sysdeps/i386/fpu/s_nextafterl.c: Add __nextafterl and nextafterl aliases. * sysdeps/ieee754/flt-32/e_lgammaf_r.c: Don't handle -Inf special. * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): Check for -Inf and return NaN. * math/gen-libm-test.pl: Fix program name in help message. * math/libm-test.inc (check_complex): It's Imaginary, not Complex. * math/libm-test.inc (gamma_test): Result of gamma(-inf) is +inf. * sysdeps/i386/Implies: Correct order of libm directories.
* Update.Ulrich Drepper1999-07-141-0/+250