about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128ibm
Commit message (Collapse)AuthorAgeFilesLines
* Fix j1, jn missing errno setting on underflow (bug 18611).Joseph Myers2015-10-231-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | j1 and jn can underflow for small arguments, but fail to set errno when underflowing to 0. This patch fixes them to set errno in that case. Tested for x86_64, x86, mips64 and powerpc. [BZ #18611] * sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_j1): Set errno and avoid excess range and precision on underflow. * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise. * sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_j1f): Likewise. * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise. * sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): Set errno on underflow. * sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise. * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise. * math/auto-libm-test-in: Do not allow missing errno setting for tests of j1 and jn. * math/auto-libm-test-out: Regenerated.
* Convert 231 sysdeps function definitions to prototype style.Joseph Myers2015-10-191-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mostly automatically-generated patch converts 231 sysdeps function definitions in glibc from old-style K&R to prototype-style. For __aio_sigqueue and __gai_sigqueue I had to add internal_function to the definitions as noted by Florian in <https://sourceware.org/ml/libc-alpha/2015-10/msg00595.html> to keep the functions compiling on x86 after conversion to prototype definitions. Otherwise, the patch is automatically generated with all the same exclusions and caveats as in <https://sourceware.org/ml/libc-alpha/2015-10/msg00594.html> except that it's a patch for sysdeps files. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). Also tested for arm, mips64 and powerpc32 that installed stripped shared libraries are unchanged by the patch. * sysdeps/arm/backtrace.c (__backtrace): Convert to prototype-style function definition. * sysdeps/i386/backtrace.c (__backtrace): Likewise. * sysdeps/i386/ffs.c (__ffs): Likewise. * sysdeps/i386/i686/ffs.c (__ffs): Likewise. * sysdeps/ia64/nptl/pthread_spin_lock.c (pthread_spin_lock): Likewise. * sysdeps/ia64/nptl/pthread_spin_trylock.c (pthread_spin_trylock): Likewise. * sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l): Likewise. * sysdeps/m68k/ffs.c (__ffs): Likewise. * sysdeps/m68k/m680x0/fpu/e_acos.c (FUNC): Likewise. * sysdeps/m68k/m680x0/fpu/e_fmod.c (FUNC): Likewise. * sysdeps/mach/adjtime.c (__adjtime): Likewise. * sysdeps/mach/gettimeofday.c (__gettimeofday): Likewise. * sysdeps/mach/hurd/_exit.c (_exit): Likewise. * sysdeps/mach/hurd/access.c (__access): Likewise. * sysdeps/mach/hurd/adjtime.c (__adjtime): Likewise. * sysdeps/mach/hurd/chdir.c (__chdir): Likewise. * sysdeps/mach/hurd/chmod.c (__chmod): Likewise. * sysdeps/mach/hurd/chown.c (__chown): Likewise. * sysdeps/mach/hurd/cthreads.c (cthread_keycreate): Likewise. (cthread_getspecific): Likewise. (cthread_setspecific): Likewise. (__libc_getspecific): Likewise. * sysdeps/mach/hurd/euidaccess.c (__euidaccess): Likewise. * sysdeps/mach/hurd/faccessat.c (faccessat): Likewise. * sysdeps/mach/hurd/fchdir.c (__fchdir): Likewise. * sysdeps/mach/hurd/fchmod.c (__fchmod): Likewise. * sysdeps/mach/hurd/fchmodat.c (fchmodat): Likewise. * sysdeps/mach/hurd/fchown.c (__fchown): Likewise. * sysdeps/mach/hurd/fchownat.c (fchownat): Likewise. * sysdeps/mach/hurd/flock.c (__flock): Likewise. * sysdeps/mach/hurd/fsync.c (fsync): Likewise. * sysdeps/mach/hurd/ftruncate.c (__ftruncate): Likewise. * sysdeps/mach/hurd/getgroups.c (__getgroups): Likewise. * sysdeps/mach/hurd/gethostname.c (__gethostname): Likewise. * sysdeps/mach/hurd/getitimer.c (__getitimer): Likewise. * sysdeps/mach/hurd/getlogin_r.c (__getlogin_r): Likewise. * sysdeps/mach/hurd/getpgid.c (__getpgid): Likewise. * sysdeps/mach/hurd/getrusage.c (__getrusage): Likewise. * sysdeps/mach/hurd/getsockname.c (__getsockname): Likewise. * sysdeps/mach/hurd/group_member.c (__group_member): Likewise. * sysdeps/mach/hurd/isatty.c (__isatty): Likewise. * sysdeps/mach/hurd/lchown.c (__lchown): Likewise. * sysdeps/mach/hurd/link.c (__link): Likewise. * sysdeps/mach/hurd/linkat.c (linkat): Likewise. * sysdeps/mach/hurd/listen.c (__listen): Likewise. * sysdeps/mach/hurd/mkdir.c (__mkdir): Likewise. * sysdeps/mach/hurd/mkdirat.c (mkdirat): Likewise. * sysdeps/mach/hurd/openat.c (__openat): Likewise. * sysdeps/mach/hurd/poll.c (__poll): Likewise. * sysdeps/mach/hurd/readlink.c (__readlink): Likewise. * sysdeps/mach/hurd/readlinkat.c (readlinkat): Likewise. * sysdeps/mach/hurd/recv.c (__recv): Likewise. * sysdeps/mach/hurd/rename.c (rename): Likewise. * sysdeps/mach/hurd/renameat.c (renameat): Likewise. * sysdeps/mach/hurd/revoke.c (revoke): Likewise. * sysdeps/mach/hurd/rewinddir.c (__rewinddir): Likewise. * sysdeps/mach/hurd/rmdir.c (__rmdir): Likewise. * sysdeps/mach/hurd/seekdir.c (seekdir): Likewise. * sysdeps/mach/hurd/send.c (__send): Likewise. * sysdeps/mach/hurd/setdomain.c (setdomainname): Likewise. * sysdeps/mach/hurd/setegid.c (setegid): Likewise. * sysdeps/mach/hurd/seteuid.c (seteuid): Likewise. * sysdeps/mach/hurd/setgid.c (__setgid): Likewise. * sysdeps/mach/hurd/setgroups.c (setgroups): Likewise. * sysdeps/mach/hurd/sethostid.c (sethostid): Likewise. * sysdeps/mach/hurd/sethostname.c (sethostname): Likewise. * sysdeps/mach/hurd/setlogin.c (setlogin): Likewise. * sysdeps/mach/hurd/setpgid.c (__setpgid): Likewise. * sysdeps/mach/hurd/setregid.c (__setregid): Likewise. * sysdeps/mach/hurd/setreuid.c (__setreuid): Likewise. * sysdeps/mach/hurd/settimeofday.c (__settimeofday): Likewise. * sysdeps/mach/hurd/setuid.c (__setuid): Likewise. * sysdeps/mach/hurd/shutdown.c (shutdown): Likewise. * sysdeps/mach/hurd/sigaction.c (__sigaction): Likewise. * sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise. * sysdeps/mach/hurd/sigpending.c (sigpending): Likewise. * sysdeps/mach/hurd/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/mach/hurd/sigsuspend.c (__sigsuspend): Likewise. * sysdeps/mach/hurd/socket.c (__socket): Likewise. * sysdeps/mach/hurd/symlink.c (__symlink): Likewise. * sysdeps/mach/hurd/symlinkat.c (symlinkat): Likewise. * sysdeps/mach/hurd/telldir.c (telldir): Likewise. * sysdeps/mach/hurd/truncate.c (__truncate): Likewise. * sysdeps/mach/hurd/umask.c (__umask): Likewise. * sysdeps/mach/hurd/unlink.c (__unlink): Likewise. * sysdeps/mach/hurd/unlinkat.c (unlinkat): Likewise. * sysdeps/mips/mips64/__longjmp.c (__longjmp): Likewise. * sysdeps/posix/alarm.c (alarm): Likewise. * sysdeps/posix/cuserid.c (cuserid): Likewise. * sysdeps/posix/dirfd.c (dirfd): Likewise. * sysdeps/posix/dup.c (__dup): Likewise. * sysdeps/posix/dup2.c (__dup2): Likewise. * sysdeps/posix/euidaccess.c (euidaccess): Likewise. (main): Likewise. * sysdeps/posix/flock.c (__flock): Likewise. * sysdeps/posix/fpathconf.c (__fpathconf): Likewise. * sysdeps/posix/getcwd.c (__getcwd): Likewise. * sysdeps/posix/gethostname.c (__gethostname): Likewise. * sysdeps/posix/gettimeofday.c (__gettimeofday): Likewise. * sysdeps/posix/isatty.c (__isatty): Likewise. * sysdeps/posix/killpg.c (killpg): Likewise. * sysdeps/posix/libc_fatal.c (__libc_fatal): Likewise. * sysdeps/posix/mkfifoat.c (mkfifoat): Likewise. * sysdeps/posix/raise.c (raise): Likewise. * sysdeps/posix/remove.c (remove): Likewise. * sysdeps/posix/rename.c (rename): Likewise. * sysdeps/posix/rewinddir.c (__rewinddir): Likewise. * sysdeps/posix/seekdir.c (seekdir): Likewise. * sysdeps/posix/sigblock.c (__sigblock): Likewise. * sysdeps/posix/sigignore.c (sigignore): Likewise. * sysdeps/posix/sigintr.c (siginterrupt): Likewise. * sysdeps/posix/signal.c (__bsd_signal): Likewise. * sysdeps/posix/sigset.c (sigset): Likewise. * sysdeps/posix/sigsuspend.c (__sigsuspend): Likewise. * sysdeps/posix/sysconf.c (__sysconf): Likewise. * sysdeps/posix/sysv_signal.c (__sysv_signal): Likewise. * sysdeps/posix/time.c (time): Likewise. * sysdeps/posix/ttyname.c (getttyname): Likewise. (ttyname): Likewise. * sysdeps/posix/ttyname_r.c (__ttyname_r): Likewise. * sysdeps/posix/utime.c (utime): Likewise. * sysdeps/powerpc/fpu/s_isnan.c (__isnan): Likewise. * sysdeps/powerpc/nptl/pthread_spin_lock.c (pthread_spin_lock): Likewise. * sysdeps/powerpc/nptl/pthread_spin_trylock.c (pthread_spin_trylock): Likewise. * sysdeps/pthread/aio_error.c (aio_error): Likewise. * sysdeps/pthread/aio_read.c (aio_read): Likewise. * sysdeps/pthread/aio_read64.c (aio_read64): Likewise. * sysdeps/pthread/aio_write.c (aio_write): Likewise. * sysdeps/pthread/aio_write64.c (aio_write64): Likewise. * sysdeps/pthread/flockfile.c (__flockfile): Likewise. * sysdeps/pthread/ftrylockfile.c (__ftrylockfile): Likewise. * sysdeps/pthread/funlockfile.c (__funlockfile): Likewise. * sysdeps/pthread/timer_create.c (timer_create): Likewise. * sysdeps/pthread/timer_getoverr.c (timer_getoverrun): Likewise. * sysdeps/pthread/timer_gettime.c (timer_gettime): Likewise. * sysdeps/s390/ffs.c (__ffs): Likewise. * sysdeps/s390/nptl/pthread_spin_lock.c (pthread_spin_lock): Likewise. * sysdeps/s390/nptl/pthread_spin_trylock.c (pthread_spin_trylock): Likewise. * sysdeps/sh/nptl/pthread_spin_lock.c (pthread_spin_lock): Likewise. * sysdeps/sparc/nptl/pthread_barrier_destroy.c (pthread_barrier_destroy): Likewise. * sysdeps/sparc/nptl/pthread_barrier_wait.c (__pthread_barrier_wait): Likewise. * sysdeps/sparc/sparc32/e_sqrt.c (__ieee754_sqrt): Likewise. * sysdeps/sparc/sparc32/pthread_barrier_wait.c (__pthread_barrier_wait): Likewise. * sysdeps/sparc/sparc32/sem_init.c (__old_sem_init): Likewise. * sysdeps/tile/memcmp.c (memcmp_common_alignment): Likewise. (memcmp_not_common_alignment): Likewise. (MEMCMP): Likewise. * sysdeps/tile/wordcopy.c (_wordcopy_fwd_aligned): Likewise. (_wordcopy_fwd_dest_aligned): Likewise. (_wordcopy_bwd_aligned): Likewise. (_wordcopy_bwd_dest_aligned): Likewise. * sysdeps/unix/bsd/ftime.c (ftime): Likewise. * sysdeps/unix/bsd/gtty.c (gtty): Likewise. * sysdeps/unix/bsd/stty.c (stty): Likewise. * sysdeps/unix/bsd/tcflow.c (tcflow): Likewise. * sysdeps/unix/bsd/tcflush.c (tcflush): Likewise. * sysdeps/unix/bsd/tcgetattr.c (__tcgetattr): Likewise. * sysdeps/unix/bsd/tcgetpgrp.c (tcgetpgrp): Likewise. * sysdeps/unix/bsd/tcsendbrk.c (tcsendbreak): Likewise. * sysdeps/unix/bsd/tcsetattr.c (tcsetattr): Likewise. * sysdeps/unix/bsd/tcsetpgrp.c (tcsetpgrp): Likewise. * sysdeps/unix/bsd/ualarm.c (ualarm): Likewise. * sysdeps/unix/bsd/wait3.c (__wait3): Likewise. * sysdeps/unix/getlogin_r.c (__getlogin_r): Likewise. * sysdeps/unix/sockatmark.c (sockatmark): Likewise. * sysdeps/unix/stime.c (stime): Likewise. * sysdeps/unix/sysv/linux/_exit.c (_exit): Likewise. * sysdeps/unix/sysv/linux/aio_sigqueue.c (__aio_sigqueue): Likewise. Use internal_function. * sysdeps/unix/sysv/linux/arm/sigaction.c (__libc_sigaction): Convert to prototype-style function definition. * sysdeps/unix/sysv/linux/faccessat.c (faccessat): Likewise. * sysdeps/unix/sysv/linux/fchmodat.c (fchmodat): Likewise. * sysdeps/unix/sysv/linux/fpathconf.c (__fpathconf): Likewise. * sysdeps/unix/sysv/linux/gai_sigqueue.c (__gai_sigqueue): Likewise. Use internal_function. * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Convert to prototype-style function definition * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Likewise. (__getlogin_r): Likewise. * sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Likewise. * sysdeps/unix/sysv/linux/hppa/pthread_cond_broadcast.c (__pthread_cond_broadcast): Likewise. * sysdeps/unix/sysv/linux/hppa/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise. * sysdeps/unix/sysv/linux/hppa/pthread_cond_init.c (__pthread_cond_init): Likewise. * sysdeps/unix/sysv/linux/hppa/pthread_cond_signal.c (__pthread_cond_signal): Likewise. * sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c (__pthread_cond_wait): Likewise. * sysdeps/unix/sysv/linux/i386/getmsg.c (getmsg): Likewise. * sysdeps/unix/sysv/linux/i386/setegid.c (setegid): Likewise. * sysdeps/unix/sysv/linux/ia64/sigaction.c (__libc_sigaction): Likewise. * sysdeps/unix/sysv/linux/ia64/sigpending.c (sigpending): Likewise. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/mips/sigaction.c (__libc_sigaction): Likewise. * sysdeps/unix/sysv/linux/msgget.c (msgget): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c (__ftruncate64): Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c (truncate64): Likewise. * sysdeps/unix/sysv/linux/pt-raise.c (raise): Likewise. * sysdeps/unix/sysv/linux/pthread_getcpuclockid.c (pthread_getcpuclockid): Likewise. * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np): Likewise. * sysdeps/unix/sysv/linux/pthread_sigmask.c (pthread_sigmask): Likewise. * sysdeps/unix/sysv/linux/pthread_sigqueue.c (pthread_sigqueue): Likewise. * sysdeps/unix/sysv/linux/raise.c (raise): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sigaction.c (__libc_sigaction): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sigpending.c (sigpending): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/semget.c (semget): Likewise. * sysdeps/unix/sysv/linux/semop.c (semop): Likewise. * sysdeps/unix/sysv/linux/setrlimit64.c (setrlimit64): Likewise. * sysdeps/unix/sysv/linux/shmat.c (shmat): Likewise. * sysdeps/unix/sysv/linux/shmdt.c (shmdt): Likewise. * sysdeps/unix/sysv/linux/shmget.c (shmget): Likewise. * sysdeps/unix/sysv/linux/sigaction.c (__libc_sigaction): Likewise. * sysdeps/unix/sysv/linux/sigpending.c (sigpending): Likewise. * sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/sigqueue.c (__sigqueue): Likewise. * sysdeps/unix/sysv/linux/sigstack.c (sigstack): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c (sigpending): Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/unix/sysv/linux/speed.c (cfgetospeed): Likewise. (cfgetispeed): Likewise. (cfsetospeed): Likewise. (cfsetispeed): Likewise. * sysdeps/unix/sysv/linux/tcflow.c (tcflow): Likewise. * sysdeps/unix/sysv/linux/tcflush.c (tcflush): Likewise. * sysdeps/unix/sysv/linux/tcgetattr.c (__tcgetattr): Likewise. * sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise. * sysdeps/unix/sysv/linux/time.c (time): Likewise. * sysdeps/unix/sysv/linux/timer_create.c (timer_create): Likewise. * sysdeps/unix/sysv/linux/timer_delete.c (timer_delete): Likewise. * sysdeps/unix/sysv/linux/timer_getoverr.c (timer_getoverrun): Likewise. * sysdeps/unix/sysv/linux/timer_gettime.c (timer_gettime): Likewise. * sysdeps/unix/sysv/linux/x86_64/sigpending.c (sigpending): Likewise. * sysdeps/unix/sysv/linux/x86_64/sigprocmask.c (__sigprocmask): Likewise. * sysdeps/x86_64/backtrace.c (__backtrace): Likewise.
* Fix ldbl-128ibm expl overflow in non-default rounding modes (bug 19078).Joseph Myers2015-10-061-5/+2
| | | | | | | | | | | | | | | | | 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.
* Fix ldbl-128ibm logl (1) sign of zero result (bug 19077).Joseph Myers2015-10-061-0/+2
| | | | | | | | | | | | 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.
* Fix ldbl-128ibm log1pl (-1) sign of infinity (bug 19076).Joseph Myers2015-10-061-1/+1
| | | | | | | | | | | | | 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.
* Work around powerpc32 integer 0 converting to -0 (bug 887, bug 19049, bug ↵Joseph Myers2015-10-052-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix nexttoward overflow in non-default rounding modes (bug 19059).Joseph Myers2015-10-022-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix ldbl-128ibm exp10l spurious overflows (bug 16620).Joseph Myers2015-09-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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).
* Fix clog, clog10 inaccuracy (bug 19016).Joseph Myers2015-09-281-15/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix pow missing underflows (bug 18825).Joseph Myers2015-09-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix hypot missing underflows (bug 18803).Joseph Myers2015-09-241-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Refactor code forcing underflow exceptions.Joseph Myers2015-09-2312-60/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use math_narrow_eval more consistently.Joseph Myers2015-09-232-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Since we now inline isinf, isnan and isfinite in math.h, replace uses of ↵Wilco Dijkstra2015-09-182-24/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | __isinf_ns(l/f) with isinf, and remove the unused inlines __isinf_ns(l/f), __isnan(f) and __finite(f). 2015-09-18 Wilco Dijkstra <wdijkstr@arm.com> * include/math.h: Remove __isinf_ns, __isinf_nsf, __isinf_nsl. * math/Makefile: Remove isinf_ns.c. * math/divtc3.c (__divtc3): Replace __isinf_nsl with isinf. * math/multc3.c (__multc3): Likewise. * math/s_casin.c (__casin): Likewise. * math/s_casinf.c (__casinf): Likewise. * math/s_casinl.c (__casinl): Likewise. * math/s_cproj.c (__cproj): Likewise. * math/s_cprojf.c (__cprojf): Likewise. * math/s_cprojl.c (__cprofl): Likewise. * math/s_ctan.c (__ctan): Likewise. * math/s_ctanf.c (__ctanf): Likewise. * math/s_ctanh.c (__ctanh): Likewise. * math/s_ctanhf.c (__ctanhf): Likewise. * math/s_ctanhl.c (__ctanhl): Likewise. * math/s_ctanl.c (__ctanl): Likewise. * math/w_fmod.c (__fmod): Likewise. * math/w_fmodf.c (__fmodf): Likewise. * math/w_fmodl.c (_fmodl): Likewise. * math/w_remainder.c (__remainder): Likewise. * math/w_remainderf.c (__remainderf): Likewise. * math/w_remainderl.c (__remainderl): Likewise. * math/w_scalb.c (__scalb): Likewise. * math/w_scalbf.c (__scalbf): Likewise. * math/w_scalbl.c (__scalbl): Likewise. * sysdeps/ieee754/dbl-64/s_isinf_ns.c: Deleted file. * sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Replace __isinf_ns with isinf. * sysdeps/ieee754/dbl-64/wordsize-64/math_private.h: Deleted file. * sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c: Deleted file. * sysdeps/ieee754/flt-32/e_exp2f.c (__ieee754_exp2f): Replace __isinf_nsf with isinf. * sysdeps/ieee754/flt-32/math_private.h: Deleted file. * sysdeps/ieee754/flt-32/s_isinf_nsf.c: Deleted file. * sysdeps/ieee754/ldbl-128/s_isinf_nsl.c: Deleted file. * sysdeps/ieee754/ldbl-128/s_sincosl.c (__sincosl): Replace __isinf_nsl with isinf. * sysdeps/ieee754/ldbl-128ibm/s_cprojl.c(__cprojll): Replace __isinf_nsl with isinf. * sysdeps/ieee754/ldbl-128ibm/s_ctanl.c(__ctanl): Replace __isinf_nsl with isinf. * sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c: Deleted file. * sysdeps/ieee754/ldbl-128ibm/s_sincosl.c (__sincosl): Replace __isinf_nsl with isinf. * sysdeps/ieee754/ldbl-96/s_isinf_nsl.c: Deleted file. * sysdeps/ieee754/ldbl-96/s_sincosl.c (__sincosl): Replace __isinf_nsl with isinf.
* Use the GCC builtin functions for the non-inlined signbit implementations.Wilco Dijkstra2015-09-181-7/+1
| | | | | | | | | | | | | 2015-09-18 Wilco Dijkstra <wdijkstr@arm.com> * sysdeps/ieee754/dbl-64/s_signbit.c (__signbit): Use __builtin_signbit. * sysdeps/ieee754/flt-32/s_signbitf.c (__signbitf): Use __builtin_signbitf. * sysdeps/ieee754/ldbl-128/s_signbitl.c (__signbitl): Use __builtin_signbitl. * sysdeps/ieee754/ldbl-128ibm/s_signbitl.c (___signbitl): Likewise. * sysdeps/ieee754/ldbl-96/s_signbitl.c (__signbitl): Likewise.
* Reduce number of constants in __finite* (bug 15384).Joseph Myers2015-09-171-1/+1
| | | | | | | | | | | | | | | | | | | Bug 15384 notes that in __finite, two different constants are used that could be the same constant (the result only depends on the exponent of the floating-point representation), and that using the same constant is better for architectures where constants need loading from a constant pool. This patch implements that change. Tested for x86_64, mips64 and powerpc. [BZ #15384] * sysdeps/ieee754/dbl-64/s_finite.c (FINITE): Use same constant as bit-mask as in subtraction. * sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c (__finite): Likewise. * sysdeps/ieee754/flt-32/s_finitef.c (FINITEF): Likewise. * sysdeps/ieee754/ldbl-128/s_finitel.c (__finitel): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_finitel.c (__finitel): Likewise.
* Fix tgamma missing underflows (bug 18951).Joseph Myers2015-09-171-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, tgamma functions can fail to raise the underflow exception when the result is tiny and inexact but one or more low bits of the intermediate result that is scaled down are zero. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #18951] * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Force underflow exception for small results. * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): Likewise. * sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Likewise. * math/auto-libm-test-in: Add more tests of tgamma. * math/auto-libm-test-out: Regenerated.
* Make scalbn set errno (bug 6803).Joseph Myers2015-09-161-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in bug 6803, scalbn fails to set errno on overflow and underflow. This patch fixes this by making scalbn an alias of ldexp, which has exactly the same semantics (for floating-point types with radix 2) and already has wrappers that deal with setting errno, instead of an alias of the internal __scalbn (which ldexp calls). Notes: * Where compat symbols were defined for scalbn functions, I didn't change what they point to (to keep the patch minimal), so such compat symbols continue to go directly to the non-errno-setting functions. * Mike, I didn't do anything with the IA64 versions of these functions, where I think both the ldexp and scalbn functions already deal with setting errno. As a cleanup (not needed to fix this bug) however you might want to make those functions into aliases for IA64; there is no need for them to be separate function implementations at all. * This concludes the fix for bug 6803 since the scalb and scalbln cases of that bug were fixed some time ago. Tested for x86_64, x86, mips64 and powerpc. [BZ #6803] * math/s_ldexp.c (scalbn): Define as weak alias of __ldexp. [NO_LONG_DOUBLE] (scalbnl): Define as weak alias of __ldexp. * math/s_ldexpf.c (scalbnf): Define as weak alias of __ldexpf. * math/s_ldexpl.c (scalbnl): Define as weak alias of __ldexpl. * sysdeps/i386/fpu/s_scalbn.S (scalbn): Remove alias. * sysdeps/i386/fpu/s_scalbnf.S (scalbnf): Likewise. * sysdeps/i386/fpu/s_scalbnl.S (scalbnl): Likewise. * sysdeps/ieee754/dbl-64/s_scalbn.c (scalbn): Likewise. [NO_LONG_DOUBLE] (scalbnl): Likewise. * sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c (scalbn): Likewise. [NO_LONG_DOUBLE] (scalbnl): Likewise. * sysdeps/ieee754/flt-32/s_scalbnf.c (scalbnf): Likewise. * sysdeps/ieee754/ldbl-128/s_scalbnl.c (scalbnl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c (scalbnl): Remove long_double_symbol calls. * sysdeps/ieee754/ldbl-64-128/s_scalbnl.c (scalbnl): Likewise. * sysdeps/ieee754/ldbl-opt/s_ldexpl.c (__ldexpl_2): Define as strong alias of __ldexpl. (scalbnl): Define using long_double_symbol. * sysdeps/m68k/m680x0/fpu/s_scalbn.c (__CONCATX(scalbn,suffix)): Remove alias. * sysdeps/sparc/sparc64/soft-fp/s_scalbnl.c (scalbnl): Likewise. * sysdeps/x86_64/fpu/s_scalbnl.S (scalbnl): Likewise. * math/libm-test.inc (scalbn_test_data): Add errno expectations. (scalbln_test_data): Add more errno expectations.
* Clean up ldbl-128 / ldbl-128ibm expm1l dead code (bug 16415).Joseph Myers2015-09-161-16/+2
| | | | | | | | | | | | | | | | The ldbl-128 and ldbl-128ibm expm1l implementations have code to handle +Inf and finite arguments above an overflow threshold. Since they now use __expl for large positive arguments to fix other problems, this code is unreachable; this patch removes it. Tested for mips64 and powerpc. [BZ #16415] * sysdeps/ieee754/ldbl-128/s_expm1l.c (maxlog): Remove variable. (__expm1l): Remove code to handle positive infinity and overflow. * sysdeps/ieee754/ldbl-128ibm/s_expm1l.c (maxlog): Remove variable. (__expm1l): Remove code to handle positive infinity and overflow.
* Fix ldbl-128ibm nearbyintl use of signaling comparisons on NaNs (bug 18857).Joseph Myers2015-09-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | The ldbl-128ibm implementation of nearbyintl wrongly uses signaling comparisons such as "if (fabs (u.d[0].d) < TWO52)" on arguments that might be NaNs, when "invalid" exceptions should not be raised. (For hard float, this issue may be hidden by <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, powerpc GCC wrongly only using unordered comparison instructions.) This patch fixes this by just returning the argument if it is not finite (because of the arbitrary value of the low part of a NaN in IBM long double, there are quite a lot of comparisons that could end up involving a NaN when the argument to nearbyintl is a NaN, so excluding NaN arguments at the start is the simplest and safest fix). Tested for powerpc-nofpu, where it removes failures for spurious "invalid" exceptions from nearbyintl. [BZ #18857] * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c (__nearbyintl): Just return non-finite argument without doing ordered comparisons on it.
* Fix lgamma (negative) inaccuracy (bug 2542, bug 2543, bug 2558).Joseph Myers2015-09-102-0/+570
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 uninitialized variable use in ldbl-128ibm nearbyintl.Joseph Myers2015-08-201-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Removing the use of -Wno-uninitialized for math/ shows errors for ldbl-128ibm: ../sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: In function '__nearbyintl': ../sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c:119:34: error: 'low' may be used uninitialized in this function [-Werror=maybe-uninitialized] u.d[1].d = high - u.d[0].d + low; ^ ../sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c:119:23: error: 'high' may be used uninitialized in this function [-Werror=maybe-uninitialized] u.d[1].d = high - u.d[0].d + low; ^ These errors are correct: if the high part of the argument is a NaN, and the low part is nonzero but has absolute value less than 2^52, those variables can be used uninitialized. This patch rearranges the code so that the variables are always initialized with the natural values, and then possibly modified later, to avoid this uninitialized use. (Note that there are still other issues with this code and NaNs that are not fixed by this patch.) No bug filed in Bugzilla or testcase added for the uninitialized use since it wasn't user-visible with the compiler I tried (that is, I still got a NaN result). Tested for powerpc. * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: Always initialize variables for high and low parts before possibly modifying them.
* Fix tanh missing underflows (bug 16520).Joseph Myers2015-08-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some tanh implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16520] * sysdeps/ieee754/dbl-64/s_tanh.c: Include <float.h>. (__tanh): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/s_tanhf.c: Include <float.h>. (__tanhf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/s_tanhl.c: Include <float.h>. (__tanhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/s_tanhl.c: Include <float.h>. (__tanhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/s_tanhl.c: Include <float.h>. (__tanhl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of tanh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Fix ldbl-128ibm tanhl inaccuracy (bug 18790).Joseph Myers2015-08-101-5/+5
| | | | | | | | | | | | | | | | ldbl-128ibm tanhl uses a too-small threshold to decide when to return +/-1, resulting in large errors. This patch changes it to a more appropriate threshold (the requirement is for 2*exp(-2|x|) to be small in terms of ulps of 1). Tested for x86_64, x86 and powerpc. [BZ #18790] * sysdeps/ieee754/ldbl-128ibm/s_tanhl.c (__tanhl): Increase threshold for returning +/- 1. * math/auto-libm-test-in: Add more tests of tanh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Fix ldbl-128ibm sinhl inaccuracy near 0 (bug 18789).Joseph Myers2015-08-101-1/+1
| | | | | | | | | | | | | | | ldbl-128ibm sinhl uses a too-big threshold to decide when to return the argument, resulting in large errors. This patch fixes it to use a more appropriate threshold. Tested for x86_64, x86 and powerpc. [BZ #18789] * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c (__ieee754_sinhl): Use smaller threshold for returning the argument. * math/auto-libm-test-in: Add more tests of sinh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Fix tan missing underflows (bug 16517).Joseph Myers2015-08-071-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some tan implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16517] * sysdeps/ieee754/dbl-64/s_tan.c: Include <float.h>. (tan): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/k_tanf.c: Include <float.h>. (__kernel_tanf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_tanl.c: Include <float.h>. (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: Include <float.h>. (__kernel_tanl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/k_tanl.c: Include <float.h>. (__kernel_tanl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of tan. * math/auto-libm-test-out: Regenerated.
* Fix sinh missing underflows (bug 16519).Joseph Myers2015-08-061-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some sinh implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16519] * sysdeps/ieee754/dbl-64/e_sinh.c: Include <float.h>. (__ieee754_sinh): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/e_sinhf.c: Include <float.h>. (__ieee754_sinhf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/e_sinhl.c: Include <float.h>. (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/e_sinhl.c: Include <float.h>. (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/e_sinhl.c: Include <float.h>. (__ieee754_sinhl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of sinh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Improve tgamma accuracy (bug 18613).Joseph Myers2015-06-291-25/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In non-default rounding modes, tgamma can be slightly less accurate than permitted by glibc's accuracy goals. Part of the problem is error accumulation, addressed in this patch by setting round-to-nearest for internal computations. However, there was also a bug in the code dealing with computing pow (x + n, x + n) where x + n is not exactly representable, providing another source of error even in round-to-nearest mode; it was necessary to address both bugs to get errors for all testcases within glibc's accuracy goals. Given this second fix, accuracy in round-to-nearest mode is also improved (hence regeneration of ulps for tgamma should be from scratch - truncate libm-test-ulps or at least remove existing tgamma entries - so that the expected ulps can be reduced). Some additional complications also arose. Certain tgamma tests should strictly, according to IEEE semantics, overflow or not depending on the rounding mode; this is beyond the scope of glibc's accuracy goals for any function without exactly-determined results, but gen-auto-libm-tests doesn't handle being lax there as it does for underflow. (libm-test.inc also doesn't handle being lax about whether the result in cases very close to the overflow threshold is infinity or a finite value close to overflow, but that doesn't cause problems in this case though I've seen it cause problems with random test generation for some functions.) Thus, spurious-overflow markings, with a comment, are added to auto-libm-test-in (no bug in Bugzilla because the issue is with the testsuite, not a user-visible bug in glibc). And on x86, after the patch I saw ERANGE issues as previously reported by Carlos (see my commentary in <https://sourceware.org/ml/libc-alpha/2015-01/msg00485.html>), which needed addressing by ensuring excess range and precision were eliminated at various points if FLT_EVAL_METHOD != 0. I also noticed and fixed a cosmetic issue where 1.0f was used in long double functions and should have been 1.0L. This completes the move of all functions to testing in all rounding modes with ALL_RM_TEST, so gen-libm-have-vector-test.sh is updated to remove the workaround for some functions not using ALL_RM_TEST. Tested for x86_64, x86, mips64 and powerpc. [BZ #18613] * sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Take log of X_ADJ not X when adjusting exponent. (__ieee754_gamma_r): Do intermediate computations in round-to-nearest then adjust overflowing and underflowing results as needed. * sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Take log of X_ADJ not X when adjusting exponent. (__ieee754_gammaf_r): Do intermediate computations in round-to-nearest then adjust overflowing and underflowing results as needed. * sysdeps/ieee754/ldbl-128/e_gammal_r.c (gammal_positive): Take log of X_ADJ not X when adjusting exponent. (__ieee754_gammal_r): Do intermediate computations in round-to-nearest then adjust overflowing and underflowing results as needed. Use 1.0L not 1.0f as numerator of division. * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (gammal_positive): Take log of X_ADJ not X when adjusting exponent. (__ieee754_gammal_r): Do intermediate computations in round-to-nearest then adjust overflowing and underflowing results as needed. Use 1.0L not 1.0f as numerator of division. * sysdeps/ieee754/ldbl-96/e_gammal_r.c (gammal_positive): Take log of X_ADJ not X when adjusting exponent. (__ieee754_gammal_r): Do intermediate computations in round-to-nearest then adjust overflowing and underflowing results as needed. Use 1.0L not 1.0f as numerator of division. * math/libm-test.inc (tgamma_test_data): Remove one test. Moved to auto-libm-test-in. (tgamma_test): Use ALL_RM_TEST. * math/auto-libm-test-in: Add one test of tgamma. Mark some other tests of tgamma with spurious-overflow. * math/auto-libm-test-out: Regenerated. * math/gen-libm-have-vector-test.sh: Do not check for START. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Fix j1, jn missing underflows (bug 16559).Joseph Myers2015-06-291-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, j1 and jn implementations can fail to raise the underflow exception when the internal computation is exact although the actual function is inexact. This patch forces the exception in a similar way to other such fixes. (The ldbl-128 / ldbl-128ibm j1l implementation is different and doesn't need a change for this until spurious underflows in it are fixed.) Tested for x86_64, x86, mips64 and powerpc. [BZ #16559] * sysdeps/ieee754/dbl-64/e_j1.c: Include <float.h>. (__ieee754_j1): Force underflow exception for small results. * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise. * sysdeps/ieee754/flt-32/e_j1f.c: Include <float.h>. (__ieee754_j1f): Force underflow exception for small results. * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise. * sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-96/e_j1l.c: Include <float.h>. (__ieee754_j1l): Force underflow exception for small results. * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise. * math/auto-libm-test-in: Add more tests of j1 and jn. * math/auto-libm-test-out: Regenerated.
* Use round-to-nearest internally in jn, test with ALL_RM_TEST (bug 18602).Joseph Myers2015-06-251-184/+190
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some existing jn tests, if run in non-default rounding modes, produce errors above those accepted in glibc, which causes problems for moving tests of jn to use ALL_RM_TEST. This patch makes jn set rounding to-nearest internally, as was done for yn some time ago, then computes the appropriate underflowing value for results that underflowed to zero in to-nearest, and moves the tests to ALL_RM_TEST. It does nothing about the general inaccuracy of Bessel function implementations in glibc, though it should make jn more accurate on average in non-default rounding modes through reduced error accumulation. The recomputation of results that underflowed to zero should as a side-effect fix some cases of bug 16559, where jn just used an exact zero, but that is *not* the goal of this patch and other cases of that bug remain unfixed. (Most of the changes in the patch are reindentation to add new scopes for SET_RESTORE_ROUND*.) Tested for x86_64, x86, powerpc and mips64. [BZ #16559] [BZ #18602] * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Set round-to-nearest internally then recompute results that underflowed to zero in the original rounding mode. * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise. * sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise. * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise * math/libm-test.inc (jn_test): Use ALL_RM_TEST. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Fix sin, sincos missing underflows (bug 16526, bug 16538).Joseph Myers2015-06-232-7/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some sin and sincos implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, mips64 and powerpc. [BZ #16526] [BZ #16538] * sysdeps/ieee754/dbl-64/s_sin.c: Include <float.h>. (__sin): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/k_sinf.c: Include <float.h>. (__kernel_sinf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_sincosl.c: Include <float.h>. (__kernel_sincosl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/k_sinl.c: Include <float.h>. (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_sincosl.c: Include <float.h>. (__kernel_sincosl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/k_sinl.c: Include <float.h>. (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/k_sinl.c: Include <float.h>. (__kernel_sinl): Force underflow exception for arguments with small absolute value. * sysdeps/powerpc/fpu/k_sinf.c: Include <float.h>. (__kernel_sinf): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Add more tests of sin and sincos. * math/auto-libm-test-out: Regenerated.
* Fix asinh missing underflows (bug 16350).Joseph Myers2015-06-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some asinh implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86 and mips64. [BZ #16350] * sysdeps/i386/fpu/s_asinh.S (__asinh): Force underflow exception for arguments with small absolute value. * sysdeps/i386/fpu/s_asinhf.S (__asinhf): Likewise. * sysdeps/i386/fpu/s_asinhl.S (__asinhl): Likewise. * sysdeps/ieee754/dbl-64/s_asinh.c: Include <float.h>. (__asinh): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/flt-32/s_asinhf.c: Include <float.h>. (__asinhf): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128/s_asinhl.c: Include <float.h>. (__asinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-128ibm/s_asinhl.c: Include <float.h>. (__asinhl): Force underflow exception for arguments with small absolute value. * sysdeps/ieee754/ldbl-96/s_asinhl.c: Include <float.h>. (__asinhl): Force underflow exception for arguments with small absolute value. * math/auto-libm-test-in: Do not mark underflow exceptions as possibly missing for bug 16350. * math/auto-libm-test-out: Regenerated.
* Remove ldbl-128ibm variants of complex math functions.Joseph Myers2015-06-173-281/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sysdeps/ieee754/ldbl-128ibm has its own versions of cprojl, ctanhl and ctanl. Having its own versions, where otherwise the math/ copies are generally used for all floating-point formats, means they are liable to get out of sync and not benefit from bug fixes to the generic versions. The substantive differences (not arising from getting out of sync and slightly different fixes for the same issues) are: long double compat handling (also done in the ldbl-opt versions, so doesn't require special versions for ldbl-128ibm); handling of LDBL_EPSILON (conditionally undefined and redefined in other math/ implementations, so doesn't justify a special version), and: /* __gcc_qmul does not respect -0.0 so we need the following fixup. */ if ((__real__ res == 0.0L) && (__real__ x == 0.0L)) __real__ res = __real__ x; if ((__real__ res == 0.0L) && (__imag__ x == 0.0L)) __imag__ res = __imag__ x; But if that statement about __gcc_qmul was ever true for an old version of that libgcc function, it's not the case for any GCC version now supported to build glibc; there's explicit logic early in that function (and similarly in __gcc_qdiv) to return an appropriately signed zero if the product of the high parts is zero. So this patch adds the special LDBL_EPSILON handling to the generic functions and removes the ldbl-128ibm versions. Tested for powerpc32 (compared test-ldouble.out before and after the changes; there are slight changes to results for ctanl / ctanhl, arising from divergence of the implementations, but nothing that affects the overall nature of the issues shown by the testsuite, and in particular nothing related to signs of zero resutls). * math/s_ctanhl.c [LDBL_MANT_DIG == 106] (LDBL_EPSILON): Undefine and redefine. * math/s_ctanl.c [LDBL_MANT_DIG == 106] (LDBL_EPSILON): Undefine and redefine. * sysdeps/ieee754/ldbl-128ibm/s_cprojl.c: Remove file. * sysdeps/ieee754/ldbl-128ibm/s_ctanhl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ctanl.c: Likewise.
* Replace finite with isfinite.Wilco Dijkstra2015-06-031-1/+1
|
* This patch renames all uses of __isinf*, __isnan*, __finite* and __signbit* ↵Wilco Dijkstra2015-06-038-10/+10
| | | | to use standard C99 macros. This has no effect on generated code.
* Fix ldbl-128 / ldbl-128ibm tanl for -Wuninitialized.Joseph Myers2015-05-221-0/+12
| | | | | | | | | | | | | | | The ldbl-128 and ldbl-128ibm implementations of tanl produce uninitialized variable warnings with -Wuninitialized because of a variable that is initialized only conditionally, then used under the same conditions under which it is set. This patch uses DIAG_* macros to suppress those warnings. Tested for powerpc and mips64. * sysdeps/ieee754/ldbl-128/k_tanl.c: Include <libc-internal.h>. (__kernel_tanl): Ignore uninitialized warnings around use of SIGN. * sysdeps/ieee754/ldbl-128ibm/k_tanl.c: Include <libc-internal.h>. (__kernel_tanl): Ignore uninitialized warnings around use of SIGN.
* Fix ldbl-128 / ldbl-128ibm erfcl for -WuninitializedJoseph Myers2015-05-221-1/+1
| | | | | | | | | | | | | | | | | | | The ldbl-128 and ldbl-128ibm implementations of erfcl produce uninitialized variable warnings with -Wuninitialized because of switch statements where in fact one of the cases will always be executed, but the compiler does not see that these cases cover all possibilities (and because the reasoning that it does involves inequalities on the representation of a floating point value leading to a set of possible values for 8.0 times that value, converted to int, it's highly nontrivial for the compiler to see that). This patch fixes those warnings by converting the last case in those switch statements to a "default" case. Tested for powerpc and mips64. * sysdeps/ieee754/ldbl-128/s_erfl.c (__erfcl): Make case 9 in switch statement into default case. * sysdeps/ieee754/ldbl-128ibm/s_erfl.c (__erfcl): Likewise.
* Fix ldbl-128 / ldbl-128ibm asinl for -Wuninitialized.Joseph Myers2015-05-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The ldbl-128 and ldbl-128ibm implementations of asinl produce uninitialized variable warnings with -Wuninitialized because the code for small arguments in fact always returns but the compiler cannot see this and instead sees that a variable would be uninitialized if the "if (huge + x > one)" conditional used to force the "inexact" exception were false. All the code in libm trying to force "inexact" for functions that are not exactly defined is suspect and should be removed at some point given that we now have a clear definition of the accuracy goals for libm functions which, following C99/C11, does not require anything about "inexact" for most functions (likewise, the multi-precision code that tries to give correctly-rounded results, very slowly, for functions for which the goals clearly do not include correct rounding, if the faster paths are accurate enough). However, for now this patch simply changes the code to use math_force_eval, rather than "if", to ensure the evaluation of the inexact computation. Tested for powerpc and mips64. * sysdeps/ieee754/ldbl-128/e_asinl.c (__ieee754_asinl): Don't use a conditional in forcing "inexact". * sysdeps/ieee754/ldbl-128ibm/e_asinl.c (__ieee754_asinl): Likewise.
* Fix atanhl missing underflows (bug 16352).Joseph Myers2015-05-151-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some atanh implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. (No change in this regard is needed for the i386 implementation; special handling to force underflows in these cases will only be needed there when the spurious underflows, bug 18049, get fixed.) Tested for x86_64, x86, powerpc and mips64. [BZ #16352] * sysdeps/i386/fpu/e_atanh.S (dbl_min): New object. (__ieee754_atanh): Force underflow exception for results with small absolute value. * sysdeps/i386/fpu/e_atanhf.S (flt_min): New object. (__ieee754_atanhf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/dbl-64/e_atanh.c: Include <float.h>. (__ieee754_atanh): Force underflow exception for results with small absolute value. * sysdeps/ieee754/flt-32/e_atanhf.c: Include <float.h>. (__ieee754_atanhf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128/e_atanhl.c: Include <float.h>. (__ieee754_atanhl): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128ibm/e_atanhl.c: Include <float.h>. (__ieee754_atanhl): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-96/e_atanhl.c: Include <float.h>. (__ieee754_atanhl): Force underflow exception for results with small absolute value. * math/auto-libm-test-in: Do not allow missing underflow exceptions from atanh. * math/auto-libm-test-out: Regenerated.
* Set errno for log1p on pole/domain error.Stefan Liebler2015-04-132-2/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to bug 6792, errno is not set to ERANGE/EDOM by calling log1p/log1pf/log1pl with x = -1 or x < -1. This patch adds a wrapper which sets errno in those cases and returns the value of the existing __log1p function. The log1p is now an alias to the wrapper function instead of __log1p. The files in sysdeps are reflecting these changes. The ia64 implementation sets errno by itself, thus the wrapper-file is empty. The libm-test is adjusted for log1p-tests to check errno. [BZ #6792] * math/w_log1p.c: New file. * math/w_log1pf.c: Likewise. * math/w_log1pl.c: Likewise. * math/Makefile (libm-calls): Add w_log1p. * math/s_log1pl.c (log1pl): Remove weak_alias. * sysdeps/i386/fpu/s_log1p.S (log1p): Likewise. * sysdeps/i386/fpu/s_log1pf.S (log1pf): Likewise. * sysdeps/i386/fpu/s_log1pl.S (log1pl): Likewise. * sysdeps/x86_64/fpu/s_log1pl.S (log1pl): Likewise. * sysdeps/ieee754/dbl-64/s_log1p.c (log1p): Likewise. [NO_LONG_DOUBLE] (log1pl): Likewise. * sysdeps/ieee754/flt-32/s_log1pf.c (log1pf): Likewise. * sysdeps/ieee754/ldbl-128/s_log1pl.c (log1pl): Likewise. * sysdeps/ieee754/ldbl-64-128/s_log1pl.c (log1p): Remove long_double_symbol. * sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (log1pl): Likewise. * sysdeps/ieee754/ldbl-64-128/w_log1pl.c: New file. * sysdeps/ieee754/ldbl-128ibm/w_log1pl.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_log1p.c: Define empty weak_alias to remove weak_alias for corresponding log1p function. * sysdeps/m68k/m680x0/fpu/s_log1pf.c: Likewise. * sysdeps/m68k/m680x0/fpu/s_log1pl.c: Likewise. * sysdeps/ia64/fpu/w_log1p.c: New file. * sysdeps/ia64/fpu/w_log1pf.c: Likewise. * sysdeps/ia64/fpu/w_log1pl.c: Likewise. * math/libm-test.inc (log1p_test_data): Add errno expectations.
* Fix ldbl-96, ldbl-128ibm atanhl inaccuracy (bug 18046, bug 18047).Joseph Myers2015-02-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The threshold in ldbl-96 atanhl for when to return the argument, 0x1p-28, is a bit too big, and that in ldbl-128ibm atanhl is much too big (the relevant condition being x^3/3 being < 0.5ulp of x), resulting in errors a bit above the limits of those considered acceptable in glibc in the ldbl-96 case, and in large errors in the ldbl-128ibm case. This patch changes those implementations to use more appropriate thresholds and adds tests around the thresholds for various formats. Tested for x86_64, x86 and powerpc. x86_64 and x86 ulps updated accordingly. [BZ #18046] [BZ #18047] * sysdeps/ieee754/ldbl-128ibm/e_atanhl.c (__ieee754_atanhl): Use 0x1p-56L as threshold for just returning the argument. * sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Use 0x1p-32L as threshold for just returning the argument. * math/auto-libm-test-in: Add more tests of atanh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulp: Likewise.
* Fix ldbl-128/ldbl-128ibm acosl inaccuracy (bug 18038, bug 18039).Joseph Myers2015-02-261-1/+1
| | | | | | | | | | | | | | | | | | | | | The ldbl-128 and ldbl-128ibm implementations of acosl have similar bugs, using a threshold of 0x1p-57L to determine when they just return pi/2. Since the result pi/2 - asinl (x) is roughly pi/2 - x for small x, the relevant cut-off is actually x being < 0.5ulp of 1. This patch fixes the implementations to use that cut-off and adds tests of small acos arguments. Tested for powerpc and mips64. Also tested for x86_64 and x86; no ulps updates needed. [BZ #18038] [BZ #18039] * sysdeps/ieee754/ldbl-128/e_acosl.c (__ieee754_acosl): Only return pi/2 for arguments below 0x1p-113L. * sysdeps/ieee754/ldbl-128ibm/e_acosl.c (__ieee754_acosl): Only return pi/2 for arguments below 0x1p-106L. * math/auto-libm-test-in: Add more tests of acos. * math/auto-libm-test-out: Regenerated.
* Fix asin missing underflows (bug 16351).Joseph Myers2015-02-261-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Similar to various other bugs in this area, some asin implementations do not raise the underflow exception for subnormal arguments, when the result is tiny and inexact. This patch forces the exception in a similar way to previous fixes. Tested for x86_64, x86, powerpc and mips64. [BZ #16351] * sysdeps/i386/fpu/e_asin.S (dbl_min): New object. (MO): New macro. (__ieee754_asin): Force underflow exception for results with small absolute value. * sysdeps/i386/fpu/e_asinf.S (flt_min): New object. (MO): New macro. (__ieee754_asinf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/dbl-64/e_asin.c: Include <float.h> and <math.h>. (__ieee754_asin): Force underflow exception for results with small absolute value. * sysdeps/ieee754/flt-32/e_asinf.c: Include <float.h>. (__ieee754_asinf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128/e_asinl.c: Include <float.h>. (__ieee754_asinl): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128ibm/e_asinl.c: Include <float.h>. (__ieee754_asinl): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-96/e_asinl.c: Include <float.h>. (__ieee754_asinl): Force underflow exception for results with small absolute value. * sysdeps/x86_64/fpu/multiarch/e_asin.c [HAVE_FMA4_SUPPORT]: Include <math.h>. * math/auto-libm-test-in: Do not mark underflow exceptions as possibly missing for bug 16351. * math/auto-libm-test-out: Regenerated.
* Fix ldbl-128ibm logbl near powers of 2 (bug 18030).Joseph Myers2015-02-261-3/+14
| | | | | | | | | | | | | | | | | The ldbl-128ibm implementation of logbl produces incorrect results when the high part of the argument is a power of 2 and the low part a nonzero number with the opposite sign (and so the returned exponent should be 1 less than that of the high part). For example, logbl (0x1.ffffffffffffffp1L) returns 2 but should return 1. (This is similar to (fixed) bug 16740 for frexpl, and (fixed) bug 18029 for ilogbl.) This patch adds checks for that case. Tested for powerpc. [BZ #18030] * sysdeps/ieee754/ldbl-128ibm/s_logbl.c (__logbl): Adjust exponent of power of 2 down when low part has opposite sign. * math/libm-test.inc (logb_test_data): Add more tests.
* Fix ldbl-128ibm ilogbl near powers of 2 (bug 18029).Joseph Myers2015-02-261-4/+19
| | | | | | | | | | | | | | | | | | The ldbl-128ibm implementation of ilogbl produces incorrect results when the high part of the argument is a power of 2 and the low part a nonzero number with the opposite sign (and so the returned exponent should be 1 less than that of the high part). For example, ilogbl (0x1.ffffffffffffffp1L) returns 2 but should return 1. (This is similar to (fixed) bug 16740 for frexpl, and bug 18030 for logbl.) This patch adds checks for that case. Tested for powerpc. [BZ #18029] * sysdeps/ieee754/ldbl-128ibm/e_ilogbl.c (__ieee754_ilogbl): Adjust exponent of power of 2 down when low part has opposite sign. * math/libm-test.inc (ilogb_test_data): Add more tests.
* Fix ldbl-128ibm asinhl inaccuracy (bug 18020).Joseph Myers2015-02-251-4/+4
| | | | | | | | | | | | | | | | | | | The ldbl-128ibm implementation of asinhl uses cut-offs of 0x1p28 and 0x1p-29 to determine when to use simpler formulas that avoid possible overflow / underflow. Both those cut-offs are inappropriate for this format, resulting in large errors. This patch changes the code to use more appropriate cut-offs of 0x1p56 and 0x1p-56, adding tests around the cut-offs for various floating-point formats. Tested for powerpc. Also tested for x86_64 and x86 and updated ulps. [BZ #18020] * sysdeps/ieee754/ldbl-128ibm/s_asinhl.c (__asinhl): Use 2**56 and 2**-56 not 2**28 and 2**-29 as thresholds for simpler formulas. * math/auto-libm-test-in: Add more tests of asinh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Fix ldbl-128ibm acoshl inaccuracy (bug 18019).Joseph Myers2015-02-251-2/+2
| | | | | | | | | | | | | | | | | | The ldbl-128ibm implementation of acoshl uses a cut-off of 0x1p28 to determine when to use log(x) + log(2) as a formula. That cut-off is too small for this format, resulting in large errors. This patch changes it to a more appropriate cut-off of 0x1p56, adding tests around the cut-offs for various floating-point formats. Tested for powerpc. Also tested for x86_64 and x86 and updated ulps. [BZ #18019] * sysdeps/ieee754/ldbl-128ibm/e_acoshl.c (__ieee754_acoshl): Use 2**56 not 2**28 as threshold for log (2x) formula. * math/auto-libm-test-in: Add more tests of acosh. * math/auto-libm-test-out: Regenerated. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Fix atan / atan2 missing underflows (bug 15319).Joseph Myers2015-02-181-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes bug 15319, missing underflows from atan / atan2 when the result of atan is very close to its small argument (or that of atan2 is very close to the ratio of its arguments, which may be an exact division). The usual approach of doing an underflowing computation if the computed result is subnormal is followed. For 32-bit x86, there are extra complications: the inline __ieee754_atan2 in bits/mathinline.h needs to be disabled for float and double because other libm functions using it generally rely on getting proper underflow exceptions from it, while the out-of-line functions have to remove excess range and precision from the underflowing result so as to return an exact 0 in the case where errno should be set for underflow to 0. (The failures I saw without that are similar to those Carlos reported for other functions, where I haven't seen a response to <https://sourceware.org/ml/libc-alpha/2015-01/msg00485.html> confirming if my diagnosis is correct. Arguably all libm functions with float and double returns should remove excess range and precision, but that's a separate matter.) The x86_64 long double case reported in a comment in bug 15319 is not a bug (it's an argument of LDBL_MIN, and x86_64 is an after-rounding architecture so the correct IEEE result is not to raise underflow in the given rounding mode, in addition to treating the result as an exact LDBL_MIN being within the newly clarified documentation of accuracy goals). I'm presuming that the fpatan instruction can be trusted to raise appropriate exceptions when the (long double) result underflows (after rounding) and so no changes are needed for x86 / x86_64 long double functions here; empirically this is the case for the cases covered in the testsuite, on my system. Tested for x86_64, x86, powerpc and mips64. Only 32-bit x86 needs ulps updates (for the changes to inlines meaning some functions no longer get excess precision from their __ieee754_atan2* calls). [BZ #15319] * sysdeps/i386/fpu/e_atan2.S (dbl_min): New object. (MO): New macro. (__ieee754_atan2): For results with small absolute value, force underflow exception and remove excess range and precision from return value. * sysdeps/i386/fpu/e_atan2f.S (flt_min): New object. (MO): New macro. (__ieee754_atan2f): For results with small absolute value, force underflow exception and remove excess range and precision from return value. * sysdeps/i386/fpu/s_atan.S (dbl_min): New object. (MO): New macro. (__atan): For results with small absolute value, force underflow exception and remove excess range and precision from return value. * sysdeps/i386/fpu/s_atanf.S (flt_min): New object. (MO): New macro. (__atanf): For results with small absolute value, force underflow exception and remove excess range and precision from return value. * sysdeps/ieee754/dbl-64/e_atan2.c: Include <float.h> and <math.h>. (__ieee754_atan2): Force underflow exception for results with small absolute value. * sysdeps/ieee754/dbl-64/s_atan.c: Include <float.h> and <math_private.h>. (atan): Force underflow exception for results with small absolute value. * sysdeps/ieee754/flt-32/s_atanf.c: Include <float.h>. (__atanf): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128/s_atanl.c: Include <float.h> and <math.h>. (__atanl): Force underflow exception for results with small absolute value. * sysdeps/ieee754/ldbl-128ibm/s_atanl.c: Include <float.h>. (__atanl): Force underflow exception for results with small absolute value. * sysdeps/x86/fpu/bits/mathinline.h [!__SSE2_MATH__ && !__x86_64__ && __LIBC_INTERNAL_MATH_INLINES] (__ieee754_atan2): Only define inline for long double. * sysdeps/x86_64/fpu/multiarch/e_atan2.c [HAVE_FMA4_SUPPORT || HAVE_AVX_SUPPORT]: Include <math.h>. * math/auto-libm-test-in: Do not mark underflow exceptions as possibly missing for bug 15319. Add more tests of atan2. * math/auto-libm-test-out: Regenerated. * math/libm-test.inc (casin_test_data): Do not mark underflow exceptions as possibly missing for bug 15319. (casinh_test_data): Likewise. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Fix sign of remquo zero remainder in round-downward mode (bug 17987).Joseph Myers2015-02-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | Various remquo implementations produce a zero remainder with the wrong sign (a zero remainder should always have the sign of the first argument, as specified in IEEE 754) in round-downward mode, resulting from the sign of 0 - 0. This patch checks for zero results and fixes their sign accordingly. Tested for x86_64, x86, mips64 and powerpc. [BZ #17987] * sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Ensure sign of zero result does not depend on the sign resulting from subtraction. * sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo): Likewise. * sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise. * sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise. * math/libm-test.inc (remquo_test_data): Add more tests.
* Fix remquo spurious overflows (bug 17978).Joseph Myers2015-02-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Various remquo implementations, when computing the last three bits of the quotient, have spurious overflows when 4 times the second argument to remquo overflows. These overflows can in turn cause bad results in rounding modes where that overflow results in a finite value. This patch adds tests to avoid the problem multiplications in cases where they would overflow, similar to those that control an earlier multiplication by 8. Tested for x86_64, x86, mips64 and powerpc. [BZ #17978] * sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Do not form products 4 * y and 2 * y where those would overflow. * sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c (__remquo): Likewise. * sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise. * sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise. * math/libm-test.inc (remquo_test_data): Add more tests.