summaryrefslogtreecommitdiff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-10-09 19:04:57 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-10-09 19:04:57 +0200
commit7bb5f8a836b916d6ebf7b6921b136e99cea2442d (patch)
tree28a7ed786dae726ad14f100e8626eee872b1ba11 /sysdeps/ieee754
parentf76453c31593957fec1a99b986bfa5506618b79c (diff)
parentab30899d880f9741a409cbc0d7a28399bdac21bf (diff)
Merge tag 'glibc-2.23' into baseline
The GNU C Library ================= The GNU C Library version 2.23 is now available. The GNU C Library is used as *the* C library in the GNU system and in GNU/Linux systems, as well as many other systems that use Linux as the kernel. The GNU C Library is primarily designed to be a portable and high performance C library. It follows all relevant standards including ISO C11 and POSIX.1-2008. It is also internationalized and has one of the most complete internationalization interfaces known. The GNU C Library webpage is at http://www.gnu.org/software/libc/ Packages for the 2.23 release may be downloaded from: http://ftpmirror.gnu.org/libc/ http://ftp.gnu.org/gnu/libc/ The mirror list is at http://www.gnu.org/order/ftp.html NEWS for version 2.23 ===================== * Unicode 8.0.0 Support: Character encoding, character type info, and transliteration tables are all updated to Unicode 8.0.0, using new and/or improved generator scripts contributed by Mike FABIAN (Red Hat). These updates cause user visible changes, such as the fixes for bugs 89, 16061, and 18568. * sched_setaffinity, pthread_setaffinity_np no longer attempt to guess the kernel-internal CPU set size. This means that requests that change the CPU affinity which failed before (for example, an all-ones CPU mask) will now succeed. Applications that need to determine the effective CPU affinities need to call sched_getaffinity or pthread_getaffinity_np after setting it because the kernel can adjust it (and the previous size check would not detect this in the majority of cases). * The fts.h header can now be used with -D_FILE_OFFSET_BITS=64. With LFS the following new symbols are used: fts64_children, fts64_close, fts64_open, fts64_read and fts64_set. * getaddrinfo now detects certain invalid responses on an internal netlink socket. If such responses are received, an affected process will terminate with an error message of "Unexpected error <number> on netlink descriptor <number>" or "Unexpected netlink response of size <number> on descriptor <number>". The most likely cause for these errors is a multi-threaded application which erroneously closes and reuses the netlink file descriptor while it is used by getaddrinfo. * A defect in the malloc implementation, present since glibc 2.15 (2012) or glibc 2.10 via --enable-experimental-malloc (2009), could result in the unnecessary serialization of memory allocation requests across threads. The defect is now corrected. Users should see a substantial increase in the concurent throughput of allocation requests for applications which trigger this bug. Affected applications typically create create and destroy threads frequently. (Bug 19048 was reported and analyzed by Ericsson.) * There is now a --disable-timezone-tools configure option for disabling the building and installing of the timezone related utilities (zic, zdump, and tzselect). This is useful for people who build the timezone data and code independent of the GNU C Library. * The obsolete header <regexp.h> has been removed. Programs that require this header must be updated to use <regex.h> instead. * The obsolete functions bdflush, create_module, get_kernel_syms, query_module and uselib are no longer available to newly linked binaries; the header <sys/kdaemon.h> has been removed. These functions and header were specific to systems using the Linux kernel and could not usefully be used with the GNU C Library on systems with version 2.6 or later of the Linux kernel. * Optimized string, wcsmbs and memory functions for IBM z13. Implemented by Stefan Liebler. * Newly linked programs that define a variable called signgam will no longer have it set by the lgamma, lgammaf and lgammal functions. Programs that require signgam to be set by those functions must ensure that they use the variable provided by the GNU C Library and declared in <math.h>, without defining their own copy. * The minimum GCC version that can be used to build this version of the GNU C Library is GCC 4.7. Older GCC versions, and non-GNU compilers, can still be used to compile programs using the GNU C Library. Security related changes: * An out-of-bounds value in a broken-out struct tm argument to strftime no longer causes a crash. Reported by Adam Nielsen. (CVE-2015-8776) * The LD_POINTER_GUARD environment variable can no longer be used to disable the pointer guard feature. It is always enabled. Previously, LD_POINTER_GUARD could be used to disable security hardening in binaries running in privileged AT_SECURE mode. Reported by Hector Marco-Gisbert. (CVE-2015-8777) * An integer overflow in hcreate and hcreate_r could lead to an out-of-bounds memory access. Reported by Szabolcs Nagy. (CVE-2015-8778) * The catopen function no longer has unbounded stack usage. Reported by Max. (CVE-2015-8779) * The nan, nanf and nanl functions no longer have unbounded stack usage depending on the length of the string passed as an argument to the functions. Reported by Joseph Myers. (CVE-2014-9761) * A stack-based buffer overflow was found in libresolv when invoked from libnss_dns, allowing specially crafted DNS responses to seize control of execution flow in the DNS client. The buffer overflow occurs in the functions send_dg (send datagram) and send_vc (send TCP) for the NSS module libnss_dns.so.2 when calling getaddrinfo with AF_UNSPEC family. The use of AF_UNSPEC triggers the low-level resolver code to send out two parallel queries for A and AAAA. A mismanagement of the buffers used for those queries could result in the response of a query writing beyond the alloca allocated buffer created by _nss_dns_gethostbyname4_r. Buffer management is simplified to remove the overflow. Thanks to the Google Security Team and Red Hat for reporting the security impact of this issue, and Robert Holiday of Ciena for reporting the related bug 18665. (CVE-2015-7547) The following bugs are resolved with this release: [89] localedata: Locales nb_NO and nn_NO should transliterate æøå [887] math: Math library function "logb" and "nextafter" inconsistent [2542] math: Incorrect return from float gamma (-0X1.FA471547C2FE5P+1) [2543] math: Incorrect return from float gamma (-0X1.9260DCP+1) [2558] math: Incorrect return from double gamma (-0X1.FA471547C2FE5P+1) [2898] libc: [improve] warning: the use of `mktemp' is dangerous, better use `mkstemp' [4404] localedata: German translation of "Alarm clock" is misleading [6799] math: nextafter() and nexttoward() doen't set errno on overflow/underflow errors [6803] math: scalb(), scalbln(), scalbn() do not set errno on overflow/underflow [10432] nis: _nss_nis_setnetgrent assertion failure [11460] libc: fts has no LFS support [12926] network: getaddrinfo()/make_request() may spin forever [13065] nptl: Race condition in pthread barriers [13690] nptl: pthread_mutex_unlock potentially cause invalid access [14341] dynamic-link: Dynamic linker crash when DT_JMPREL and DT_REL{,A} are not contiguous [14551] math: [ldbl-128ibm] strtold overflow handling for IBM long double [14912] libc: Rename non-installed bits/*.h headers [15002] libc: Avoid undefined behavior in posix_fallocate overflow check [15367] math: Let gcc use __builtin_isinf [15384] math: One constant fewer in ieee754/dbl-64/wordsize-64/s_finite.c [15421] math: lgamma wrongly sets signgam for ISO C [15470] math: [arm] On ARM llrintl() and llroundl() do not raise FE_INVALID with argument out of range [15491] math: [i386/x86_64] x86 nearbyint implementations wrongly clear all exceptions [15786] dynamic-link: ifunc resolver functions can smash function arguments [15918] math: Unnecessary check for equality in hypotf() [16061] localedata: Review / update transliteration data [16068] math: [i386/x86_64] x86 and x86_64 fesetenv exclude state they should include [16141] time: strptime %z offset restriction [16171] math: drem should be alias of remainder [16296] math: fegetround is pure? [16347] math: [ldbl-128ibm] ldbl-128/e_lgammal_r.c may not be suitable. [16364] libc: sleep may leave SIGCHLD blocked on sync cancellation on GNU/Linux [16399] math: [mips] lrint / llrint / lround / llround missing exceptions [16415] math: Clean up ldbl-128 / ldbl-128ibm expm1l for large positive arguments [16422] math: [powerpc] math-float, math-double failing llrint tests with "Exception "Inexact" set" on ppc32 [16495] localedata: nl_NL: date_fmt: shuffle year/month around [16517] math: Missing underflow exception from tanf/tan/tanl [16519] math: Missing underflow exception from sinhf [16520] math: Missing underflow exception from tanhf [16521] math: Missing underflow exception from exp2 [16620] math: [ldbl-128ibm] exp10l spurious overflows / bad directed rounding results [16734] stdio: fopen calls mmap to allocate its buffer [16961] math: nan function incorrect handling of bad sequences [16962] math: nan function unbounded stack allocation (CVE-2014-9761) [16973] localedata: Fix lang_lib/lang_term as per ISO 639-2 [16985] locale: localedef: confusing error message when opening output fails [17118] math: ctanh(INFINITY + 2 * I) returns incorrect value [17197] locale: Redundant shift character in iconv conversion output at block boundary [17243] libc: trunk/posix/execl.c:53: va_args problem ? [17244] libc: trunk/sysdeps/unix/sysv/linux/semctl.c:116: va_args muxup ? [17250] dynamic-link: static linking breaks nss loading (getaddrinfo/getpwnam/etc...) [17404] libc: atomic_exchange_rel lacking a barrier on MIPS16, GCC before 4.7? [17441] math: isnan() should use __builtin_isnan() in GCC [17514] nptl: Assert failure unlocking ERRORCHECK mutex after timedlock (related to lock elision) [17787] manual: Exponent on page 324 of the PDF ends prematurely [17886] time: strptime should be able to parse "Z" as a timezone with %z [17887] time: strptime should be able to parse "+01:00" style timezones [17905] libc: catopen() Multiple unbounded stack allocations (CVE-2015-8779) [18084] libc: backtrace (..., 0) dumps core on x86 [18086] libc: nice() sets errno to 0 on success [18240] libc: hcreate, hcreate_r should fail with ENOMEM if element count is too large (CVE-2015-8778) [18251] dynamic-link: SONAME missing when audit modules provides path [18265] libc: add attributes for wchar string and memory functions [18370] math: csqrt missing underflows [18421] libc: [hppa] read-only segment has dynamic relocations [18472] libc: Obsolete syscall wrappers should be compat symbols [18480] libc: hppa glibc miscompilation in sched_setaffinity() [18491] localedata: Update tr_TR LC_CTYPE as part of Unicode updates [18525] localedata: Remove locale timezone information [18560] libc: [powerpc] spurious bits/ipc.h definitions [18568] localedata: Update locale data to Unicode 8.0 [18589] locale: sort-test.sh fails at random [18595] math: ctan, ctanh missing underflows [18604] libc: assert macro-expands its argument [18610] math: S390: fetestexcept() reports any exception if DXC-code contains a vector instruction exception. [18611] math: j1, jn missing errno setting on underflow [18618] localedata: sync Chechen locale definitions with other *_RU locales [18647] math: powf(-0x1.000002p0, 0x1p30) returns 0 instead of +inf [18661] libc: Some x86-64 assembly codes don't align stack to 16 bytes [18665] network: In send_dg, the recvfrom function is NOT always using the buffer size of a newly created buffer (CVE-2015-7547) [18674] libc: [i386] trunk/sysdeps/i386/tst-auditmod3b.c:84: possible missing break ? [18675] libc: fpathconf(_PC_NAME_MAX) fails against large filesystems for 32bit processes [18681] libc: regexp.h is obsolete and buggy, and should be desupported [18699] math: tilegx cproj() for various complex infinities does not yield infinity [18724] libc: Harden put*ent functions against data injection [18743] nptl: PowerPC: findutils testcase fails with --enable-lock-elision [18755] build: build errors with -DNDEBUG [18757] stdio: fmemopen fails to set errno on failure [18778] dynamic-link: ld.so crashes if failed dlopen causes libpthread to be forced unloaded [18781] libc: openat64 lacks O_LARGEFILE [18787] libc: [hppa] sysdeps/unix/sysv/linux/hppa/bits/atomic.h:71:6: error: can’t find a register in class ‘R1_REGS’ while reloading ‘asm’ [18789] math: [ldbl-128ibm] sinhl inaccurate near 0 [18790] math: [ldbl-128ibm] tanhl inaccurate [18795] libc: stpncpy fortification misses buffer lengths that are statically too large [18796] build: build fails for --disable-mathvec [18803] math: hypot missing underflows [18820] stdio: fmemopen may leak memory on failure [18823] math: csqrt spurious underflows [18824] math: fma spurious underflows [18825] math: pow missing underflows [18857] math: [ldbl-128ibm] nearbyintl wrongly uses signaling comparisons [18868] nptl: pthread_barrier_init typo has in-theory-undefined behavior [18870] build: sem_open.c fails to compile with missing symbol FUTEX_SHARED [18872] stdio: Fix memory leak in printf_positional [18873] libc: posix_fallocate overflow check ineffective [18875] math: Excess precision leads incorrect libm [18877] libc: arm: mmap offset regression [18887] libc: memory corruption when using getmntent on blank lines [18918] localedata: hu_HU: change time to HH:MM:SS format [18921] libc: Regression: extraneous stat() and fstat() performed by opendir() [18928] dynamic-link: LD_POINTER_GUARD is not ignored for privileged binaries (CVE-2015-8777) [18951] math: tgamma missing underflows [18952] math: [ldbl-128/ldbl-128ibm] lgammal spurious "invalid", incorrect signgam [18953] localedata: lt_LT: change currency symbol to the euro [18956] math: powf inaccuracy [18961] math: [i386] exp missing underflows [18966] math: [i386] exp10 missing underflows [18967] math: math.h XSI POSIX namespace (gamma, isnan, scalb) [18969] build: multiple string test failures due to missing locale dependencies [18970] libc: Reference of pthread_setcancelstate in libc.a [18977] math: float / long double Bessel functions not in XSI POSIX [18980] math: i386 libm functions return with excess range and precision [18981] math: i386 scalb*, ldexp return with excess range and precision [18982] stdio: va_list and vprintf [18985] time: Passing out of range data to strftime() causes a segfault (CVE-2015-8776) [19003] math: [x86_64] fma4 version of pow inappropriate contraction [19007] libc: FAIL: elf/check-localplt with -z now and binutils 2.26 [19012] locale: iconv_open leaks memory on error path [19016] math: clog, clog10 inaccuracy [19018] nptl: Mangle function pointers in tls_dtor_list [19032] math: [i386] acosh (-qNaN) spurious "invalid" exception [19046] math: ldbl-128 / ldbl-128ibm lgamma bad overflow handling [19048] malloc: malloc: arena free list can become cyclic, increasing contention [19049] math: [powerpc] erfc incorrect zero sign [19050] math: [powerpc] log* incorrect zero sign [19058] math: [x86_64] Link fail with -fopenmp and -flto [19059] math: nexttoward overflow incorrect in non-default rounding modes [19071] math: ldbl-96 lroundl incorrect just below powers of 2 [19074] network: Data race in _res_hconf_reorder_addrs [19076] math: [ldbl-128ibm] log1pl (-1) wrong sign of infinity [19077] math: [ldbl-128ibm] logl (1) incorrect sign of zero result [19078] math: [ldbl-128ibm] expl overflow incorrect in non-default rounding modes [19079] math: dbl-64/wordsize-64 lround based on llround incorrect for ILP32 [19085] math: ldbl-128 lrintl, lroundl missing exceptions for 32-bit long [19086] manual: posix_fallocate64 documented argument order is wrong. [19088] math: lround, llround missing exceptions close to overflow threshold [19094] math: lrint, llrint missing exceptions close to overflow threshold [19095] math: dbl-64 lrint incorrect for 64-bit long [19122] dynamic-link: Unnecessary PLT relocations in librtld.os [19124] dynamic-link: ld.so failed to build with older assmebler [19125] math: [powerpc32] llroundf, llround incorrect exceptions [19129] dynamic-link: [arm] Concurrent lazy TLSDESC resolution can crash [19134] math: [powerpc32] lround, lroundf spurious exceptions [19137] libc: i386/epoll_pwait.S doesn't support cancellation [19143] nptl: Remove CPU set size checking from sched_setaffinity, pthread_setaffinity_np [19156] math: [ldbl-128] j0l spurious underflows [19164] nptl: tst-getcpu fails with many possible CPUs [19168] math: math/test-ildoubl and math/test-ldouble failure [19174] nptl: PowerPC: TLE enabled pthread mutex performs poorly. [19178] dynamic-link: ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA confuses prelink [19181] math: [i386/x86_64] fesetenv (FE_DFL_ENV), fesetenv (FE_NOMASK_ENV) do not clear SSE exceptions [19182] malloc: malloc deadlock between ptmalloc_lock_all and _int_new_arena/reused_arena [19189] math: [ldbl-128] log1pl (-qNaN) spurious "invalid" exception [19201] math: dbl-64 remainder incorrect sign of zero result [19205] math: bits/math-finite.h conditions do not match math.h and bits/mathcalls.h [19209] math: bits/math-finite.h wrongly maps ldexp to scalbn [19211] math: lgamma functions do not set signgam for -ffinite-math-only for C99-based standards [19212] libc: features.h not -Wundef clean [19213] math: [i386/x86_64] log* (1) incorrect zero sign for -ffinite- math-only [19214] libc: Family and model identification for AMD CPU's are incorrect. [19219] libc: GLIBC build fails for ia64 with missing __nearbyintl [19228] math: [powerpc] nearbyint wrongly clears "inexact", leaves traps disabled [19235] math: [powerpc64] lround, lroundf, llround, llroundf spurious "inexact" exceptions [19238] math: [powerpc] round, roundf spurious "inexact" for integer arguments [19242] libc: strtol incorrect in Turkish locales [19243] malloc: reused_arena can pick an arena on the free list, leading to an assertion failure and reference count corruption [19253] time: tzset() ineffective when temporary TZ did not include DST rules [19266] math: strtod ("NAN(I)") incorrect in Turkish locales [19270] math: [hppa] Shared libm missing __isnanl [19285] libc: [hppa] sysdeps/unix/sysv/linux/hppa/bits/mman.h: missing MAP_HUGETLB and MAP_STACK defines [19313] nptl: Wrong __cpu_mask for x32 [19347] libc: grantpt: try to force a specific gid even without pt_chown [19349] math: [ldbl-128ibm] tanhl inaccurate for small arguments [19350] math: [ldbl-128ibm] sinhl spurious overflows [19351] math: [ldbl-128ibm] logl inaccurate near 1 [19363] time: x32: times() return value wrongly truncates/sign extends from 32bit [19367] dynamic-link: Improve branch prediction on Silvermont [19369] network: Default domain name not reset by res_ninit when "search" / "domain" entry is removed from resolv.conf [19375] math: powerpc: incorrect results for POWER7 logb with negative subnormals [19385] localedata: bg_BG: time separator should be colon, not comma [19408] libc: linux personality syscall wrapper may erroneously return an error on 32-bit architectures [19415] libc: dladdr returns wrong names on hppa [19432] libc: iconv rejects redundant escape sequences in IBM900, IBM903, IBM905, IBM907, and IBM909 [19439] math: Unix98 isinf and isnan functions conflict with C++11 [19443] build: build failures with -DDEBUG [19451] build: Make check fails on test-double-vlen2 [19462] libc: Glibc failed to build with -Os [19465] math: Wrong code with -Os [19466] time: time/tst-mktime2.c is compiled into an infinite loop with -Os [19467] string: Fast_Unaligned_Load needs to be enabled for Excavator core CPU's. [19475] libc: Glibc 2.22 doesn't build on sparc [PATCH] [19486] math: S390: Math tests fail with "Exception Inexact set". [19529] libc: [ARM]: FAIL: stdlib/tst-makecontext [19550] libc: [mips] mmap negative offset handling inconsistent with other architectures [19590] math: Fail to build shared objects that use libmvec.so functions. Contributors ============ This release was made possible by the contributions of many people. The maintainers are grateful to everyone who has contributed changes or bug reports. These include: Adhemerval Zanella Alan Modra Amit Pawar Andreas Schwab Andrew Bennett Andrew Senkevich Andrew Stubbs Anton Blanchard Arjun Shankar Arslanbek Astemirov Aurelien Jarno Brett Neumeier Carlos Eduardo Seo Carlos O'Donell Chris Metcalf Chung-Lin Tang Damyan Ivanov Daniel Marjamäki David Kastrup David Lamparter David S. Miller Dmitry V. Levin Egmont Koblinger Evert Flavio Cruz Florian Weimer Gabriel F. T. Gomes Geoffrey Thomas Gleb Fotengauer-Malinovskiy Gunnar Hjalmarsson H.J. Lu Helge Deller James Perkins John David Anglin Joseph Myers Justus Winter Khem Raj Ludovic Courtès Maciej W. Rozycki Manolis Ragkousis Marcin Kościelnicki Mark Wielaard Marko Myllynen Martin Sebor Maxim Ostapenko Mike FABIAN Mike Frysinger Namhyung Kim Ondrej Bilka Ondřej Bílka Paul E. Murphy Paul Eggert Paul Murphy Paul Pluzhnikov Petar Jovanovic Phil Blundell Rajalakshmi Srinivasaraghavan Rasmus Villemoes Richard Henderson Rob Wu Roland McGrath Samuel Thibault Siddhesh Poyarekar Stan Shebs Stefan Liebler Steve Ellcey Szabolcs Nagy Thomas Schwinge Torvald Riegel Tulio Magno Quites Machado Filho Vincent Bernat Wilco Dijkstra Zack Weinberg
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/bits/huge_val.h2
-rw-r--r--sysdeps/ieee754/bits/huge_valf.h2
-rw-r--r--sysdeps/ieee754/bits/inf.h2
-rw-r--r--sysdeps/ieee754/bits/nan.h2
-rw-r--r--sysdeps/ieee754/dbl-64/MathLib.h2
-rw-r--r--sysdeps/ieee754/dbl-64/asincos.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/atnat.h2
-rw-r--r--sysdeps/ieee754/dbl-64/atnat2.h6
-rw-r--r--sysdeps/ieee754/dbl-64/branred.c2
-rw-r--r--sysdeps/ieee754/dbl-64/branred.h2
-rw-r--r--sysdeps/ieee754/dbl-64/dbl2mpn.c2
-rw-r--r--sysdeps/ieee754/dbl-64/dla.h2
-rw-r--r--sysdeps/ieee754/dbl-64/doasin.c2
-rw-r--r--sysdeps/ieee754/dbl-64/doasin.h2
-rw-r--r--sysdeps/ieee754/dbl-64/dosincos.c2
-rw-r--r--sysdeps/ieee754/dbl-64/dosincos.h2
-rw-r--r--sysdeps/ieee754/dbl-64/e_asin.c8
-rw-r--r--sysdeps/ieee754/dbl-64/e_atan2.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_atanh.c8
-rw-r--r--sysdeps/ieee754/dbl-64/e_cosh.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_exp.c7
-rw-r--r--sysdeps/ieee754/dbl-64/e_exp10.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_exp2.c8
-rw-r--r--sysdeps/ieee754/dbl-64/e_gamma_r.c23
-rw-r--r--sysdeps/ieee754/dbl-64/e_hypot.c4
-rw-r--r--sysdeps/ieee754/dbl-64/e_j1.c10
-rw-r--r--sysdeps/ieee754/dbl-64/e_jn.c9
-rw-r--r--sysdeps/ieee754/dbl-64/e_lgamma_r.c8
-rw-r--r--sysdeps/ieee754/dbl-64/e_log.c2
-rw-r--r--sysdeps/ieee754/dbl-64/e_log10.c3
-rw-r--r--sysdeps/ieee754/dbl-64/e_log2.c7
-rw-r--r--sysdeps/ieee754/dbl-64/e_pow.c10
-rw-r--r--sysdeps/ieee754/dbl-64/e_remainder.c4
-rw-r--r--sysdeps/ieee754/dbl-64/e_sinh.c9
-rw-r--r--sysdeps/ieee754/dbl-64/e_sqrt.c7
-rw-r--r--sysdeps/ieee754/dbl-64/gamma_product.c2
-rw-r--r--sysdeps/ieee754/dbl-64/gamma_productf.c7
-rw-r--r--sysdeps/ieee754/dbl-64/halfulp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/k_rem_pio2.c19
-rw-r--r--sysdeps/ieee754/dbl-64/lgamma_neg.c383
-rw-r--r--sysdeps/ieee754/dbl-64/lgamma_product.c82
-rw-r--r--sysdeps/ieee754/dbl-64/mpa-arch.h2
-rw-r--r--sysdeps/ieee754/dbl-64/mpa.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpa.h2
-rw-r--r--sysdeps/ieee754/dbl-64/mpatan.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpatan.h2
-rw-r--r--sysdeps/ieee754/dbl-64/mpatan2.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpexp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mplog.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpn2dbl.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpsqrt.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mpsqrt.h2
-rw-r--r--sysdeps/ieee754/dbl-64/mptan.c2
-rw-r--r--sysdeps/ieee754/dbl-64/mydefs.h2
-rw-r--r--sysdeps/ieee754/dbl-64/powtwo.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/root.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/s_asinh.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_atan.c8
-rw-r--r--sysdeps/ieee754/dbl-64/s_cbrt.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_erf.c17
-rw-r--r--sysdeps/ieee754/dbl-64/s_expm1.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_finite.c12
-rw-r--r--sysdeps/ieee754/dbl-64/s_fma.c15
-rw-r--r--sysdeps/ieee754/dbl-64/s_fmaf.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_fpclassify.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_isinf.c5
-rw-r--r--sysdeps/ieee754/dbl-64/s_isinf_ns.c20
-rw-r--r--sysdeps/ieee754/dbl-64/s_isnan.c5
-rw-r--r--sysdeps/ieee754/dbl-64/s_issignaling.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_llrint.c23
-rw-r--r--sysdeps/ieee754/dbl-64/s_llround.c17
-rw-r--r--sysdeps/ieee754/dbl-64/s_log1p.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_logb.c3
-rw-r--r--sysdeps/ieee754/dbl-64/s_lrint.c51
-rw-r--r--sysdeps/ieee754/dbl-64/s_lround.c41
-rw-r--r--sysdeps/ieee754/dbl-64/s_remquo.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_round.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_scalbn.c2
-rw-r--r--sysdeps/ieee754/dbl-64/s_signbit.c9
-rw-r--r--sysdeps/ieee754/dbl-64/s_sin.c883
-rw-r--r--sysdeps/ieee754/dbl-64/s_sincos.c88
-rw-r--r--sysdeps/ieee754/dbl-64/s_tan.c4
-rw-r--r--sysdeps/ieee754/dbl-64/s_tanh.c6
-rw-r--r--sysdeps/ieee754/dbl-64/s_trunc.c2
-rw-r--r--sysdeps/ieee754/dbl-64/sincos32.c2
-rw-r--r--sysdeps/ieee754/dbl-64/sincos32.h2
-rw-r--r--sysdeps/ieee754/dbl-64/sincostab.c2
-rw-r--r--sysdeps/ieee754/dbl-64/slowexp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/slowpow.c2
-rw-r--r--sysdeps/ieee754/dbl-64/t_exp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/uasncs.h2
-rw-r--r--sysdeps/ieee754/dbl-64/uatan.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/uexp.h4
-rw-r--r--sysdeps/ieee754/dbl-64/uexp.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/ulog.h2
-rw-r--r--sysdeps/ieee754/dbl-64/ulog.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/upow.h4
-rw-r--r--sysdeps/ieee754/dbl-64/upow.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/urem.h2
-rw-r--r--sysdeps/ieee754/dbl-64/uroot.h43
-rw-r--r--sysdeps/ieee754/dbl-64/usncs.h2
-rw-r--r--sysdeps/ieee754/dbl-64/utan.h2
-rw-r--r--sysdeps/ieee754/dbl-64/utan.tbl2
-rw-r--r--sysdeps/ieee754/dbl-64/w_exp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/math_private.h36
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c12
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c5
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c20
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c5
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c3
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c19
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c90
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_round.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c2
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c2
-rw-r--r--sysdeps/ieee754/dbl-64/x2y2m1.c24
-rw-r--r--sysdeps/ieee754/dbl-64/x2y2m1f.c6
-rw-r--r--sysdeps/ieee754/flt-32/e_asinf.c6
-rw-r--r--sysdeps/ieee754/flt-32/e_atanhf.c8
-rw-r--r--sysdeps/ieee754/flt-32/e_coshf.c2
-rw-r--r--sysdeps/ieee754/flt-32/e_exp2f.c14
-rw-r--r--sysdeps/ieee754/flt-32/e_expf.c2
-rw-r--r--sysdeps/ieee754/flt-32/e_gammaf_r.c23
-rw-r--r--sysdeps/ieee754/flt-32/e_hypotf.c12
-rw-r--r--sysdeps/ieee754/flt-32/e_j1f.c9
-rw-r--r--sysdeps/ieee754/flt-32/e_jnf.c12
-rw-r--r--sysdeps/ieee754/flt-32/e_lgammaf_r.c9
-rw-r--r--sysdeps/ieee754/flt-32/e_log10f.c5
-rw-r--r--sysdeps/ieee754/flt-32/e_log2f.c8
-rw-r--r--sysdeps/ieee754/flt-32/e_powf.c13
-rw-r--r--sysdeps/ieee754/flt-32/e_sinhf.c7
-rw-r--r--sysdeps/ieee754/flt-32/k_rem_pio2f.c23
-rw-r--r--sysdeps/ieee754/flt-32/k_sinf.c6
-rw-r--r--sysdeps/ieee754/flt-32/k_tanf.c9
-rw-r--r--sysdeps/ieee754/flt-32/lgamma_negf.c280
-rw-r--r--sysdeps/ieee754/flt-32/lgamma_productf.c1
-rw-r--r--sysdeps/ieee754/flt-32/math_private.h35
-rw-r--r--sysdeps/ieee754/flt-32/mpn2flt.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_asinhf.c6
-rw-r--r--sysdeps/ieee754/flt-32/s_atanf.c6
-rw-r--r--sysdeps/ieee754/flt-32/s_cbrtf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_cosf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_erff.c17
-rw-r--r--sysdeps/ieee754/flt-32/s_expm1f.c6
-rw-r--r--sysdeps/ieee754/flt-32/s_finitef.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_fpclassifyf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_isinf_nsf.c20
-rw-r--r--sysdeps/ieee754/flt-32/s_issignalingf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_llrintf.c21
-rw-r--r--sysdeps/ieee754/flt-32/s_llroundf.c17
-rw-r--r--sysdeps/ieee754/flt-32/s_log1pf.c6
-rw-r--r--sysdeps/ieee754/flt-32/s_logbf.c3
-rw-r--r--sysdeps/ieee754/flt-32/s_lrintf.c21
-rw-r--r--sysdeps/ieee754/flt-32/s_lroundf.c17
-rw-r--r--sysdeps/ieee754/flt-32/s_nextafterf.c3
-rw-r--r--sysdeps/ieee754/flt-32/s_remquof.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_roundf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_scalbnf.c1
-rw-r--r--sysdeps/ieee754/flt-32/s_signbitf.c9
-rw-r--r--sysdeps/ieee754/flt-32/s_sincosf.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_tanhf.c4
-rw-r--r--sysdeps/ieee754/flt-32/s_truncf.c2
-rw-r--r--sysdeps/ieee754/flt-32/t_exp2f.h2
-rw-r--r--sysdeps/ieee754/flt-32/w_expf.c2
-rw-r--r--sysdeps/ieee754/ieee754.h2
-rw-r--r--sysdeps/ieee754/k_standardf.c2
-rw-r--r--sysdeps/ieee754/k_standardl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/e_asinl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/e_atanhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/e_exp10l.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/e_expl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/e_gammal_r.c3
-rw-r--r--sysdeps/ieee754/ldbl-128/e_hypotl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128/e_j0l.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/e_j1l.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/e_jnl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/e_lgammal_r.c20
-rw-r--r--sysdeps/ieee754/ldbl-128/e_log2l.c3
-rw-r--r--sysdeps/ieee754/ldbl-128/e_powl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/e_rem_pio2l.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/e_sinhl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/gamma_productl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/ieee754.h2
-rw-r--r--sysdeps/ieee754/ldbl-128/k_cosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/k_sincosl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/k_sinl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/k_tanl.c12
-rw-r--r--sysdeps/ieee754/ldbl-128/ldbl2mpn.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/lgamma_negl.c551
-rw-r--r--sysdeps/ieee754/ldbl-128/lgamma_productl.c82
-rw-r--r--sysdeps/ieee754/ldbl-128/mpn2ldbl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/printf_fphex.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_asinhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/s_atanl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/s_erfl.c7
-rw-r--r--sysdeps/ieee754/ldbl-128/s_expm1l.c24
-rw-r--r--sysdeps/ieee754/ldbl-128/s_finitel.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_fma.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_fmal.c15
-rw-r--r--sysdeps/ieee754/ldbl-128/s_fpclassifyl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_isinf_nsl.c19
-rw-r--r--sysdeps/ieee754/ldbl-128/s_issignalingl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_llrintl.c46
-rw-r--r--sysdeps/ieee754/ldbl-128/s_llroundl.c36
-rw-r--r--sysdeps/ieee754/ldbl-128/s_log1pl.c11
-rw-r--r--sysdeps/ieee754/ldbl-128/s_lrintl.c85
-rw-r--r--sysdeps/ieee754/ldbl-128/s_lroundl.c63
-rw-r--r--sysdeps/ieee754/ldbl-128/s_nextafterl.c3
-rw-r--r--sysdeps/ieee754/ldbl-128/s_nexttoward.c10
-rw-r--r--sysdeps/ieee754/ldbl-128/s_nexttowardf.c8
-rw-r--r--sysdeps/ieee754/ldbl-128/s_remquol.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_roundl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_scalbnl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128/s_signbitl.c9
-rw-r--r--sysdeps/ieee754/ldbl-128/s_sincosl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128/s_tanhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128/s_truncl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h33
-rw-r--r--sysdeps/ieee754/ldbl-128/strtold_l.c15
-rw-r--r--sysdeps/ieee754/ldbl-128/t_expl.h2
-rw-r--r--sysdeps/ieee754/ldbl-128/t_sincosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/x2y2m1l.c24
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/Makefile5
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_asinl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_atanhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_exp10l.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_expl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c3
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_hypotl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_jnl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_log2l.c3
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_logl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_powl.c1
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_sinhl.c7
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/gamma_productl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/ieee754.h2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/k_cosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/k_sincosl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/k_sinl.c8
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/k_tanl.c12
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c532
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c38
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c19
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/printf_fphex.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_asinhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_atanl.c6
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_ceill.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_erfl.c13
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_expm1l.c18
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_finitel.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_floorl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_fmal.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c23
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_llrintl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_llroundl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_log1pl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_logbl.c3
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_lrintl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_lroundl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c20
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c12
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c10
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c10
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_remquol.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_rintl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_roundl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c5
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_signbitl.c10
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_sincosl.c4
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_tanhl.c16
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_truncl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h30
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/strtold_l.c12
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/t_sincosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c85
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/w_expl.c7
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/w_log1pl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/w_scalblnl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c26
-rw-r--r--sysdeps/ieee754/ldbl-64-128/s_scalbnl.c5
-rw-r--r--sysdeps/ieee754/ldbl-64-128/strtold_l.c15
-rw-r--r--sysdeps/ieee754/ldbl-64-128/w_log1pl.c2
-rw-r--r--sysdeps/ieee754/ldbl-64-128/w_scalblnl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/e_asinl.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/e_atanhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/e_gammal_r.c3
-rw-r--r--sysdeps/ieee754/ldbl-96/e_hypotl.c4
-rw-r--r--sysdeps/ieee754/ldbl-96/e_j1l.c8
-rw-r--r--sysdeps/ieee754/ldbl-96/e_jnl.c8
-rw-r--r--sysdeps/ieee754/ldbl-96/e_lgammal_r.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/e_rem_pio2l.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/e_sinhl.c5
-rw-r--r--sysdeps/ieee754/ldbl-96/gamma_product.c7
-rw-r--r--sysdeps/ieee754/ldbl-96/gamma_productl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/k_cosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/k_sinl.c8
-rw-r--r--sysdeps/ieee754/ldbl-96/k_tanl.c16
-rw-r--r--sysdeps/ieee754/ldbl-96/ldbl2mpn.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/lgamma_negl.c418
-rw-r--r--sysdeps/ieee754/ldbl-96/lgamma_product.c37
-rw-r--r--sysdeps/ieee754/ldbl-96/lgamma_productl.c82
-rw-r--r--sysdeps/ieee754/ldbl-96/mpn2ldbl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/printf_fphex.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/s_asinhl.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/s_cbrtl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/s_erfl.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/s_fma.c7
-rw-r--r--sysdeps/ieee754/ldbl-96/s_fmal.c15
-rw-r--r--sysdeps/ieee754/ldbl-96/s_isinf_nsl.c18
-rw-r--r--sysdeps/ieee754/ldbl-96/s_issignalingl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/s_llrintl.c23
-rw-r--r--sysdeps/ieee754/ldbl-96/s_llroundl.c13
-rw-r--r--sysdeps/ieee754/ldbl-96/s_lrintl.c59
-rw-r--r--sysdeps/ieee754/ldbl-96/s_lroundl.c43
-rw-r--r--sysdeps/ieee754/ldbl-96/s_nexttoward.c10
-rw-r--r--sysdeps/ieee754/ldbl-96/s_nexttowardf.c10
-rw-r--r--sysdeps/ieee754/ldbl-96/s_remquol.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/s_roundl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/s_signbitl.c9
-rw-r--r--sysdeps/ieee754/ldbl-96/s_sincosl.c4
-rw-r--r--sysdeps/ieee754/ldbl-96/s_tanhl.c4
-rw-r--r--sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h30
-rw-r--r--sysdeps/ieee754/ldbl-96/strtold_l.c12
-rw-r--r--sysdeps/ieee754/ldbl-96/t_sincosl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/w_expl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/x2y2m1.c6
-rw-r--r--sysdeps/ieee754/ldbl-96/x2y2m1l.c24
-rw-r--r--sysdeps/ieee754/ldbl-opt/Makefile5
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.c4
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.h2
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-drem.c8
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-remainder.c2
-rw-r--r--sysdeps/ieee754/ldbl-opt/s_ldexpl.c3
-rw-r--r--sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c10
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_drem.c5
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_dreml.c5
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_lgamma.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c7
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c11
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_lgammal.c6
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_remainder.c2
-rw-r--r--sysdeps/ieee754/ldbl-opt/w_remainderl.c2
-rw-r--r--sysdeps/ieee754/s_signgam.c3
352 files changed, 4401 insertions, 1816 deletions
diff --git a/sysdeps/ieee754/bits/huge_val.h b/sysdeps/ieee754/bits/huge_val.h
index d71aeaed10..42d416f703 100644
--- a/sysdeps/ieee754/bits/huge_val.h
+++ b/sysdeps/ieee754/bits/huge_val.h
@@ -1,6 +1,6 @@
/* `HUGE_VAL' constant for IEEE 754 machines (where it is infinity).
Used by <stdlib.h> and <math.h> functions for overflow.
- Copyright (C) 1992-2015 Free Software Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/bits/huge_valf.h b/sysdeps/ieee754/bits/huge_valf.h
index 1d4ceca7f3..9d418ba320 100644
--- a/sysdeps/ieee754/bits/huge_valf.h
+++ b/sysdeps/ieee754/bits/huge_valf.h
@@ -1,6 +1,6 @@
/* `HUGE_VALF' constant for IEEE 754 machines (where it is infinity).
Used by <stdlib.h> and <math.h> functions for overflow.
- Copyright (C) 1992-2015 Free Software Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/bits/inf.h b/sysdeps/ieee754/bits/inf.h
index 280c42a48a..179bf48a87 100644
--- a/sysdeps/ieee754/bits/inf.h
+++ b/sysdeps/ieee754/bits/inf.h
@@ -1,5 +1,5 @@
/* `INFINITY' constant for IEEE 754 machines.
- Copyright (C) 2004-2015 Free Software Foundation, Inc.
+ Copyright (C) 2004-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/bits/nan.h b/sysdeps/ieee754/bits/nan.h
index 700ff07aac..b832724d6b 100644
--- a/sysdeps/ieee754/bits/nan.h
+++ b/sysdeps/ieee754/bits/nan.h
@@ -1,5 +1,5 @@
/* `NAN' constant for IEEE 754 machines.
- Copyright (C) 1992-2015 Free Software Foundation, Inc.
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/MathLib.h b/sysdeps/ieee754/dbl-64/MathLib.h
index 8d8de6fa1b..94182e45c1 100644
--- a/sysdeps/ieee754/dbl-64/MathLib.h
+++ b/sysdeps/ieee754/dbl-64/MathLib.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/asincos.tbl b/sysdeps/ieee754/dbl-64/asincos.tbl
index 84efa43a2d..8da9ff3c07 100644
--- a/sysdeps/ieee754/dbl-64/asincos.tbl
+++ b/sysdeps/ieee754/dbl-64/asincos.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/atnat.h b/sysdeps/ieee754/dbl-64/atnat.h
index a9c265fe41..a9649c57ea 100644
--- a/sysdeps/ieee754/dbl-64/atnat.h
+++ b/sysdeps/ieee754/dbl-64/atnat.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/atnat2.h b/sysdeps/ieee754/dbl-64/atnat2.h
index e0d65afd06..d5f4ab946d 100644
--- a/sysdeps/ieee754/dbl-64/atnat2.h
+++ b/sysdeps/ieee754/dbl-64/atnat2.h
@@ -2,7 +2,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -65,10 +65,8 @@
/**/ hpi1 = {{0x3c91a626, 0x33145c07} }, /* pi/2-hpi */
/**/ mhpi = {{0xbff921fb, 0x54442d18} }, /* -pi/2 */
/**/ qpi = {{0x3fe921fb, 0x54442d18} }, /* pi/4 */
-/**/ qpi1 = {{0x3c81a626, 0x33145c07} }, /* pi/4-qpi */
/**/ mqpi = {{0xbfe921fb, 0x54442d18} }, /* -pi/4 */
/**/ tqpi = {{0x4002d97c, 0x7f3321d2} }, /* 3pi/4 */
-/**/ tqpi1 = {{0x3c9a7939, 0x4c9e8a0a} }, /* 3pi/4-tqpi */
/**/ mtqpi = {{0xc002d97c, 0x7f3321d2} }, /* -3pi/4 */
/**/ u1 = {{0x3c314c2a, 0x00000000} }, /* 9.377e-19 */
/**/ u2 = {{0x3bf955e4, 0x00000000} }, /* 8.584e-20 */
@@ -129,10 +127,8 @@
/**/ hpi1 = {{0x33145c07, 0x3c91a626} }, /* pi/2-hpi */
/**/ mhpi = {{0x54442d18, 0xbff921fb} }, /* -pi/2 */
/**/ qpi = {{0x54442d18, 0x3fe921fb} }, /* pi/4 */
-/**/ qpi1 = {{0x33145c07, 0x3c81a626} }, /* pi/4-qpi */
/**/ mqpi = {{0x54442d18, 0xbfe921fb} }, /* -pi/4 */
/**/ tqpi = {{0x7f3321d2, 0x4002d97c} }, /* 3pi/4 */
-/**/ tqpi1 = {{0x4c9e8a0a, 0x3c9a7939} }, /* 3pi/4-tqpi */
/**/ mtqpi = {{0x7f3321d2, 0xc002d97c} }, /* -3pi/4 */
/**/ u1 = {{0x00000000, 0x3c314c2a} }, /* 9.377e-19 */
/**/ u2 = {{0x00000000, 0x3bf955e4} }, /* 8.584e-20 */
diff --git a/sysdeps/ieee754/dbl-64/branred.c b/sysdeps/ieee754/dbl-64/branred.c
index 7757a9c833..ca9dd90aff 100644
--- a/sysdeps/ieee754/dbl-64/branred.c
+++ b/sysdeps/ieee754/dbl-64/branred.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/branred.h b/sysdeps/ieee754/dbl-64/branred.h
index 431bce0c84..7b6b5473b6 100644
--- a/sysdeps/ieee754/dbl-64/branred.h
+++ b/sysdeps/ieee754/dbl-64/branred.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/dbl2mpn.c b/sysdeps/ieee754/dbl-64/dbl2mpn.c
index bb28192883..cb5a070914 100644
--- a/sysdeps/ieee754/dbl-64/dbl2mpn.c
+++ b/sysdeps/ieee754/dbl-64/dbl2mpn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/dla.h b/sysdeps/ieee754/dbl-64/dla.h
index 641644eeb1..d21c47a68f 100644
--- a/sysdeps/ieee754/dbl-64/dla.h
+++ b/sysdeps/ieee754/dbl-64/dla.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/doasin.c b/sysdeps/ieee754/dbl-64/doasin.c
index 2372e1bc53..903b5484ba 100644
--- a/sysdeps/ieee754/dbl-64/doasin.c
+++ b/sysdeps/ieee754/dbl-64/doasin.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/doasin.h b/sysdeps/ieee754/dbl-64/doasin.h
index ac4c84367e..044d597f9c 100644
--- a/sysdeps/ieee754/dbl-64/doasin.h
+++ b/sysdeps/ieee754/dbl-64/doasin.h
@@ -2,7 +2,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/dosincos.c b/sysdeps/ieee754/dbl-64/dosincos.c
index ed5e2c9027..931975e6c3 100644
--- a/sysdeps/ieee754/dbl-64/dosincos.c
+++ b/sysdeps/ieee754/dbl-64/dosincos.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/dosincos.h b/sysdeps/ieee754/dbl-64/dosincos.h
index 7d9324f736..02772592e8 100644
--- a/sysdeps/ieee754/dbl-64/dosincos.h
+++ b/sysdeps/ieee754/dbl-64/dosincos.h
@@ -2,7 +2,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/e_asin.c b/sysdeps/ieee754/dbl-64/e_asin.c
index a7684d1078..d8c012d1d3 100644
--- a/sysdeps/ieee754/dbl-64/e_asin.c
+++ b/sysdeps/ieee754/dbl-64/e_asin.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -71,11 +71,7 @@ __ieee754_asin(double x){
if (k < 0x3e500000)
{
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x; /* for x->0 => sin(x)=x */
}
/*----------------------2^-26 <= |x| < 2^ -3 -----------------*/
diff --git a/sysdeps/ieee754/dbl-64/e_atan2.c b/sysdeps/ieee754/dbl-64/e_atan2.c
index 0c2902855e..22e8fb8fef 100644
--- a/sysdeps/ieee754/dbl-64/e_atan2.c
+++ b/sysdeps/ieee754/dbl-64/e_atan2.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/e_atanh.c b/sysdeps/ieee754/dbl-64/e_atanh.c
index 6b00b800f2..395118e92a 100644
--- a/sysdeps/ieee754/dbl-64/e_atanh.c
+++ b/sysdeps/ieee754/dbl-64/e_atanh.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
@@ -52,11 +52,7 @@ __ieee754_atanh (double x)
if (__glibc_unlikely (xa < 0x1.0p-28))
{
math_force_eval (huge + x);
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
diff --git a/sysdeps/ieee754/dbl-64/e_cosh.c b/sysdeps/ieee754/dbl-64/e_cosh.c
index af3910dd6e..52a5d5007d 100644
--- a/sysdeps/ieee754/dbl-64/e_cosh.c
+++ b/sysdeps/ieee754/dbl-64/e_cosh.c
@@ -83,6 +83,6 @@ __ieee754_cosh (double x)
return x * x;
/* |x| > overflowthresold, cosh(x) overflow */
- return huge * huge;
+ return math_narrow_eval (huge * huge);
}
strong_alias (__ieee754_cosh, __cosh_finite)
diff --git a/sysdeps/ieee754/dbl-64/e_exp.c b/sysdeps/ieee754/dbl-64/e_exp.c
index bb76907f74..ad1bc84625 100644
--- a/sysdeps/ieee754/dbl-64/e_exp.c
+++ b/sysdeps/ieee754/dbl-64/e_exp.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -200,10 +200,7 @@ __ieee754_exp (double x)
check_uflow_ret:
if (retval < DBL_MIN)
{
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- double force_underflow = tiny * tiny;
+ double force_underflow = tiny * tiny;
math_force_eval (force_underflow);
}
if (retval == 0)
diff --git a/sysdeps/ieee754/dbl-64/e_exp10.c b/sysdeps/ieee754/dbl-64/e_exp10.c
index b14eaa9833..e3b39f7e31 100644
--- a/sysdeps/ieee754/dbl-64/e_exp10.c
+++ b/sysdeps/ieee754/dbl-64/e_exp10.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/e_exp2.c b/sysdeps/ieee754/dbl-64/e_exp2.c
index 30f0a8f529..7402bd7d89 100644
--- a/sysdeps/ieee754/dbl-64/e_exp2.c
+++ b/sysdeps/ieee754/dbl-64/e_exp2.c
@@ -1,5 +1,5 @@
/* Double-precision floating point 2^x.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
@@ -120,7 +120,11 @@ __ieee754_exp2 (double x)
if (!unsafe)
return result;
else
- return result * scale_u.d;
+ {
+ result *= scale_u.d;
+ math_check_force_underflow_nonneg (result);
+ return result;
+ }
}
else
/* Return x, if x is a NaN or Inf; or overflow, otherwise. */
diff --git a/sysdeps/ieee754/dbl-64/e_gamma_r.c b/sysdeps/ieee754/dbl-64/e_gamma_r.c
index adeb61a248..2d156850d5 100644
--- a/sysdeps/ieee754/dbl-64/e_gamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_gamma_r.c
@@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -76,11 +76,7 @@ gamma_positive (double x, int *exp2_adj)
/* Adjust into the range for applying Stirling's
approximation. */
double n = __ceil (12.0 - x);
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- double x_tmp = x + n;
- x_adj = x_tmp;
+ x_adj = math_narrow_eval (x + n);
x_eps = (x - (x_adj - n));
prod = __gamma_product (x_adj - n, x_eps, n, &eps);
}
@@ -119,9 +115,6 @@ __ieee754_gamma_r (double x, int *signgamp)
{
int32_t hx;
u_int32_t lx;
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
double ret;
EXTRACT_WORDS (hx, lx, x);
@@ -157,7 +150,7 @@ __ieee754_gamma_r (double x, int *signgamp)
{
/* Overflow. */
*signgamp = 0;
- ret = DBL_MAX * DBL_MAX;
+ ret = math_narrow_eval (DBL_MAX * DBL_MAX);
return ret;
}
else
@@ -194,29 +187,31 @@ __ieee754_gamma_r (double x, int *signgamp)
double tret = M_PI / (-x * sinpix
* gamma_positive (-x, &exp2_adj));
ret = __scalbn (tret, -exp2_adj);
+ math_check_force_underflow_nonneg (ret);
}
}
+ ret = math_narrow_eval (ret);
}
if (isinf (ret) && x != 0)
{
if (*signgamp < 0)
{
- ret = -__copysign (DBL_MAX, ret) * DBL_MAX;
+ ret = math_narrow_eval (-__copysign (DBL_MAX, ret) * DBL_MAX);
ret = -ret;
}
else
- ret = __copysign (DBL_MAX, ret) * DBL_MAX;
+ ret = math_narrow_eval (__copysign (DBL_MAX, ret) * DBL_MAX);
return ret;
}
else if (ret == 0)
{
if (*signgamp < 0)
{
- ret = -__copysign (DBL_MIN, ret) * DBL_MIN;
+ ret = math_narrow_eval (-__copysign (DBL_MIN, ret) * DBL_MIN);
ret = -ret;
}
else
- ret = __copysign (DBL_MIN, ret) * DBL_MIN;
+ ret = math_narrow_eval (__copysign (DBL_MIN, ret) * DBL_MIN);
return ret;
}
else
diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c
index 5cbfcbeb48..f142c450a2 100644
--- a/sysdeps/ieee754/dbl-64/e_hypot.c
+++ b/sysdeps/ieee754/dbl-64/e_hypot.c
@@ -149,7 +149,9 @@ __ieee754_hypot (double x, double y)
t1 = 1.0;
GET_HIGH_WORD (high, t1);
SET_HIGH_WORD (t1, high + (k << 20));
- return t1 * w;
+ w *= t1;
+ math_check_force_underflow_nonneg (w);
+ return w;
}
else
return w;
diff --git a/sysdeps/ieee754/dbl-64/e_j1.c b/sysdeps/ieee754/dbl-64/e_j1.c
index 26ffdfe282..4827fbf3d3 100644
--- a/sysdeps/ieee754/dbl-64/e_j1.c
+++ b/sysdeps/ieee754/dbl-64/e_j1.c
@@ -127,12 +127,10 @@ __ieee754_j1 (double x)
{
if (huge + x > one) /* inexact if x!=0 necessary */
{
- double ret = 0.5 * x;
- if (fabs (ret) < DBL_MIN)
- {
- double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ double ret = math_narrow_eval (0.5 * x);
+ math_check_force_underflow (ret);
+ if (ret == 0 && x != 0)
+ __set_errno (ERANGE);
return ret;
}
}
diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
index ccef2dcd80..3fecf82f10 100644
--- a/sysdeps/ieee754/dbl-64/e_jn.c
+++ b/sysdeps/ieee754/dbl-64/e_jn.c
@@ -243,14 +243,15 @@ __ieee754_jn (int n, double x)
ret = -b;
else
ret = b;
+ ret = math_narrow_eval (ret);
}
if (ret == 0)
- ret = __copysign (DBL_MIN, ret) * DBL_MIN;
- else if (fabs (ret) < DBL_MIN)
{
- double force_underflow = ret * ret;
- math_force_eval (force_underflow);
+ ret = math_narrow_eval (__copysign (DBL_MIN, ret) * DBL_MIN);
+ __set_errno (ERANGE);
}
+ else
+ math_check_force_underflow (ret);
return ret;
}
strong_alias (__ieee754_jn, __jn_finite)
diff --git a/sysdeps/ieee754/dbl-64/e_lgamma_r.c b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
index fc6f594d62..15154c0f43 100644
--- a/sysdeps/ieee754/dbl-64/e_lgamma_r.c
+++ b/sysdeps/ieee754/dbl-64/e_lgamma_r.c
@@ -226,6 +226,8 @@ __ieee754_lgamma_r(double x, int *signgamp)
if(__builtin_expect(ix>=0x43300000, 0))
/* |x|>=2**52, must be -integer */
return x/zero;
+ if (x < -2.0 && x > -28.0)
+ return __lgamma_neg (x, signgamp);
t = sin_pi(x);
if(t==zero) return one/fabsf(t); /* -integer */
nadj = __ieee754_log(pi/fabs(t*x));
@@ -294,17 +296,13 @@ __ieee754_lgamma_r(double x, int *signgamp)
r = (x-half)*(t-one)+w;
} else
/* 2**58 <= x <= inf */
- r = x*(__ieee754_log(x)-one);
+ r = math_narrow_eval (x*(__ieee754_log(x)-one));
/* NADJ is set for negative arguments but not otherwise,
resulting in warnings that it may be used uninitialized
although in the cases where it is used it has always been
set. */
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (4, 7)
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#else
- DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wuninitialized");
-#endif
if(hx<0) r = nadj - r;
DIAG_POP_NEEDS_COMMENT;
return r;
diff --git a/sysdeps/ieee754/dbl-64/e_log.c b/sysdeps/ieee754/dbl-64/e_log.c
index a9117fb4c5..9917dc236f 100644
--- a/sysdeps/ieee754/dbl-64/e_log.c
+++ b/sysdeps/ieee754/dbl-64/e_log.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/e_log10.c b/sysdeps/ieee754/dbl-64/e_log10.c
index 8548ee3942..df59d9dce4 100644
--- a/sysdeps/ieee754/dbl-64/e_log10.c
+++ b/sysdeps/ieee754/dbl-64/e_log10.c
@@ -45,6 +45,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */
static const double ivln10 = 4.34294481903251816668e-01; /* 0x3FDBCB7B, 0x1526E50E */
@@ -77,6 +78,8 @@ __ieee754_log10 (double x)
i = ((u_int32_t) k & 0x80000000) >> 31;
hx = (hx & 0x000fffff) | ((0x3ff - i) << 20);
y = (double) (k + i);
+ if (FIX_INT_FP_CONVERT_ZERO && y == 0.0)
+ y = 0.0;
SET_HIGH_WORD (x, hx);
z = y * log10_2lo + ivln10 * __ieee754_log (x);
return z + y * log10_2hi;
diff --git a/sysdeps/ieee754/dbl-64/e_log2.c b/sysdeps/ieee754/dbl-64/e_log2.c
index 997d7cefc8..bc6a34192a 100644
--- a/sysdeps/ieee754/dbl-64/e_log2.c
+++ b/sysdeps/ieee754/dbl-64/e_log2.c
@@ -56,6 +56,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const double ln2 = 0.69314718055994530942;
static const double two54 = 1.80143985094819840000e+16; /* 43500000 00000000 */
@@ -101,7 +102,11 @@ __ieee754_log2 (double x)
if ((0x000fffff & (2 + hx)) < 3)
{ /* |f| < 2**-20 */
if (f == zero)
- return dk;
+ {
+ if (FIX_INT_FP_CONVERT_ZERO && dk == 0.0)
+ dk = 0.0;
+ return dk;
+ }
R = f * f * (0.5 - 0.33333333333333333 * f);
return dk - (R - f) / ln2;
}
diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c
index 3c027fe7f5..663fa392c2 100644
--- a/sysdeps/ieee754/dbl-64/e_pow.c
+++ b/sysdeps/ieee754/dbl-64/e_pow.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -119,6 +119,8 @@ __ieee754_pow (double x, double y)
retval = huge * huge;
else if (retval == 0)
retval = tiny * tiny;
+ else
+ math_check_force_underflow_nonneg (retval);
return retval;
}
@@ -243,7 +245,8 @@ static double
SECTION
log1 (double x, double *delta, double *error)
{
- int i, j, m;
+ unsigned int i, j;
+ int m;
double uu, vv, eps, nx, e, e1, e2, t, t1, t2, res, add = 0;
mynumber u, v;
#ifdef BIG_ENDI
@@ -342,7 +345,8 @@ static double
SECTION
my_log2 (double x, double *delta, double *error)
{
- int i, j, m;
+ unsigned int i, j;
+ int m;
double uu, vv, eps, nx, e, e1, e2, t, t1, t2, res, add = 0;
double ou1, ou2, lu1, lu2, ov, lv1, lv2, a, a1, a2;
double y, yy, z, zz, j1, j2, j7, j8;
diff --git a/sysdeps/ieee754/dbl-64/e_remainder.c b/sysdeps/ieee754/dbl-64/e_remainder.c
index 7f3a02b3c2..a445e74b5c 100644
--- a/sysdeps/ieee754/dbl-64/e_remainder.c
+++ b/sysdeps/ieee754/dbl-64/e_remainder.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -130,6 +130,8 @@ __ieee754_remainder (double x, double y)
d = fabs (z);
if (d <= fabs (d - y))
return z;
+ else if (d == y)
+ return 0.0 * x;
else
return (z > 0) ? z - y : z + y;
}
diff --git a/sysdeps/ieee754/dbl-64/e_sinh.c b/sysdeps/ieee754/dbl-64/e_sinh.c
index 4ff28bf85d..8479bdd9b8 100644
--- a/sysdeps/ieee754/dbl-64/e_sinh.c
+++ b/sysdeps/ieee754/dbl-64/e_sinh.c
@@ -32,6 +32,7 @@ static char rcsid[] = "$NetBSD: e_sinh.c,v 1.7 1995/05/10 20:46:13 jtc Exp $";
* only sinh(0)=0 is exact for finite x.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -58,10 +59,12 @@ __ieee754_sinh (double x)
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x40360000) /* |x|<22 */
{
- if (__glibc_unlikely (ix < 0x3e300000)) /* |x|<2**-28 */
+ if (__glibc_unlikely (ix < 0x3e300000)) { /* |x|<2**-28 */
+ math_check_force_underflow (x);
if (shuge + x > one)
return x;
- /* sinh(tiny) = tiny with inexact */
+ /* sinh(tiny) = tiny with inexact */
+ }
t = __expm1 (fabs (x));
if (ix < 0x3ff00000)
return h * (2.0 * t - t * t / (t + one));
@@ -82,6 +85,6 @@ __ieee754_sinh (double x)
}
/* |x| > overflowthresold, sinh(x) overflow */
- return x * shuge;
+ return math_narrow_eval (x * shuge);
}
strong_alias (__ieee754_sinh, __sinh_finite)
diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c
index fff6d148fe..8304a2bb63 100644
--- a/sysdeps/ieee754/dbl-64/e_sqrt.c
+++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -21,7 +21,7 @@
/* */
/* FUNCTION: usqrt */
/* */
-/* FILES NEEDED: dla.h endian.h mydefs.h uroot.h */
+/* FILES NEEDED: dla.h endian.h mydefs.h */
/* uroot.tbl */
/* */
/* An ultimate sqrt routine. Given an IEEE double machine number x */
@@ -47,7 +47,6 @@
double
__ieee754_sqrt (double x)
{
-#include "uroot.h"
static const double
rt0 = 9.99999999859990725855365213134618E-01,
rt1 = 4.99999999495955425917856814202739E-01,
@@ -134,7 +133,7 @@ __ieee754_sqrt (double x)
return x; /* sqrt(+0)=+0, sqrt(-0)=-0 */
if (k < 0)
return (x - x) / (x - x); /* sqrt(-ve)=sNaN */
- return tm256.x * __ieee754_sqrt (x * t512.x);
+ return 0x1p-256 * __ieee754_sqrt (x * 0x1p512);
}
}
strong_alias (__ieee754_sqrt, __sqrt_finite)
diff --git a/sysdeps/ieee754/dbl-64/gamma_product.c b/sysdeps/ieee754/dbl-64/gamma_product.c
index 6c0d6210d9..7ae144aeb3 100644
--- a/sysdeps/ieee754/dbl-64/gamma_product.c
+++ b/sysdeps/ieee754/dbl-64/gamma_product.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/gamma_productf.c b/sysdeps/ieee754/dbl-64/gamma_productf.c
index df59e1beec..58b4e761fe 100644
--- a/sysdeps/ieee754/dbl-64/gamma_productf.c
+++ b/sysdeps/ieee754/dbl-64/gamma_productf.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,10 +36,7 @@ __gamma_productf (float x, float x_eps, int n, float *eps)
for (int i = 1; i < n; i++)
ret *= x_full + i;
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- float fret = ret;
+ float fret = math_narrow_eval ((float) ret);
*eps = (ret - fret) / fret;
return fret;
diff --git a/sysdeps/ieee754/dbl-64/halfulp.c b/sysdeps/ieee754/dbl-64/halfulp.c
index 028cb748f6..5e3e731754 100644
--- a/sysdeps/ieee754/dbl-64/halfulp.c
+++ b/sysdeps/ieee754/dbl-64/halfulp.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index 047c6c2886..e58c9e854c 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -315,34 +315,25 @@ recompute:
break;
case 1:
case 2:;
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
double fv = 0.0;
for (i = jz; i >= 0; i--)
- fv += fq[i];
+ fv = math_narrow_eval (fv + fq[i]);
y[0] = (ih == 0) ? fv : -fv;
- fv = fq[0] - fv;
+ fv = math_narrow_eval (fq[0] - fv);
for (i = 1; i <= jz; i++)
- fv += fq[i];
+ fv = math_narrow_eval (fv + fq[i]);
y[1] = (ih == 0) ? fv : -fv;
break;
case 3: /* painful */
for (i = jz; i > 0; i--)
{
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
- double fv = (double) (fq[i - 1] + fq[i]);
+ double fv = math_narrow_eval (fq[i - 1] + fq[i]);
fq[i] += fq[i - 1] - fv;
fq[i - 1] = fv;
}
for (i = jz; i > 1; i--)
{
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
- double fv = (double) (fq[i - 1] + fq[i]);
+ double fv = math_narrow_eval (fq[i - 1] + fq[i]);
fq[i] += fq[i - 1] - fv;
fq[i - 1] = fv;
}
diff --git a/sysdeps/ieee754/dbl-64/lgamma_neg.c b/sysdeps/ieee754/dbl-64/lgamma_neg.c
new file mode 100644
index 0000000000..fbf992203c
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/lgamma_neg.c
@@ -0,0 +1,383 @@
+/* lgamma expanding around zeros.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <math_private.h>
+
+static const double lgamma_zeros[][2] =
+ {
+ { -0x2.74ff92c01f0d8p+0, -0x2.abec9f315f1ap-56 },
+ { -0x2.bf6821437b202p+0, 0x6.866a5b4b9be14p-56 },
+ { -0x3.24c1b793cb35ep+0, -0xf.b8be699ad3d98p-56 },
+ { -0x3.f48e2a8f85fcap+0, -0x1.70d4561291237p-56 },
+ { -0x4.0a139e1665604p+0, 0xf.3c60f4f21e7fp-56 },
+ { -0x4.fdd5de9bbabf4p+0, 0xa.ef2f55bf89678p-56 },
+ { -0x5.021a95fc2db64p+0, -0x3.2a4c56e595394p-56 },
+ { -0x5.ffa4bd647d034p+0, -0x1.7dd4ed62cbd32p-52 },
+ { -0x6.005ac9625f234p+0, 0x4.9f83d2692e9c8p-56 },
+ { -0x6.fff2fddae1bcp+0, 0xc.29d949a3dc03p-60 },
+ { -0x7.000cff7b7f87cp+0, 0x1.20bb7d2324678p-52 },
+ { -0x7.fffe5fe05673cp+0, -0x3.ca9e82b522b0cp-56 },
+ { -0x8.0001a01459fc8p+0, -0x1.f60cb3cec1cedp-52 },
+ { -0x8.ffffd1c425e8p+0, -0xf.fc864e9574928p-56 },
+ { -0x9.00002e3bb47d8p+0, -0x6.d6d843fedc35p-56 },
+ { -0x9.fffffb606bep+0, 0x2.32f9d51885afap-52 },
+ { -0xa.0000049f93bb8p+0, -0x1.927b45d95e154p-52 },
+ { -0xa.ffffff9466eap+0, 0xe.4c92532d5243p-56 },
+ { -0xb.0000006b9915p+0, -0x3.15d965a6ffea4p-52 },
+ { -0xb.fffffff708938p+0, -0x7.387de41acc3d4p-56 },
+ { -0xc.00000008f76c8p+0, 0x8.cea983f0fdafp-56 },
+ { -0xc.ffffffff4f6ep+0, 0x3.09e80685a0038p-52 },
+ { -0xd.00000000b092p+0, -0x3.09c06683dd1bap-52 },
+ { -0xd.fffffffff3638p+0, 0x3.a5461e7b5c1f6p-52 },
+ { -0xe.000000000c9c8p+0, -0x3.a545e94e75ec6p-52 },
+ { -0xe.ffffffffff29p+0, 0x3.f9f399fb10cfcp-52 },
+ { -0xf.0000000000d7p+0, -0x3.f9f399bd0e42p-52 },
+ { -0xf.fffffffffff28p+0, -0xc.060c6621f513p-56 },
+ { -0x1.000000000000dp+4, -0x7.3f9f399da1424p-52 },
+ { -0x1.0ffffffffffffp+4, -0x3.569c47e7a93e2p-52 },
+ { -0x1.1000000000001p+4, 0x3.569c47e7a9778p-52 },
+ { -0x1.2p+4, 0xb.413c31dcbecdp-56 },
+ { -0x1.2p+4, -0xb.413c31dcbeca8p-56 },
+ { -0x1.3p+4, 0x9.7a4da340a0ab8p-60 },
+ { -0x1.3p+4, -0x9.7a4da340a0ab8p-60 },
+ { -0x1.4p+4, 0x7.950ae90080894p-64 },
+ { -0x1.4p+4, -0x7.950ae90080894p-64 },
+ { -0x1.5p+4, 0x5.c6e3bdb73d5c8p-68 },
+ { -0x1.5p+4, -0x5.c6e3bdb73d5c8p-68 },
+ { -0x1.6p+4, 0x4.338e5b6dfe14cp-72 },
+ { -0x1.6p+4, -0x4.338e5b6dfe14cp-72 },
+ { -0x1.7p+4, 0x2.ec368262c7034p-76 },
+ { -0x1.7p+4, -0x2.ec368262c7034p-76 },
+ { -0x1.8p+4, 0x1.f2cf01972f578p-80 },
+ { -0x1.8p+4, -0x1.f2cf01972f578p-80 },
+ { -0x1.9p+4, 0x1.3f3ccdd165fa9p-84 },
+ { -0x1.9p+4, -0x1.3f3ccdd165fa9p-84 },
+ { -0x1.ap+4, 0xc.4742fe35272dp-92 },
+ { -0x1.ap+4, -0xc.4742fe35272dp-92 },
+ { -0x1.bp+4, 0x7.46ac70b733a8cp-96 },
+ { -0x1.bp+4, -0x7.46ac70b733a8cp-96 },
+ { -0x1.cp+4, 0x4.2862898d42174p-100 },
+ };
+
+static const double e_hi = 0x2.b7e151628aed2p+0, e_lo = 0xa.6abf7158809dp-56;
+
+/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) in Stirling's
+ approximation to lgamma function. */
+
+static const double lgamma_coeff[] =
+ {
+ 0x1.5555555555555p-4,
+ -0xb.60b60b60b60b8p-12,
+ 0x3.4034034034034p-12,
+ -0x2.7027027027028p-12,
+ 0x3.72a3c5631fe46p-12,
+ -0x7.daac36664f1f4p-12,
+ 0x1.a41a41a41a41ap-8,
+ -0x7.90a1b2c3d4e6p-8,
+ 0x2.dfd2c703c0dp-4,
+ -0x1.6476701181f3ap+0,
+ 0xd.672219167003p+0,
+ -0x9.cd9292e6660d8p+4,
+ };
+
+#define NCOEFF (sizeof (lgamma_coeff) / sizeof (lgamma_coeff[0]))
+
+/* Polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0), where n is
+ the integer end-point of the half-integer interval containing x and
+ x0 is the zero of lgamma in that half-integer interval. Each
+ polynomial is expressed in terms of x-xm, where xm is the midpoint
+ of the interval for which the polynomial applies. */
+
+static const double poly_coeff[] =
+ {
+ /* Interval [-2.125, -2] (polynomial degree 10). */
+ -0x1.0b71c5c54d42fp+0,
+ -0xc.73a1dc05f3758p-4,
+ -0x1.ec84140851911p-4,
+ -0xe.37c9da23847e8p-4,
+ -0x1.03cd87cdc0ac6p-4,
+ -0xe.ae9aedce12eep-4,
+ 0x9.b11a1780cfd48p-8,
+ -0xe.f25fc460bdebp-4,
+ 0x2.6e984c61ca912p-4,
+ -0xf.83fea1c6d35p-4,
+ 0x4.760c8c8909758p-4,
+ /* Interval [-2.25, -2.125] (polynomial degree 11). */
+ -0xf.2930890d7d678p-4,
+ -0xc.a5cfde054eaa8p-4,
+ 0x3.9c9e0fdebd99cp-4,
+ -0x1.02a5ad35619d9p+0,
+ 0x9.6e9b1167c164p-4,
+ -0x1.4d8332eba090ap+0,
+ 0x1.1c0c94b1b2b6p+0,
+ -0x1.c9a70d138c74ep+0,
+ 0x1.d7d9cf1d4c196p+0,
+ -0x2.91fbf4cd6abacp+0,
+ 0x2.f6751f74b8ff8p+0,
+ -0x3.e1bb7b09e3e76p+0,
+ /* Interval [-2.375, -2.25] (polynomial degree 12). */
+ -0xd.7d28d505d618p-4,
+ -0xe.69649a3040958p-4,
+ 0xb.0d74a2827cd6p-4,
+ -0x1.924b09228a86ep+0,
+ 0x1.d49b12bcf6175p+0,
+ -0x3.0898bb530d314p+0,
+ 0x4.207a6be8fda4cp+0,
+ -0x6.39eef56d4e9p+0,
+ 0x8.e2e42acbccec8p+0,
+ -0xd.0d91c1e596a68p+0,
+ 0x1.2e20d7099c585p+4,
+ -0x1.c4eb6691b4ca9p+4,
+ 0x2.96a1a11fd85fep+4,
+ /* Interval [-2.5, -2.375] (polynomial degree 13). */
+ -0xb.74ea1bcfff948p-4,
+ -0x1.2a82bd590c376p+0,
+ 0x1.88020f828b81p+0,
+ -0x3.32279f040d7aep+0,
+ 0x5.57ac8252ce868p+0,
+ -0x9.c2aedd093125p+0,
+ 0x1.12c132716e94cp+4,
+ -0x1.ea94dfa5c0a6dp+4,
+ 0x3.66b61abfe858cp+4,
+ -0x6.0cfceb62a26e4p+4,
+ 0xa.beeba09403bd8p+4,
+ -0x1.3188d9b1b288cp+8,
+ 0x2.37f774dd14c44p+8,
+ -0x3.fdf0a64cd7136p+8,
+ /* Interval [-2.625, -2.5] (polynomial degree 13). */
+ -0x3.d10108c27ebbp-4,
+ 0x1.cd557caff7d2fp+0,
+ 0x3.819b4856d36cep+0,
+ 0x6.8505cbacfc42p+0,
+ 0xb.c1b2e6567a4dp+0,
+ 0x1.50a53a3ce6c73p+4,
+ 0x2.57adffbb1ec0cp+4,
+ 0x4.2b15549cf400cp+4,
+ 0x7.698cfd82b3e18p+4,
+ 0xd.2decde217755p+4,
+ 0x1.7699a624d07b9p+8,
+ 0x2.98ecf617abbfcp+8,
+ 0x4.d5244d44d60b4p+8,
+ 0x8.e962bf7395988p+8,
+ /* Interval [-2.75, -2.625] (polynomial degree 12). */
+ -0x6.b5d252a56e8a8p-4,
+ 0x1.28d60383da3a6p+0,
+ 0x1.db6513ada89bep+0,
+ 0x2.e217118fa8c02p+0,
+ 0x4.450112c651348p+0,
+ 0x6.4af990f589b8cp+0,
+ 0x9.2db5963d7a238p+0,
+ 0xd.62c03647da19p+0,
+ 0x1.379f81f6416afp+4,
+ 0x1.c5618b4fdb96p+4,
+ 0x2.9342d0af2ac4ep+4,
+ 0x3.d9cdf56d2b186p+4,
+ 0x5.ab9f91d5a27a4p+4,
+ /* Interval [-2.875, -2.75] (polynomial degree 11). */
+ -0x8.a41b1e4f36ff8p-4,
+ 0xc.da87d3b69dbe8p-4,
+ 0x1.1474ad5c36709p+0,
+ 0x1.761ecb90c8c5cp+0,
+ 0x1.d279bff588826p+0,
+ 0x2.4e5d003fb36a8p+0,
+ 0x2.d575575566842p+0,
+ 0x3.85152b0d17756p+0,
+ 0x4.5213d921ca13p+0,
+ 0x5.55da7dfcf69c4p+0,
+ 0x6.acef729b9404p+0,
+ 0x8.483cc21dd0668p+0,
+ /* Interval [-3, -2.875] (polynomial degree 11). */
+ -0xa.046d667e468f8p-4,
+ 0x9.70b88dcc006cp-4,
+ 0xa.a8a39421c94dp-4,
+ 0xd.2f4d1363f98ep-4,
+ 0xd.ca9aa19975b7p-4,
+ 0xf.cf09c2f54404p-4,
+ 0x1.04b1365a9adfcp+0,
+ 0x1.22b54ef213798p+0,
+ 0x1.2c52c25206bf5p+0,
+ 0x1.4aa3d798aace4p+0,
+ 0x1.5c3f278b504e3p+0,
+ 0x1.7e08292cc347bp+0,
+ };
+
+static const size_t poly_deg[] =
+ {
+ 10,
+ 11,
+ 12,
+ 13,
+ 13,
+ 12,
+ 11,
+ 11,
+ };
+
+static const size_t poly_end[] =
+ {
+ 10,
+ 22,
+ 35,
+ 49,
+ 63,
+ 76,
+ 88,
+ 100,
+ };
+
+/* Compute sin (pi * X) for -0.25 <= X <= 0.5. */
+
+static double
+lg_sinpi (double x)
+{
+ if (x <= 0.25)
+ return __sin (M_PI * x);
+ else
+ return __cos (M_PI * (0.5 - x));
+}
+
+/* Compute cos (pi * X) for -0.25 <= X <= 0.5. */
+
+static double
+lg_cospi (double x)
+{
+ if (x <= 0.25)
+ return __cos (M_PI * x);
+ else
+ return __sin (M_PI * (0.5 - x));
+}
+
+/* Compute cot (pi * X) for -0.25 <= X <= 0.5. */
+
+static double
+lg_cotpi (double x)
+{
+ return lg_cospi (x) / lg_sinpi (x);
+}
+
+/* Compute lgamma of a negative argument -28 < X < -2, setting
+ *SIGNGAMP accordingly. */
+
+double
+__lgamma_neg (double x, int *signgamp)
+{
+ /* Determine the half-integer region X lies in, handle exact
+ integers and determine the sign of the result. */
+ int i = __floor (-2 * x);
+ if ((i & 1) == 0 && i == -2 * x)
+ return 1.0 / 0.0;
+ double xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
+ i -= 4;
+ *signgamp = ((i & 2) == 0 ? -1 : 1);
+
+ SET_RESTORE_ROUND (FE_TONEAREST);
+
+ /* Expand around the zero X0 = X0_HI + X0_LO. */
+ double x0_hi = lgamma_zeros[i][0], x0_lo = lgamma_zeros[i][1];
+ double xdiff = x - x0_hi - x0_lo;
+
+ /* For arguments in the range -3 to -2, use polynomial
+ approximations to an adjusted version of the gamma function. */
+ if (i < 2)
+ {
+ int j = __floor (-8 * x) - 16;
+ double xm = (-33 - 2 * j) * 0.0625;
+ double x_adj = x - xm;
+ size_t deg = poly_deg[j];
+ size_t end = poly_end[j];
+ double g = poly_coeff[end];
+ for (size_t j = 1; j <= deg; j++)
+ g = g * x_adj + poly_coeff[end - j];
+ return __log1p (g * xdiff / (x - xn));
+ }
+
+ /* The result we want is log (sinpi (X0) / sinpi (X))
+ + log (gamma (1 - X0) / gamma (1 - X)). */
+ double x_idiff = fabs (xn - x), x0_idiff = fabs (xn - x0_hi - x0_lo);
+ double log_sinpi_ratio;
+ if (x0_idiff < x_idiff * 0.5)
+ /* Use log not log1p to avoid inaccuracy from log1p of arguments
+ close to -1. */
+ log_sinpi_ratio = __ieee754_log (lg_sinpi (x0_idiff)
+ / lg_sinpi (x_idiff));
+ else
+ {
+ /* Use log1p not log to avoid inaccuracy from log of arguments
+ close to 1. X0DIFF2 has positive sign if X0 is further from
+ XN than X is from XN, negative sign otherwise. */
+ double x0diff2 = ((i & 1) == 0 ? xdiff : -xdiff) * 0.5;
+ double sx0d2 = lg_sinpi (x0diff2);
+ double cx0d2 = lg_cospi (x0diff2);
+ log_sinpi_ratio = __log1p (2 * sx0d2
+ * (-sx0d2 + cx0d2 * lg_cotpi (x_idiff)));
+ }
+
+ double log_gamma_ratio;
+ double y0 = math_narrow_eval (1 - x0_hi);
+ double y0_eps = -x0_hi + (1 - y0) - x0_lo;
+ double y = math_narrow_eval (1 - x);
+ double y_eps = -x + (1 - y);
+ /* We now wish to compute LOG_GAMMA_RATIO
+ = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF
+ accurately approximates the difference Y0 + Y0_EPS - Y -
+ Y_EPS. Use Stirling's approximation. First, we may need to
+ adjust into the range where Stirling's approximation is
+ sufficiently accurate. */
+ double log_gamma_adj = 0;
+ if (i < 6)
+ {
+ int n_up = (7 - i) / 2;
+ double ny0, ny0_eps, ny, ny_eps;
+ ny0 = math_narrow_eval (y0 + n_up);
+ ny0_eps = y0 - (ny0 - n_up) + y0_eps;
+ y0 = ny0;
+ y0_eps = ny0_eps;
+ ny = math_narrow_eval (y + n_up);
+ ny_eps = y - (ny - n_up) + y_eps;
+ y = ny;
+ y_eps = ny_eps;
+ double prodm1 = __lgamma_product (xdiff, y - n_up, y_eps, n_up);
+ log_gamma_adj = -__log1p (prodm1);
+ }
+ double log_gamma_high
+ = (xdiff * __log1p ((y0 - e_hi - e_lo + y0_eps) / e_hi)
+ + (y - 0.5 + y_eps) * __log1p (xdiff / y) + log_gamma_adj);
+ /* Compute the sum of (B_2k / 2k(2k-1))(Y0^-(2k-1) - Y^-(2k-1)). */
+ double y0r = 1 / y0, yr = 1 / y;
+ double y0r2 = y0r * y0r, yr2 = yr * yr;
+ double rdiff = -xdiff / (y * y0);
+ double bterm[NCOEFF];
+ double dlast = rdiff, elast = rdiff * yr * (yr + y0r);
+ bterm[0] = dlast * lgamma_coeff[0];
+ for (size_t j = 1; j < NCOEFF; j++)
+ {
+ double dnext = dlast * y0r2 + elast;
+ double enext = elast * yr2;
+ bterm[j] = dnext * lgamma_coeff[j];
+ dlast = dnext;
+ elast = enext;
+ }
+ double log_gamma_low = 0;
+ for (size_t j = 0; j < NCOEFF; j++)
+ log_gamma_low += bterm[NCOEFF - 1 - j];
+ log_gamma_ratio = log_gamma_high + log_gamma_low;
+
+ return log_sinpi_ratio + log_gamma_ratio;
+}
diff --git a/sysdeps/ieee754/dbl-64/lgamma_product.c b/sysdeps/ieee754/dbl-64/lgamma_product.c
new file mode 100644
index 0000000000..d956575bc7
--- /dev/null
+++ b/sysdeps/ieee754/dbl-64/lgamma_product.c
@@ -0,0 +1,82 @@
+/* Compute a product of 1 + (T/X), 1 + (T/(X+1)), ....
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+/* Calculate X * Y exactly and store the result in *HI + *LO. It is
+ given that the values are small enough that no overflow occurs and
+ large enough (or zero) that no underflow occurs. */
+
+static void
+mul_split (double *hi, double *lo, double x, double y)
+{
+#ifdef __FP_FAST_FMA
+ /* Fast built-in fused multiply-add. */
+ *hi = x * y;
+ *lo = __builtin_fma (x, y, -*hi);
+#elif defined FP_FAST_FMA
+ /* Fast library fused multiply-add, compiler before GCC 4.6. */
+ *hi = x * y;
+ *lo = __fma (x, y, -*hi);
+#else
+ /* Apply Dekker's algorithm. */
+ *hi = x * y;
+# define C ((1 << (DBL_MANT_DIG + 1) / 2) + 1)
+ double x1 = x * C;
+ double y1 = y * C;
+# undef C
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ double x2 = x - x1;
+ double y2 = y - y1;
+ *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
+#endif
+}
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+
+double
+__lgamma_product (double t, double x, double x_eps, int n)
+{
+ double ret = 0, ret_eps = 0;
+ for (int i = 0; i < n; i++)
+ {
+ double xi = x + i;
+ double quot = t / xi;
+ double mhi, mlo;
+ mul_split (&mhi, &mlo, quot, xi);
+ double quot_lo = (t - mhi - mlo) / xi - t * x_eps / (xi * xi);
+ /* We want (1 + RET + RET_EPS) * (1 + QUOT + QUOT_LO) - 1. */
+ double rhi, rlo;
+ mul_split (&rhi, &rlo, ret, quot);
+ double rpq = ret + quot;
+ double rpq_eps = (ret - rpq) + quot;
+ double nret = rpq + rhi;
+ double nret_eps = (rpq - nret) + rhi;
+ ret_eps += (rpq_eps + nret_eps + rlo + ret_eps * quot
+ + quot_lo + quot_lo * (ret + ret_eps));
+ ret = nret;
+ }
+ return ret + ret_eps;
+}
diff --git a/sysdeps/ieee754/dbl-64/mpa-arch.h b/sysdeps/ieee754/dbl-64/mpa-arch.h
index 0940f0bb57..ea33a14219 100644
--- a/sysdeps/ieee754/dbl-64/mpa-arch.h
+++ b/sysdeps/ieee754/dbl-64/mpa-arch.h
@@ -1,5 +1,5 @@
/* Overridable constants and operations.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpa.c b/sysdeps/ieee754/dbl-64/mpa.c
index 7b52da91d5..4b21d1d2e6 100644
--- a/sysdeps/ieee754/dbl-64/mpa.c
+++ b/sysdeps/ieee754/dbl-64/mpa.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpa.h b/sysdeps/ieee754/dbl-64/mpa.h
index 47dd6c457c..b8ca297eb7 100644
--- a/sysdeps/ieee754/dbl-64/mpa.h
+++ b/sysdeps/ieee754/dbl-64/mpa.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpatan.c b/sysdeps/ieee754/dbl-64/mpatan.c
index d9ac3d62b1..dbd49b2bee 100644
--- a/sysdeps/ieee754/dbl-64/mpatan.c
+++ b/sysdeps/ieee754/dbl-64/mpatan.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpatan.h b/sysdeps/ieee754/dbl-64/mpatan.h
index 2ceb966998..36c02602ac 100644
--- a/sysdeps/ieee754/dbl-64/mpatan.h
+++ b/sysdeps/ieee754/dbl-64/mpatan.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpatan2.c b/sysdeps/ieee754/dbl-64/mpatan2.c
index 78f01d9839..e7de6bc158 100644
--- a/sysdeps/ieee754/dbl-64/mpatan2.c
+++ b/sysdeps/ieee754/dbl-64/mpatan2.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpexp.c b/sysdeps/ieee754/dbl-64/mpexp.c
index b5a1def93d..f17baf2139 100644
--- a/sysdeps/ieee754/dbl-64/mpexp.c
+++ b/sysdeps/ieee754/dbl-64/mpexp.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mplog.c b/sysdeps/ieee754/dbl-64/mplog.c
index 53e1b57621..b297153b10 100644
--- a/sysdeps/ieee754/dbl-64/mplog.c
+++ b/sysdeps/ieee754/dbl-64/mplog.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpn2dbl.c b/sysdeps/ieee754/dbl-64/mpn2dbl.c
index c0cf8e238d..1050ec3b0e 100644
--- a/sysdeps/ieee754/dbl-64/mpn2dbl.c
+++ b/sysdeps/ieee754/dbl-64/mpn2dbl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/mpsqrt.c b/sysdeps/ieee754/dbl-64/mpsqrt.c
index f3ef55eb7f..a77d3938a9 100644
--- a/sysdeps/ieee754/dbl-64/mpsqrt.c
+++ b/sysdeps/ieee754/dbl-64/mpsqrt.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mpsqrt.h b/sysdeps/ieee754/dbl-64/mpsqrt.h
index e322398a7a..0f1cf58fb2 100644
--- a/sysdeps/ieee754/dbl-64/mpsqrt.h
+++ b/sysdeps/ieee754/dbl-64/mpsqrt.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mptan.c b/sysdeps/ieee754/dbl-64/mptan.c
index 0d58d9c786..280c4909d6 100644
--- a/sysdeps/ieee754/dbl-64/mptan.c
+++ b/sysdeps/ieee754/dbl-64/mptan.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/mydefs.h b/sysdeps/ieee754/dbl-64/mydefs.h
index 31585142b7..b1d67d4445 100644
--- a/sysdeps/ieee754/dbl-64/mydefs.h
+++ b/sysdeps/ieee754/dbl-64/mydefs.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/powtwo.tbl b/sysdeps/ieee754/dbl-64/powtwo.tbl
index 2406ee5d65..2d828f6022 100644
--- a/sysdeps/ieee754/dbl-64/powtwo.tbl
+++ b/sysdeps/ieee754/dbl-64/powtwo.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/root.tbl b/sysdeps/ieee754/dbl-64/root.tbl
index cb0c8b11ec..61c859248c 100644
--- a/sysdeps/ieee754/dbl-64/root.tbl
+++ b/sysdeps/ieee754/dbl-64/root.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/s_asinh.c b/sysdeps/ieee754/dbl-64/s_asinh.c
index ebe471015b..9193301b5e 100644
--- a/sysdeps/ieee754/dbl-64/s_asinh.c
+++ b/sysdeps/ieee754/dbl-64/s_asinh.c
@@ -39,11 +39,7 @@ __asinh (double x)
ix = hx & 0x7fffffff;
if (__glibc_unlikely (ix < 0x3e300000)) /* |x|<2**-28 */
{
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (huge + x > one)
return x; /* return x inexact except 0 */
}
diff --git a/sysdeps/ieee754/dbl-64/s_atan.c b/sysdeps/ieee754/dbl-64/s_atan.c
index 5035ae87bc..780c3ff17a 100644
--- a/sysdeps/ieee754/dbl-64/s_atan.c
+++ b/sysdeps/ieee754/dbl-64/s_atan.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -90,11 +90,7 @@ atan (double x)
{
if (u < A)
{
- if (u < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow_nonneg (u);
return x;
}
else
diff --git a/sysdeps/ieee754/dbl-64/s_cbrt.c b/sysdeps/ieee754/dbl-64/s_cbrt.c
index a728968a1d..647f30bc71 100644
--- a/sysdeps/ieee754/dbl-64/s_cbrt.c
+++ b/sysdeps/ieee754/dbl-64/s_cbrt.c
@@ -1,5 +1,5 @@
/* Compute cubic root of double value.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Dirk Alboth <dirka@uni-paderborn.de> and
Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/s_erf.c b/sysdeps/ieee754/dbl-64/s_erf.c
index ea0a73424e..b4975a8af8 100644
--- a/sysdeps/ieee754/dbl-64/s_erf.c
+++ b/sysdeps/ieee754/dbl-64/s_erf.c
@@ -116,6 +116,7 @@ static char rcsid[] = "$NetBSD: s_erf.c,v 1.8 1995/05/10 20:47:05 jtc Exp $";
#include <float.h>
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const double
tiny = 1e-300,
@@ -213,11 +214,7 @@ __erf (double x)
{
/* Avoid spurious underflow. */
double ret = 0.0625 * (16.0 * x + (16.0 * efx) * x);
- if (fabs (ret) < DBL_MIN)
- {
- double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
return ret;
}
return x + efx * x;
@@ -312,7 +309,10 @@ __erfc (double x)
ix = hx & 0x7fffffff;
if (ix >= 0x7ff00000) /* erfc(nan)=nan */
{ /* erfc(+-inf)=0,2 */
- return (double) (((u_int32_t) hx >> 31) << 1) + one / x;
+ double ret = (double) (((u_int32_t) hx >> 31) << 1) + one / x;
+ if (FIX_INT_FP_CONVERT_ZERO && ret == 0.0)
+ return 0.0;
+ return ret;
}
if (ix < 0x3feb0000) /* |x|<0.84375 */
@@ -402,10 +402,7 @@ __erfc (double x)
__ieee754_exp ((z - x) * (z + x) + R / S);
if (hx > 0)
{
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- double ret = r / x;
+ double ret = math_narrow_eval (r / x);
if (ret == 0)
__set_errno (ERANGE);
return ret;
diff --git a/sysdeps/ieee754/dbl-64/s_expm1.c b/sysdeps/ieee754/dbl-64/s_expm1.c
index 41ef63a786..54d771007a 100644
--- a/sysdeps/ieee754/dbl-64/s_expm1.c
+++ b/sysdeps/ieee754/dbl-64/s_expm1.c
@@ -195,11 +195,7 @@ __expm1 (double x)
}
else if (hx < 0x3c900000) /* when |x|<2**-54, return x */
{
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
t = huge + x; /* return x with inexact flags when x!=0 */
return x - (t - (huge + x));
}
diff --git a/sysdeps/ieee754/dbl-64/s_finite.c b/sysdeps/ieee754/dbl-64/s_finite.c
index 49986bbde9..69141db75d 100644
--- a/sysdeps/ieee754/dbl-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/s_finite.c
@@ -21,6 +21,7 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
#undef __finite
@@ -32,11 +33,18 @@ int FINITE(double x)
{
int32_t hx;
GET_HIGH_WORD (hx, x);
- return (int) ((u_int32_t) ((hx & 0x7fffffff) - 0x7ff00000) >> 31);
+ return (int) ((u_int32_t) ((hx & 0x7ff00000) - 0x7ff00000) >> 31);
}
hidden_def (__finite)
weak_alias (__finite, finite)
#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
+# ifdef LDBL_CLASSIFY_COMPAT
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
+# endif
+# if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_23)
+compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
+# endif
+# endif
weak_alias (__finite, finitel)
#endif
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index 716b41273d..a3492434e4 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
@@ -66,7 +66,7 @@ __fma (double x, double y, double z)
/* If fma will certainly overflow, compute as x * y. */
if (u.ieee.exponent + v.ieee.exponent > 0x7ff + IEEE754_DOUBLE_BIAS)
return x * y;
- /* If x * y is less than 1/4 of DBL_DENORM_MIN, neither the
+ /* If x * y is less than 1/4 of DBL_TRUE_MIN, neither the
result nor whether there is underflow depends on its exact
value, only on its sign. */
if (u.ieee.exponent + v.ieee.exponent
@@ -90,8 +90,8 @@ __fma (double x, double y, double z)
&& w.ieee.mantissa1 == 0
&& w.ieee.mantissa0 == 0)))
{
- volatile double force_underflow = x * y;
- (void) force_underflow;
+ double force_underflow = x * y;
+ math_force_eval (force_underflow);
}
return v.d * 0x1p-54;
}
@@ -117,7 +117,7 @@ __fma (double x, double y, double z)
very small, adjust them up to avoid spurious underflows,
rather than down. */
if (u.ieee.exponent + v.ieee.exponent
- <= IEEE754_DOUBLE_BIAS + DBL_MANT_DIG)
+ <= IEEE754_DOUBLE_BIAS + 2 * DBL_MANT_DIG)
{
if (u.ieee.exponent > v.ieee.exponent)
u.ieee.exponent += 2 * DBL_MANT_DIG + 2;
@@ -175,7 +175,10 @@ __fma (double x, double y, double z)
/* Ensure correct sign of exact 0 + 0. */
if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
- return x * y + z;
+ {
+ x = math_opt_barrier (x);
+ return x * y + z;
+ }
fenv_t env;
libc_feholdexcept_setround (&env, FE_TONEAREST);
diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
index 86b8662dbf..582c205572 100644
--- a/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
diff --git a/sysdeps/ieee754/dbl-64/s_fpclassify.c b/sysdeps/ieee754/dbl-64/s_fpclassify.c
index 2e8751277d..176e29fccb 100644
--- a/sysdeps/ieee754/dbl-64/s_fpclassify.c
+++ b/sysdeps/ieee754/dbl-64/s_fpclassify.c
@@ -1,5 +1,5 @@
/* Return classification value corresponding to argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/s_isinf.c b/sysdeps/ieee754/dbl-64/s_isinf.c
index 46a7266e7f..c0ad54538a 100644
--- a/sysdeps/ieee754/dbl-64/s_isinf.c
+++ b/sysdeps/ieee754/dbl-64/s_isinf.c
@@ -15,6 +15,7 @@ static char rcsid[] = "$NetBSD: s_isinf.c,v 1.3 1995/05/11 23:20:14 jtc Exp $";
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
int
__isinf (double x)
@@ -28,6 +29,8 @@ __isinf (double x)
hidden_def (__isinf)
weak_alias (__isinf, isinf)
#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
+# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
+# endif
weak_alias (__isinf, isinfl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/s_isinf_ns.c b/sysdeps/ieee754/dbl-64/s_isinf_ns.c
deleted file mode 100644
index d8142bcf6e..0000000000
--- a/sysdeps/ieee754/dbl-64/s_isinf_ns.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Written by Ulrich Drepper <drepper@gmail.com>.
- */
-
-/*
- * __isinf_ns(x) returns != 0 if x is ±inf, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-
-#undef __isinf_ns
-int
-__isinf_ns (double x)
-{
- int32_t hx, lx;
- EXTRACT_WORDS (hx, lx, x);
- return !(lx | ((hx & 0x7fffffff) ^ 0x7ff00000));
-}
diff --git a/sysdeps/ieee754/dbl-64/s_isnan.c b/sysdeps/ieee754/dbl-64/s_isnan.c
index 5d9f31be20..2174d988d8 100644
--- a/sysdeps/ieee754/dbl-64/s_isnan.c
+++ b/sysdeps/ieee754/dbl-64/s_isnan.c
@@ -21,6 +21,7 @@ static char rcsid[] = "$NetBSD: s_isnan.c,v 1.8 1995/05/10 20:47:36 jtc Exp $";
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
#undef __isnan
int
@@ -36,6 +37,8 @@ __isnan (double x)
hidden_def (__isnan)
weak_alias (__isnan, isnan)
#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
+# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
+# endif
weak_alias (__isnan, isnanl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/s_issignaling.c b/sysdeps/ieee754/dbl-64/s_issignaling.c
index 925d85fb21..4b93d6ae60 100644
--- a/sysdeps/ieee754/dbl-64/s_issignaling.c
+++ b/sysdeps/ieee754/dbl-64/s_issignaling.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/dbl-64/s_llrint.c b/sysdeps/ieee754/dbl-64/s_llrint.c
index 62acb67c38..ff40ee626d 100644
--- a/sysdeps/ieee754/dbl-64/s_llrint.c
+++ b/sysdeps/ieee754/dbl-64/s_llrint.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,9 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const double two52[2] =
{
@@ -35,7 +38,7 @@ __llrint (double x)
int32_t j0;
u_int32_t i1, i0;
long long int result;
- volatile double w;
+ double w;
double t;
int sx;
@@ -47,7 +50,7 @@ __llrint (double x)
if (j0 < 20)
{
- w = two52[sx] + x;
+ w = math_narrow_eval (two52[sx] + x);
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
@@ -62,7 +65,7 @@ __llrint (double x)
result = (((long long int) i0 << 32) | i1) << (j0 - 52);
else
{
- w = two52[sx] + x;
+ w = math_narrow_eval (two52[sx] + x);
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
@@ -77,8 +80,16 @@ __llrint (double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LLONG_MAX : LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/dbl-64/s_llround.c b/sysdeps/ieee754/dbl-64/s_llround.c
index c8b3c190b5..1d6a5205f1 100644
--- a/sysdeps/ieee754/dbl-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/s_llround.c
@@ -1,5 +1,5 @@
/* Round double value to long long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,9 +17,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
long long int
@@ -65,8 +68,16 @@ __llround (double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LLONG_MAX : LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/dbl-64/s_log1p.c b/sysdeps/ieee754/dbl-64/s_log1p.c
index cff555b0aa..340f6377f7 100644
--- a/sysdeps/ieee754/dbl-64/s_log1p.c
+++ b/sysdeps/ieee754/dbl-64/s_log1p.c
@@ -120,11 +120,7 @@ __log1p (double x)
math_force_eval (two54 + x); /* raise inexact */
if (ax < 0x3c900000) /* |x| < 2**-54 */
{
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
else
diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index 7a6c49abf5..3a26b18f78 100644
--- a/sysdeps/ieee754/dbl-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/s_logb.c
@@ -18,6 +18,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
double
__logb (double x)
@@ -41,6 +42,8 @@ __logb (double x)
ma = __builtin_clz (ix);
rix -= ma - 12;
}
+ if (FIX_INT_FP_CONVERT_ZERO && rix == 1023)
+ return 0.0;
return (double) (rix - 1023);
}
weak_alias (__logb, logb)
diff --git a/sysdeps/ieee754/dbl-64/s_lrint.c b/sysdeps/ieee754/dbl-64/s_lrint.c
index 9cce37f3cf..4e7cbef97b 100644
--- a/sysdeps/ieee754/dbl-64/s_lrint.c
+++ b/sysdeps/ieee754/dbl-64/s_lrint.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,9 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const double two52[2] =
{
@@ -34,7 +37,7 @@ __lrint (double x)
{
int32_t j0;
u_int32_t i0, i1;
- volatile double w;
+ double w;
double t;
long int result;
int sx;
@@ -47,7 +50,7 @@ __lrint (double x)
if (j0 < 20)
{
- w = two52[sx] + x;
+ w = math_narrow_eval (two52[sx] + x);
t = w - two52[sx];
EXTRACT_WORDS (i0, i1, t);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
@@ -59,11 +62,25 @@ __lrint (double x)
else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
{
if (j0 >= 52)
- result = ((long int) i0 << (j0 - 20)) | (i1 << (j0 - 52));
+ result = ((long int) i0 << (j0 - 20)) | ((long int) i1 << (j0 - 52));
else
{
- w = two52[sx] + x;
- t = w - two52[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LONG_MAX + 1 implied by J0 < 31. */
+ if (sizeof (long int) == 4
+ && x > (double) LONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyint (x);
+ feraiseexcept (t == LONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = math_narrow_eval (two52[sx] + x);
+ t = w - two52[sx];
+ }
EXTRACT_WORDS (i0, i1, t);
j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
i0 &= 0xfffff;
@@ -77,8 +94,26 @@ __lrint (double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#if defined FE_INVALID || defined FE_INEXACT
+ if (sizeof (long int) == 4
+ && x < (double) LONG_MIN
+ && x > (double) LONG_MIN - 1.0)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ t = __nearbyint (x);
+ feraiseexcept (t == LONG_MIN ? FE_INEXACT : FE_INVALID);
+ return LONG_MIN;
+ }
+ else if (FIX_DBL_LONG_CONVERT_OVERFLOW && x != (double) LONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LONG_MAX : LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/dbl-64/s_lround.c b/sysdeps/ieee754/dbl-64/s_lround.c
index bdc838a676..aa1275ddc3 100644
--- a/sysdeps/ieee754/dbl-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/s_lround.c
@@ -1,5 +1,5 @@
/* Round double value to long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,9 +17,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
long int
@@ -60,13 +63,43 @@ __lround (double x)
if (j0 == 20)
result = (long int) i0;
else
- result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0));
+ {
+ result = ((long int) i0 << (j0 - 20)) | (j >> (52 - j0));
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#ifdef FE_INVALID
+ if (FIX_DBL_LONG_CONVERT_OVERFLOW
+ && !(sign == -1
+ && (sizeof (long int) == 4
+ ? x > (double) LONG_MIN - 0.5
+ : x >= (double) LONG_MIN)))
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LONG_MAX : LONG_MIN;
+ }
+ else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
+ && sizeof (long int) == 4
+ && x <= (double) LONG_MIN - 0.5)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ feraiseexcept (FE_INVALID);
+ return LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/dbl-64/s_remquo.c b/sysdeps/ieee754/dbl-64/s_remquo.c
index b081d26b0d..16215e1e29 100644
--- a/sysdeps/ieee754/dbl-64/s_remquo.c
+++ b/sysdeps/ieee754/dbl-64/s_remquo.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/s_round.c b/sysdeps/ieee754/dbl-64/s_round.c
index 770f8e6386..aeed6faf0e 100644
--- a/sysdeps/ieee754/dbl-64/s_round.c
+++ b/sysdeps/ieee754/dbl-64/s_round.c
@@ -1,5 +1,5 @@
/* Round double to integer away from zero.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/s_scalbn.c b/sysdeps/ieee754/dbl-64/s_scalbn.c
index 0f58034df5..58c7e1b33a 100644
--- a/sysdeps/ieee754/dbl-64/s_scalbn.c
+++ b/sysdeps/ieee754/dbl-64/s_scalbn.c
@@ -58,8 +58,6 @@ __scalbn (double x, int n)
SET_HIGH_WORD (x, (hx & 0x800fffff) | (k << 20));
return x * twom54;
}
-weak_alias (__scalbn, scalbn)
#ifdef NO_LONG_DOUBLE
strong_alias (__scalbn, __scalbnl)
-weak_alias (__scalbn, scalbnl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/s_signbit.c b/sysdeps/ieee754/dbl-64/s_signbit.c
index 764f11a2d2..f4ef4d238f 100644
--- a/sysdeps/ieee754/dbl-64/s_signbit.c
+++ b/sysdeps/ieee754/dbl-64/s_signbit.c
@@ -1,5 +1,5 @@
/* Return nonzero value if number is negative.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -19,13 +19,8 @@
#include <math.h>
-#include <math_private.h>
-
int
__signbit (double x)
{
- int32_t hx;
-
- GET_HIGH_WORD (hx, x);
- return hx & 0x80000000;
+ return __builtin_signbit (x);
}
diff --git a/sysdeps/ieee754/dbl-64/s_sin.c b/sysdeps/ieee754/dbl-64/s_sin.c
index eff120e88d..ca2532fb63 100644
--- a/sysdeps/ieee754/dbl-64/s_sin.c
+++ b/sysdeps/ieee754/dbl-64/s_sin.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -32,9 +32,6 @@
/* bsloww1 */
/* bsloww2 */
/* cslow2 */
-/* csloww */
-/* csloww1 */
-/* csloww2 */
/* FILES NEEDED: dla.h endian.h mpa.h mydefs.h usncs.h */
/* branred.c sincos32.c dosincos.c mpa.c */
/* sincos.tbl */
@@ -135,17 +132,14 @@ double __mpcos (double x, double dx, bool reduce_range);
static double slow (double x);
static double slow1 (double x);
static double slow2 (double x);
-static double sloww (double x, double dx, double orig);
-static double sloww1 (double x, double dx, double orig, int m);
+static double sloww (double x, double dx, double orig, int n);
+static double sloww1 (double x, double dx, double orig, int m, int n);
static double sloww2 (double x, double dx, double orig, int n);
static double bsloww (double x, double dx, double orig, int n);
static double bsloww1 (double x, double dx, double orig, int n);
static double bsloww2 (double x, double dx, double orig, int n);
int __branred (double x, double *a, double *aa);
static double cslow2 (double x);
-static double csloww (double x, double dx, double orig);
-static double csloww1 (double x, double dx, double orig, int m);
-static double csloww2 (double x, double dx, double orig, int n);
/* Given a number partitioned into U and X such that U is an index into the
sin/cos table, this macro computes the cosine of the number by combining
@@ -276,32 +270,216 @@ reduce_and_compute (double x, unsigned int k)
return retval;
}
+static inline int4
+__always_inline
+reduce_sincos_1 (double x, double *a, double *da)
+{
+ mynumber v;
+
+ double t = (x * hpinv + toint);
+ double xn = t - toint;
+ v.x = t;
+ double y = (x - xn * mp1) - xn * mp2;
+ int4 n = v.i[LOW_HALF] & 3;
+ double db = xn * mp3;
+ double b = y - db;
+ db = (y - b) - db;
+
+ *a = b;
+ *da = db;
+
+ return n;
+}
+
+/* Compute sin (A + DA). cos can be computed by shifting the quadrant N
+ clockwise. */
+static double
+__always_inline
+do_sincos_1 (double a, double da, double x, int4 n, int4 k)
+{
+ double xx, retval, res, cor, y;
+ mynumber u;
+ int m;
+ double eps = fabs (x) * 1.2e-30;
+
+ int k1 = (n + k) & 3;
+ switch (k1)
+ { /* quarter of unit circle */
+ case 2:
+ a = -a;
+ da = -da;
+ case 0:
+ xx = a * a;
+ if (xx < 0.01588)
+ {
+ /* Taylor series. */
+ res = TAYLOR_SIN (xx, a, da, cor);
+ cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+ retval = (res == res + cor) ? res : sloww (a, da, x, k);
+ }
+ else
+ {
+ if (a > 0)
+ m = 1;
+ else
+ {
+ m = 0;
+ a = -a;
+ da = -da;
+ }
+ u.x = big + a;
+ y = a - (u.x - big);
+ res = do_sin (u, y, da, &cor);
+ cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+ retval = ((res == res + cor) ? ((m) ? res : -res)
+ : sloww1 (a, da, x, m, k));
+ }
+ break;
+
+ case 1:
+ case 3:
+ if (a < 0)
+ {
+ a = -a;
+ da = -da;
+ }
+ u.x = big + a;
+ y = a - (u.x - big) + da;
+ res = do_cos (u, y, &cor);
+ cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+ retval = ((res == res + cor) ? ((k1 & 2) ? -res : res)
+ : sloww2 (a, da, x, n));
+ break;
+ }
+
+ return retval;
+}
+
+static inline int4
+__always_inline
+reduce_sincos_2 (double x, double *a, double *da)
+{
+ mynumber v;
+
+ double t = (x * hpinv + toint);
+ double xn = t - toint;
+ v.x = t;
+ double xn1 = (xn + 8.0e22) - 8.0e22;
+ double xn2 = xn - xn1;
+ double y = ((((x - xn1 * mp1) - xn1 * mp2) - xn2 * mp1) - xn2 * mp2);
+ int4 n = v.i[LOW_HALF] & 3;
+ double db = xn1 * pp3;
+ t = y - db;
+ db = (y - t) - db;
+ db = (db - xn2 * pp3) - xn * pp4;
+ double b = t + db;
+ db = (t - b) + db;
+
+ *a = b;
+ *da = db;
+
+ return n;
+}
+
+/* Compute sin (A + DA). cos can be computed by shifting the quadrant N
+ clockwise. */
+static double
+__always_inline
+do_sincos_2 (double a, double da, double x, int4 n, int4 k)
+{
+ double res, retval, cor, xx;
+ mynumber u;
+
+ double eps = 1.0e-24;
+
+ k = (n + k) & 3;
+
+ switch (k)
+ {
+ case 2:
+ a = -a;
+ da = -da;
+ /* Fall through. */
+ case 0:
+ xx = a * a;
+ if (xx < 0.01588)
+ {
+ /* Taylor series. */
+ res = TAYLOR_SIN (xx, a, da, cor);
+ cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
+ retval = (res == res + cor) ? res : bsloww (a, da, x, n);
+ }
+ else
+ {
+ double t, db, y;
+ int m;
+ if (a > 0)
+ {
+ m = 1;
+ t = a;
+ db = da;
+ }
+ else
+ {
+ m = 0;
+ t = -a;
+ db = -da;
+ }
+ u.x = big + t;
+ y = t - (u.x - big);
+ res = do_sin (u, y, db, &cor);
+ cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
+ retval = ((res == res + cor) ? ((m) ? res : -res)
+ : bsloww1 (a, da, x, n));
+ }
+ break;
+
+ case 1:
+ case 3:
+ if (a < 0)
+ {
+ a = -a;
+ da = -da;
+ }
+ u.x = big + a;
+ double y = a - (u.x - big) + da;
+ res = do_cos (u, y, &cor);
+ cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
+ retval = ((res == res + cor) ? ((n & 2) ? -res : res)
+ : bsloww2 (a, da, x, n));
+ break;
+ }
+
+ return retval;
+}
+
/*******************************************************************/
/* An ultimate sin routine. Given an IEEE double machine number x */
/* it computes the correctly rounded (to nearest) value of sin(x) */
/*******************************************************************/
+#ifdef IN_SINCOS
+static double
+#else
double
SECTION
+#endif
__sin (double x)
{
- double xx, res, t, cor, y, s, c, sn, ssn, cs, ccs, xn, a, da, db, eps, xn1,
- xn2;
- mynumber u, v;
- int4 k, m, n;
+ double xx, res, t, cor, y, s, c, sn, ssn, cs, ccs;
+ mynumber u;
+ int4 k, m;
double retval = 0;
+#ifndef IN_SINCOS
SET_RESTORE_ROUND_53BIT (FE_TONEAREST);
+#endif
u.x = x;
m = u.i[HIGH_HALF];
k = 0x7fffffff & m; /* no sign */
if (k < 0x3e500000) /* if x->0 =>sin(x)=x */
{
- if (fabs (x) < DBL_MIN)
- {
- double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
retval = x;
}
/*---------------------------- 2^-26 < |x|< 0.25 ----------------------*/
@@ -353,146 +531,22 @@ __sin (double x)
retval = (res == res + 1.020 * cor) ? ((m > 0) ? res : -res) : slow2 (x);
} /* else if (k < 0x400368fd) */
+#ifndef IN_SINCOS
/*-------------------------- 2.426265<|x|< 105414350 ----------------------*/
else if (k < 0x419921FB)
{
- t = (x * hpinv + toint);
- xn = t - toint;
- v.x = t;
- y = (x - xn * mp1) - xn * mp2;
- n = v.i[LOW_HALF] & 3;
- da = xn * mp3;
- a = y - da;
- da = (y - a) - da;
- eps = fabs (x) * 1.2e-30;
-
- switch (n)
- { /* quarter of unit circle */
- case 0:
- case 2:
- xx = a * a;
- if (n)
- {
- a = -a;
- da = -da;
- }
- if (xx < 0.01588)
- {
- /* Taylor series. */
- res = TAYLOR_SIN (xx, a, da, cor);
- cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
- retval = (res == res + cor) ? res : sloww (a, da, x);
- }
- else
- {
- if (a > 0)
- m = 1;
- else
- {
- m = 0;
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big);
- res = do_sin (u, y, da, &cor);
- cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
- retval = ((res == res + cor) ? ((m) ? res : -res)
- : sloww1 (a, da, x, m));
- }
- break;
-
- case 1:
- case 3:
- if (a < 0)
- {
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big) + da;
- res = do_cos (u, y, &cor);
- cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
- retval = ((res == res + cor) ? ((n & 2) ? -res : res)
- : sloww2 (a, da, x, n));
- break;
- }
+ double a, da;
+ int4 n = reduce_sincos_1 (x, &a, &da);
+ retval = do_sincos_1 (a, da, x, n, 0);
} /* else if (k < 0x419921FB ) */
/*---------------------105414350 <|x|< 281474976710656 --------------------*/
else if (k < 0x42F00000)
{
- t = (x * hpinv + toint);
- xn = t - toint;
- v.x = t;
- xn1 = (xn + 8.0e22) - 8.0e22;
- xn2 = xn - xn1;
- y = ((((x - xn1 * mp1) - xn1 * mp2) - xn2 * mp1) - xn2 * mp2);
- n = v.i[LOW_HALF] & 3;
- da = xn1 * pp3;
- t = y - da;
- da = (y - t) - da;
- da = (da - xn2 * pp3) - xn * pp4;
- a = t + da;
- da = (t - a) + da;
- eps = 1.0e-24;
-
- switch (n)
- {
- case 0:
- case 2:
- xx = a * a;
- if (n)
- {
- a = -a;
- da = -da;
- }
- if (xx < 0.01588)
- {
- /* Taylor series. */
- res = TAYLOR_SIN (xx, a, da, cor);
- cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
- retval = (res == res + cor) ? res : bsloww (a, da, x, n);
- }
- else
- {
- double t;
- if (a > 0)
- {
- m = 1;
- t = a;
- db = da;
- }
- else
- {
- m = 0;
- t = -a;
- db = -da;
- }
- u.x = big + t;
- y = t - (u.x - big);
- res = do_sin (u, y, db, &cor);
- cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
- retval = ((res == res + cor) ? ((m) ? res : -res)
- : bsloww1 (a, da, x, n));
- }
- break;
+ double a, da;
- case 1:
- case 3:
- if (a < 0)
- {
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big) + da;
- res = do_cos (u, y, &cor);
- cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
- retval = ((res == res + cor) ? ((n & 2) ? -res : res)
- : bsloww2 (a, da, x, n));
- break;
- }
+ int4 n = reduce_sincos_2 (x, &a, &da);
+ retval = do_sincos_2 (a, da, x, n, 0);
} /* else if (k < 0x42F00000 ) */
/* -----------------281474976710656 <|x| <2^1024----------------------------*/
@@ -506,6 +560,7 @@ __sin (double x)
__set_errno (EDOM);
retval = x / x;
}
+#endif
return retval;
}
@@ -516,18 +571,23 @@ __sin (double x)
/* it computes the correctly rounded (to nearest) value of cos(x) */
/*******************************************************************/
+#ifdef IN_SINCOS
+static double
+#else
double
SECTION
+#endif
__cos (double x)
{
- double y, xx, res, t, cor, xn, a, da, db, eps, xn1,
- xn2;
- mynumber u, v;
- int4 k, m, n;
+ double y, xx, res, cor, a, da;
+ mynumber u;
+ int4 k, m;
double retval = 0;
+#ifndef IN_SINCOS
SET_RESTORE_ROUND_53BIT (FE_TONEAREST);
+#endif
u.x = x;
m = u.i[HIGH_HALF];
@@ -556,7 +616,7 @@ __cos (double x)
{
res = TAYLOR_SIN (xx, a, da, cor);
cor = (cor > 0) ? 1.02 * cor + 1.0e-31 : 1.02 * cor - 1.0e-31;
- retval = (res == res + cor) ? res : csloww (a, da, x);
+ retval = (res == res + cor) ? res : sloww (a, da, x, 1);
}
else
{
@@ -575,150 +635,26 @@ __cos (double x)
res = do_sin (u, y, da, &cor);
cor = (cor > 0) ? 1.035 * cor + 1.0e-31 : 1.035 * cor - 1.0e-31;
retval = ((res == res + cor) ? ((m) ? res : -res)
- : csloww1 (a, da, x, m));
+ : sloww1 (a, da, x, m, 1));
}
} /* else if (k < 0x400368fd) */
+#ifndef IN_SINCOS
else if (k < 0x419921FB)
{ /* 2.426265<|x|< 105414350 */
- t = (x * hpinv + toint);
- xn = t - toint;
- v.x = t;
- y = (x - xn * mp1) - xn * mp2;
- n = v.i[LOW_HALF] & 3;
- da = xn * mp3;
- a = y - da;
- da = (y - a) - da;
- eps = fabs (x) * 1.2e-30;
-
- switch (n)
- {
- case 1:
- case 3:
- xx = a * a;
- if (n == 1)
- {
- a = -a;
- da = -da;
- }
- if (xx < 0.01588)
- {
- res = TAYLOR_SIN (xx, a, da, cor);
- cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
- retval = (res == res + cor) ? res : csloww (a, da, x);
- }
- else
- {
- if (a > 0)
- {
- m = 1;
- }
- else
- {
- m = 0;
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big);
- res = do_sin (u, y, da, &cor);
- cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
- retval = ((res == res + cor) ? ((m) ? res : -res)
- : csloww1 (a, da, x, m));
- }
- break;
-
- case 0:
- case 2:
- if (a < 0)
- {
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big) + da;
- res = do_cos (u, y, &cor);
- cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
- retval = ((res == res + cor) ? ((n) ? -res : res)
- : csloww2 (a, da, x, n));
- break;
- }
+ double a, da;
+ int4 n = reduce_sincos_1 (x, &a, &da);
+ retval = do_sincos_1 (a, da, x, n, 1);
} /* else if (k < 0x419921FB ) */
else if (k < 0x42F00000)
{
- t = (x * hpinv + toint);
- xn = t - toint;
- v.x = t;
- xn1 = (xn + 8.0e22) - 8.0e22;
- xn2 = xn - xn1;
- y = ((((x - xn1 * mp1) - xn1 * mp2) - xn2 * mp1) - xn2 * mp2);
- n = v.i[LOW_HALF] & 3;
- da = xn1 * pp3;
- t = y - da;
- da = (y - t) - da;
- da = (da - xn2 * pp3) - xn * pp4;
- a = t + da;
- da = (t - a) + da;
- eps = 1.0e-24;
-
- switch (n)
- {
- case 1:
- case 3:
- xx = a * a;
- if (n == 1)
- {
- a = -a;
- da = -da;
- }
- if (xx < 0.01588)
- {
- res = TAYLOR_SIN (xx, a, da, cor);
- cor = (cor > 0) ? 1.02 * cor + eps : 1.02 * cor - eps;
- retval = (res == res + cor) ? res : bsloww (a, da, x, n);
- }
- else
- {
- double t;
- if (a > 0)
- {
- m = 1;
- t = a;
- db = da;
- }
- else
- {
- m = 0;
- t = -a;
- db = -da;
- }
- u.x = big + t;
- y = t - (u.x - big);
- res = do_sin (u, y, db, &cor);
- cor = (cor > 0) ? 1.035 * cor + eps : 1.035 * cor - eps;
- retval = ((res == res + cor) ? ((m) ? res : -res)
- : bsloww1 (a, da, x, n));
- }
- break;
+ double a, da;
- case 0:
- case 2:
- if (a < 0)
- {
- a = -a;
- da = -da;
- }
- u.x = big + a;
- y = a - (u.x - big) + da;
- res = do_cos (u, y, &cor);
- cor = (cor > 0) ? 1.025 * cor + eps : 1.025 * cor - eps;
- retval = ((res == res + cor) ? ((n) ? -res : res)
- : bsloww2 (a, da, x, n));
- break;
- }
+ int4 n = reduce_sincos_2 (x, &a, &da);
+ retval = do_sincos_2 (a, da, x, n, 1);
} /* else if (k < 0x42F00000 ) */
/* 281474976710656 <|x| <2^1024 */
@@ -731,6 +667,7 @@ __cos (double x)
__set_errno (EDOM);
retval = x / x; /* |x| > 2^1024 */
}
+#endif
return retval;
}
@@ -748,14 +685,12 @@ slow (double x)
res = TAYLOR_SLOW (x, 0, cor);
if (res == res + 1.0007 * cor)
return res;
- else
- {
- __dubsin (fabs (x), 0, w);
- if (w[0] == w[0] + 1.000000001 * w[1])
- return (x > 0) ? w[0] : -w[0];
- else
- return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
- }
+
+ __dubsin (fabs (x), 0, w);
+ if (w[0] == w[0] + 1.000000001 * w[1])
+ return (x > 0) ? w[0] : -w[0];
+
+ return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
}
/*******************************************************************************/
@@ -775,14 +710,12 @@ slow1 (double x)
res = do_sin_slow (u, y, 0, 0, &cor);
if (res == res + cor)
return (x > 0) ? res : -res;
- else
- {
- __dubsin (fabs (x), 0, w);
- if (w[0] == w[0] + 1.000000005 * w[1])
- return (x > 0) ? w[0] : -w[0];
- else
- return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
- }
+
+ __dubsin (fabs (x), 0, w);
+ if (w[0] == w[0] + 1.000000005 * w[1])
+ return (x > 0) ? w[0] : -w[0];
+
+ return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
}
/**************************************************************************/
@@ -813,17 +746,15 @@ slow2 (double x)
res = do_cos_slow (u, y, del, 0, &cor);
if (res == res + cor)
return (x > 0) ? res : -res;
- else
- {
- y = fabs (x) - hp0;
- y1 = y - hp1;
- y2 = (y - y1) - hp1;
- __docos (y1, y2, w);
- if (w[0] == w[0] + 1.000000005 * w[1])
- return (x > 0) ? w[0] : -w[0];
- else
- return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
- }
+
+ y = fabs (x) - hp0;
+ y1 = y - hp1;
+ y2 = (y - y1) - hp1;
+ __docos (y1, y2, w);
+ if (w[0] == w[0] + 1.000000005 * w[1])
+ return (x > 0) ? w[0] : -w[0];
+
+ return (x > 0) ? __mpsin (x, 0, false) : -__mpsin (-x, 0, false);
}
/***************************************************************************/
@@ -836,12 +767,13 @@ slow2 (double x)
static double
SECTION
-sloww (double x, double dx, double orig)
+sloww (double x, double dx, double orig, int k)
{
double y, t, res, cor, w[2], a, da, xn;
mynumber v;
int4 n;
res = TAYLOR_SLOW (x, dx, cor);
+
if (cor > 0)
cor = 1.0005 * cor + fabs (orig) * 3.1e-30;
else
@@ -849,46 +781,43 @@ sloww (double x, double dx, double orig)
if (res == res + cor)
return res;
+
+ (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
+ if (w[1] > 0)
+ cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30;
else
+ cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30;
+
+ if (w[0] == w[0] + cor)
+ return (x > 0) ? w[0] : -w[0];
+
+ t = (orig * hpinv + toint);
+ xn = t - toint;
+ v.x = t;
+ y = (orig - xn * mp1) - xn * mp2;
+ n = (v.i[LOW_HALF] + k) & 3;
+ da = xn * pp3;
+ t = y - da;
+ da = (y - t) - da;
+ y = xn * pp4;
+ a = t - y;
+ da = ((t - a) - y) + da;
+
+ if (n == 2 || n == 1)
{
- (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
- if (w[1] > 0)
- cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30;
- else
- cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30;
+ a = -a;
+ da = -da;
+ }
+ (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
+ if (w[1] > 0)
+ cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40;
+ else
+ cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40;
- if (w[0] == w[0] + cor)
- return (x > 0) ? w[0] : -w[0];
- else
- {
- t = (orig * hpinv + toint);
- xn = t - toint;
- v.x = t;
- y = (orig - xn * mp1) - xn * mp2;
- n = v.i[LOW_HALF] & 3;
- da = xn * pp3;
- t = y - da;
- da = (y - t) - da;
- y = xn * pp4;
- a = t - y;
- da = ((t - a) - y) + da;
- if (n & 2)
- {
- a = -a;
- da = -da;
- }
- (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
- if (w[1] > 0)
- cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40;
- else
- cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40;
+ if (w[0] == w[0] + cor)
+ return (a > 0) ? w[0] : -w[0];
- if (w[0] == w[0] + cor)
- return (a > 0) ? w[0] : -w[0];
- else
- return __mpsin (orig, 0, true);
- }
- }
+ return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
}
/***************************************************************************/
@@ -900,7 +829,7 @@ sloww (double x, double dx, double orig)
static double
SECTION
-sloww1 (double x, double dx, double orig, int m)
+sloww1 (double x, double dx, double orig, int m, int k)
{
mynumber u;
double w[2], y, cor, res;
@@ -911,20 +840,18 @@ sloww1 (double x, double dx, double orig, int m)
if (res == res + cor)
return (m > 0) ? res : -res;
+
+ __dubsin (x, dx, w);
+
+ if (w[1] > 0)
+ cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
else
- {
- __dubsin (x, dx, w);
+ cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
- else
- cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
+ if (w[0] == w[0] + cor)
+ return (m > 0) ? w[0] : -w[0];
- if (w[0] == w[0] + cor)
- return (m > 0) ? w[0] : -w[0];
- else
- return __mpsin (orig, 0, true);
- }
+ return (k == 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
}
/***************************************************************************/
@@ -947,20 +874,18 @@ sloww2 (double x, double dx, double orig, int n)
if (res == res + cor)
return (n & 2) ? -res : res;
+
+ __docos (x, dx, w);
+
+ if (w[1] > 0)
+ cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
else
- {
- __docos (x, dx, w);
+ cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
- else
- cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
+ if (w[0] == w[0] + cor)
+ return (n & 2) ? -w[0] : w[0];
- if (w[0] == w[0] + cor)
- return (n & 2) ? -w[0] : w[0];
- else
- return __mpsin (orig, 0, true);
- }
+ return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true);
}
/***************************************************************************/
@@ -981,18 +906,17 @@ bsloww (double x, double dx, double orig, int n)
cor = (cor > 0) ? 1.0005 * cor + 1.1e-24 : 1.0005 * cor - 1.1e-24;
if (res == res + cor)
return res;
+
+ (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
+ if (w[1] > 0)
+ cor = 1.000000001 * w[1] + 1.1e-24;
else
- {
- (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
- if (w[1] > 0)
- cor = 1.000000001 * w[1] + 1.1e-24;
- else
- cor = 1.000000001 * w[1] - 1.1e-24;
- if (w[0] == w[0] + cor)
- return (x > 0) ? w[0] : -w[0];
- else
- return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
- }
+ cor = 1.000000001 * w[1] - 1.1e-24;
+
+ if (w[0] == w[0] + cor)
+ return (x > 0) ? w[0] : -w[0];
+
+ return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
}
/***************************************************************************/
@@ -1016,20 +940,18 @@ bsloww1 (double x, double dx, double orig, int n)
res = do_sin_slow (u, y, dx, 1.1e-24, &cor);
if (res == res + cor)
return (x > 0) ? res : -res;
+
+ __dubsin (fabs (x), dx, w);
+
+ if (w[1] > 0)
+ cor = 1.000000005 * w[1] + 1.1e-24;
else
- {
- __dubsin (fabs (x), dx, w);
+ cor = 1.000000005 * w[1] - 1.1e-24;
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-24;
- else
- cor = 1.000000005 * w[1] - 1.1e-24;
+ if (w[0] == w[0] + cor)
+ return (x > 0) ? w[0] : -w[0];
- if (w[0] == w[0] + cor)
- return (x > 0) ? w[0] : -w[0];
- else
- return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
- }
+ return (n & 1) ? __mpcos (orig, 0, true) : __mpsin (orig, 0, true);
}
/***************************************************************************/
@@ -1053,20 +975,18 @@ bsloww2 (double x, double dx, double orig, int n)
res = do_cos_slow (u, y, dx, 1.1e-24, &cor);
if (res == res + cor)
return (n & 2) ? -res : res;
+
+ __docos (fabs (x), dx, w);
+
+ if (w[1] > 0)
+ cor = 1.000000005 * w[1] + 1.1e-24;
else
- {
- __docos (fabs (x), dx, w);
+ cor = 1.000000005 * w[1] - 1.1e-24;
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-24;
- else
- cor = 1.000000005 * w[1] - 1.1e-24;
+ if (w[0] == w[0] + cor)
+ return (n & 2) ? -w[0] : w[0];
- if (w[0] == w[0] + cor)
- return (n & 2) ? -w[0] : w[0];
- else
- return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true);
- }
+ return (n & 1) ? __mpsin (orig, 0, true) : __mpcos (orig, 0, true);
}
/************************************************************************/
@@ -1087,154 +1007,13 @@ cslow2 (double x)
res = do_cos_slow (u, y, 0, 0, &cor);
if (res == res + cor)
return res;
- else
- {
- y = fabs (x);
- __docos (y, 0, w);
- if (w[0] == w[0] + 1.000000005 * w[1])
- return w[0];
- else
- return __mpcos (x, 0, false);
- }
-}
-
-/***************************************************************************/
-/* Routine compute cos(x+dx) (Double-Length number) where x is small enough*/
-/* to use Taylor series around zero and (x+dx) .Routine receive also */
-/* (right argument) the original value of x for computing error of */
-/* result.And if result not accurate enough routine calls other routines */
-/***************************************************************************/
-
-
-static double
-SECTION
-csloww (double x, double dx, double orig)
-{
- double y, t, res, cor, w[2], a, da, xn;
- mynumber v;
- int4 n;
-
- /* Taylor series */
- res = TAYLOR_SLOW (x, dx, cor);
-
- if (cor > 0)
- cor = 1.0005 * cor + fabs (orig) * 3.1e-30;
- else
- cor = 1.0005 * cor - fabs (orig) * 3.1e-30;
-
- if (res == res + cor)
- return res;
- else
- {
- (x > 0) ? __dubsin (x, dx, w) : __dubsin (-x, -dx, w);
-
- if (w[1] > 0)
- cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-30;
- else
- cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-30;
-
- if (w[0] == w[0] + cor)
- return (x > 0) ? w[0] : -w[0];
- else
- {
- t = (orig * hpinv + toint);
- xn = t - toint;
- v.x = t;
- y = (orig - xn * mp1) - xn * mp2;
- n = v.i[LOW_HALF] & 3;
- da = xn * pp3;
- t = y - da;
- da = (y - t) - da;
- y = xn * pp4;
- a = t - y;
- da = ((t - a) - y) + da;
- if (n == 1)
- {
- a = -a;
- da = -da;
- }
- (a > 0) ? __dubsin (a, da, w) : __dubsin (-a, -da, w);
-
- if (w[1] > 0)
- cor = 1.000000001 * w[1] + fabs (orig) * 1.1e-40;
- else
- cor = 1.000000001 * w[1] - fabs (orig) * 1.1e-40;
-
- if (w[0] == w[0] + cor)
- return (a > 0) ? w[0] : -w[0];
- else
- return __mpcos (orig, 0, true);
- }
- }
-}
-
-/***************************************************************************/
-/* Routine compute sin(x+dx) (Double-Length number) where x in first or */
-/* third quarter of unit circle.Routine receive also (right argument) the */
-/* original value of x for computing error of result.And if result not */
-/* accurate enough routine calls other routines */
-/***************************************************************************/
-static double
-SECTION
-csloww1 (double x, double dx, double orig, int m)
-{
- mynumber u;
- double w[2], y, cor, res;
-
- u.x = big + x;
- y = x - (u.x - big);
- res = do_sin_slow (u, y, dx, 3.1e-30 * fabs (orig), &cor);
-
- if (res == res + cor)
- return (m > 0) ? res : -res;
- else
- {
- __dubsin (x, dx, w);
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
- else
- cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
- if (w[0] == w[0] + cor)
- return (m > 0) ? w[0] : -w[0];
- else
- return __mpcos (orig, 0, true);
- }
-}
-
-
-/***************************************************************************/
-/* Routine compute sin(x+dx) (Double-Length number) where x in second or */
-/* fourth quarter of unit circle.Routine receive also the original value */
-/* and quarter(n= 1or 3)of x for computing error of result.And if result not*/
-/* accurate enough routine calls other routines */
-/***************************************************************************/
-
-static double
-SECTION
-csloww2 (double x, double dx, double orig, int n)
-{
- mynumber u;
- double w[2], y, cor, res;
-
- u.x = big + x;
- y = x - (u.x - big);
- res = do_cos_slow (u, y, dx, 3.1e-30 * fabs (orig), &cor);
+ y = fabs (x);
+ __docos (y, 0, w);
+ if (w[0] == w[0] + 1.000000005 * w[1])
+ return w[0];
- if (res == res + cor)
- return (n) ? -res : res;
- else
- {
- __docos (x, dx, w);
- if (w[1] > 0)
- cor = 1.000000005 * w[1] + 1.1e-30 * fabs (orig);
- else
- cor = 1.000000005 * w[1] - 1.1e-30 * fabs (orig);
- if (w[0] == w[0] + cor)
- return (n) ? -w[0] : w[0];
- else
- return __mpcos (orig, 0, true);
- }
+ return __mpcos (x, 0, false);
}
#ifndef __cos
diff --git a/sysdeps/ieee754/dbl-64/s_sincos.c b/sysdeps/ieee754/dbl-64/s_sincos.c
index c8a99991cc..c389226b04 100644
--- a/sysdeps/ieee754/dbl-64/s_sincos.c
+++ b/sysdeps/ieee754/dbl-64/s_sincos.c
@@ -1,5 +1,5 @@
/* Compute sine and cosine of argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -22,29 +22,89 @@
#include <math_private.h>
+#define __sin __sin_local
+#define __cos __cos_local
+#define IN_SINCOS 1
+#include "s_sin.c"
+
+/* Consolidated version of reduce_and_compute in s_sin.c that does range
+ reduction only once and computes sin and cos together. */
+static inline void
+__always_inline
+reduce_and_compute_sincos (double x, double *sinx, double *cosx)
+{
+ double a, da;
+ unsigned int n = __branred (x, &a, &da);
+
+ n = n & 3;
+
+ if (n == 1 || n == 2)
+ {
+ a = -a;
+ da = -da;
+ }
+
+ if (n & 1)
+ {
+ double *temp = cosx;
+ cosx = sinx;
+ sinx = temp;
+ }
+
+ if (a * a < 0.01588)
+ *sinx = bsloww (a, da, x, n);
+ else
+ *sinx = bsloww1 (a, da, x, n);
+ *cosx = bsloww2 (a, da, x, n);
+}
void
__sincos (double x, double *sinx, double *cosx)
{
- int32_t ix;
+ mynumber u;
+ int k;
- /* High word of x. */
- GET_HIGH_WORD (ix, x);
+ SET_RESTORE_ROUND_53BIT (FE_TONEAREST);
- /* |x| ~< pi/4 */
- ix &= 0x7fffffff;
- if (ix >= 0x7ff00000)
+ u.x = x;
+ k = 0x7fffffff & u.i[HIGH_HALF];
+
+ if (k < 0x400368fd)
{
- /* sin(Inf or NaN) is NaN */
- *sinx = *cosx = x - x;
- if (__isinf_ns (x))
- __set_errno (EDOM);
+ *sinx = __sin_local (x);
+ *cosx = __cos_local (x);
+ return;
}
- else
+ if (k < 0x419921FB)
+ {
+ double a, da;
+ int4 n = reduce_sincos_1 (x, &a, &da);
+
+ *sinx = do_sincos_1 (a, da, x, n, 0);
+ *cosx = do_sincos_1 (a, da, x, n, 1);
+
+ return;
+ }
+ if (k < 0x42F00000)
{
- *sinx = __sin (x);
- *cosx = __cos (x);
+ double a, da;
+ int4 n = reduce_sincos_2 (x, &a, &da);
+
+ *sinx = do_sincos_2 (a, da, x, n, 0);
+ *cosx = do_sincos_2 (a, da, x, n, 1);
+
+ return;
+ }
+ if (k < 0x7ff00000)
+ {
+ reduce_and_compute_sincos (x, sinx, cosx);
+ return;
}
+
+ if (isinf (x))
+ __set_errno (EDOM);
+
+ *sinx = *cosx = x / x;
}
weak_alias (__sincos, sincos)
#ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/ieee754/dbl-64/s_tan.c b/sysdeps/ieee754/dbl-64/s_tan.c
index dcb4aca2de..ccffdd62d7 100644
--- a/sysdeps/ieee754/dbl-64/s_tan.c
+++ b/sysdeps/ieee754/dbl-64/s_tan.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -34,6 +34,7 @@
/*********************************************************************/
#include <errno.h>
+#include <float.h>
#include "endian.h"
#include <dla.h>
#include "mpa.h"
@@ -91,6 +92,7 @@ tan (double x)
/* (I) The case abs(x) <= 1.259e-8 */
if (w <= g1.d)
{
+ math_check_force_underflow_nonneg (w);
retval = x;
goto ret;
}
diff --git a/sysdeps/ieee754/dbl-64/s_tanh.c b/sysdeps/ieee754/dbl-64/s_tanh.c
index 23cfcdead5..344a2f0330 100644
--- a/sysdeps/ieee754/dbl-64/s_tanh.c
+++ b/sysdeps/ieee754/dbl-64/s_tanh.c
@@ -38,6 +38,7 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
* only tanh(0)=0 is exact for finite argument.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -68,7 +69,10 @@ __tanh (double x)
if ((ix | lx) == 0)
return x; /* x == +-0 */
if (ix < 0x3c800000) /* |x|<2**-55 */
- return x * (one + x); /* tanh(small) = small */
+ {
+ math_check_force_underflow (x);
+ return x * (one + x); /* tanh(small) = small */
+ }
if (ix >= 0x3ff00000) /* |x|>=1 */
{
t = __expm1 (two * fabs (x));
diff --git a/sysdeps/ieee754/dbl-64/s_trunc.c b/sysdeps/ieee754/dbl-64/s_trunc.c
index ac6c7597b5..f64e097f16 100644
--- a/sysdeps/ieee754/dbl-64/s_trunc.c
+++ b/sysdeps/ieee754/dbl-64/s_trunc.c
@@ -1,5 +1,5 @@
/* Truncate argument to nearest integral value not larger than the argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/sincos32.c b/sysdeps/ieee754/dbl-64/sincos32.c
index d942a1f29f..ad43465f64 100644
--- a/sysdeps/ieee754/dbl-64/sincos32.c
+++ b/sysdeps/ieee754/dbl-64/sincos32.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/sincos32.h b/sysdeps/ieee754/dbl-64/sincos32.h
index ee70b08743..5a5f2e223a 100644
--- a/sysdeps/ieee754/dbl-64/sincos32.h
+++ b/sysdeps/ieee754/dbl-64/sincos32.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/sincostab.c b/sysdeps/ieee754/dbl-64/sincostab.c
index 44cb525f42..cd88af7331 100644
--- a/sysdeps/ieee754/dbl-64/sincostab.c
+++ b/sysdeps/ieee754/dbl-64/sincostab.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/slowexp.c b/sysdeps/ieee754/dbl-64/slowexp.c
index 7950111412..b602262783 100644
--- a/sysdeps/ieee754/dbl-64/slowexp.c
+++ b/sysdeps/ieee754/dbl-64/slowexp.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/slowpow.c b/sysdeps/ieee754/dbl-64/slowpow.c
index 117225ea46..266910c979 100644
--- a/sysdeps/ieee754/dbl-64/slowpow.c
+++ b/sysdeps/ieee754/dbl-64/slowpow.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/t_exp.c b/sysdeps/ieee754/dbl-64/t_exp.c
index 8d5c7b81a3..3c921f1d3d 100644
--- a/sysdeps/ieee754/dbl-64/t_exp.c
+++ b/sysdeps/ieee754/dbl-64/t_exp.c
@@ -1,5 +1,5 @@
/* Accurate tables for exp().
- Copyright (C) 1998-2015 Free Software Foundation, Inc.
+ Copyright (C) 1998-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
diff --git a/sysdeps/ieee754/dbl-64/uasncs.h b/sysdeps/ieee754/dbl-64/uasncs.h
index c60e93c0a2..e88bd1bf3e 100644
--- a/sysdeps/ieee754/dbl-64/uasncs.h
+++ b/sysdeps/ieee754/dbl-64/uasncs.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/uatan.tbl b/sysdeps/ieee754/dbl-64/uatan.tbl
index f1337fce21..979d65d8b2 100644
--- a/sysdeps/ieee754/dbl-64/uatan.tbl
+++ b/sysdeps/ieee754/dbl-64/uatan.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/uexp.h b/sysdeps/ieee754/dbl-64/uexp.h
index 6817eaf074..eb7aa5f5fb 100644
--- a/sysdeps/ieee754/dbl-64/uexp.h
+++ b/sysdeps/ieee754/dbl-64/uexp.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -29,7 +29,7 @@
#include "mydefs.h"
-const static double one = 1.0, zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
+const static double zero = 0.0, hhuge = 1.0e300, tiny = 1.0e-300,
err_0 = 1.000014, err_1 = 0.000016;
const static int4 bigint = 0x40862002,
badint = 0x40876000,smallint = 0x3C8fffff;
diff --git a/sysdeps/ieee754/dbl-64/uexp.tbl b/sysdeps/ieee754/dbl-64/uexp.tbl
index 859e908c5d..9abfc7ef71 100644
--- a/sysdeps/ieee754/dbl-64/uexp.tbl
+++ b/sysdeps/ieee754/dbl-64/uexp.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/ulog.h b/sysdeps/ieee754/dbl-64/ulog.h
index ce4db49024..d507c693d8 100644
--- a/sysdeps/ieee754/dbl-64/ulog.h
+++ b/sysdeps/ieee754/dbl-64/ulog.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/ulog.tbl b/sysdeps/ieee754/dbl-64/ulog.tbl
index e5d2fdd34b..dd92cbb886 100644
--- a/sysdeps/ieee754/dbl-64/ulog.tbl
+++ b/sysdeps/ieee754/dbl-64/ulog.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/upow.h b/sysdeps/ieee754/dbl-64/upow.h
index c8569a9456..dd9ba32b71 100644
--- a/sysdeps/ieee754/dbl-64/upow.h
+++ b/sysdeps/ieee754/dbl-64/upow.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -34,7 +34,6 @@
/**/ nZERO = {{0x80000000, 0}}, /* -0.0 */
/**/ INF = {{0x7ff00000, 0x00000000}}, /* INF */
/**/ nINF = {{0xfff00000, 0x00000000}}, /* -INF */
-/**/ sqrt_2 = {{0x3ff6a09e, 0x667f3bcc}}, /* sqrt(2) */
/**/ ln2a = {{0x3fe62e42, 0xfefa3800}}, /* ln(2) 43 bits */
/**/ ln2b = {{0x3d2ef357, 0x93c76730}}, /* ln(2)-ln2a */
/**/ bigu = {{0x4297ffff, 0xfffffd2c}}, /* 1.5*2**42 -724*2**-10 */
@@ -48,7 +47,6 @@
/**/ nZERO = {{0, 0x80000000}}, /* -0.0 */
/**/ INF = {{0x00000000, 0x7ff00000}}, /* INF */
/**/ nINF = {{0x00000000, 0xfff00000}}, /* -INF */
-/**/ sqrt_2 = {{0x667f3bcc, 0x3ff6a09e}}, /* sqrt(2) */
/**/ ln2a = {{0xfefa3800, 0x3fe62e42}}, /* ln(2) 43 bits */
/**/ ln2b = {{0x93c76730, 0x3d2ef357}}, /* ln(2)-ln2a */
/**/ bigu = {{0xfffffd2c, 0x4297ffff}}, /* 1.5*2**42 -724*2**-10 */
diff --git a/sysdeps/ieee754/dbl-64/upow.tbl b/sysdeps/ieee754/dbl-64/upow.tbl
index 1d506b5ad7..55d878edad 100644
--- a/sysdeps/ieee754/dbl-64/upow.tbl
+++ b/sysdeps/ieee754/dbl-64/upow.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/urem.h b/sysdeps/ieee754/dbl-64/urem.h
index f612c135f8..42b26273fd 100644
--- a/sysdeps/ieee754/dbl-64/urem.h
+++ b/sysdeps/ieee754/dbl-64/urem.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/uroot.h b/sysdeps/ieee754/dbl-64/uroot.h
deleted file mode 100644
index 4bbcc3bac7..0000000000
--- a/sysdeps/ieee754/dbl-64/uroot.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * IBM Accurate Mathematical Library
- * Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-/******************************************************************/
-/* */
-/* MODULE_NAME:uroot.h */
-/* */
-/* common data and variables prototype and definition */
-/******************************************************************/
-
-#ifndef UROOT_H
-#define UROOT_H
-
-#ifdef BIG_ENDI
- static const mynumber
-/**/ t512 = {{0x5ff00000, 0x00000000 }}, /* 2^512 */
-/**/ tm256 = {{0x2ff00000, 0x00000000 }}; /* 2^-256 */
-
-#else
-#ifdef LITTLE_ENDI
- static const mynumber
-/**/ t512 = {{0x00000000, 0x5ff00000 }}, /* 2^512 */
-/**/ tm256 = {{0x00000000, 0x2ff00000 }}; /* 2^-256 */
-#endif
-#endif
-
-#endif
diff --git a/sysdeps/ieee754/dbl-64/usncs.h b/sysdeps/ieee754/dbl-64/usncs.h
index e3a8193c40..1408695c85 100644
--- a/sysdeps/ieee754/dbl-64/usncs.h
+++ b/sysdeps/ieee754/dbl-64/usncs.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/utan.h b/sysdeps/ieee754/dbl-64/utan.h
index efa13ca5cf..0a99812754 100644
--- a/sysdeps/ieee754/dbl-64/utan.h
+++ b/sysdeps/ieee754/dbl-64/utan.h
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/utan.tbl b/sysdeps/ieee754/dbl-64/utan.tbl
index c088588229..8a8c2afa53 100644
--- a/sysdeps/ieee754/dbl-64/utan.tbl
+++ b/sysdeps/ieee754/dbl-64/utan.tbl
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* Written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/dbl-64/w_exp.c b/sysdeps/ieee754/dbl-64/w_exp.c
index 61b2dbbd0f..595ed992d2 100644
--- a/sysdeps/ieee754/dbl-64/w_exp.c
+++ b/sysdeps/ieee754/dbl-64/w_exp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/math_private.h b/sysdeps/ieee754/dbl-64/wordsize-64/math_private.h
deleted file mode 100644
index 4f9219934a..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/math_private.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _MATH_PRIVATE_H_
-
-#include_next <math_private.h>
-#include <stdint.h>
-
-#ifndef __isnan
-extern __always_inline int
-__isnan (double d)
-{
- uint64_t di;
- EXTRACT_WORDS64 (di, d);
- return (di & 0x7fffffffffffffffull) > 0x7ff0000000000000ull;
-}
-#endif
-
-#ifndef __isinf_ns
-extern __always_inline int
-__isinf_ns (double d)
-{
- uint64_t di;
- EXTRACT_WORDS64 (di, d);
- return (di & 0x7fffffffffffffffull) == 0x7ff0000000000000ull;
-}
-#endif
-
-#ifndef __finite
-extern __always_inline int
-__finite (double d)
-{
- uint64_t di;
- EXTRACT_WORDS64 (di, d);
- return (di & 0x7fffffffffffffffull) < 0x7ff0000000000000ull;
-}
-#endif
-
-#endif /* _MATH_PRIVATE_H_ */
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
index fcf2e6d5b6..ef51608f6e 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
@@ -16,6 +16,7 @@
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
#include <stdint.h>
#undef __finite
@@ -24,11 +25,18 @@ __finite(double x)
{
int64_t lx;
EXTRACT_WORDS64(lx,x);
- return (int)((uint64_t)((lx&INT64_C(0x7fffffffffffffff))-INT64_C(0x7ff0000000000000))>>63);
+ return (int)((uint64_t)((lx&INT64_C(0x7ff0000000000000))-INT64_C(0x7ff0000000000000))>>63);
}
hidden_def (__finite)
weak_alias (__finite, finite)
#ifdef NO_LONG_DOUBLE
-strong_alias (__finite, __finitel)
+# ifdef LDBL_CLASSIFY_COMPAT
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
+# endif
+# if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_23)
+compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
+# endif
+# endif
weak_alias (__finite, finitel)
#endif
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c
index 0dbadb15eb..b7ed14bfa2 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_floor.c
@@ -1,5 +1,5 @@
/* Round double to integer away from zero.
- Copyright (C) 2011-2015 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2011.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c
index f1fa3154ee..42068f8187 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_frexp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
index 163fc31efc..951fb73239 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf.c
@@ -11,6 +11,7 @@
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
int
__isinf (double x)
@@ -25,6 +26,8 @@ __isinf (double x)
hidden_def (__isinf)
weak_alias (__isinf, isinf)
#ifdef NO_LONG_DOUBLE
-strong_alias (__isinf, __isinfl)
+# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __isinf, __isinfl, GLIBC_2_0);
+# endif
weak_alias (__isinf, isinfl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c
deleted file mode 100644
index 9d78ed13ae..0000000000
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isinf_ns.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Written by Ulrich Drepper <drepper@gmail.com>.
- */
-
-/*
- * __isinf_ns(x) returns != 0 if x is ±inf, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-
-#undef __isinf_ns
-int
-__isinf_ns (double x)
-{
- int64_t ix;
- EXTRACT_WORDS64(ix,x);
- return (ix & UINT64_C(0x7fffffffffffffff)) == UINT64_C(0x7ff0000000000000);
-}
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
index e80b84ca02..bcff9e3b67 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_isnan.c
@@ -17,6 +17,7 @@
#include <math.h>
#include <math_private.h>
+#include <shlib-compat.h>
#include <stdint.h>
#undef __isnan
@@ -31,6 +32,8 @@ int __isnan(double x)
hidden_def (__isnan)
weak_alias (__isnan, isnan)
#ifdef NO_LONG_DOUBLE
-strong_alias (__isnan, __isnanl)
+# if defined LDBL_CLASSIFY_COMPAT && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_23)
+compat_symbol (libc, __isnan, __isnanl, GLIBC_2_0);
+# endif
weak_alias (__isnan, isnanl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
index 67d77d5732..c22e608c6e 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +25,6 @@ __issignaling (double x)
u_int64_t xi;
EXTRACT_WORDS64 (xi, x);
#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
-# error untested
/* We only have to care about the high-order bit of x's significand, because
having it set (sNaN) already makes the significand different from that
used to designate infinity. */
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
index 8bb52524b7..73ddd8dd9f 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
@@ -1,5 +1,5 @@
/* Round double value to long long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -69,23 +69,10 @@ strong_alias (__llround, __llroundl)
weak_alias (__llround, llroundl)
#endif
-/* long has the same width as long long on LP64 machines, so use an alias.
- If building for ILP32 on a machine with 64-bit registers, however,
- use a cast if necessary. */
+/* long has the same width as long long on LP64 machines, so use an alias. */
#undef lround
#undef __lround
-#if !defined (_LP64) && REGISTER_CAST_INT32_TO_INT64
-long int
-__lround (double x)
-{
- return __llround (x);
-}
-weak_alias (__lround, lround)
-# ifdef NO_LONG_DOUBLE
-strong_alias (__lround, __lroundl)
-weak_alias (__lround, lroundl)
-# endif
-#else
+#ifdef _LP64
strong_alias (__llround, __lround)
weak_alias (__llround, lround)
# ifdef NO_LONG_DOUBLE
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
index 1d20e93e6d..c7846054a6 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
@@ -1,5 +1,5 @@
/* Compute radix independent exponent.
- Copyright (C) 2011-2015 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
index 1e06fcb16e..9e665b01ec 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
@@ -1 +1,89 @@
-/* The code is the same as llround. Use an alias, see s_llround.c. */
+/* Round double value to long int.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <fenv.h>
+#include <limits.h>
+#include <math.h>
+
+#include <math_private.h>
+
+/* For LP64, lround is an alias for llround. */
+#ifndef _LP64
+
+long int
+__lround (double x)
+{
+ int32_t j0;
+ int64_t i0;
+ long int result;
+ int sign;
+
+ EXTRACT_WORDS64 (i0, x);
+ j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
+ sign = i0 < 0 ? -1 : 1;
+ i0 &= UINT64_C(0xfffffffffffff);
+ i0 |= UINT64_C(0x10000000000000);
+
+ if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
+ {
+ if (j0 < 0)
+ return j0 < -1 ? 0 : sign;
+ else if (j0 >= 52)
+ result = i0 << (j0 - 52);
+ else
+ {
+ i0 += UINT64_C(0x8000000000000) >> j0;
+
+ result = i0 >> (52 - j0);
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
+ }
+ else
+ {
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && x <= (double) LONG_MIN - 0.5)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ feraiseexcept (FE_INVALID);
+ return LONG_MIN;
+ }
+#endif
+ return (long int) x;
+ }
+
+ return sign * result;
+}
+
+weak_alias (__lround, lround)
+# ifdef NO_LONG_DOUBLE
+strong_alias (__lround, __lroundl)
+weak_alias (__lround, lroundl)
+# endif
+
+#endif
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
index 304e9d0fb4..716e07e54d 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_remquo.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c
index 565a4622d4..f1d75bbe68 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_round.c
@@ -1,5 +1,5 @@
/* Round double to integer away from zero.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c
index 3822e1737d..d517a919c8 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c
@@ -55,8 +55,6 @@ __scalbn (double x, int n)
INSERT_WORDS64(x,(ix&INT64_C(0x800fffffffffffff))|(k<<52));
return x*twom54;
}
-weak_alias (__scalbn, scalbn)
#ifdef NO_LONG_DOUBLE
strong_alias (__scalbn, __scalbnl)
-weak_alias (__scalbn, scalbnl)
#endif
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c
index 3810f8134d..81ac55e2f6 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c
@@ -1,5 +1,5 @@
/* Truncate argument to nearest integral value not larger than the argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/dbl-64/x2y2m1.c b/sysdeps/ieee754/dbl-64/x2y2m1.c
index c96dae59e1..96078888a7 100644
--- a/sysdeps/ieee754/dbl-64/x2y2m1.c
+++ b/sysdeps/ieee754/dbl-64/x2y2m1.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -80,32 +80,26 @@ compare (const void *p, const void *q)
}
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
double
__x2y2m1 (double x, double y)
{
- double vals[4];
+ double vals[5];
SET_RESTORE_ROUND (FE_TONEAREST);
mul_split (&vals[1], &vals[0], x, x);
mul_split (&vals[3], &vals[2], y, y);
- if (x >= 0.75)
- vals[1] -= 1.0;
- else
- {
- vals[1] -= 0.5;
- vals[3] -= 0.5;
- }
- qsort (vals, 4, sizeof (double), compare);
+ vals[4] = -1.0;
+ qsort (vals, 5, sizeof (double), compare);
/* Add up the values so that each element of VALS has absolute value
at most equal to the last set bit of the next nonzero
element. */
- for (size_t i = 0; i <= 2; i++)
+ for (size_t i = 0; i <= 3; i++)
{
add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]);
- qsort (vals + i + 1, 3 - i, sizeof (double), compare);
+ qsort (vals + i + 1, 4 - i, sizeof (double), compare);
}
/* Now any error from this addition will be small. */
- return vals[3] + vals[2] + vals[1] + vals[0];
+ return vals[4] + vals[3] + vals[2] + vals[1] + vals[0];
}
diff --git a/sysdeps/ieee754/dbl-64/x2y2m1f.c b/sysdeps/ieee754/dbl-64/x2y2m1f.c
index 43a8acf8a8..480b4c0c67 100644
--- a/sysdeps/ieee754/dbl-64/x2y2m1f.c
+++ b/sysdeps/ieee754/dbl-64/x2y2m1f.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,8 +21,8 @@
#include <float.h>
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
float
__x2y2m1f (float x, float y)
diff --git a/sysdeps/ieee754/flt-32/e_asinf.c b/sysdeps/ieee754/flt-32/e_asinf.c
index 00bad4239b..2ca2dbcb28 100644
--- a/sysdeps/ieee754/flt-32/e_asinf.c
+++ b/sysdeps/ieee754/flt-32/e_asinf.c
@@ -73,11 +73,7 @@ float __ieee754_asinf(float x)
return (x-x)/(x-x); /* asin(|x|>1) is NaN */
} else if (ix<0x3f000000) { /* |x|<0.5 */
if(ix<0x32000000) { /* if |x| < 2**-27 */
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if(huge+x>one) return x;/* return x with inexact if x!=0*/
} else {
t = x*x;
diff --git a/sysdeps/ieee754/flt-32/e_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c
index bc74960e16..82de071ab8 100644
--- a/sysdeps/ieee754/flt-32/e_atanhf.c
+++ b/sysdeps/ieee754/flt-32/e_atanhf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
@@ -52,11 +52,7 @@ __ieee754_atanhf (float x)
if (__glibc_unlikely (xa < 0x1.0p-28f))
{
math_force_eval (huge + x);
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
diff --git a/sysdeps/ieee754/flt-32/e_coshf.c b/sysdeps/ieee754/flt-32/e_coshf.c
index dedda47c09..7b223758e1 100644
--- a/sysdeps/ieee754/flt-32/e_coshf.c
+++ b/sysdeps/ieee754/flt-32/e_coshf.c
@@ -58,6 +58,6 @@ __ieee754_coshf (float x)
if(ix>=0x7f800000) return x*x;
/* |x| > overflowthresold, cosh(x) overflow */
- return huge*huge;
+ return math_narrow_eval (huge*huge);
}
strong_alias (__ieee754_coshf, __coshf_finite)
diff --git a/sysdeps/ieee754/flt-32/e_exp2f.c b/sysdeps/ieee754/flt-32/e_exp2f.c
index 0b75a7ea2a..1723c482de 100644
--- a/sysdeps/ieee754/flt-32/e_exp2f.c
+++ b/sysdeps/ieee754/flt-32/e_exp2f.c
@@ -1,5 +1,5 @@
/* Single-precision floating point 2^x.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
@@ -37,8 +37,8 @@
#include "t_exp2f.h"
-static const volatile float TWOM100 = 7.88860905e-31;
-static const volatile float TWO127 = 1.7014118346e+38;
+static const float TWOM100 = 7.88860905e-31;
+static const float TWO127 = 1.7014118346e+38;
float
__ieee754_exp2f (float x)
@@ -109,12 +109,16 @@ __ieee754_exp2f (float x)
if (!unsafe)
return result;
else
- return result * scale_u.f;
+ {
+ result *= scale_u.f;
+ math_check_force_underflow_nonneg (result);
+ return result;
+ }
}
/* Exceptional cases: */
else if (isless (x, himark))
{
- if (__isinf_nsf (x))
+ if (isinf (x))
/* e^-inf == 0, with no error. */
return 0;
else
diff --git a/sysdeps/ieee754/flt-32/e_expf.c b/sysdeps/ieee754/flt-32/e_expf.c
index abf9111a74..071f615ef4 100644
--- a/sysdeps/ieee754/flt-32/e_expf.c
+++ b/sysdeps/ieee754/flt-32/e_expf.c
@@ -1,5 +1,5 @@
/* Single-precision floating point e^x.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
diff --git a/sysdeps/ieee754/flt-32/e_gammaf_r.c b/sysdeps/ieee754/flt-32/e_gammaf_r.c
index 29fe8b46c2..19f51b0c8b 100644
--- a/sysdeps/ieee754/flt-32/e_gammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_gammaf_r.c
@@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -69,11 +69,7 @@ gammaf_positive (float x, int *exp2_adj)
/* Adjust into the range for applying Stirling's
approximation. */
float n = __ceilf (4.0f - x);
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- float x_tmp = x + n;
- x_adj = x_tmp;
+ x_adj = math_narrow_eval (x + n);
x_eps = (x - (x_adj - n));
prod = __gamma_productf (x_adj - n, x_eps, n, &eps);
}
@@ -111,9 +107,6 @@ float
__ieee754_gammaf_r (float x, int *signgamp)
{
int32_t hx;
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
float ret;
GET_FLOAT_WORD (hx, x);
@@ -149,7 +142,7 @@ __ieee754_gammaf_r (float x, int *signgamp)
{
/* Overflow. */
*signgamp = 0;
- ret = FLT_MAX * FLT_MAX;
+ ret = math_narrow_eval (FLT_MAX * FLT_MAX);
return ret;
}
else
@@ -186,29 +179,31 @@ __ieee754_gammaf_r (float x, int *signgamp)
float tret = (float) M_PI / (-x * sinpix
* gammaf_positive (-x, &exp2_adj));
ret = __scalbnf (tret, -exp2_adj);
+ math_check_force_underflow_nonneg (ret);
}
}
+ ret = math_narrow_eval (ret);
}
if (isinf (ret) && x != 0)
{
if (*signgamp < 0)
{
- ret = -__copysignf (FLT_MAX, ret) * FLT_MAX;
+ ret = math_narrow_eval (-__copysignf (FLT_MAX, ret) * FLT_MAX);
ret = -ret;
}
else
- ret = __copysignf (FLT_MAX, ret) * FLT_MAX;
+ ret = math_narrow_eval (__copysignf (FLT_MAX, ret) * FLT_MAX);
return ret;
}
else if (ret == 0)
{
if (*signgamp < 0)
{
- ret = -__copysignf (FLT_MIN, ret) * FLT_MIN;
+ ret = math_narrow_eval (-__copysignf (FLT_MIN, ret) * FLT_MIN);
ret = -ret;
}
else
- ret = __copysignf (FLT_MIN, ret) * FLT_MIN;
+ ret = math_narrow_eval (__copysignf (FLT_MIN, ret) * FLT_MIN);
return ret;
}
else
diff --git a/sysdeps/ieee754/flt-32/e_hypotf.c b/sysdeps/ieee754/flt-32/e_hypotf.c
index 8f499b5fde..717b82e42f 100644
--- a/sysdeps/ieee754/flt-32/e_hypotf.c
+++ b/sysdeps/ieee754/flt-32/e_hypotf.c
@@ -27,17 +27,9 @@ __ieee754_hypotf(float x, float y)
GET_FLOAT_WORD(hb,y);
hb &= 0x7fffffff;
if (ha == 0x7f800000)
- {
- if (x == y)
- return fabsf(y);
- return fabsf(x);
- }
+ return fabsf(x);
else if (hb == 0x7f800000)
- {
- if (x == y)
- return fabsf(x);
- return fabsf(y);
- }
+ return fabsf(y);
else if (ha > 0x7f800000 || hb > 0x7f800000)
return fabsf(x) * fabsf(y);
else if (ha == 0)
diff --git a/sysdeps/ieee754/flt-32/e_j1f.c b/sysdeps/ieee754/flt-32/e_j1f.c
index 63de21f609..f359a3d9ba 100644
--- a/sysdeps/ieee754/flt-32/e_j1f.c
+++ b/sysdeps/ieee754/flt-32/e_j1f.c
@@ -71,11 +71,10 @@ __ieee754_j1f(float x)
}
if(__builtin_expect(ix<0x32000000, 0)) { /* |x|<2**-27 */
if(huge+x>one) { /* inexact if x!=0 necessary */
- float ret = (float) 0.5 * x;
- if (fabsf (ret) < FLT_MIN) {
- float force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ float ret = math_narrow_eval ((float) 0.5 * x);
+ math_check_force_underflow (ret);
+ if (ret == 0 && x != 0)
+ __set_errno (ERANGE);
return ret;
}
}
diff --git a/sysdeps/ieee754/flt-32/e_jnf.c b/sysdeps/ieee754/flt-32/e_jnf.c
index 44a3761adb..4e634778d3 100644
--- a/sysdeps/ieee754/flt-32/e_jnf.c
+++ b/sysdeps/ieee754/flt-32/e_jnf.c
@@ -167,13 +167,15 @@ __ieee754_jnf(int n, float x)
}
}
if(sgn==1) ret = -b; else ret = b;
+ ret = math_narrow_eval (ret);
}
if (ret == 0)
- ret = __copysignf (FLT_MIN, ret) * FLT_MIN;
- else if (fabsf (ret) < FLT_MIN) {
- float force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ {
+ ret = math_narrow_eval (__copysignf (FLT_MIN, ret) * FLT_MIN);
+ __set_errno (ERANGE);
+ }
+ else
+ math_check_force_underflow (ret);
return ret;
}
strong_alias (__ieee754_jnf, __jnf_finite)
diff --git a/sysdeps/ieee754/flt-32/e_lgammaf_r.c b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
index c0bf4156ff..4d8a66bb39 100644
--- a/sysdeps/ieee754/flt-32/e_lgammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
@@ -161,6 +161,9 @@ __ieee754_lgammaf_r(float x, int *signgamp)
if(hx<0) {
if(ix>=0x4b000000) /* |x|>=2**23, must be -integer */
return x/zero;
+ if (ix > 0x40000000 /* X < 2.0f. */
+ && ix < 0x41700000 /* X > -15.0f. */)
+ return __lgamma_negf (x, signgamp);
t = sin_pif(x);
if(t==zero) return one/fabsf(t); /* -integer */
nadj = __ieee754_logf(pi/fabsf(t*x));
@@ -229,17 +232,13 @@ __ieee754_lgammaf_r(float x, int *signgamp)
r = (x-half)*(t-one)+w;
} else
/* 2**26 <= x <= inf */
- r = x*(__ieee754_logf(x)-one);
+ r = math_narrow_eval (x*(__ieee754_logf(x)-one));
/* NADJ is set for negative arguments but not otherwise,
resulting in warnings that it may be used uninitialized
although in the cases where it is used it has always been
set. */
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (4, 7)
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#else
- DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wuninitialized");
-#endif
if(hx<0) r = nadj - r;
DIAG_POP_NEEDS_COMMENT;
return r;
diff --git a/sysdeps/ieee754/flt-32/e_log10f.c b/sysdeps/ieee754/flt-32/e_log10f.c
index 96f0e81c52..2cd01b4a50 100644
--- a/sysdeps/ieee754/flt-32/e_log10f.c
+++ b/sysdeps/ieee754/flt-32/e_log10f.c
@@ -15,6 +15,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const float
two25 = 3.3554432000e+07, /* 0x4c000000 */
@@ -22,8 +23,6 @@ ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */
log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */
log10_2lo = 7.9034151668e-07; /* 0x355427db */
-static const float zero = 0.0;
-
float
__ieee754_log10f(float x)
{
@@ -46,6 +45,8 @@ __ieee754_log10f(float x)
i = ((u_int32_t)k&0x80000000)>>31;
hx = (hx&0x007fffff)|((0x7f-i)<<23);
y = (float)(k+i);
+ if (FIX_INT_FP_CONVERT_ZERO && y == 0.0f)
+ y = 0.0f;
SET_FLOAT_WORD(x,hx);
z = y*log10_2lo + ivln10*__ieee754_logf(x);
return z+y*log10_2hi;
diff --git a/sysdeps/ieee754/flt-32/e_log2f.c b/sysdeps/ieee754/flt-32/e_log2f.c
index 245be4e6f7..857d13fb9b 100644
--- a/sysdeps/ieee754/flt-32/e_log2f.c
+++ b/sysdeps/ieee754/flt-32/e_log2f.c
@@ -17,6 +17,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const float
ln2 = 0.69314718055994530942,
@@ -57,7 +58,12 @@ __ieee754_log2f(float x)
dk = (float)k;
f = x-(float)1.0;
if((0x007fffff&(15+ix))<16) { /* |f| < 2**-20 */
- if(f==zero) return dk;
+ if(f==zero)
+ {
+ if (FIX_INT_FP_CONVERT_ZERO && dk == 0.0f)
+ dk = 0.0f;
+ return dk;
+ }
R = f*f*((float)0.5-(float)0.33333333333333333*f);
return dk-(R-f)/ln2;
}
diff --git a/sysdeps/ieee754/flt-32/e_powf.c b/sysdeps/ieee754/flt-32/e_powf.c
index 12c408f93c..c72fe37d3b 100644
--- a/sysdeps/ieee754/flt-32/e_powf.c
+++ b/sysdeps/ieee754/flt-32/e_powf.c
@@ -131,7 +131,7 @@ __ieee754_powf(float x, float y)
if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny;
/* now |1-x| is tiny <= 2**-20, suffice to compute
log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = x-1; /* t has 20 trailing zeros */
+ t = ax-1; /* t has 20 trailing zeros */
w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25));
u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
v = t*ivln2_l-w*ivln2;
@@ -166,7 +166,9 @@ __ieee754_powf(float x, float y)
GET_FLOAT_WORD(is,s_h);
SET_FLOAT_WORD(s_h,is&0xfffff000);
/* t_h=ax+bp[k] High */
- SET_FLOAT_WORD(t_h,((ix>>1)|0x20000000)+0x0040000+(k<<21));
+ SET_FLOAT_WORD (t_h,
+ ((((ix>>1)|0x20000000)+0x00400000+(k<<21))
+ & 0xfffff000));
t_l = ax - (t_h-bp[k]);
s_l = v*((u-s_h*t_h)-s_h*t_l);
/* compute log(ax) */
@@ -244,7 +246,12 @@ __ieee754_powf(float x, float y)
z = one-(r-z);
GET_FLOAT_WORD(j,z);
j += (n<<23);
- if((j>>23)<=0) z = __scalbnf(z,n); /* subnormal output */
+ if((j>>23)<=0) /* subnormal output */
+ {
+ z = __scalbnf (z, n);
+ float force_underflow = z * z;
+ math_force_eval (force_underflow);
+ }
else SET_FLOAT_WORD(z,j);
return s*z;
}
diff --git a/sysdeps/ieee754/flt-32/e_sinhf.c b/sysdeps/ieee754/flt-32/e_sinhf.c
index 0a3cc90cd1..6100d95c55 100644
--- a/sysdeps/ieee754/flt-32/e_sinhf.c
+++ b/sysdeps/ieee754/flt-32/e_sinhf.c
@@ -13,6 +13,7 @@
* ====================================================
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -34,8 +35,10 @@ __ieee754_sinhf(float x)
if (jx<0) h = -h;
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x41b00000) { /* |x|<22 */
- if (__builtin_expect(ix<0x31800000, 0)) /* |x|<2**-28 */
+ if (__builtin_expect(ix<0x31800000, 0)) { /* |x|<2**-28 */
+ math_check_force_underflow (x);
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
+ }
t = __expm1f(fabsf(x));
if(ix<0x3f800000) return h*((float)2.0*t-t*t/(t+one));
return h*(t+t/(t+one));
@@ -52,6 +55,6 @@ __ieee754_sinhf(float x)
}
/* |x| > overflowthresold, sinh(x) overflow */
- return x*shuge;
+ return math_narrow_eval (x*shuge);
}
strong_alias (__ieee754_sinhf, __sinhf_finite)
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index 6f14d5bac7..392afdbb6c 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -65,7 +65,9 @@ int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32
/* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) {
- for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+ for(j=0,fw=0.0;j<=jx;j++)
+ fw += x[j]*f[jx+i-j];
+ q[i] = fw;
}
jz = jk;
@@ -167,30 +169,21 @@ recompute:
break;
case 1:
case 2:;
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
float fv = 0.0;
- for (i=jz;i>=0;i--) fv += fq[i];
+ for (i=jz;i>=0;i--) fv = math_narrow_eval (fv + fq[i]);
y[0] = (ih==0)? fv: -fv;
- fv = fq[0]-fv;
- for (i=1;i<=jz;i++) fv += fq[i];
+ fv = math_narrow_eval (fq[0]-fv);
+ for (i=1;i<=jz;i++) fv = math_narrow_eval (fv + fq[i]);
y[1] = (ih==0)? fv: -fv;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
- float fv = fq[i-1]+fq[i];
+ float fv = math_narrow_eval (fq[i-1]+fq[i]);
fq[i] += fq[i-1]-fv;
fq[i-1] = fv;
}
for (i=jz;i>1;i--) {
-#if __FLT_EVAL_METHOD__ != 0
- volatile
-#endif
- float fv = fq[i-1]+fq[i];
+ float fv = math_narrow_eval (fq[i-1]+fq[i]);
fq[i] += fq[i-1]-fv;
fq[i-1] = fv;
}
diff --git a/sysdeps/ieee754/flt-32/k_sinf.c b/sysdeps/ieee754/flt-32/k_sinf.c
index 0c98a2ae91..a195d59466 100644
--- a/sysdeps/ieee754/flt-32/k_sinf.c
+++ b/sysdeps/ieee754/flt-32/k_sinf.c
@@ -38,11 +38,7 @@ float __kernel_sinf(float x, float y, int iy)
ix &= 0x7fffffff; /* high word of x */
if(ix<0x32000000) /* |x| < 2**-27 */
{
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if ((int) x == 0)
return x; /* generate inexact */
}
diff --git a/sysdeps/ieee754/flt-32/k_tanf.c b/sysdeps/ieee754/flt-32/k_tanf.c
index a67f36e283..9f0e55860f 100644
--- a/sysdeps/ieee754/flt-32/k_tanf.c
+++ b/sysdeps/ieee754/flt-32/k_tanf.c
@@ -17,6 +17,7 @@
static char rcsid[] = "$NetBSD: k_tanf.c,v 1.4 1995/05/10 20:46:39 jtc Exp $";
#endif
+#include <float.h>
#include <math.h>
#include <math_private.h>
static const float
@@ -48,7 +49,13 @@ float __kernel_tanf(float x, float y, int iy)
if(ix<0x39000000) /* x < 2**-13 */
{if((int)x==0) { /* generate inexact */
if((ix|(iy+1))==0) return one/fabsf(x);
- else return (iy==1)? x: -one/x;
+ else if (iy == 1)
+ {
+ math_check_force_underflow (x);
+ return x;
+ }
+ else
+ return -one / x;
}
}
if(ix>=0x3f2ca140) { /* |x|>=0.6744 */
diff --git a/sysdeps/ieee754/flt-32/lgamma_negf.c b/sysdeps/ieee754/flt-32/lgamma_negf.c
new file mode 100644
index 0000000000..f15719b059
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/lgamma_negf.c
@@ -0,0 +1,280 @@
+/* lgammaf expanding around zeros.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <math_private.h>
+
+static const float lgamma_zeros[][2] =
+ {
+ { -0x2.74ff94p+0f, 0x1.3fe0f2p-24f },
+ { -0x2.bf682p+0f, -0x1.437b2p-24f },
+ { -0x3.24c1b8p+0f, 0x6.c34cap-28f },
+ { -0x3.f48e2cp+0f, 0x1.707a04p-24f },
+ { -0x4.0a13ap+0f, 0x1.e99aap-24f },
+ { -0x4.fdd5ep+0f, 0x1.64454p-24f },
+ { -0x5.021a98p+0f, 0x2.03d248p-24f },
+ { -0x5.ffa4cp+0f, 0x2.9b82fcp-24f },
+ { -0x6.005ac8p+0f, -0x1.625f24p-24f },
+ { -0x6.fff3p+0f, 0x2.251e44p-24f },
+ { -0x7.000dp+0f, 0x8.48078p-28f },
+ { -0x7.fffe6p+0f, 0x1.fa98c4p-28f },
+ { -0x8.0001ap+0f, -0x1.459fcap-28f },
+ { -0x8.ffffdp+0f, -0x1.c425e8p-24f },
+ { -0x9.00003p+0f, 0x1.c44b82p-24f },
+ { -0xap+0f, 0x4.9f942p-24f },
+ { -0xap+0f, -0x4.9f93b8p-24f },
+ { -0xbp+0f, 0x6.b9916p-28f },
+ { -0xbp+0f, -0x6.b9915p-28f },
+ { -0xcp+0f, 0x8.f76c8p-32f },
+ { -0xcp+0f, -0x8.f76c7p-32f },
+ { -0xdp+0f, 0xb.09231p-36f },
+ { -0xdp+0f, -0xb.09231p-36f },
+ { -0xep+0f, 0xc.9cba5p-40f },
+ { -0xep+0f, -0xc.9cba5p-40f },
+ { -0xfp+0f, 0xd.73f9fp-44f },
+ };
+
+static const float e_hi = 0x2.b7e15p+0f, e_lo = 0x1.628aeep-24f;
+
+/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) in Stirling's
+ approximation to lgamma function. */
+
+static const float lgamma_coeff[] =
+ {
+ 0x1.555556p-4f,
+ -0xb.60b61p-12f,
+ 0x3.403404p-12f,
+ };
+
+#define NCOEFF (sizeof (lgamma_coeff) / sizeof (lgamma_coeff[0]))
+
+/* Polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0), where n is
+ the integer end-point of the half-integer interval containing x and
+ x0 is the zero of lgamma in that half-integer interval. Each
+ polynomial is expressed in terms of x-xm, where xm is the midpoint
+ of the interval for which the polynomial applies. */
+
+static const float poly_coeff[] =
+ {
+ /* Interval [-2.125, -2] (polynomial degree 5). */
+ -0x1.0b71c6p+0f,
+ -0xc.73a1ep-4f,
+ -0x1.ec8462p-4f,
+ -0xe.37b93p-4f,
+ -0x1.02ed36p-4f,
+ -0xe.cbe26p-4f,
+ /* Interval [-2.25, -2.125] (polynomial degree 5). */
+ -0xf.29309p-4f,
+ -0xc.a5cfep-4f,
+ 0x3.9c93fcp-4f,
+ -0x1.02a2fp+0f,
+ 0x9.896bep-4f,
+ -0x1.519704p+0f,
+ /* Interval [-2.375, -2.25] (polynomial degree 5). */
+ -0xd.7d28dp-4f,
+ -0xe.6964cp-4f,
+ 0xb.0d4f1p-4f,
+ -0x1.9240aep+0f,
+ 0x1.dadabap+0f,
+ -0x3.1778c4p+0f,
+ /* Interval [-2.5, -2.375] (polynomial degree 6). */
+ -0xb.74ea2p-4f,
+ -0x1.2a82cp+0f,
+ 0x1.880234p+0f,
+ -0x3.320c4p+0f,
+ 0x5.572a38p+0f,
+ -0x9.f92bap+0f,
+ 0x1.1c347ep+4f,
+ /* Interval [-2.625, -2.5] (polynomial degree 6). */
+ -0x3.d10108p-4f,
+ 0x1.cd5584p+0f,
+ 0x3.819c24p+0f,
+ 0x6.84cbb8p+0f,
+ 0xb.bf269p+0f,
+ 0x1.57fb12p+4f,
+ 0x2.7b9854p+4f,
+ /* Interval [-2.75, -2.625] (polynomial degree 6). */
+ -0x6.b5d25p-4f,
+ 0x1.28d604p+0f,
+ 0x1.db6526p+0f,
+ 0x2.e20b38p+0f,
+ 0x4.44c378p+0f,
+ 0x6.62a08p+0f,
+ 0x9.6db3ap+0f,
+ /* Interval [-2.875, -2.75] (polynomial degree 5). */
+ -0x8.a41b2p-4f,
+ 0xc.da87fp-4f,
+ 0x1.147312p+0f,
+ 0x1.7617dap+0f,
+ 0x1.d6c13p+0f,
+ 0x2.57a358p+0f,
+ /* Interval [-3, -2.875] (polynomial degree 5). */
+ -0xa.046d6p-4f,
+ 0x9.70b89p-4f,
+ 0xa.a89a6p-4f,
+ 0xd.2f2d8p-4f,
+ 0xd.e32b4p-4f,
+ 0xf.fb741p-4f,
+ };
+
+static const size_t poly_deg[] =
+ {
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 5,
+ 5,
+ };
+
+static const size_t poly_end[] =
+ {
+ 5,
+ 11,
+ 17,
+ 24,
+ 31,
+ 38,
+ 44,
+ 50,
+ };
+
+/* Compute sin (pi * X) for -0.25 <= X <= 0.5. */
+
+static float
+lg_sinpi (float x)
+{
+ if (x <= 0.25f)
+ return __sinf ((float) M_PI * x);
+ else
+ return __cosf ((float) M_PI * (0.5f - x));
+}
+
+/* Compute cos (pi * X) for -0.25 <= X <= 0.5. */
+
+static float
+lg_cospi (float x)
+{
+ if (x <= 0.25f)
+ return __cosf ((float) M_PI * x);
+ else
+ return __sinf ((float) M_PI * (0.5f - x));
+}
+
+/* Compute cot (pi * X) for -0.25 <= X <= 0.5. */
+
+static float
+lg_cotpi (float x)
+{
+ return lg_cospi (x) / lg_sinpi (x);
+}
+
+/* Compute lgamma of a negative argument -15 < X < -2, setting
+ *SIGNGAMP accordingly. */
+
+float
+__lgamma_negf (float x, int *signgamp)
+{
+ /* Determine the half-integer region X lies in, handle exact
+ integers and determine the sign of the result. */
+ int i = __floorf (-2 * x);
+ if ((i & 1) == 0 && i == -2 * x)
+ return 1.0f / 0.0f;
+ float xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
+ i -= 4;
+ *signgamp = ((i & 2) == 0 ? -1 : 1);
+
+ SET_RESTORE_ROUNDF (FE_TONEAREST);
+
+ /* Expand around the zero X0 = X0_HI + X0_LO. */
+ float x0_hi = lgamma_zeros[i][0], x0_lo = lgamma_zeros[i][1];
+ float xdiff = x - x0_hi - x0_lo;
+
+ /* For arguments in the range -3 to -2, use polynomial
+ approximations to an adjusted version of the gamma function. */
+ if (i < 2)
+ {
+ int j = __floorf (-8 * x) - 16;
+ float xm = (-33 - 2 * j) * 0.0625f;
+ float x_adj = x - xm;
+ size_t deg = poly_deg[j];
+ size_t end = poly_end[j];
+ float g = poly_coeff[end];
+ for (size_t j = 1; j <= deg; j++)
+ g = g * x_adj + poly_coeff[end - j];
+ return __log1pf (g * xdiff / (x - xn));
+ }
+
+ /* The result we want is log (sinpi (X0) / sinpi (X))
+ + log (gamma (1 - X0) / gamma (1 - X)). */
+ float x_idiff = fabsf (xn - x), x0_idiff = fabsf (xn - x0_hi - x0_lo);
+ float log_sinpi_ratio;
+ if (x0_idiff < x_idiff * 0.5f)
+ /* Use log not log1p to avoid inaccuracy from log1p of arguments
+ close to -1. */
+ log_sinpi_ratio = __ieee754_logf (lg_sinpi (x0_idiff)
+ / lg_sinpi (x_idiff));
+ else
+ {
+ /* Use log1p not log to avoid inaccuracy from log of arguments
+ close to 1. X0DIFF2 has positive sign if X0 is further from
+ XN than X is from XN, negative sign otherwise. */
+ float x0diff2 = ((i & 1) == 0 ? xdiff : -xdiff) * 0.5f;
+ float sx0d2 = lg_sinpi (x0diff2);
+ float cx0d2 = lg_cospi (x0diff2);
+ log_sinpi_ratio = __log1pf (2 * sx0d2
+ * (-sx0d2 + cx0d2 * lg_cotpi (x_idiff)));
+ }
+
+ float log_gamma_ratio;
+ float y0 = math_narrow_eval (1 - x0_hi);
+ float y0_eps = -x0_hi + (1 - y0) - x0_lo;
+ float y = math_narrow_eval (1 - x);
+ float y_eps = -x + (1 - y);
+ /* We now wish to compute LOG_GAMMA_RATIO
+ = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF
+ accurately approximates the difference Y0 + Y0_EPS - Y -
+ Y_EPS. Use Stirling's approximation. */
+ float log_gamma_high
+ = (xdiff * __log1pf ((y0 - e_hi - e_lo + y0_eps) / e_hi)
+ + (y - 0.5f + y_eps) * __log1pf (xdiff / y));
+ /* Compute the sum of (B_2k / 2k(2k-1))(Y0^-(2k-1) - Y^-(2k-1)). */
+ float y0r = 1 / y0, yr = 1 / y;
+ float y0r2 = y0r * y0r, yr2 = yr * yr;
+ float rdiff = -xdiff / (y * y0);
+ float bterm[NCOEFF];
+ float dlast = rdiff, elast = rdiff * yr * (yr + y0r);
+ bterm[0] = dlast * lgamma_coeff[0];
+ for (size_t j = 1; j < NCOEFF; j++)
+ {
+ float dnext = dlast * y0r2 + elast;
+ float enext = elast * yr2;
+ bterm[j] = dnext * lgamma_coeff[j];
+ dlast = dnext;
+ elast = enext;
+ }
+ float log_gamma_low = 0;
+ for (size_t j = 0; j < NCOEFF; j++)
+ log_gamma_low += bterm[NCOEFF - 1 - j];
+ log_gamma_ratio = log_gamma_high + log_gamma_low;
+
+ return log_sinpi_ratio + log_gamma_ratio;
+}
diff --git a/sysdeps/ieee754/flt-32/lgamma_productf.c b/sysdeps/ieee754/flt-32/lgamma_productf.c
new file mode 100644
index 0000000000..1cc8931700
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/lgamma_productf.c
@@ -0,0 +1 @@
+/* Not needed. */
diff --git a/sysdeps/ieee754/flt-32/math_private.h b/sysdeps/ieee754/flt-32/math_private.h
deleted file mode 100644
index e33db02b4c..0000000000
--- a/sysdeps/ieee754/flt-32/math_private.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _MATH_PRIVATE_H_
-
-#include_next <math_private.h>
-
-#ifndef __isnanf
-extern __always_inline int
-__isnanf (float d)
-{
- u_int32_t di;
- GET_FLOAT_WORD (di, d);
- return (di & 0x7fffffff) > 0x7f800000;
-}
-#endif
-
-#ifndef __isinf_nsf
-extern __always_inline int
-__isinf_nsf (float d)
-{
- u_int32_t di;
- GET_FLOAT_WORD (di, d);
- return (di & 0x7fffffff) == 0x7f800000;
-}
-#endif
-
-#ifndef __finitef
-extern __always_inline int
-__finitef (float d)
-{
- u_int32_t di;
- GET_FLOAT_WORD (di, d);
- return (di & 0x7fffffff) < 0x7f800000;
-}
-#endif
-
-#endif /* _MATH_PRIVATE_H_ */
diff --git a/sysdeps/ieee754/flt-32/mpn2flt.c b/sysdeps/ieee754/flt-32/mpn2flt.c
index 36a6dc3ad3..7f40f56d33 100644
--- a/sysdeps/ieee754/flt-32/mpn2flt.c
+++ b/sysdeps/ieee754/flt-32/mpn2flt.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/flt-32/s_asinhf.c b/sysdeps/ieee754/flt-32/s_asinhf.c
index 697faa843c..da9cafb600 100644
--- a/sysdeps/ieee754/flt-32/s_asinhf.c
+++ b/sysdeps/ieee754/flt-32/s_asinhf.c
@@ -30,11 +30,7 @@ __asinhf(float x)
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(__builtin_expect(ix< 0x38000000, 0)) { /* |x|<2**-14 */
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if(huge+x>one) return x; /* return x inexact except 0 */
}
if(__builtin_expect(ix>0x47000000, 0)) { /* |x| > 2**14 */
diff --git a/sysdeps/ieee754/flt-32/s_atanf.c b/sysdeps/ieee754/flt-32/s_atanf.c
index be2addbdff..e322a1d41f 100644
--- a/sysdeps/ieee754/flt-32/s_atanf.c
+++ b/sysdeps/ieee754/flt-32/s_atanf.c
@@ -67,11 +67,7 @@ float __atanf(float x)
else return -atanhi[3]-atanlo[3];
} if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x31000000) { /* |x| < 2^-29 */
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if(huge+x>one) return x; /* raise inexact */
}
id = -1;
diff --git a/sysdeps/ieee754/flt-32/s_cbrtf.c b/sysdeps/ieee754/flt-32/s_cbrtf.c
index 6d6c366c6f..b9e2b3738c 100644
--- a/sysdeps/ieee754/flt-32/s_cbrtf.c
+++ b/sysdeps/ieee754/flt-32/s_cbrtf.c
@@ -1,5 +1,5 @@
/* Compute cubic root of float value.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Dirk Alboth <dirka@uni-paderborn.de> and
Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/s_cosf.c b/sysdeps/ieee754/flt-32/s_cosf.c
index 864ab27a4f..0affd406bb 100644
--- a/sysdeps/ieee754/flt-32/s_cosf.c
+++ b/sysdeps/ieee754/flt-32/s_cosf.c
@@ -21,8 +21,6 @@ static char rcsid[] = "$NetBSD: s_cosf.c,v 1.4 1995/05/10 20:47:03 jtc Exp $";
#include <math.h>
#include <math_private.h>
-static const float one=1.0;
-
#ifndef COSF
# define COSF_FUNC __cosf
#else
diff --git a/sysdeps/ieee754/flt-32/s_erff.c b/sysdeps/ieee754/flt-32/s_erff.c
index 2be44cc40c..c8b6287503 100644
--- a/sysdeps/ieee754/flt-32/s_erff.c
+++ b/sysdeps/ieee754/flt-32/s_erff.c
@@ -21,6 +21,7 @@ static char rcsid[] = "$NetBSD: s_erff.c,v 1.4 1995/05/10 20:47:07 jtc Exp $";
#include <float.h>
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
static const float
tiny = 1e-30,
@@ -113,11 +114,7 @@ float __erff(float x)
{
/* Avoid spurious underflow. */
float ret = 0.0625f * (16.0f * x + (16.0f * efx) * x);
- if (fabsf (ret) < FLT_MIN)
- {
- float force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
return ret;
}
return x + efx*x;
@@ -165,7 +162,10 @@ float __erfcf(float x)
ix = hx&0x7fffffff;
if(ix>=0x7f800000) { /* erfc(nan)=nan */
/* erfc(+-inf)=0,2 */
- return (float)(((u_int32_t)hx>>31)<<1)+one/x;
+ float ret = (float)(((u_int32_t)hx>>31)<<1)+one/x;
+ if (FIX_INT_FP_CONVERT_ZERO && ret == 0.0f)
+ return 0.0f;
+ return ret;
}
if(ix < 0x3f580000) { /* |x|<0.84375 */
@@ -213,10 +213,7 @@ float __erfcf(float x)
r = __ieee754_expf(-z*z-(float)0.5625)*
__ieee754_expf((z-x)*(z+x)+R/S);
if(hx>0) {
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- float ret = r/x;
+ float ret = math_narrow_eval (r/x);
if (ret == 0)
__set_errno (ERANGE);
return ret;
diff --git a/sysdeps/ieee754/flt-32/s_expm1f.c b/sysdeps/ieee754/flt-32/s_expm1f.c
index c81b057f24..c515d25e28 100644
--- a/sysdeps/ieee754/flt-32/s_expm1f.c
+++ b/sysdeps/ieee754/flt-32/s_expm1f.c
@@ -81,11 +81,7 @@ __expm1f(float x)
c = (hi-x)-lo;
}
else if(hx < 0x33000000) { /* when |x|<2**-25, return x */
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
t = huge+x; /* return x with inexact flags when x!=0 */
return x - (t-(huge+x));
}
diff --git a/sysdeps/ieee754/flt-32/s_finitef.c b/sysdeps/ieee754/flt-32/s_finitef.c
index 4ea270ae07..4c5b339235 100644
--- a/sysdeps/ieee754/flt-32/s_finitef.c
+++ b/sysdeps/ieee754/flt-32/s_finitef.c
@@ -35,7 +35,7 @@ int FINITEF(float x)
{
int32_t ix;
GET_FLOAT_WORD(ix,x);
- return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31);
+ return (int)((u_int32_t)((ix&0x7f800000)-0x7f800000)>>31);
}
hidden_def (__finitef)
weak_alias (__finitef, finitef)
diff --git a/sysdeps/ieee754/flt-32/s_fpclassifyf.c b/sysdeps/ieee754/flt-32/s_fpclassifyf.c
index 8053184ae7..480557e2ae 100644
--- a/sysdeps/ieee754/flt-32/s_fpclassifyf.c
+++ b/sysdeps/ieee754/flt-32/s_fpclassifyf.c
@@ -1,5 +1,5 @@
/* Return classification value corresponding to argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/s_isinf_nsf.c b/sysdeps/ieee754/flt-32/s_isinf_nsf.c
deleted file mode 100644
index 284d61926a..0000000000
--- a/sysdeps/ieee754/flt-32/s_isinf_nsf.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Written by Ulrich Drepper <drepper@gmail.com>.
- */
-
-/*
- * __isinf_nsf(x) returns != 0 if x is ±inf, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-
-#undef __isinf_nsf
-int
-__isinf_nsf (float x)
-{
- int32_t ix;
- GET_FLOAT_WORD(ix,x);
- return (ix & 0x7fffffff) == 0x7f800000;
-}
diff --git a/sysdeps/ieee754/flt-32/s_issignalingf.c b/sysdeps/ieee754/flt-32/s_issignalingf.c
index 093630c12e..2409ff408c 100644
--- a/sysdeps/ieee754/flt-32/s_issignalingf.c
+++ b/sysdeps/ieee754/flt-32/s_issignalingf.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/flt-32/s_llrintf.c b/sysdeps/ieee754/flt-32/s_llrintf.c
index ac8c1a2216..56415d34f8 100644
--- a/sysdeps/ieee754/flt-32/s_llrintf.c
+++ b/sysdeps/ieee754/flt-32/s_llrintf.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,9 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const float two23[2] =
{
@@ -34,7 +37,7 @@ __llrintf (float x)
{
int32_t j0;
u_int32_t i0;
- volatile float w;
+ float w;
float t;
long long int result;
int sx;
@@ -52,7 +55,7 @@ __llrintf (float x)
result = (long long int) i0 << (j0 - 23);
else
{
- w = two23[sx] + x;
+ w = math_narrow_eval (two23[sx] + x);
t = w - two23[sx];
GET_FLOAT_WORD (i0, t);
j0 = ((i0 >> 23) & 0xff) - 0x7f;
@@ -64,8 +67,16 @@ __llrintf (float x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_FLT_LLONG_CONVERT_OVERFLOW && x != (float) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LLONG_MAX : LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/flt-32/s_llroundf.c b/sysdeps/ieee754/flt-32/s_llroundf.c
index f695c63710..1d35f71321 100644
--- a/sysdeps/ieee754/flt-32/s_llroundf.c
+++ b/sysdeps/ieee754/flt-32/s_llroundf.c
@@ -1,5 +1,5 @@
/* Round float value to long long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,9 +17,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
long long int
@@ -51,8 +54,16 @@ __llroundf (float x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_FLT_LLONG_CONVERT_OVERFLOW && x != (float) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LLONG_MAX : LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/flt-32/s_log1pf.c b/sysdeps/ieee754/flt-32/s_log1pf.c
index 83a09f1414..ade60a2e27 100644
--- a/sysdeps/ieee754/flt-32/s_log1pf.c
+++ b/sysdeps/ieee754/flt-32/s_log1pf.c
@@ -50,11 +50,7 @@ __log1pf(float x)
math_force_eval(two25+x); /* raise inexact */
if (ax<0x24800000) /* |x| < 2**-54 */
{
- if (fabsf (x) < FLT_MIN)
- {
- float force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
else
diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c
index ba0267ebcb..9ae20e332a 100644
--- a/sysdeps/ieee754/flt-32/s_logbf.c
+++ b/sysdeps/ieee754/flt-32/s_logbf.c
@@ -15,6 +15,7 @@
#include <math.h>
#include <math_private.h>
+#include <fix-int-fp-convert-zero.h>
float
__logbf (float x)
@@ -33,6 +34,8 @@ __logbf (float x)
though it were normalized. */
rix -= __builtin_clz (ix) - 9;
}
+ if (FIX_INT_FP_CONVERT_ZERO && rix == 127)
+ return 0.0f;
return (float) (rix - 127);
}
weak_alias (__logbf, logbf)
diff --git a/sysdeps/ieee754/flt-32/s_lrintf.c b/sysdeps/ieee754/flt-32/s_lrintf.c
index 7581a8d286..3b480a2107 100644
--- a/sysdeps/ieee754/flt-32/s_lrintf.c
+++ b/sysdeps/ieee754/flt-32/s_lrintf.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,9 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const float two23[2] =
{
@@ -34,7 +37,7 @@ __lrintf (float x)
{
int32_t j0;
u_int32_t i0;
- volatile float w;
+ float w;
float t;
long int result;
int sx;
@@ -52,7 +55,7 @@ __lrintf (float x)
result = (long int) i0 << (j0 - 23);
else
{
- w = two23[sx] + x;
+ w = math_narrow_eval (two23[sx] + x);
t = w - two23[sx];
GET_FLOAT_WORD (i0, t);
j0 = ((i0 >> 23) & 0xff) - 0x7f;
@@ -64,8 +67,16 @@ __lrintf (float x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_FLT_LONG_CONVERT_OVERFLOW && x != (float) LONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LONG_MAX : LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/flt-32/s_lroundf.c b/sysdeps/ieee754/flt-32/s_lroundf.c
index f20352a3c8..116c9e0627 100644
--- a/sysdeps/ieee754/flt-32/s_lroundf.c
+++ b/sysdeps/ieee754/flt-32/s_lroundf.c
@@ -1,5 +1,5 @@
/* Round float value to long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,9 +17,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
long int
@@ -51,8 +54,16 @@ __lroundf (float x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+#ifdef FE_INVALID
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+ if (FIX_FLT_LONG_CONVERT_OVERFLOW && x != (float) LONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LONG_MAX : LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/flt-32/s_nextafterf.c b/sysdeps/ieee754/flt-32/s_nextafterf.c
index 22e0b3d4ed..625d54b768 100644
--- a/sysdeps/ieee754/flt-32/s_nextafterf.c
+++ b/sysdeps/ieee754/flt-32/s_nextafterf.c
@@ -17,6 +17,7 @@
static char rcsid[] = "$NetBSD: s_nextafterf.c,v 1.4 1995/05/10 20:48:01 jtc Exp $";
#endif
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <float.h>
@@ -59,10 +60,12 @@ float __nextafterf(float x, float y)
if(hy>=0x7f800000) {
float u = x+x; /* overflow */
math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00800000) {
float u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_FLOAT_WORD(x,hx);
return x;
diff --git a/sysdeps/ieee754/flt-32/s_remquof.c b/sysdeps/ieee754/flt-32/s_remquof.c
index 36cf359b9d..ecf831deaf 100644
--- a/sysdeps/ieee754/flt-32/s_remquof.c
+++ b/sysdeps/ieee754/flt-32/s_remquof.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/s_roundf.c b/sysdeps/ieee754/flt-32/s_roundf.c
index 2c2a9e198d..a75d98f384 100644
--- a/sysdeps/ieee754/flt-32/s_roundf.c
+++ b/sysdeps/ieee754/flt-32/s_roundf.c
@@ -1,5 +1,5 @@
/* Round float to integer away from zero.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/s_scalbnf.c b/sysdeps/ieee754/flt-32/s_scalbnf.c
index 5d9bdd647b..f36ae241b2 100644
--- a/sysdeps/ieee754/flt-32/s_scalbnf.c
+++ b/sysdeps/ieee754/flt-32/s_scalbnf.c
@@ -50,4 +50,3 @@ __scalbnf (float x, int n)
SET_FLOAT_WORD(x,(ix&0x807fffff)|(k<<23));
return x*twom25;
}
-weak_alias (__scalbnf, scalbnf)
diff --git a/sysdeps/ieee754/flt-32/s_signbitf.c b/sysdeps/ieee754/flt-32/s_signbitf.c
index 169820e9df..3cdde778d5 100644
--- a/sysdeps/ieee754/flt-32/s_signbitf.c
+++ b/sysdeps/ieee754/flt-32/s_signbitf.c
@@ -1,5 +1,5 @@
/* Return nonzero value if number is negative.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -19,13 +19,8 @@
#include <math.h>
-#include <math_private.h>
-
int
__signbitf (float x)
{
- int32_t hx;
-
- GET_FLOAT_WORD (hx, x);
- return hx & 0x80000000;
+ return __builtin_signbitf (x);
}
diff --git a/sysdeps/ieee754/flt-32/s_sincosf.c b/sysdeps/ieee754/flt-32/s_sincosf.c
index 596e076609..e0737b5ce4 100644
--- a/sysdeps/ieee754/flt-32/s_sincosf.c
+++ b/sysdeps/ieee754/flt-32/s_sincosf.c
@@ -1,5 +1,5 @@
/* Compute sine and cosine of argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/s_tanhf.c b/sysdeps/ieee754/flt-32/s_tanhf.c
index dc96da9a5b..f70702b29c 100644
--- a/sysdeps/ieee754/flt-32/s_tanhf.c
+++ b/sysdeps/ieee754/flt-32/s_tanhf.c
@@ -17,6 +17,7 @@
static char rcsid[] = "$NetBSD: s_tanhf.c,v 1.4 1995/05/10 20:48:24 jtc Exp $";
#endif
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -41,7 +42,10 @@ float __tanhf(float x)
if (ix == 0)
return x; /* x == +-0 */
if (ix<0x24000000) /* |x|<2**-55 */
+ {
+ math_check_force_underflow (x);
return x*(one+x); /* tanh(small) = small */
+ }
if (ix>=0x3f800000) { /* |x|>=1 */
t = __expm1f(two*fabsf(x));
z = one - two/(t+two);
diff --git a/sysdeps/ieee754/flt-32/s_truncf.c b/sysdeps/ieee754/flt-32/s_truncf.c
index 1c4f9c94ed..43d35c7f6a 100644
--- a/sysdeps/ieee754/flt-32/s_truncf.c
+++ b/sysdeps/ieee754/flt-32/s_truncf.c
@@ -1,5 +1,5 @@
/* Truncate argument to nearest integral value not larger than the argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/flt-32/t_exp2f.h b/sysdeps/ieee754/flt-32/t_exp2f.h
index db528038f1..3045b82cd1 100644
--- a/sysdeps/ieee754/flt-32/t_exp2f.h
+++ b/sysdeps/ieee754/flt-32/t_exp2f.h
@@ -1,5 +1,5 @@
/* Accurate tables for exp2f().
- Copyright (C) 1998-2015 Free Software Foundation, Inc.
+ Copyright (C) 1998-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Geoffrey Keating <geoffk@ozemail.com.au>
diff --git a/sysdeps/ieee754/flt-32/w_expf.c b/sysdeps/ieee754/flt-32/w_expf.c
index cc5ff76421..ed1550972f 100644
--- a/sysdeps/ieee754/flt-32/w_expf.c
+++ b/sysdeps/ieee754/flt-32/w_expf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
diff --git a/sysdeps/ieee754/ieee754.h b/sysdeps/ieee754/ieee754.h
index b82f92aed9..e7a5e93610 100644
--- a/sysdeps/ieee754/ieee754.h
+++ b/sysdeps/ieee754/ieee754.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/k_standardf.c b/sysdeps/ieee754/k_standardf.c
index 336ab485b5..2b9c1bddb5 100644
--- a/sysdeps/ieee754/k_standardf.c
+++ b/sysdeps/ieee754/k_standardf.c
@@ -1,5 +1,5 @@
/* Implement __kernel_standard_f.
- Copyright (C) 2011-2015 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/k_standardl.c b/sysdeps/ieee754/k_standardl.c
index aa95748825..d2d6f7466e 100644
--- a/sysdeps/ieee754/k_standardl.c
+++ b/sysdeps/ieee754/k_standardl.c
@@ -1,5 +1,5 @@
/* Implement __kernel_standard_l.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/e_asinl.c b/sysdeps/ieee754/ldbl-128/e_asinl.c
index 691ac267fb..5a0e473ef0 100644
--- a/sysdeps/ieee754/ldbl-128/e_asinl.c
+++ b/sysdeps/ieee754/ldbl-128/e_asinl.c
@@ -153,11 +153,7 @@ __ieee754_asinl (long double x)
{
if (ix < 0x3fc60000) /* |x| < 2**-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
long double force_inexact = huge + x;
math_force_eval (force_inexact);
return x; /* return x with inexact if x!=0 */
diff --git a/sysdeps/ieee754/ldbl-128/e_atanhl.c b/sysdeps/ieee754/ldbl-128/e_atanhl.c
index a5a7ee0712..7fa53ef436 100644
--- a/sysdeps/ieee754/ldbl-128/e_atanhl.c
+++ b/sysdeps/ieee754/ldbl-128/e_atanhl.c
@@ -60,11 +60,7 @@ __ieee754_atanhl(long double x)
}
if(ix<0x3fc60000 && (huge+x)>zero) /* x < 2^-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
diff --git a/sysdeps/ieee754/ldbl-128/e_exp10l.c b/sysdeps/ieee754/ldbl-128/e_exp10l.c
index c5b5cb7505..987002567a 100644
--- a/sysdeps/ieee754/ldbl-128/e_exp10l.c
+++ b/sysdeps/ieee754/ldbl-128/e_exp10l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/e_expl.c b/sysdeps/ieee754/ldbl-128/e_expl.c
index 1cd095cb77..7b71e644be 100644
--- a/sysdeps/ieee754/ldbl-128/e_expl.c
+++ b/sysdeps/ieee754/ldbl-128/e_expl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point e^x.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
Partly based on double-precision code
@@ -232,11 +232,7 @@ __ieee754_expl (long double x)
else
{
result *= scale_u.d;
- if (result < LDBL_MIN)
- {
- long double force_underflow = result * result;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow_nonneg (result);
return result;
}
}
diff --git a/sysdeps/ieee754/ldbl-128/e_gammal_r.c b/sysdeps/ieee754/ldbl-128/e_gammal_r.c
index c51b050e0e..d0286e31eb 100644
--- a/sysdeps/ieee754/ldbl-128/e_gammal_r.c
+++ b/sysdeps/ieee754/ldbl-128/e_gammal_r.c
@@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz, 1999.
@@ -194,6 +194,7 @@ __ieee754_gammal_r (long double x, int *signgamp)
ret = M_PIl / (-x * sinpix
* gammal_positive (-x, &exp2_adj));
ret = __scalbnl (ret, -exp2_adj);
+ math_check_force_underflow_nonneg (ret);
}
}
}
diff --git a/sysdeps/ieee754/ldbl-128/e_hypotl.c b/sysdeps/ieee754/ldbl-128/e_hypotl.c
index 01444cfb4e..80e5e38c72 100644
--- a/sysdeps/ieee754/ldbl-128/e_hypotl.c
+++ b/sysdeps/ieee754/ldbl-128/e_hypotl.c
@@ -130,7 +130,9 @@ __ieee754_hypotl(long double x, long double y)
t1 = 1.0L;
GET_LDOUBLE_MSW64(high,t1);
SET_LDOUBLE_MSW64(t1,high+(k<<48));
- return t1*w;
+ w *= t1;
+ math_check_force_underflow_nonneg (w);
+ return w;
} else return w;
}
strong_alias (__ieee754_hypotl, __hypotl_finite)
diff --git a/sysdeps/ieee754/ldbl-128/e_j0l.c b/sysdeps/ieee754/ldbl-128/e_j0l.c
index 1320de7044..c208916a79 100644
--- a/sysdeps/ieee754/ldbl-128/e_j0l.c
+++ b/sysdeps/ieee754/ldbl-128/e_j0l.c
@@ -693,6 +693,8 @@ __ieee754_j0l (long double x)
xx = fabsl (x);
if (xx <= 2.0L)
{
+ if (xx < 0x1p-57L)
+ return 1.0L;
/* 0 <= x <= 2 */
z = xx * xx;
p = z * z * neval (z, J0_2N, NJ0_2N) / deval (z, J0_2D, NJ0_2D);
diff --git a/sysdeps/ieee754/ldbl-128/e_j1l.c b/sysdeps/ieee754/ldbl-128/e_j1l.c
index 591c38efd0..f5b04c073d 100644
--- a/sysdeps/ieee754/ldbl-128/e_j1l.c
+++ b/sysdeps/ieee754/ldbl-128/e_j1l.c
@@ -700,11 +700,9 @@ __ieee754_j1l (long double x)
if (xx <= 0x1p-58L)
{
long double ret = x * 0.5L;
- if (fabsl (ret) < LDBL_MIN)
- {
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
+ if (ret == 0)
+ __set_errno (ERANGE);
return ret;
}
if (xx <= 2.0L)
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index a419994a86..98669e6e3e 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -296,12 +296,12 @@ __ieee754_jnl (int n, long double x)
ret = b;
}
if (ret == 0)
- ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
- else if (fabsl (ret) < LDBL_MIN)
{
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
+ ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
+ __set_errno (ERANGE);
}
+ else
+ math_check_force_underflow (ret);
return ret;
}
strong_alias (__ieee754_jnl, __jnl_finite)
diff --git a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
index d8a5e5b9ec..5b513ea1df 100644
--- a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
+++ b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c
@@ -70,19 +70,15 @@
#include <math.h>
#include <math_private.h>
-#include <libc-internal.h>
#include <float.h>
-/* BZ#16347: ldbl-128ibm uses this file as is, however the MAXLGM
- definition overflows for IBM long double. This directive prevents the
- overflow warnings until IBM long double version is fixed. */
static const long double PIL = 3.1415926535897932384626433832795028841972E0L;
-DIAG_PUSH_NEEDS_COMMENT;
-DIAG_IGNORE_NEEDS_COMMENT (4.6, "-Woverflow");
+#if LDBL_MANT_DIG == 106
+static const long double MAXLGM = 0x5.d53649e2d469dbc1f01e99fd66p+1012L;
+#else
static const long double MAXLGM = 1.0485738685148938358098967157129705071571E4928L;
-DIAG_POP_NEEDS_COMMENT;
+#endif
static const long double one = 1.0L;
-static const long double zero = 0.0L;
static const long double huge = LDBL_MAX;
/* log gamma(x) = ( x - 0.5 ) * log(x) - x + LS2PI + 1/x P(1/x^2)
@@ -781,12 +777,14 @@ __ieee754_lgammal_r (long double x, int *signgamp)
if (x < 0.0L)
{
+ if (x < -2.0L && x > (LDBL_MANT_DIG == 106 ? -48.0L : -50.0L))
+ return __lgamma_negl (x, signgamp);
q = -x;
p = __floorl (q);
if (p == q)
return (one / (p - p));
- i = p;
- if ((i & 1) == 0)
+ long double halfp = p * 0.5L;
+ if (halfp == __floorl (halfp))
*signgamp = -1;
else
*signgamp = 1;
@@ -1034,6 +1032,8 @@ __ieee754_lgammal_r (long double x, int *signgamp)
if (x > MAXLGM)
return (*signgamp * huge * huge);
+ if (x > 0x1p120L)
+ return x * (__logl (x) - 1.0L);
q = ls2pi - x;
q = (x - 0.5L) * __logl (x) + q;
if (x > 1.0e18L)
diff --git a/sysdeps/ieee754/ldbl-128/e_log2l.c b/sysdeps/ieee754/ldbl-128/e_log2l.c
index 991a3b73e2..6b1faa0523 100644
--- a/sysdeps/ieee754/ldbl-128/e_log2l.c
+++ b/sysdeps/ieee754/ldbl-128/e_log2l.c
@@ -171,8 +171,7 @@ deval (long double x, const long double *p, int n)
long double
-__ieee754_log2l (x)
- long double x;
+__ieee754_log2l (long double x)
{
long double z;
long double y;
diff --git a/sysdeps/ieee754/ldbl-128/e_powl.c b/sysdeps/ieee754/ldbl-128/e_powl.c
index f531385232..7f3037fb51 100644
--- a/sysdeps/ieee754/ldbl-128/e_powl.c
+++ b/sysdeps/ieee754/ldbl-128/e_powl.c
@@ -435,7 +435,11 @@ __ieee754_powl (long double x, long double y)
j = o.parts32.w0;
j += (n << 16);
if ((j >> 16) <= 0)
- z = __scalbnl (z, n); /* subnormal output */
+ {
+ z = __scalbnl (z, n); /* subnormal output */
+ long double force_underflow = z * z;
+ math_force_eval (force_underflow);
+ }
else
{
o.parts32.w0 = j;
diff --git a/sysdeps/ieee754/ldbl-128/e_rem_pio2l.c b/sysdeps/ieee754/ldbl-128/e_rem_pio2l.c
index 2b60263119..101a4c9015 100644
--- a/sysdeps/ieee754/ldbl-128/e_rem_pio2l.c
+++ b/sysdeps/ieee754/ldbl-128/e_rem_pio2l.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point argument reduction.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128/e_sinhl.c b/sysdeps/ieee754/ldbl-128/e_sinhl.c
index 1ca3c6e507..11974a39af 100644
--- a/sysdeps/ieee754/ldbl-128/e_sinhl.c
+++ b/sysdeps/ieee754/ldbl-128/e_sinhl.c
@@ -53,6 +53,7 @@
* only sinhl(0)=0 is exact for finite x.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -86,8 +87,11 @@ __ieee754_sinhl (long double x)
if (ix <= 0x40044000)
{
if (ix < 0x3fc60000) /* |x| < 2^-57 */
- if (shuge + x > one)
- return x; /* sinh(tiny) = tiny with inexact */
+ {
+ math_check_force_underflow (x);
+ if (shuge + x > one)
+ return x; /* sinh(tiny) = tiny with inexact */
+ }
t = __expm1l (u.value);
if (ix < 0x3fff0000)
return h * (2.0 * t - t * t / (t + one));
diff --git a/sysdeps/ieee754/ldbl-128/gamma_productl.c b/sysdeps/ieee754/ldbl-128/gamma_productl.c
index 32990b8f1c..849b57d95d 100644
--- a/sysdeps/ieee754/ldbl-128/gamma_productl.c
+++ b/sysdeps/ieee754/ldbl-128/gamma_productl.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/ieee754.h b/sysdeps/ieee754/ldbl-128/ieee754.h
index d8d7aa69a2..fb42140933 100644
--- a/sysdeps/ieee754/ldbl-128/ieee754.h
+++ b/sysdeps/ieee754/ldbl-128/ieee754.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/k_cosl.c b/sysdeps/ieee754/ldbl-128/k_cosl.c
index f2743ddf5f..3985b1225b 100644
--- a/sysdeps/ieee754/ldbl-128/k_cosl.c
+++ b/sysdeps/ieee754/ldbl-128/k_cosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point cosine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128/k_sincosl.c b/sysdeps/ieee754/ldbl-128/k_sincosl.c
index 7b5c4b0e81..404df352d3 100644
--- a/sysdeps/ieee754/ldbl-128/k_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128/k_sincosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine and cosine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
@@ -111,11 +111,7 @@ __kernel_sincosl(long double x, long double y, long double *sinx, long double *c
polynomial of degree 16(17). */
if (tix < 0x3fc60000) /* |x| < 2^-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (!((int)x)) /* generate inexact */
{
*sinx = x;
diff --git a/sysdeps/ieee754/ldbl-128/k_sinl.c b/sysdeps/ieee754/ldbl-128/k_sinl.c
index 04d539ff1a..6290b173b4 100644
--- a/sysdeps/ieee754/ldbl-128/k_sinl.c
+++ b/sysdeps/ieee754/ldbl-128/k_sinl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
@@ -92,11 +92,7 @@ __kernel_sinl(long double x, long double y, int iy)
polynomial of degree 17. */
if (tix < 0x3fc60000) /* |x| < 2^-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (!((int)x)) return x; /* generate inexact */
}
z = x * x;
diff --git a/sysdeps/ieee754/ldbl-128/k_tanl.c b/sysdeps/ieee754/ldbl-128/k_tanl.c
index dfba2d9a76..6bb221e4a6 100644
--- a/sysdeps/ieee754/ldbl-128/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-128/k_tanl.c
@@ -56,6 +56,7 @@
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
+#include <float.h>
#include <libc-internal.h>
#include <math.h>
#include <math_private.h>
@@ -98,8 +99,13 @@ __kernel_tanl (long double x, long double y, int iy)
if ((ix | u.parts32.w1 | u.parts32.w2 | u.parts32.w3
| (iy + 1)) == 0)
return one / fabs (x);
+ else if (iy == 1)
+ {
+ math_check_force_underflow (x);
+ return x;
+ }
else
- return (iy == 1) ? x : -one / x;
+ return -one / x;
}
}
if (ix >= 0x3ffe5942) /* |x| >= 0.6743316650390625 */
@@ -135,11 +141,7 @@ __kernel_tanl (long double x, long double y, int iy)
uninitialized although in the cases where it is used it has
always been set. */
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (4, 7)
DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
-#else
- DIAG_IGNORE_NEEDS_COMMENT (5, "-Wuninitialized");
-#endif
if (sign < 0)
w = -w;
DIAG_POP_NEEDS_COMMENT;
diff --git a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
index 08953af819..e3f97623ed 100644
--- a/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
+++ b/sysdeps/ieee754/ldbl-128/ldbl2mpn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/lgamma_negl.c b/sysdeps/ieee754/ldbl-128/lgamma_negl.c
new file mode 100644
index 0000000000..df46199b82
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/lgamma_negl.c
@@ -0,0 +1,551 @@
+/* lgammal expanding around zeros.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <math_private.h>
+
+static const long double lgamma_zeros[][2] =
+ {
+ { -0x2.74ff92c01f0d82abec9f315f1a08p+0L, 0xe.d3ccb7fb2658634a2b9f6b2ba81p-116L },
+ { -0x2.bf6821437b20197995a4b4641eaep+0L, -0xb.f4b00b4829f961e428533e6ad048p-116L },
+ { -0x3.24c1b793cb35efb8be699ad3d9bap+0L, -0x6.5454cb7fac60e3f16d9d7840c2ep-116L },
+ { -0x3.f48e2a8f85fca170d4561291236cp+0L, -0xc.320a4887d1cb4c711828a75d5758p-116L },
+ { -0x4.0a139e16656030c39f0b0de18114p+0L, 0x1.53e84029416e1242006b2b3d1cfp-112L },
+ { -0x4.fdd5de9bbabf3510d0aa40769884p+0L, -0x1.01d7d78125286f78d1e501f14966p-112L },
+ { -0x5.021a95fc2db6432a4c56e595394cp+0L, -0x1.ecc6af0430d4fe5746fa7233356fp-112L },
+ { -0x5.ffa4bd647d0357dd4ed62cbd31ecp+0L, -0x1.f8e3f8e5deba2d67dbd70dd96ce1p-112L },
+ { -0x6.005ac9625f233b607c2d96d16384p+0L, -0x1.cb86ac569340cf1e5f24df7aab7bp-112L },
+ { -0x6.fff2fddae1bbff3d626b65c23fd4p+0L, 0x1.e0bfcff5c457ebcf4d3ad9674167p-112L },
+ { -0x7.000cff7b7f87adf4482dcdb98784p+0L, 0x1.54d99e35a74d6407b80292df199fp-112L },
+ { -0x7.fffe5fe05673c3ca9e82b522b0ccp+0L, 0x1.62d177c832e0eb42c2faffd1b145p-112L },
+ { -0x8.0001a01459fc9f60cb3cec1cec88p+0L, 0x2.8998835ac7277f7bcef67c47f188p-112L },
+ { -0x8.ffffd1c425e80ffc864e95749258p+0L, -0x1.e7e20210e7f81cf781b44e9d2b02p-112L },
+ { -0x9.00002e3bb47d86d6d843fedc352p+0L, 0x2.14852f613a16291751d2ab751f7ep-112L },
+ { -0x9.fffffb606bdfdcd062ae77a50548p+0L, 0x3.962d1490cc2e8f031c7007eaa1ap-116L },
+ { -0xa.0000049f93bb9927b45d95e1544p+0L, -0x1.e03086db9146a9287bd4f2172d5ap-112L },
+ { -0xa.ffffff9466e9f1b36dacd2adbd18p+0L, -0xd.05a4e458062f3f95345a4d9c9b6p-116L },
+ { -0xb.0000006b9915315d965a6ffea41p+0L, 0x1.b415c6fff233e7b7fdc3a094246fp-112L },
+ { -0xb.fffffff7089387387de41acc3d4p+0L, 0x3.687427c6373bd74a10306e10a28ep-112L },
+ { -0xc.00000008f76c7731567c0f0250fp+0L, -0x3.87920df5675833859190eb128ef6p-112L },
+ { -0xc.ffffffff4f6dcf617f97a5ffc758p+0L, 0x2.ab72d76f32eaee2d1a42ed515d3ap-116L },
+ { -0xd.00000000b092309c06683dd1b9p+0L, -0x3.e3700857a15c19ac5a611de9688ap-112L },
+ { -0xd.fffffffff36345ab9e184a3e09dp+0L, -0x1.176dc48e47f62d917973dd44e553p-112L },
+ { -0xe.000000000c9cba545e94e75ec57p+0L, -0x1.8f753e2501e757a17cf2ecbeeb89p-112L },
+ { -0xe.ffffffffff28c060c6604ef3037p+0L, -0x1.f89d37357c9e3dc17c6c6e63becap-112L },
+ { -0xf.0000000000d73f9f399bd0e420f8p+0L, -0x5.e9ee31b0b890744fc0e3fbc01048p-116L },
+ { -0xf.fffffffffff28c060c6621f512e8p+0L, 0xd.1b2eec9d960bd9adc5be5f5fa5p-116L },
+ { -0x1.000000000000d73f9f399da1424cp+4L, 0x6.c46e0e88305d2800f0e414c506a8p-116L },
+ { -0x1.0ffffffffffff3569c47e7a93e1cp+4L, -0x4.6a08a2e008a998ebabb8087efa2cp-112L },
+ { -0x1.1000000000000ca963b818568887p+4L, -0x6.ca5a3a64ec15db0a95caf2c9ffb4p-112L },
+ { -0x1.1fffffffffffff4bec3ce234132dp+4L, -0x8.b2b726187c841cb92cd5221e444p-116L },
+ { -0x1.20000000000000b413c31dcbeca5p+4L, 0x3.c4d005344b6cd0e7231120294abcp-112L },
+ { -0x1.2ffffffffffffff685b25cbf5f54p+4L, -0x5.ced932e38485f7dd296b8fa41448p-112L },
+ { -0x1.30000000000000097a4da340a0acp+4L, 0x7.e484e0e0ffe38d406ebebe112f88p-112L },
+ { -0x1.3fffffffffffffff86af516ff7f7p+4L, -0x6.bd67e720d57854502b7db75e1718p-112L },
+ { -0x1.40000000000000007950ae900809p+4L, 0x6.bec33375cac025d9c073168c5d9p-112L },
+ { -0x1.4ffffffffffffffffa391c4248c3p+4L, 0x5.c63022b62b5484ba346524db607p-112L },
+ { -0x1.500000000000000005c6e3bdb73dp+4L, -0x5.c62f55ed5322b2685c5e9a51e6a8p-112L },
+ { -0x1.5fffffffffffffffffbcc71a492p+4L, -0x1.eb5aeb96c74d7ad25e060528fb5p-112L },
+ { -0x1.6000000000000000004338e5b6ep+4L, 0x1.eb5aec04b2f2eb663e4e3d8a018cp-112L },
+ { -0x1.6ffffffffffffffffffd13c97d9dp+4L, -0x3.8fcc4d08d6fe5aa56ab04307ce7ep-112L },
+ { -0x1.70000000000000000002ec368263p+4L, 0x3.8fcc4d090cee2f5d0b69a99c353cp-112L },
+ { -0x1.7fffffffffffffffffffe0d30fe7p+4L, 0x7.2f577cca4b4c8cb1dc14001ac5ecp-112L },
+ { -0x1.800000000000000000001f2cf019p+4L, -0x7.2f577cca4b3442e35f0040b3b9e8p-112L },
+ { -0x1.8ffffffffffffffffffffec0c332p+4L, -0x2.e9a0572b1bb5b95f346a92d67a6p-112L },
+ { -0x1.90000000000000000000013f3ccep+4L, 0x2.e9a0572b1bb5c371ddb3561705ap-112L },
+ { -0x1.9ffffffffffffffffffffff3b8bdp+4L, -0x1.cad8d32e386fd783e97296d63dcbp-116L },
+ { -0x1.a0000000000000000000000c4743p+4L, 0x1.cad8d32e386fd7c1ab8c1fe34c0ep-116L },
+ { -0x1.afffffffffffffffffffffff8b95p+4L, -0x3.8f48cc5737d5979c39db806c5406p-112L },
+ { -0x1.b00000000000000000000000746bp+4L, 0x3.8f48cc5737d5979c3b3a6bda06f6p-112L },
+ { -0x1.bffffffffffffffffffffffffbd8p+4L, 0x6.2898d42174dcf171470d8c8c6028p-112L },
+ { -0x1.c000000000000000000000000428p+4L, -0x6.2898d42174dcf171470d18ba412cp-112L },
+ { -0x1.cfffffffffffffffffffffffffdbp+4L, -0x4.c0ce9794ea50a839e311320bde94p-112L },
+ { -0x1.d000000000000000000000000025p+4L, 0x4.c0ce9794ea50a839e311322f7cf8p-112L },
+ { -0x1.dfffffffffffffffffffffffffffp+4L, 0x3.932c5047d60e60caded4c298a174p-112L },
+ { -0x1.e000000000000000000000000001p+4L, -0x3.932c5047d60e60caded4c298973ap-112L },
+ { -0x1.fp+4L, 0xa.1a6973c1fade2170f7237d35fe3p-116L },
+ { -0x1.fp+4L, -0xa.1a6973c1fade2170f7237d35fe08p-116L },
+ { -0x2p+4L, 0x5.0d34b9e0fd6f10b87b91be9aff1p-120L },
+ { -0x2p+4L, -0x5.0d34b9e0fd6f10b87b91be9aff0cp-120L },
+ { -0x2.1p+4L, 0x2.73024a9ba1aa36a7059bff52e844p-124L },
+ { -0x2.1p+4L, -0x2.73024a9ba1aa36a7059bff52e844p-124L },
+ { -0x2.2p+4L, 0x1.2710231c0fd7a13f8a2b4af9d6b7p-128L },
+ { -0x2.2p+4L, -0x1.2710231c0fd7a13f8a2b4af9d6b7p-128L },
+ { -0x2.3p+4L, 0x8.6e2ce38b6c8f9419e3fad3f0312p-136L },
+ { -0x2.3p+4L, -0x8.6e2ce38b6c8f9419e3fad3f0312p-136L },
+ { -0x2.4p+4L, 0x3.bf30652185952560d71a254e4eb8p-140L },
+ { -0x2.4p+4L, -0x3.bf30652185952560d71a254e4eb8p-140L },
+ { -0x2.5p+4L, 0x1.9ec8d1c94e85af4c78b15c3d89d3p-144L },
+ { -0x2.5p+4L, -0x1.9ec8d1c94e85af4c78b15c3d89d3p-144L },
+ { -0x2.6p+4L, 0xa.ea565ce061d57489e9b85276274p-152L },
+ { -0x2.6p+4L, -0xa.ea565ce061d57489e9b85276274p-152L },
+ { -0x2.7p+4L, 0x4.7a6512692eb37804111dabad30ecp-156L },
+ { -0x2.7p+4L, -0x4.7a6512692eb37804111dabad30ecp-156L },
+ { -0x2.8p+4L, 0x1.ca8ed42a12ae3001a07244abad2bp-160L },
+ { -0x2.8p+4L, -0x1.ca8ed42a12ae3001a07244abad2bp-160L },
+ { -0x2.9p+4L, 0xb.2f30e1ce812063f12e7e8d8d96e8p-168L },
+ { -0x2.9p+4L, -0xb.2f30e1ce812063f12e7e8d8d96e8p-168L },
+ { -0x2.ap+4L, 0x4.42bd49d4c37a0db136489772e428p-172L },
+ { -0x2.ap+4L, -0x4.42bd49d4c37a0db136489772e428p-172L },
+ { -0x2.bp+4L, 0x1.95db45257e5122dcbae56def372p-176L },
+ { -0x2.bp+4L, -0x1.95db45257e5122dcbae56def372p-176L },
+ { -0x2.cp+4L, 0x9.3958d81ff63527ecf993f3fb6f48p-184L },
+ { -0x2.cp+4L, -0x9.3958d81ff63527ecf993f3fb6f48p-184L },
+ { -0x2.dp+4L, 0x3.47970e4440c8f1c058bd238c9958p-188L },
+ { -0x2.dp+4L, -0x3.47970e4440c8f1c058bd238c9958p-188L },
+ { -0x2.ep+4L, 0x1.240804f65951062ca46e4f25c608p-192L },
+ { -0x2.ep+4L, -0x1.240804f65951062ca46e4f25c608p-192L },
+ { -0x2.fp+4L, 0x6.36a382849fae6de2d15362d8a394p-200L },
+ { -0x2.fp+4L, -0x6.36a382849fae6de2d15362d8a394p-200L },
+ { -0x3p+4L, 0x2.123680d6dfe4cf4b9b1bcb9d8bdcp-204L },
+ { -0x3p+4L, -0x2.123680d6dfe4cf4b9b1bcb9d8bdcp-204L },
+ { -0x3.1p+4L, 0xa.d21786ff5842eca51fea0870919p-212L },
+ { -0x3.1p+4L, -0xa.d21786ff5842eca51fea0870919p-212L },
+ { -0x3.2p+4L, 0x3.766dedc259af040be140a68a6c04p-216L },
+ };
+
+static const long double e_hi = 0x2.b7e151628aed2a6abf7158809cf4p+0L;
+static const long double e_lo = 0xf.3c762e7160f38b4da56a784d9048p-116L;
+
+
+/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) in Stirling's
+ approximation to lgamma function. */
+
+static const long double lgamma_coeff[] =
+ {
+ 0x1.5555555555555555555555555555p-4L,
+ -0xb.60b60b60b60b60b60b60b60b60b8p-12L,
+ 0x3.4034034034034034034034034034p-12L,
+ -0x2.7027027027027027027027027028p-12L,
+ 0x3.72a3c5631fe46ae1d4e700dca8f2p-12L,
+ -0x7.daac36664f1f207daac36664f1f4p-12L,
+ 0x1.a41a41a41a41a41a41a41a41a41ap-8L,
+ -0x7.90a1b2c3d4e5f708192a3b4c5d7p-8L,
+ 0x2.dfd2c703c0cfff430edfd2c703cp-4L,
+ -0x1.6476701181f39edbdb9ce625987dp+0L,
+ 0xd.672219167002d3a7a9c886459cp+0L,
+ -0x9.cd9292e6660d55b3f712eb9e07c8p+4L,
+ 0x8.911a740da740da740da740da741p+8L,
+ -0x8.d0cc570e255bf59ff6eec24b49p+12L,
+ 0xa.8d1044d3708d1c219ee4fdc446ap+16L,
+ -0xe.8844d8a169abbc406169abbc406p+20L,
+ 0x1.6d29a0f6433b79890cede62433b8p+28L,
+ -0x2.88a233b3c8cddaba9809357125d8p+32L,
+ 0x5.0dde6f27500939a85c40939a85c4p+36L,
+ -0xb.4005bde03d4642a243581714af68p+40L,
+ 0x1.bc8cd6f8f1f755c78753cdb5d5c9p+48L,
+ -0x4.bbebb143bb94de5a0284fa7ec424p+52L,
+ 0xe.2e1337f5af0bed90b6b0a352d4fp+56L,
+ -0x2.e78250162b62405ad3e4bfe61b38p+64L,
+ 0xa.5f7eef9e71ac7c80326ab4cc8bfp+68L,
+ -0x2.83be0395e550213369924971b21ap+76L,
+ 0xa.8ebfe48da17dd999790760b0cep+80L,
+ };
+
+#define NCOEFF (sizeof (lgamma_coeff) / sizeof (lgamma_coeff[0]))
+
+/* Polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0), where n is
+ the integer end-point of the half-integer interval containing x and
+ x0 is the zero of lgamma in that half-integer interval. Each
+ polynomial is expressed in terms of x-xm, where xm is the midpoint
+ of the interval for which the polynomial applies. */
+
+static const long double poly_coeff[] =
+ {
+ /* Interval [-2.125, -2] (polynomial degree 23). */
+ -0x1.0b71c5c54d42eb6c17f30b7aa8f5p+0L,
+ -0xc.73a1dc05f34951602554c6d7506p-4L,
+ -0x1.ec841408528b51473e6c425ee5ffp-4L,
+ -0xe.37c9da26fc3c9a3c1844c8c7f1cp-4L,
+ -0x1.03cd87c519305703b021fa33f827p-4L,
+ -0xe.ae9ada65e09aa7f1c75216128f58p-4L,
+ 0x9.b11855a4864b5731cf85736015a8p-8L,
+ -0xe.f28c133e697a95c28607c9701dep-4L,
+ 0x2.6ec14a1c586a72a7cc33ee569d6ap-4L,
+ -0xf.57cab973e14464a262fc24723c38p-4L,
+ 0x4.5b0fc25f16e52997b2886bbae808p-4L,
+ -0xf.f50e59f1a9b56e76e988dac9ccf8p-4L,
+ 0x6.5f5eae15e9a93369e1d85146c6fcp-4L,
+ -0x1.0d2422daac459e33e0994325ed23p+0L,
+ 0x8.82000a0e7401fb1117a0e6606928p-4L,
+ -0x1.1f492f178a3f1b19f58a2ca68e55p+0L,
+ 0xa.cb545f949899a04c160b19389abp-4L,
+ -0x1.36165a1b155ba3db3d1b77caf498p+0L,
+ 0xd.44c5d5576f74302e5cf79e183eep-4L,
+ -0x1.51f22e0cdd33d3d481e326c02f3ep+0L,
+ 0xf.f73a349c08244ac389c007779bfp-4L,
+ -0x1.73317bf626156ba716747c4ca866p+0L,
+ 0x1.379c3c97b9bc71e1c1c4802dd657p+0L,
+ -0x1.a72a351c54f902d483052000f5dfp+0L,
+ /* Interval [-2.25, -2.125] (polynomial degree 24). */
+ -0xf.2930890d7d675a80c36afb0fd5e8p-4L,
+ -0xc.a5cfde054eab5c6770daeca577f8p-4L,
+ 0x3.9c9e0fdebb07cdf89c61d41c9238p-4L,
+ -0x1.02a5ad35605fcf4af65a6dbacb84p+0L,
+ 0x9.6e9b1185bb48be9de1918e00a2e8p-4L,
+ -0x1.4d8332f3cfbfa116fd611e9ce90dp+0L,
+ 0x1.1c0c8cb4d9f4b1d490e1a41fae4dp+0L,
+ -0x1.c9a6f5ae9130cd0299e293a42714p+0L,
+ 0x1.d7e9307fd58a2ea997f29573a112p+0L,
+ -0x2.921cb3473d96178ca2a11d2a8d46p+0L,
+ 0x2.e8d59113b6f3409ff8db226e9988p+0L,
+ -0x3.cbab931625a1ae2b26756817f264p+0L,
+ 0x4.7d9f0f05d5296d18663ca003912p+0L,
+ -0x5.ade9cba12a14ea485667b7135bbp+0L,
+ 0x6.dc983a5da74fb48e767b7fec0a3p+0L,
+ -0x8.8d9ed454ae31d9e138dd8ee0d1a8p+0L,
+ 0xa.6fa099d4e7c202e0c0fd6ed8492p+0L,
+ -0xc.ebc552a8090a0f0115e92d4ebbc8p+0L,
+ 0xf.d695e4772c0d829b53fba9ca5568p+0L,
+ -0x1.38c32ae38e5e9eb79b2a4c5570a9p+4L,
+ 0x1.8035145646cfab49306d0999a51bp+4L,
+ -0x1.d930adbb03dd342a4c2a8c4e1af6p+4L,
+ 0x2.45c2edb1b4943ddb3686cd9c6524p+4L,
+ -0x2.e818ebbfafe2f916fa21abf7756p+4L,
+ 0x3.9804ce51d0fb9a430a711fd7307p+4L,
+ /* Interval [-2.375, -2.25] (polynomial degree 25). */
+ -0xd.7d28d505d6181218a25f31d5e45p-4L,
+ -0xe.69649a3040985140cdf946829fap-4L,
+ 0xb.0d74a2827d053a8d44595012484p-4L,
+ -0x1.924b0922853617cac181afbc08ddp+0L,
+ 0x1.d49b12bccf0a568582e2d3c410f3p+0L,
+ -0x3.0898bb7d8c4093e636279c791244p+0L,
+ 0x4.207a6cac711cb53868e8a5057eep+0L,
+ -0x6.39ee63ea4fb1dcab0c9144bf3ddcp+0L,
+ 0x8.e2e2556a797b649bf3f53bd26718p+0L,
+ -0xd.0e83ac82552ef12af508589e7a8p+0L,
+ 0x1.2e4525e0ce6670563c6484a82b05p+4L,
+ -0x1.b8e350d6a8f2b222fa390a57c23dp+4L,
+ 0x2.805cd69b919087d8a80295892c2cp+4L,
+ -0x3.a42585424a1b7e64c71743ab014p+4L,
+ 0x5.4b4f409f98de49f7bfb03c05f984p+4L,
+ -0x7.b3c5827fbe934bc820d6832fb9fcp+4L,
+ 0xb.33b7b90cc96c425526e0d0866e7p+4L,
+ -0x1.04b77047ac4f59ee3775ca10df0dp+8L,
+ 0x1.7b366f5e94a34f41386eac086313p+8L,
+ -0x2.2797338429385c9849ca6355bfc2p+8L,
+ 0x3.225273cf92a27c9aac1b35511256p+8L,
+ -0x4.8f078aa48afe6cb3a4e89690f898p+8L,
+ 0x6.9f311d7b6654fc1d0b5195141d04p+8L,
+ -0x9.a0c297b6b4621619ca9bacc48ed8p+8L,
+ 0xe.ce1f06b6f90d92138232a76e4cap+8L,
+ -0x1.5b0e6806fa064daf011613e43b17p+12L,
+ /* Interval [-2.5, -2.375] (polynomial degree 27). */
+ -0xb.74ea1bcfff94b2c01afba9daa7d8p-4L,
+ -0x1.2a82bd590c37538cab143308de4dp+0L,
+ 0x1.88020f828b966fec66b8649fd6fcp+0L,
+ -0x3.32279f040eb694970e9db24863dcp+0L,
+ 0x5.57ac82517767e68a721005853864p+0L,
+ -0x9.c2aedcfe22833de43834a0a6cc4p+0L,
+ 0x1.12c132f1f5577f99e1a0ed3538e1p+4L,
+ -0x1.ea94e26628a3de3597f7bb55a948p+4L,
+ 0x3.66b4ac4fa582f58b59f96b2f7c7p+4L,
+ -0x6.0cf746a9cf4cba8c39afcc73fc84p+4L,
+ 0xa.c102ef2c20d75a342197df7fedf8p+4L,
+ -0x1.31ebff06e8f14626782df58db3b6p+8L,
+ 0x2.1fd6f0c0e710994e059b9dbdb1fep+8L,
+ -0x3.c6d76040407f447f8b5074f07706p+8L,
+ 0x6.b6d18e0d8feb4c2ef5af6a40ed18p+8L,
+ -0xb.efaf542c529f91e34217f24ae6a8p+8L,
+ 0x1.53852d873210e7070f5d9eb2296p+12L,
+ -0x2.5b977c0ddc6d540717173ac29fc8p+12L,
+ 0x4.310d452ae05100eff1e02343a724p+12L,
+ -0x7.73a5d8f20c4f986a7dd1912b2968p+12L,
+ 0xd.3f5ea2484f3fca15eab1f4d1a218p+12L,
+ -0x1.78d18aac156d1d93a2ffe7e08d3fp+16L,
+ 0x2.9df49ca75e5b567f5ea3e47106cp+16L,
+ -0x4.a7149af8961a08aa7c3233b5bb94p+16L,
+ 0x8.3db10ffa742c707c25197d989798p+16L,
+ -0xe.a26d6dd023cadd02041a049ec368p+16L,
+ 0x1.c825d90514e7c57c7fa5316f947cp+20L,
+ -0x3.34bb81e5a0952df8ca1abdc6684cp+20L,
+ /* Interval [-2.625, -2.5] (polynomial degree 28). */
+ -0x3.d10108c27ebafad533c20eac32bp-4L,
+ 0x1.cd557caff7d2b2085f41dbec5106p+0L,
+ 0x3.819b4856d399520dad9776ea2cacp+0L,
+ 0x6.8505cbad03dc34c5e42e8b12eb78p+0L,
+ 0xb.c1b2e653a9e38f82b399c94e7f08p+0L,
+ 0x1.50a53a38f148138105124df65419p+4L,
+ 0x2.57ae00cbe5232cbeeed34d89727ap+4L,
+ 0x4.2b156301b8604db85a601544bfp+4L,
+ 0x7.6989ed23ca3ca7579b3462592b5cp+4L,
+ 0xd.2dd2976557939517f831f5552cc8p+4L,
+ 0x1.76e1c3430eb860969bce40cd494p+8L,
+ 0x2.9a77bf5488742466db3a2c7c1ec6p+8L,
+ 0x4.a0d62ed7266e8eb36f725a8ebcep+8L,
+ 0x8.3a6184dd3021067df2f8b91e99c8p+8L,
+ 0xe.a0ade1538245bf55d39d7e436b1p+8L,
+ 0x1.a01359fae8617b5826dd74428e9p+12L,
+ 0x2.e3b0a32caae77251169acaca1ad4p+12L,
+ 0x5.2301257c81589f62b38fb5993ee8p+12L,
+ 0x9.21c9275db253d4e719b73b18cb9p+12L,
+ 0x1.03c104bc96141cda3f3fa4b112bcp+16L,
+ 0x1.cdc8ed65119196a08b0c78f1445p+16L,
+ 0x3.34f31d2eaacf34382cdb0073572ap+16L,
+ 0x5.b37628cadf12bf0000907d0ef294p+16L,
+ 0xa.22d8b332c0b1e6a616f425dfe5ap+16L,
+ 0x1.205b01444804c3ff922cd78b4c42p+20L,
+ 0x1.fe8f0cea9d1e0ff25be2470b4318p+20L,
+ 0x3.8872aebeb368399aee02b39340aep+20L,
+ 0x6.ebd560d351e84e26a4381f5b293cp+20L,
+ 0xc.c3644d094b0dae2fbcbf682cd428p+20L,
+ /* Interval [-2.75, -2.625] (polynomial degree 26). */
+ -0x6.b5d252a56e8a75458a27ed1c2dd4p-4L,
+ 0x1.28d60383da3ac721aed3c5794da9p+0L,
+ 0x1.db6513ada8a66ea77d87d9a8827bp+0L,
+ 0x2.e217118f9d348a27f7506a707e6ep+0L,
+ 0x4.450112c5cbf725a0fb9802396c9p+0L,
+ 0x6.4af99151eae7810a75df2a0303c4p+0L,
+ 0x9.2db598b4a97a7f69aeef32aec758p+0L,
+ 0xd.62bef9c22471f5ee47ea1b9c0b5p+0L,
+ 0x1.379f294e412bd62328326d4222f9p+4L,
+ 0x1.c5827349d8865f1e8825c37c31c6p+4L,
+ 0x2.93a7e7a75b7568cc8cbe8c016c12p+4L,
+ 0x3.bf9bb882afe57edb383d41879d3ap+4L,
+ 0x5.73c737828cee095c43a5566731c8p+4L,
+ 0x7.ee4653493a7f81e0442062b3823cp+4L,
+ 0xb.891c6b83fc8b55bd973b5d962d6p+4L,
+ 0x1.0c775d7de3bf9b246c0208e0207ep+8L,
+ 0x1.867ee43ec4bd4f4fd56abc05110ap+8L,
+ 0x2.37fe9ba6695821e9822d8c8af0a6p+8L,
+ 0x3.3a2c667e37c942f182cd3223a936p+8L,
+ 0x4.b1b500eb59f3f782c7ccec88754p+8L,
+ 0x6.d3efd3b65b3d0d8488d30b79fa4cp+8L,
+ 0x9.ee8224e65bed5ced8b75eaec609p+8L,
+ 0xe.72416e510cca77d53fc615c1f3dp+8L,
+ 0x1.4fb538b0a2dfe567a8904b7e0445p+12L,
+ 0x1.e7f56a9266cf525a5b8cf4cb76cep+12L,
+ 0x2.f0365c983f68c597ee49d099cce8p+12L,
+ 0x4.53aa229e1b9f5b5e59625265951p+12L,
+ /* Interval [-2.875, -2.75] (polynomial degree 24). */
+ -0x8.a41b1e4f36ff88dc820815607d68p-4L,
+ 0xc.da87d3b69dc0f2f9c6f368b8ca1p-4L,
+ 0x1.1474ad5c36158a7bea04fd2f98c6p+0L,
+ 0x1.761ecb90c555df6555b7dba955b6p+0L,
+ 0x1.d279bff9ae291caf6c4b4bcb3202p+0L,
+ 0x2.4e5d00559a6e2b9b5d7fe1f6689cp+0L,
+ 0x2.d57545a75cee8743ae2b17bc8d24p+0L,
+ 0x3.8514eee3aac88b89bec2307021bap+0L,
+ 0x4.5235e3b6e1891ffeb87fed9f8a24p+0L,
+ 0x5.562acdb10eef3c9a773b3e27a864p+0L,
+ 0x6.8ec8965c76efe03c26bff60b1194p+0L,
+ 0x8.15251aca144877af32658399f9b8p+0L,
+ 0x9.f08d56aba174d844138af782c0f8p+0L,
+ 0xc.3dbbeda2679e8a1346ccc3f6da88p+0L,
+ 0xf.0f5bfd5eacc26db308ffa0556fa8p+0L,
+ 0x1.28a6ccd84476fbc713d6bab49ac9p+4L,
+ 0x1.6d0a3ae2a3b1c8ff400641a3a21fp+4L,
+ 0x1.c15701b28637f87acfb6a91d33b5p+4L,
+ 0x2.28fbe0eccf472089b017651ca55ep+4L,
+ 0x2.a8a453004f6e8ffaacd1603bc3dp+4L,
+ 0x3.45ae4d9e1e7cd1a5dba0e4ec7f6cp+4L,
+ 0x4.065fbfacb7fad3e473cb577a61e8p+4L,
+ 0x4.f3d1473020927acac1944734a39p+4L,
+ 0x6.54bb091245815a36fb74e314dd18p+4L,
+ 0x7.d7f445129f7fb6c055e582d3f6ep+4L,
+ /* Interval [-3, -2.875] (polynomial degree 23). */
+ -0xa.046d667e468f3e44dcae1afcc648p-4L,
+ 0x9.70b88dcc006c214d8d996fdf5ccp-4L,
+ 0xa.a8a39421c86d3ff24931a0929fp-4L,
+ 0xd.2f4d1363f324da2b357c8b6ec94p-4L,
+ 0xd.ca9aa1a3a5c00de11bf60499a97p-4L,
+ 0xf.cf09c31eeb52a45dfa7ebe3778dp-4L,
+ 0x1.04b133a39ed8a09691205660468bp+0L,
+ 0x1.22b547a06edda944fcb12fd9b5ecp+0L,
+ 0x1.2c57fce7db86a91df09602d344b3p+0L,
+ 0x1.4aade4894708f84795212fe257eep+0L,
+ 0x1.579c8b7b67ec4afed5b28c8bf787p+0L,
+ 0x1.776820e7fc80ae5284239733078ap+0L,
+ 0x1.883ab28c7301fde4ca6b8ec26ec8p+0L,
+ 0x1.aa2ef6e1ae52eb42c9ee83b206e3p+0L,
+ 0x1.bf4ad50f0a9a9311300cf0c51ee7p+0L,
+ 0x1.e40206e0e96b1da463814dde0d09p+0L,
+ 0x1.fdcbcffef3a21b29719c2bd9feb1p+0L,
+ 0x2.25e2e8948939c4d42cf108fae4bep+0L,
+ 0x2.44ce14d2b59c1c0e6bf2cfa81018p+0L,
+ 0x2.70ee80bbd0387162be4861c43622p+0L,
+ 0x2.954b64d2c2ebf3489b949c74476p+0L,
+ 0x2.c616e133a811c1c9446105208656p+0L,
+ 0x3.05a69dfe1a9ba1079f90fcf26bd4p+0L,
+ 0x3.410d2ad16a0506de29736e6aafdap+0L,
+ };
+
+static const size_t poly_deg[] =
+ {
+ 23,
+ 24,
+ 25,
+ 27,
+ 28,
+ 26,
+ 24,
+ 23,
+ };
+
+static const size_t poly_end[] =
+ {
+ 23,
+ 48,
+ 74,
+ 102,
+ 131,
+ 158,
+ 183,
+ 207,
+ };
+
+/* Compute sin (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_sinpi (long double x)
+{
+ if (x <= 0.25L)
+ return __sinl (M_PIl * x);
+ else
+ return __cosl (M_PIl * (0.5L - x));
+}
+
+/* Compute cos (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cospi (long double x)
+{
+ if (x <= 0.25L)
+ return __cosl (M_PIl * x);
+ else
+ return __sinl (M_PIl * (0.5L - x));
+}
+
+/* Compute cot (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cotpi (long double x)
+{
+ return lg_cospi (x) / lg_sinpi (x);
+}
+
+/* Compute lgamma of a negative argument -50 < X < -2, setting
+ *SIGNGAMP accordingly. */
+
+long double
+__lgamma_negl (long double x, int *signgamp)
+{
+ /* Determine the half-integer region X lies in, handle exact
+ integers and determine the sign of the result. */
+ int i = __floorl (-2 * x);
+ if ((i & 1) == 0 && i == -2 * x)
+ return 1.0L / 0.0L;
+ long double xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
+ i -= 4;
+ *signgamp = ((i & 2) == 0 ? -1 : 1);
+
+ SET_RESTORE_ROUNDL (FE_TONEAREST);
+
+ /* Expand around the zero X0 = X0_HI + X0_LO. */
+ long double x0_hi = lgamma_zeros[i][0], x0_lo = lgamma_zeros[i][1];
+ long double xdiff = x - x0_hi - x0_lo;
+
+ /* For arguments in the range -3 to -2, use polynomial
+ approximations to an adjusted version of the gamma function. */
+ if (i < 2)
+ {
+ int j = __floorl (-8 * x) - 16;
+ long double xm = (-33 - 2 * j) * 0.0625L;
+ long double x_adj = x - xm;
+ size_t deg = poly_deg[j];
+ size_t end = poly_end[j];
+ long double g = poly_coeff[end];
+ for (size_t j = 1; j <= deg; j++)
+ g = g * x_adj + poly_coeff[end - j];
+ return __log1pl (g * xdiff / (x - xn));
+ }
+
+ /* The result we want is log (sinpi (X0) / sinpi (X))
+ + log (gamma (1 - X0) / gamma (1 - X)). */
+ long double x_idiff = fabsl (xn - x), x0_idiff = fabsl (xn - x0_hi - x0_lo);
+ long double log_sinpi_ratio;
+ if (x0_idiff < x_idiff * 0.5L)
+ /* Use log not log1p to avoid inaccuracy from log1p of arguments
+ close to -1. */
+ log_sinpi_ratio = __ieee754_logl (lg_sinpi (x0_idiff)
+ / lg_sinpi (x_idiff));
+ else
+ {
+ /* Use log1p not log to avoid inaccuracy from log of arguments
+ close to 1. X0DIFF2 has positive sign if X0 is further from
+ XN than X is from XN, negative sign otherwise. */
+ long double x0diff2 = ((i & 1) == 0 ? xdiff : -xdiff) * 0.5L;
+ long double sx0d2 = lg_sinpi (x0diff2);
+ long double cx0d2 = lg_cospi (x0diff2);
+ log_sinpi_ratio = __log1pl (2 * sx0d2
+ * (-sx0d2 + cx0d2 * lg_cotpi (x_idiff)));
+ }
+
+ long double log_gamma_ratio;
+ long double y0 = 1 - x0_hi;
+ long double y0_eps = -x0_hi + (1 - y0) - x0_lo;
+ long double y = 1 - x;
+ long double y_eps = -x + (1 - y);
+ /* We now wish to compute LOG_GAMMA_RATIO
+ = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF
+ accurately approximates the difference Y0 + Y0_EPS - Y -
+ Y_EPS. Use Stirling's approximation. First, we may need to
+ adjust into the range where Stirling's approximation is
+ sufficiently accurate. */
+ long double log_gamma_adj = 0;
+ if (i < 20)
+ {
+ int n_up = (21 - i) / 2;
+ long double ny0, ny0_eps, ny, ny_eps;
+ ny0 = y0 + n_up;
+ ny0_eps = y0 - (ny0 - n_up) + y0_eps;
+ y0 = ny0;
+ y0_eps = ny0_eps;
+ ny = y + n_up;
+ ny_eps = y - (ny - n_up) + y_eps;
+ y = ny;
+ y_eps = ny_eps;
+ long double prodm1 = __lgamma_productl (xdiff, y - n_up, y_eps, n_up);
+ log_gamma_adj = -__log1pl (prodm1);
+ }
+ long double log_gamma_high
+ = (xdiff * __log1pl ((y0 - e_hi - e_lo + y0_eps) / e_hi)
+ + (y - 0.5L + y_eps) * __log1pl (xdiff / y) + log_gamma_adj);
+ /* Compute the sum of (B_2k / 2k(2k-1))(Y0^-(2k-1) - Y^-(2k-1)). */
+ long double y0r = 1 / y0, yr = 1 / y;
+ long double y0r2 = y0r * y0r, yr2 = yr * yr;
+ long double rdiff = -xdiff / (y * y0);
+ long double bterm[NCOEFF];
+ long double dlast = rdiff, elast = rdiff * yr * (yr + y0r);
+ bterm[0] = dlast * lgamma_coeff[0];
+ for (size_t j = 1; j < NCOEFF; j++)
+ {
+ long double dnext = dlast * y0r2 + elast;
+ long double enext = elast * yr2;
+ bterm[j] = dnext * lgamma_coeff[j];
+ dlast = dnext;
+ elast = enext;
+ }
+ long double log_gamma_low = 0;
+ for (size_t j = 0; j < NCOEFF; j++)
+ log_gamma_low += bterm[NCOEFF - 1 - j];
+ log_gamma_ratio = log_gamma_high + log_gamma_low;
+
+ return log_sinpi_ratio + log_gamma_ratio;
+}
diff --git a/sysdeps/ieee754/ldbl-128/lgamma_productl.c b/sysdeps/ieee754/ldbl-128/lgamma_productl.c
new file mode 100644
index 0000000000..de67cbe665
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/lgamma_productl.c
@@ -0,0 +1,82 @@
+/* Compute a product of 1 + (T/X), 1 + (T/(X+1)), ....
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+/* Calculate X * Y exactly and store the result in *HI + *LO. It is
+ given that the values are small enough that no overflow occurs and
+ large enough (or zero) that no underflow occurs. */
+
+static void
+mul_split (long double *hi, long double *lo, long double x, long double y)
+{
+#ifdef __FP_FAST_FMAL
+ /* Fast built-in fused multiply-add. */
+ *hi = x * y;
+ *lo = __builtin_fmal (x, y, -*hi);
+#elif defined FP_FAST_FMAL
+ /* Fast library fused multiply-add, compiler before GCC 4.6. */
+ *hi = x * y;
+ *lo = __fmal (x, y, -*hi);
+#else
+ /* Apply Dekker's algorithm. */
+ *hi = x * y;
+# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
+ long double x1 = x * C;
+ long double y1 = y * C;
+# undef C
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ long double x2 = x - x1;
+ long double y2 = y - y1;
+ *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
+#endif
+}
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+
+long double
+__lgamma_productl (long double t, long double x, long double x_eps, int n)
+{
+ long double ret = 0, ret_eps = 0;
+ for (int i = 0; i < n; i++)
+ {
+ long double xi = x + i;
+ long double quot = t / xi;
+ long double mhi, mlo;
+ mul_split (&mhi, &mlo, quot, xi);
+ long double quot_lo = (t - mhi - mlo) / xi - t * x_eps / (xi * xi);
+ /* We want (1 + RET + RET_EPS) * (1 + QUOT + QUOT_LO) - 1. */
+ long double rhi, rlo;
+ mul_split (&rhi, &rlo, ret, quot);
+ long double rpq = ret + quot;
+ long double rpq_eps = (ret - rpq) + quot;
+ long double nret = rpq + rhi;
+ long double nret_eps = (rpq - nret) + rhi;
+ ret_eps += (rpq_eps + nret_eps + rlo + ret_eps * quot
+ + quot_lo + quot_lo * (ret + ret_eps));
+ ret = nret;
+ }
+ return ret + ret_eps;
+}
diff --git a/sysdeps/ieee754/ldbl-128/mpn2ldbl.c b/sysdeps/ieee754/ldbl-128/mpn2ldbl.c
index b4cab91211..f9e4a39f59 100644
--- a/sysdeps/ieee754/ldbl-128/mpn2ldbl.c
+++ b/sysdeps/ieee754/ldbl-128/mpn2ldbl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/printf_fphex.c b/sysdeps/ieee754/ldbl-128/printf_fphex.c
index 59c276b295..83f8f39ae8 100644
--- a/sysdeps/ieee754/ldbl-128/printf_fphex.c
+++ b/sysdeps/ieee754/ldbl-128/printf_fphex.c
@@ -1,6 +1,6 @@
/* Print floating point number in hexadecimal notation according to
ISO C99.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/s_asinhl.c b/sysdeps/ieee754/ldbl-128/s_asinhl.c
index 8d5721a73c..5f3b9f2c76 100644
--- a/sysdeps/ieee754/ldbl-128/s_asinhl.c
+++ b/sysdeps/ieee754/ldbl-128/s_asinhl.c
@@ -52,11 +52,7 @@ __asinhl (long double x)
return x + x; /* x is inf or NaN */
if (ix < 0x3fc70000)
{ /* |x| < 2^ -56 */
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (huge + x > one)
return x; /* return x inexact except 0 */
}
diff --git a/sysdeps/ieee754/ldbl-128/s_atanl.c b/sysdeps/ieee754/ldbl-128/s_atanl.c
index 1367b6b15d..aaae701551 100644
--- a/sysdeps/ieee754/ldbl-128/s_atanl.c
+++ b/sysdeps/ieee754/ldbl-128/s_atanl.c
@@ -202,11 +202,7 @@ __atanl (long double x)
if (k <= 0x3fc50000) /* |x| < 2**-58 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
/* Raise inexact. */
if (huge + x > 0.0)
return x;
diff --git a/sysdeps/ieee754/ldbl-128/s_erfl.c b/sysdeps/ieee754/ldbl-128/s_erfl.c
index fa4609f136..dd275a7dd9 100644
--- a/sysdeps/ieee754/ldbl-128/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-128/s_erfl.c
@@ -140,7 +140,6 @@ deval (long double x, const long double *p, int n)
static const long double
tiny = 1e-4931L,
- half = 0.5L,
one = 1.0L,
two = 2.0L,
/* 2/sqrt(pi) - 1 */
@@ -786,11 +785,7 @@ __erfl (long double x)
{
/* Avoid spurious underflow. */
long double ret = 0.0625 * (16.0 * x + (16.0 * efx) * x);
- if (fabsl (ret) < LDBL_MIN)
- {
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
return ret;
}
return x + efx * x;
diff --git a/sysdeps/ieee754/ldbl-128/s_expm1l.c b/sysdeps/ieee754/ldbl-128/s_expm1l.c
index 573d00be57..b1100a9d0e 100644
--- a/sysdeps/ieee754/ldbl-128/s_expm1l.c
+++ b/sysdeps/ieee754/ldbl-128/s_expm1l.c
@@ -84,8 +84,6 @@ static const long double
C1 = 6.93145751953125E-1L,
C2 = 1.428606820309417232121458176568075500134E-6L,
-/* ln (2^16384 * (1 - 2^-113)) */
- maxlog = 1.1356523406294143949491931077970764891253E4L,
/* ln 2^-114 */
minarg = -7.9018778583833765273564461846232128760607E1L, big = 1e4932L;
@@ -110,14 +108,9 @@ __expm1l (long double x)
}
if (ix >= 0x7fff0000)
{
- /* Infinity. */
+ /* Infinity (which must be negative infinity). */
if (((ix & 0xffff) | u.parts32.w1 | u.parts32.w2 | u.parts32.w3) == 0)
- {
- if (sign)
- return -1.0L;
- else
- return x;
- }
+ return -1.0L;
/* NaN. No invalid exception. */
return x;
}
@@ -126,13 +119,6 @@ __expm1l (long double x)
if ((ix == 0) && (u.parts32.w1 | u.parts32.w2 | u.parts32.w3) == 0)
return x;
- /* Overflow. */
- if (x > maxlog)
- {
- __set_errno (ERANGE);
- return (big * big);
- }
-
/* Minimum value. */
if (x < minarg)
return (4.0/big - 1.0L);
@@ -142,11 +128,7 @@ __expm1l (long double x)
when the result does underflow. */
if (fabsl (x) < 0x1p-113L)
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
diff --git a/sysdeps/ieee754/ldbl-128/s_finitel.c b/sysdeps/ieee754/ldbl-128/s_finitel.c
index f862a448ed..ea8a9ba379 100644
--- a/sysdeps/ieee754/ldbl-128/s_finitel.c
+++ b/sysdeps/ieee754/ldbl-128/s_finitel.c
@@ -29,7 +29,7 @@ int __finitel(long double x)
{
int64_t hx;
GET_LDOUBLE_MSW64(hx,x);
- return (int)((u_int64_t)((hx&0x7fffffffffffffffLL)
+ return (int)((u_int64_t)((hx&0x7fff000000000000LL)
-0x7fff000000000000LL)>>63);
}
hidden_def (__finitel)
diff --git a/sysdeps/ieee754/ldbl-128/s_fma.c b/sysdeps/ieee754/ldbl-128/s_fma.c
index 813f54a9da..cbe708f4b8 100644
--- a/sysdeps/ieee754/ldbl-128/s_fma.c
+++ b/sysdeps/ieee754/ldbl-128/s_fma.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c b/sysdeps/ieee754/ldbl-128/s_fmal.c
index b13178ffe7..728949c916 100644
--- a/sysdeps/ieee754/ldbl-128/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
@@ -68,7 +68,7 @@ __fmal (long double x, long double y, long double z)
if (u.ieee.exponent + v.ieee.exponent
> 0x7fff + IEEE854_LONG_DOUBLE_BIAS)
return x * y;
- /* If x * y is less than 1/4 of LDBL_DENORM_MIN, neither the
+ /* If x * y is less than 1/4 of LDBL_TRUE_MIN, neither the
result nor whether there is underflow depends on its exact
value, only on its sign. */
if (u.ieee.exponent + v.ieee.exponent
@@ -94,8 +94,8 @@ __fmal (long double x, long double y, long double z)
&& w.ieee.mantissa1 == 0
&& w.ieee.mantissa0 == 0)))
{
- volatile long double force_underflow = x * y;
- (void) force_underflow;
+ long double force_underflow = x * y;
+ math_force_eval (force_underflow);
}
return v.d * 0x1p-114L;
}
@@ -121,7 +121,7 @@ __fmal (long double x, long double y, long double z)
very small, adjust them up to avoid spurious underflows,
rather than down. */
if (u.ieee.exponent + v.ieee.exponent
- <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG)
+ <= IEEE854_LONG_DOUBLE_BIAS + 2 * LDBL_MANT_DIG)
{
if (u.ieee.exponent > v.ieee.exponent)
u.ieee.exponent += 2 * LDBL_MANT_DIG + 2;
@@ -179,7 +179,10 @@ __fmal (long double x, long double y, long double z)
/* Ensure correct sign of exact 0 + 0. */
if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
- return x * y + z;
+ {
+ x = math_opt_barrier (x);
+ return x * y + z;
+ }
fenv_t env;
feholdexcept (&env);
diff --git a/sysdeps/ieee754/ldbl-128/s_fpclassifyl.c b/sysdeps/ieee754/ldbl-128/s_fpclassifyl.c
index 2d41185ccd..c89686f8f9 100644
--- a/sysdeps/ieee754/ldbl-128/s_fpclassifyl.c
+++ b/sysdeps/ieee754/ldbl-128/s_fpclassifyl.c
@@ -1,5 +1,5 @@
/* Return classification value corresponding to argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128/s_isinf_nsl.c b/sysdeps/ieee754/ldbl-128/s_isinf_nsl.c
deleted file mode 100644
index 7d6cfb9a62..0000000000
--- a/sysdeps/ieee754/ldbl-128/s_isinf_nsl.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Written by Ulrich Drepper <drepper@gmail.com>
- */
-
-/*
- * __isinf_nsl(x) returns != 0 if x is ±inf, else 0;
- * no branching!
- */
-
-#include <math.h>
-#include <math_private.h>
-
-int
-__isinf_nsl (long double x)
-{
- int64_t hx,lx;
- GET_LDOUBLE_WORDS64(hx,lx,x);
- return !(lx | ((hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL));
-}
diff --git a/sysdeps/ieee754/ldbl-128/s_issignalingl.c b/sysdeps/ieee754/ldbl-128/s_issignalingl.c
index 0db27c4d76..c06f14dd12 100644
--- a/sysdeps/ieee754/ldbl-128/s_issignalingl.c
+++ b/sysdeps/ieee754/ldbl-128/s_issignalingl.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128/s_llrintl.c b/sysdeps/ieee754/ldbl-128/s_llrintl.c
index 27196c95a4..84fc576ab6 100644
--- a/sysdeps/ieee754/ldbl-128/s_llrintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_llrintl.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -19,9 +19,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const long double two112[2] =
{
@@ -34,7 +37,7 @@ __llrintl (long double x)
{
int32_t j0;
u_int64_t i0,i1;
- volatile long double w;
+ long double w;
long double t;
long long int result;
int sx;
@@ -47,8 +50,21 @@ __llrintl (long double x)
if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
{
- w = two112[sx] + x;
- t = w - two112[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LLONG_MAX + 1 implied by J0 < 63. */
+ if (x > (long double) LLONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LLONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two112[sx] + x;
+ t = w - two112[sx];
+ }
GET_LDOUBLE_WORDS64 (i0, i1, t);
j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
i0 &= 0x0000ffffffffffffLL;
@@ -63,8 +79,26 @@ __llrintl (long double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#if defined FE_INVALID || defined FE_INEXACT
+ if (x < (long double) LLONG_MIN
+ && x > (long double) LLONG_MIN - 1.0L)
+ {
+ /* If truncation produces LLONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LLONG_MIN ? FE_INEXACT : FE_INVALID);
+ return LLONG_MIN;
+ }
+ else if (FIX_LDBL_LLONG_CONVERT_OVERFLOW && x != (long double) LLONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LLONG_MAX : LLONG_MIN;
+ }
+
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/ldbl-128/s_llroundl.c b/sysdeps/ieee754/ldbl-128/s_llroundl.c
index 4adc50eaa4..bfc81cc534 100644
--- a/sysdeps/ieee754/ldbl-128/s_llroundl.c
+++ b/sysdeps/ieee754/ldbl-128/s_llroundl.c
@@ -1,5 +1,5 @@
/* Round long double value to long long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -18,10 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
-
+#include <fix-fp-int-convert-overflow.h>
long long int
__llroundl (long double x)
@@ -60,13 +62,37 @@ __llroundl (long double x)
if (j0 == 48)
result = (long long int) i0;
else
- result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+ {
+ result = ((long long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+#ifdef FE_INVALID
+ if (sign == 1 && result == LLONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LLONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#ifdef FE_INVALID
+ if (FIX_LDBL_LLONG_CONVERT_OVERFLOW
+ && !(sign == -1 && x > (long double) LLONG_MIN - 0.5L))
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LLONG_MAX : LLONG_MIN;
+ }
+ else if (!FIX_LDBL_LLONG_CONVERT_OVERFLOW
+ && x <= (long double) LLONG_MIN - 0.5L)
+ {
+ /* If truncation produces LLONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ feraiseexcept (FE_INVALID);
+ return LLONG_MIN;
+ }
+#endif
return (long long int) x;
}
diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c
index ff759bc000..b348f41e55 100644
--- a/sysdeps/ieee754/ldbl-128/s_log1pl.c
+++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c
@@ -117,7 +117,6 @@ static const long double C2 = 1.428606820309417232121458176568075500134E-6L;
static const long double sqrth = 0.7071067811865475244008443621048490392848L;
/* ln (2^16384 * (1 - 2^-113)) */
-static const long double maxlog = 1.1356523406294143949491931077970764891253E4L;
static const long double zero = 0.0L;
long double
@@ -131,8 +130,8 @@ __log1pl (long double xm1)
/* Test for NaN or infinity input. */
u.value = xm1;
hx = u.parts32.w0;
- if (hx >= 0x7fff0000)
- return xm1;
+ if ((hx & 0x7fffffff) >= 0x7fff0000)
+ return xm1 + fabsl (xm1);
/* log1p(+- 0) = +- 0. */
if (((hx & 0x7fffffff) == 0)
@@ -141,11 +140,7 @@ __log1pl (long double xm1)
if ((hx & 0x7fffffff) < 0x3f8e0000)
{
- if (fabsl (xm1) < LDBL_MIN)
- {
- long double force_underflow = xm1 * xm1;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (xm1);
if ((int) xm1 == 0)
return xm1;
}
diff --git a/sysdeps/ieee754/ldbl-128/s_lrintl.c b/sysdeps/ieee754/ldbl-128/s_lrintl.c
index dc678d585d..23f828f862 100644
--- a/sysdeps/ieee754/ldbl-128/s_lrintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_lrintl.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -19,9 +19,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
+#include <fix-fp-int-convert-overflow.h>
static const long double two112[2] =
{
@@ -34,7 +37,7 @@ __lrintl (long double x)
{
int32_t j0;
u_int64_t i0,i1;
- volatile long double w;
+ long double w;
long double t;
long int result;
int sx;
@@ -45,25 +48,53 @@ __lrintl (long double x)
i0 &= 0x0000ffffffffffffLL;
i0 |= 0x0001000000000000LL;
- if (j0 < 48)
+ if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
{
- w = two112[sx] + x;
- t = w - two112[sx];
- GET_LDOUBLE_WORDS64 (i0, i1, t);
- j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
- i0 &= 0x0000ffffffffffffLL;
- i0 |= 0x0001000000000000LL;
+ if (j0 < 48)
+ {
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LONG_MAX + 1 implied by J0 < 31. */
+ if (sizeof (long int) == 4
+ && x > (long double) LONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two112[sx] + x;
+ t = w - two112[sx];
+ }
+ GET_LDOUBLE_WORDS64 (i0, i1, t);
+ j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
+ i0 &= 0x0000ffffffffffffLL;
+ i0 |= 0x0001000000000000LL;
- result = (j0 < 0 ? 0 : i0 >> (48 - j0));
- }
- else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
- {
- if (j0 >= 112)
+ result = (j0 < 0 ? 0 : i0 >> (48 - j0));
+ }
+ else if (j0 >= 112)
result = ((long int) i0 << (j0 - 48)) | (i1 << (j0 - 112));
else
{
- w = two112[sx] + x;
- t = w - two112[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LONG_MAX + 1 implied by J0 < 63. */
+ if (sizeof (long int) == 8
+ && x > (long double) LONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two112[sx] + x;
+ t = w - two112[sx];
+ }
GET_LDOUBLE_WORDS64 (i0, i1, t);
j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
i0 &= 0x0000ffffffffffffLL;
@@ -77,8 +108,26 @@ __lrintl (long double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#if defined FE_INVALID || defined FE_INEXACT
+ if (x < (long double) LONG_MIN
+ && x > (long double) LONG_MIN - 1.0L)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MIN ? FE_INEXACT : FE_INVALID);
+ return LONG_MIN;
+ }
+ else if (FIX_LDBL_LONG_CONVERT_OVERFLOW && x != (long double) LONG_MIN)
+ {
+ feraiseexcept (FE_INVALID);
+ return sx == 0 ? LONG_MAX : LONG_MIN;
+ }
+
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/ldbl-128/s_lroundl.c b/sysdeps/ieee754/ldbl-128/s_lroundl.c
index 8421609676..f03262543f 100644
--- a/sysdeps/ieee754/ldbl-128/s_lroundl.c
+++ b/sysdeps/ieee754/ldbl-128/s_lroundl.c
@@ -1,5 +1,5 @@
/* Round long double value to long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
@@ -18,10 +18,12 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
-
+#include <fix-fp-int-convert-overflow.h>
long int
__lroundl (long double x)
@@ -37,19 +39,26 @@ __lroundl (long double x)
i0 &= 0x0000ffffffffffffLL;
i0 |= 0x0001000000000000LL;
- if (j0 < 48)
+ if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
{
- if (j0 < 0)
- return j0 < -1 ? 0 : sign;
- else
+ if (j0 < 48)
{
- i0 += 0x0000800000000000LL >> j0;
- result = i0 >> (48 - j0);
+ if (j0 < 0)
+ return j0 < -1 ? 0 : sign;
+ else
+ {
+ i0 += 0x0000800000000000LL >> j0;
+ result = i0 >> (48 - j0);
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
- }
- else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
- {
- if (j0 >= 112)
+ else if (j0 >= 112)
result = ((long int) i0 << (j0 - 48)) | (i1 << (j0 - 112));
else
{
@@ -60,11 +69,39 @@ __lroundl (long double x)
if (j0 == 48)
result = (long int) i0;
else
- result = ((long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+ {
+ result = ((long int) i0 << (j0 - 48)) | (j >> (112 - j0));
+#ifdef FE_INVALID
+ if (sizeof (long int) == 8
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
else
{
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#ifdef FE_INVALID
+ if (FIX_LDBL_LONG_CONVERT_OVERFLOW
+ && !(sign == -1 && x > (long double) LONG_MIN - 0.5L))
+ {
+ feraiseexcept (FE_INVALID);
+ return sign == 1 ? LONG_MAX : LONG_MIN;
+ }
+ else if (!FIX_LDBL_LONG_CONVERT_OVERFLOW
+ && x <= (long double) LONG_MIN - 0.5L)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ feraiseexcept (FE_INVALID);
+ return LONG_MIN;
+ }
+#endif
/* The number is too large. It is left implementation defined
what happens. */
return (long int) x;
diff --git a/sysdeps/ieee754/ldbl-128/s_nextafterl.c b/sysdeps/ieee754/ldbl-128/s_nextafterl.c
index d5eaa1cc91..4e9a2ce520 100644
--- a/sysdeps/ieee754/ldbl-128/s_nextafterl.c
+++ b/sysdeps/ieee754/ldbl-128/s_nextafterl.c
@@ -24,6 +24,7 @@ static char rcsid[] = "$NetBSD: $";
* Special cases:
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
@@ -70,10 +71,12 @@ long double __nextafterl(long double x, long double y)
if(hy==0x7fff000000000000LL) {
long double u = x + x; /* overflow */
math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy==0) {
long double u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_LDOUBLE_WORDS64(x,hx,lx);
return x;
diff --git a/sysdeps/ieee754/ldbl-128/s_nexttoward.c b/sysdeps/ieee754/ldbl-128/s_nexttoward.c
index 2cd2e58391..4343fe83f8 100644
--- a/sysdeps/ieee754/ldbl-128/s_nexttoward.c
+++ b/sysdeps/ieee754/ldbl-128/s_nexttoward.c
@@ -25,6 +25,7 @@ static char rcsid[] = "$NetBSD: $";
* Special cases:
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <float.h>
@@ -73,15 +74,14 @@ double __nexttoward(double x, long double y)
}
hy = hx&0x7ff00000;
if(hy>=0x7ff00000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
- /* Force conversion to double. */
- asm ("" : "+m"(x));
- return x;
+ double u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00100000) {
double u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
INSERT_WORDS(x,hx,lx);
return x;
diff --git a/sysdeps/ieee754/ldbl-128/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128/s_nexttowardf.c
index ccd49d235d..8703359d4f 100644
--- a/sysdeps/ieee754/ldbl-128/s_nexttowardf.c
+++ b/sysdeps/ieee754/ldbl-128/s_nexttowardf.c
@@ -18,6 +18,7 @@
static char rcsid[] = "$NetBSD: $";
#endif
+#include <errno.h>
#include <math.h>
#include <math_private.h>
@@ -59,10 +60,15 @@ float __nexttowardf(float x, long double y)
}
}
hy = hx&0x7f800000;
- if(hy>=0x7f800000) return x+x; /* overflow */
+ if(hy>=0x7f800000) {
+ float u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
+ }
if(hy<0x00800000) {
float u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_FLOAT_WORD(x,hx);
return x;
diff --git a/sysdeps/ieee754/ldbl-128/s_remquol.c b/sysdeps/ieee754/ldbl-128/s_remquol.c
index 82cdf1a589..7356f5f4ef 100644
--- a/sysdeps/ieee754/ldbl-128/s_remquol.c
+++ b/sysdeps/ieee754/ldbl-128/s_remquol.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128/s_roundl.c b/sysdeps/ieee754/ldbl-128/s_roundl.c
index 3ff6ebe7cc..98b448e4f3 100644
--- a/sysdeps/ieee754/ldbl-128/s_roundl.c
+++ b/sysdeps/ieee754/ldbl-128/s_roundl.c
@@ -1,5 +1,5 @@
/* Round long double to integer away from zero.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128/s_scalbnl.c b/sysdeps/ieee754/ldbl-128/s_scalbnl.c
index 8916dcbfdd..a5cbd0d9d2 100644
--- a/sysdeps/ieee754/ldbl-128/s_scalbnl.c
+++ b/sysdeps/ieee754/ldbl-128/s_scalbnl.c
@@ -60,4 +60,3 @@ long double __scalbnl (long double x, int n)
SET_LDOUBLE_MSW64(x,(hx&0x8000ffffffffffffULL)|(k<<48));
return x*twom114;
}
-weak_alias (__scalbnl, scalbnl)
diff --git a/sysdeps/ieee754/ldbl-128/s_signbitl.c b/sysdeps/ieee754/ldbl-128/s_signbitl.c
index acfe859a2e..ee5d77e27a 100644
--- a/sysdeps/ieee754/ldbl-128/s_signbitl.c
+++ b/sysdeps/ieee754/ldbl-128/s_signbitl.c
@@ -1,5 +1,5 @@
/* Return nonzero value if number is negative.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -19,13 +19,8 @@
#include <math.h>
-#include <math_private.h>
-
int
__signbitl (long double x)
{
- int64_t e;
-
- GET_LDOUBLE_MSW64 (e, x);
- return e < 0;
+ return __builtin_signbitl (x);
}
diff --git a/sysdeps/ieee754/ldbl-128/s_sincosl.c b/sysdeps/ieee754/ldbl-128/s_sincosl.c
index 6c4cbd7237..1abdb4419e 100644
--- a/sysdeps/ieee754/ldbl-128/s_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128/s_sincosl.c
@@ -1,5 +1,5 @@
/* Compute sine and cosine of argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>.
@@ -39,7 +39,7 @@ __sincosl (long double x, long double *sinx, long double *cosx)
{
/* sin(Inf or NaN) is NaN */
*sinx = *cosx = x - x;
- if (__isinf_nsl (x))
+ if (isinf (x))
__set_errno (EDOM);
}
else
diff --git a/sysdeps/ieee754/ldbl-128/s_tanhl.c b/sysdeps/ieee754/ldbl-128/s_tanhl.c
index 129735b1b5..f7a1d20f79 100644
--- a/sysdeps/ieee754/ldbl-128/s_tanhl.c
+++ b/sysdeps/ieee754/ldbl-128/s_tanhl.c
@@ -41,6 +41,7 @@
* only tanhl(0)=0 is exact for finite argument.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -73,7 +74,10 @@ __tanhl (long double x)
if (u.value == 0)
return x; /* x == +- 0 */
if (ix < 0x3fc60000) /* |x| < 2^-57 */
- return x * (one + tiny); /* tanh(small) = small */
+ {
+ math_check_force_underflow (x);
+ return x * (one + tiny); /* tanh(small) = small */
+ }
u.parts32.w0 = ix; /* Absolute value of x. */
if (ix >= 0x3fff0000)
{ /* |x| >= 1 */
diff --git a/sysdeps/ieee754/ldbl-128/s_truncl.c b/sysdeps/ieee754/ldbl-128/s_truncl.c
index 14205c76a4..c71f0aba92 100644
--- a/sysdeps/ieee754/ldbl-128/s_truncl.c
+++ b/sysdeps/ieee754/ldbl-128/s_truncl.c
@@ -1,5 +1,5 @@
/* Truncate argument to nearest integral value not larger than the argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h
new file mode 100644
index 0000000000..aed8953421
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/strtod_nan_ldouble.h
@@ -0,0 +1,33 @@
+/* Convert string for NaN payload to corresponding NaN. For ldbl-128.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FLOAT long double
+#define SET_MANTISSA(flt, mant) \
+ do \
+ { \
+ union ieee854_long_double u; \
+ u.d = (flt); \
+ u.ieee_nan.mantissa0 = 0; \
+ u.ieee_nan.mantissa1 = 0; \
+ u.ieee_nan.mantissa2 = (mant) >> 32; \
+ u.ieee_nan.mantissa3 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1 \
+ | u.ieee.mantissa2 | u.ieee.mantissa3) != 0) \
+ (flt) = u.d; \
+ } \
+ while (0)
diff --git a/sysdeps/ieee754/ldbl-128/strtold_l.c b/sysdeps/ieee754/ldbl-128/strtold_l.c
index d1ae57e304..12ccd93ee5 100644
--- a/sysdeps/ieee754/ldbl-128/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-128/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,22 +25,13 @@
#ifdef USE_WIDE_CHAR
# define STRTOF wcstold_l
# define __STRTOF __wcstold_l
+# define STRTOF_NAN __wcstold_nan
#else
# define STRTOF strtold_l
# define __STRTOF __strtold_l
+# define STRTOF_NAN __strtold_nan
#endif
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
-#define SET_MANTISSA(flt, mant) \
- do { union ieee854_long_double u; \
- u.d = (flt); \
- u.ieee_nan.mantissa0 = 0; \
- u.ieee_nan.mantissa1 = 0; \
- u.ieee_nan.mantissa2 = (mant) >> 32; \
- u.ieee_nan.mantissa3 = (mant); \
- if ((u.ieee.mantissa0 | u.ieee.mantissa1 \
- | u.ieee.mantissa2 | u.ieee.mantissa3) != 0) \
- (flt) = u.d; \
- } while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-128/t_expl.h b/sysdeps/ieee754/ldbl-128/t_expl.h
index a9bf752e8f..a23d3d9344 100644
--- a/sysdeps/ieee754/ldbl-128/t_expl.h
+++ b/sysdeps/ieee754/ldbl-128/t_expl.h
@@ -1,5 +1,5 @@
/* Accurate table for expl().
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128/t_sincosl.c b/sysdeps/ieee754/ldbl-128/t_sincosl.c
index b6125f5612..de5fe0d9e9 100644
--- a/sysdeps/ieee754/ldbl-128/t_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128/t_sincosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine and cosine tables.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128/x2y2m1l.c b/sysdeps/ieee754/ldbl-128/x2y2m1l.c
index 11757c6af8..733742da04 100644
--- a/sysdeps/ieee754/ldbl-128/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-128/x2y2m1l.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -80,32 +80,26 @@ compare (const void *p, const void *q)
}
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
long double
__x2y2m1l (long double x, long double y)
{
- long double vals[4];
+ long double vals[5];
SET_RESTORE_ROUNDL (FE_TONEAREST);
mul_split (&vals[1], &vals[0], x, x);
mul_split (&vals[3], &vals[2], y, y);
- if (x >= 0.75L)
- vals[1] -= 1.0L;
- else
- {
- vals[1] -= 0.5L;
- vals[3] -= 0.5L;
- }
- qsort (vals, 4, sizeof (long double), compare);
+ vals[4] = -1.0L;
+ qsort (vals, 5, sizeof (long double), compare);
/* Add up the values so that each element of VALS has absolute value
at most equal to the last set bit of the next nonzero
element. */
- for (size_t i = 0; i <= 2; i++)
+ for (size_t i = 0; i <= 3; i++)
{
add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]);
- qsort (vals + i + 1, 3 - i, sizeof (long double), compare);
+ qsort (vals + i + 1, 4 - i, sizeof (long double), compare);
}
/* Now any error from this addition will be small. */
- return vals[3] + vals[2] + vals[1] + vals[0];
+ return vals[4] + vals[3] + vals[2] + vals[1] + vals[0];
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/Makefile b/sysdeps/ieee754/ldbl-128ibm/Makefile
index 8e1e2e6ae5..5591814824 100644
--- a/sysdeps/ieee754/ldbl-128ibm/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm/Makefile
@@ -3,3 +3,8 @@
# when -mlong-double-64 is not used).
long-double-fcts = yes
sysdep-CFLAGS += -mlong-double-128
+
+ifeq ($(subdir),stdlib)
+tests += tst-strtold-ldbl-128ibm
+$(objpfx)tst-strtold-ldbl-128ibm: $(libm)
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
index 57c3ac09c8..6ed5e8d68d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_asinl.c
@@ -147,11 +147,7 @@ __ieee754_asinl (long double x)
{
if (a < 6.938893903907228e-18L) /* |x| < 2**-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
long double force_inexact = huge + x;
math_force_eval (force_inexact);
return x; /* return x with inexact if x!=0 */
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c b/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c
index bcd1fce4ed..b576f42030 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_atanhl.c
@@ -57,11 +57,7 @@ __ieee754_atanhl(long double x)
}
if(ix<0x3c70000000000000LL&&(huge+x)>zero) /* x<2**-56 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x;
}
x = fabsl (x);
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c b/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c
index deefe7f54f..5699b8e53d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_exp10l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -19,8 +19,8 @@
#include <math_private.h>
#include <float.h>
-static const long double log10_high = 0x2.4d763776aaa2cp0L;
-static const long double log10_low = -0xf.a456a4a751f4b3d75c75c04c18p-56L;
+static const long double log10_high = 0x2.4d763776aaap+0L;
+static const long double log10_low = 0x2.b05ba95b58ae0b4c28a38a3fb4p-48L;
long double
__ieee754_exp10l (long double arg)
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_expl.c b/sysdeps/ieee754/ldbl-128ibm/e_expl.c
index 15ccc454e1..ca3cbb53af 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_expl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_expl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point e^x.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
Partly based on double-precision code
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c b/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c
index 48098c18f6..8dbb131f93 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c
@@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz, 1999.
@@ -194,6 +194,7 @@ __ieee754_gammal_r (long double x, int *signgamp)
ret = M_PIl / (-x * sinpix
* gammal_positive (-x, &exp2_adj));
ret = __scalbnl (ret, -exp2_adj);
+ math_check_force_underflow_nonneg (ret);
}
}
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c b/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c
index 3b07a47b40..c68dac03b0 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_hypotl.c
@@ -125,7 +125,11 @@ __ieee754_hypotl(long double x, long double y)
w = __ieee754_sqrtl(a1*b1-(w*(-w)-(a1*b2+a2*b)));
}
if(k!=0)
- return w*kld;
+ {
+ w *= kld;
+ math_check_force_underflow_nonneg (w);
+ return w;
+ }
else
return w;
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 7594196a1f..4a8ccb044e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
@@ -296,12 +296,12 @@ __ieee754_jnl (int n, long double x)
ret = b;
}
if (ret == 0)
- ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
- else if (fabsl (ret) < LDBL_MIN)
{
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
+ ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
+ __set_errno (ERANGE);
}
+ else
+ math_check_force_underflow (ret);
return ret;
}
strong_alias (__ieee754_jnl, __jnl_finite)
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_log2l.c b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c
index 442ad97254..e39eaba72a 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_log2l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_log2l.c
@@ -171,8 +171,7 @@ deval (long double x, const long double *p, int n)
long double
-__ieee754_log2l (x)
- long double x;
+__ieee754_log2l (long double x)
{
long double z;
long double y;
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_logl.c b/sysdeps/ieee754/ldbl-128ibm/e_logl.c
index 58d6bc6972..14acfc2db7 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_logl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_logl.c
@@ -219,6 +219,8 @@ __ieee754_logl(long double x)
/* On this interval the table is not used due to cancellation error. */
if ((x <= 1.0078125L) && (x >= 0.9921875L))
{
+ if (x == 1.0L)
+ return 0.0L;
z = x - 1.0L;
k = 64;
t = 1.0L;
@@ -268,7 +270,7 @@ __ieee754_logl(long double x)
/* Series expansion of log(1+z). */
w = z * z;
/* Avoid spurious underflows. */
- if (__glibc_unlikely(w <= ldbl_epsilon))
+ if (__glibc_unlikely (fabsl (z) <= ldbl_epsilon))
y = 0.0L;
else
{
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_powl.c b/sysdeps/ieee754/ldbl-128ibm/e_powl.c
index c942f2f249..90340e890e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_powl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_powl.c
@@ -409,6 +409,7 @@ __ieee754_powl (long double x, long double y)
r = (z * t1) / (t1 - two) - (w + z * w);
z = one - (r - z);
z = __scalbnl (z, n);
+ math_check_force_underflow_nonneg (z);
return s * z;
}
strong_alias (__ieee754_powl, __powl_finite)
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c b/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c
index 9c6ebbdbff..cc2b235534 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point argument reduction.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c
index 1790bef87e..67d9d24ce7 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_sinhl.c
@@ -28,6 +28,7 @@
* only sinh(0)=0 is exact for finite x.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -52,8 +53,10 @@ __ieee754_sinhl(long double x)
if (jx<0) h = -h;
/* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x4044000000000000LL) { /* |x|<40 */
- if (ix<0x3e20000000000000LL) /* |x|<2**-29 */
+ if (ix<0x3c90000000000000LL) { /* |x|<2**-54 */
+ math_check_force_underflow (x);
if(shuge+x>one) return x;/* sinhl(tiny) = tiny with inexact */
+ }
t = __expm1l(fabsl(x));
if(ix<0x3ff0000000000000LL) return h*(2.0*t-t*t/(t+one));
w = t/(t+one);
@@ -64,7 +67,7 @@ __ieee754_sinhl(long double x)
if (ix < 0x40862e42fefa39efLL) return h*__ieee754_expl(fabsl(x));
/* |x| in [log(maxdouble), overflowthresold] */
- if (ix <= 0x408633ce8fb9f87dLL) {
+ if (ix <= 0x408633ce8fb9f87eLL) {
w = __ieee754_expl(0.5*fabsl(x));
t = h*w;
return t*w;
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c b/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c
index ac1b22175e..96845fe5f8 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c
@@ -1,7 +1,7 @@
/*
* IBM Accurate Mathematical Library
* written by International Business Machines Corp.
- * Copyright (C) 2001-2015 Free Software Foundation, Inc.
+ * Copyright (C) 2001-2016 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
diff --git a/sysdeps/ieee754/ldbl-128ibm/gamma_productl.c b/sysdeps/ieee754/ldbl-128ibm/gamma_productl.c
index 905a78025a..b631f90a44 100644
--- a/sysdeps/ieee754/ldbl-128ibm/gamma_productl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/gamma_productl.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/ieee754.h b/sysdeps/ieee754/ldbl-128ibm/ieee754.h
index d11e040469..c07a6def4b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/ieee754.h
+++ b/sysdeps/ieee754/ldbl-128ibm/ieee754.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/k_cosl.c b/sysdeps/ieee754/ldbl-128ibm/k_cosl.c
index e812786bcc..2a3189ad36 100644
--- a/sysdeps/ieee754/ldbl-128ibm/k_cosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/k_cosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point cosine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c
index 0a76e1c7e7..4e43c8622e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/k_sincosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine and cosine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
@@ -114,11 +114,7 @@ __kernel_sincosl(long double x, long double y, long double *sinx, long double *c
polynomial of degree 16(17). */
if (tix < 0x3c600000) /* |x| < 2^-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (!((int)x)) /* generate inexact */
{
*sinx = x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/k_sinl.c b/sysdeps/ieee754/ldbl-128ibm/k_sinl.c
index 2050cd2b49..44da02b0f3 100644
--- a/sysdeps/ieee754/ldbl-128ibm/k_sinl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/k_sinl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
@@ -95,11 +95,7 @@ __kernel_sinl(long double x, long double y, int iy)
polynomial of degree 17. */
if (tix < 0x3c600000) /* |x| < 2^-57 */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (!((int)x)) return x; /* generate inexact */
}
z = x * x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
index 7f1caeebdf..3c1bf32af9 100644
--- a/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/k_tanl.c
@@ -56,6 +56,7 @@
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
+#include <float.h>
#include <libc-internal.h>
#include <math.h>
#include <math_private.h>
@@ -98,8 +99,13 @@ __kernel_tanl (long double x, long double y, int iy)
{
if ((ix | lx | (iy + 1)) == 0)
return one / fabs (x);
+ else if (iy == 1)
+ {
+ math_check_force_underflow (x);
+ return x;
+ }
else
- return (iy == 1) ? x : -one / x;
+ return -one / x;
}
}
if (ix >= 0x3fe59420) /* |x| >= 0.6743316650390625 */
@@ -135,11 +141,7 @@ __kernel_tanl (long double x, long double y, int iy)
uninitialized although in the cases where it is used it has
always been set. */
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (4, 7)
DIAG_IGNORE_NEEDS_COMMENT (5, "-Wmaybe-uninitialized");
-#else
- DIAG_IGNORE_NEEDS_COMMENT (5, "-Wuninitialized");
-#endif
if (sign < 0)
w = -w;
DIAG_POP_NEEDS_COMMENT;
diff --git a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
index e9b5803de3..4f550ef47c 100644
--- a/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
+++ b/sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c b/sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c
new file mode 100644
index 0000000000..c2a5cd29b6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c
@@ -0,0 +1,532 @@
+/* lgammal expanding around zeros.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <math_private.h>
+
+static const long double lgamma_zeros[][2] =
+ {
+ { -0x2.74ff92c01f0d82abec9f315f1ap+0L, -0x7.12c334804d9a79cb5d46094d46p-112L },
+ { -0x2.bf6821437b20197995a4b4641fp+0L, 0x5.140b4ff4b7d6069e1bd7acc196p-108L },
+ { -0x3.24c1b793cb35efb8be699ad3dap+0L, 0x4.59abab3480539f1c0e926287cp-108L },
+ { -0x3.f48e2a8f85fca170d456129123p+0L, -0x6.cc320a4887d1cb4c711828a75ep-108L },
+ { -0x4.0a139e16656030c39f0b0de182p+0L, 0xe.d53e84029416e1242006b2b3dp-108L },
+ { -0x4.fdd5de9bbabf3510d0aa407698p+0L, -0x8.501d7d78125286f78d1e501f14p-108L },
+ { -0x5.021a95fc2db6432a4c56e5953ap+0L, 0xb.2133950fbcf2b01a8b9058dcccp-108L },
+ { -0x5.ffa4bd647d0357dd4ed62cbd32p+0L, 0x1.2071c071a2145d2982428f2269p-108L },
+ { -0x6.005ac9625f233b607c2d96d164p+0L, 0x7.a347953a96cbf30e1a0db20856p-108L },
+ { -0x6.fff2fddae1bbff3d626b65c24p+0L, 0x2.de0bfcff5c457ebcf4d3ad9674p-108L },
+ { -0x7.000cff7b7f87adf4482dcdb988p+0L, 0x7.d54d99e35a74d6407b80292df2p-108L },
+ { -0x7.fffe5fe05673c3ca9e82b522bp+0L, -0xc.a9d2e8837cd1f14bd3d05002e4p-108L },
+ { -0x8.0001a01459fc9f60cb3cec1cecp+0L, -0x8.576677ca538d88084310983b8p-108L },
+ { -0x8.ffffd1c425e80ffc864e957494p+0L, 0x1.a6181dfdef1807e3087e4bb163p-104L },
+ { -0x9.00002e3bb47d86d6d843fedc34p+0L, -0x1.1deb7ad09ec5e9d6e8ae2d548bp-104L },
+ { -0x9.fffffb606bdfdcd062ae77a504p+0L, -0x1.47c69d2eb6f33d170fce38ff818p-104L },
+ { -0xa.0000049f93bb9927b45d95e154p+0L, -0x4.1e03086db9146a9287bd4f2172p-108L },
+ { -0xa.ffffff9466e9f1b36dacd2adbcp+0L, -0x1.18d05a4e458062f3f95345a4dap-104L },
+ { -0xb.0000006b9915315d965a6ffea4p+0L, -0xe.4bea39000dcc1848023c5f6bdcp-112L },
+ { -0xb.fffffff7089387387de41acc3cp+0L, -0x1.3c978bd839c8c428b5efcf91ef8p-104L },
+ { -0xc.00000008f76c7731567c0f025p+0L, -0xf.387920df5675833859190eb128p-108L },
+ { -0xc.ffffffff4f6dcf617f97a5ffc8p+0L, 0xa.82ab72d76f32eaee2d1a42ed5p-108L },
+ { -0xd.00000000b092309c06683dd1b8p+0L, -0x1.03e3700857a15c19ac5a611de98p-104L },
+ { -0xd.fffffffff36345ab9e184a3e08p+0L, -0x1.d1176dc48e47f62d917973dd45p-104L },
+ { -0xe.000000000c9cba545e94e75ec4p+0L, -0x1.718f753e2501e757a17cf2ecbfp-104L },
+ { -0xe.ffffffffff28c060c6604ef304p+0L, 0x8.e0762c8ca8361c23e8393919c4p-108L },
+ { -0xf.0000000000d73f9f399bd0e42p+0L, -0xf.85e9ee31b0b890744fc0e3fbcp-108L },
+ { -0xf.fffffffffff28c060c6621f514p+0L, 0x1.18d1b2eec9d960bd9adc5be5f6p-104L },
+ { -0x1.000000000000d73f9f399da1428p+4L, 0x3.406c46e0e88305d2800f0e414cp-104L },
+ { -0x1.0ffffffffffff3569c47e7a93ep+4L, -0x1.c46a08a2e008a998ebabb8087fp-104L },
+ { -0x1.1000000000000ca963b81856888p+4L, -0x7.6ca5a3a64ec15db0a95caf2cap-108L },
+ { -0x1.1fffffffffffff4bec3ce23413p+4L, -0x2.d08b2b726187c841cb92cd5222p-104L },
+ { -0x1.20000000000000b413c31dcbec8p+4L, -0x2.4c3b2ffacbb4932f18dceedfd7p-104L },
+ { -0x1.2ffffffffffffff685b25cbf5f8p+4L, 0x2.ba3126cd1c7b7a0822d694705cp-104L },
+ { -0x1.30000000000000097a4da340a08p+4L, -0x2.b81b7b1f1f001c72bf914141efp-104L },
+ { -0x1.3fffffffffffffff86af516ff8p+4L, 0x8.9429818df2a87abafd48248a2p-108L },
+ { -0x1.40000000000000007950ae9008p+4L, -0x8.9413ccc8a353fda263f8ce973cp-108L },
+ { -0x1.4ffffffffffffffffa391c4249p+4L, 0x3.d5c63022b62b5484ba346524dbp-104L },
+ { -0x1.500000000000000005c6e3bdb7p+4L, -0x3.d5c62f55ed5322b2685c5e9a52p-104L },
+ { -0x1.5fffffffffffffffffbcc71a49p+4L, -0x2.01eb5aeb96c74d7ad25e060529p-104L },
+ { -0x1.6000000000000000004338e5b7p+4L, 0x2.01eb5aec04b2f2eb663e4e3d8ap-104L },
+ { -0x1.6ffffffffffffffffffd13c97d8p+4L, -0x1.d38fcc4d08d6fe5aa56ab04308p-104L },
+ { -0x1.70000000000000000002ec36828p+4L, 0x1.d38fcc4d090cee2f5d0b69a99cp-104L },
+ { -0x1.7fffffffffffffffffffe0d31p+4L, 0x1.972f577cca4b4c8cb1dc14001bp-104L },
+ { -0x1.800000000000000000001f2cfp+4L, -0x1.972f577cca4b3442e35f0040b38p-104L },
+ { -0x1.8ffffffffffffffffffffec0c3p+4L, -0x3.22e9a0572b1bb5b95f346a92d6p-104L },
+ { -0x1.90000000000000000000013f3dp+4L, 0x3.22e9a0572b1bb5c371ddb35617p-104L },
+ { -0x1.9ffffffffffffffffffffff3b88p+4L, -0x3.d01cad8d32e386fd783e97296dp-104L },
+ { -0x1.a0000000000000000000000c478p+4L, 0x3.d01cad8d32e386fd7c1ab8c1fep-104L },
+ { -0x1.afffffffffffffffffffffff8b8p+4L, -0x1.538f48cc5737d5979c39db806c8p-104L },
+ { -0x1.b00000000000000000000000748p+4L, 0x1.538f48cc5737d5979c3b3a6bdap-104L },
+ { -0x1.bffffffffffffffffffffffffcp+4L, 0x2.862898d42174dcf171470d8c8cp-104L },
+ { -0x1.c0000000000000000000000004p+4L, -0x2.862898d42174dcf171470d18bap-104L },
+ { -0x1.dp+4L, 0x2.4b3f31686b15af57c61ceecdf4p-104L },
+ { -0x1.dp+4L, -0x2.4b3f31686b15af57c61ceecdd1p-104L },
+ { -0x1.ep+4L, 0x1.3932c5047d60e60caded4c298ap-108L },
+ { -0x1.ep+4L, -0x1.3932c5047d60e60caded4c29898p-108L },
+ { -0x1.fp+4L, 0xa.1a6973c1fade2170f7237d36p-116L },
+ { -0x1.fp+4L, -0xa.1a6973c1fade2170f7237d36p-116L },
+ { -0x2p+4L, 0x5.0d34b9e0fd6f10b87b91be9bp-120L },
+ { -0x2p+4L, -0x5.0d34b9e0fd6f10b87b91be9bp-120L },
+ { -0x2.1p+4L, 0x2.73024a9ba1aa36a7059bff52e8p-124L },
+ { -0x2.1p+4L, -0x2.73024a9ba1aa36a7059bff52e8p-124L },
+ { -0x2.2p+4L, 0x1.2710231c0fd7a13f8a2b4af9d68p-128L },
+ { -0x2.2p+4L, -0x1.2710231c0fd7a13f8a2b4af9d68p-128L },
+ { -0x2.3p+4L, 0x8.6e2ce38b6c8f9419e3fad3f03p-136L },
+ { -0x2.3p+4L, -0x8.6e2ce38b6c8f9419e3fad3f03p-136L },
+ { -0x2.4p+4L, 0x3.bf30652185952560d71a254e4fp-140L },
+ { -0x2.4p+4L, -0x3.bf30652185952560d71a254e4fp-140L },
+ { -0x2.5p+4L, 0x1.9ec8d1c94e85af4c78b15c3d8ap-144L },
+ { -0x2.5p+4L, -0x1.9ec8d1c94e85af4c78b15c3d8ap-144L },
+ { -0x2.6p+4L, 0xa.ea565ce061d57489e9b8527628p-152L },
+ { -0x2.6p+4L, -0xa.ea565ce061d57489e9b8527628p-152L },
+ { -0x2.7p+4L, 0x4.7a6512692eb37804111dabad3p-156L },
+ { -0x2.7p+4L, -0x4.7a6512692eb37804111dabad3p-156L },
+ { -0x2.8p+4L, 0x1.ca8ed42a12ae3001a07244abadp-160L },
+ { -0x2.8p+4L, -0x1.ca8ed42a12ae3001a07244abadp-160L },
+ { -0x2.9p+4L, 0xb.2f30e1ce812063f12e7e8d8d98p-168L },
+ { -0x2.9p+4L, -0xb.2f30e1ce812063f12e7e8d8d98p-168L },
+ { -0x2.ap+4L, 0x4.42bd49d4c37a0db136489772e4p-172L },
+ { -0x2.ap+4L, -0x4.42bd49d4c37a0db136489772e4p-172L },
+ { -0x2.bp+4L, 0x1.95db45257e5122dcbae56def37p-176L },
+ { -0x2.bp+4L, -0x1.95db45257e5122dcbae56def37p-176L },
+ { -0x2.cp+4L, 0x9.3958d81ff63527ecf993f3fb7p-184L },
+ { -0x2.cp+4L, -0x9.3958d81ff63527ecf993f3fb7p-184L },
+ { -0x2.dp+4L, 0x3.47970e4440c8f1c058bd238c99p-188L },
+ { -0x2.dp+4L, -0x3.47970e4440c8f1c058bd238c99p-188L },
+ { -0x2.ep+4L, 0x1.240804f65951062ca46e4f25c6p-192L },
+ { -0x2.ep+4L, -0x1.240804f65951062ca46e4f25c6p-192L },
+ { -0x2.fp+4L, 0x6.36a382849fae6de2d15362d8a4p-200L },
+ { -0x2.fp+4L, -0x6.36a382849fae6de2d15362d8a4p-200L },
+ { -0x3p+4L, 0x2.123680d6dfe4cf4b9b1bcb9d8cp-204L },
+ };
+
+static const long double e_hi = 0x2.b7e151628aed2a6abf7158809dp+0L;
+static const long double e_lo = -0xb.0c389d18e9f0c74b25a9587b28p-112L;
+
+/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) in Stirling's
+ approximation to lgamma function. */
+
+static const long double lgamma_coeff[] =
+ {
+ 0x1.555555555555555555555555558p-4L,
+ -0xb.60b60b60b60b60b60b60b60b6p-12L,
+ 0x3.4034034034034034034034034p-12L,
+ -0x2.7027027027027027027027027p-12L,
+ 0x3.72a3c5631fe46ae1d4e700dca9p-12L,
+ -0x7.daac36664f1f207daac36664f2p-12L,
+ 0x1.a41a41a41a41a41a41a41a41a4p-8L,
+ -0x7.90a1b2c3d4e5f708192a3b4c5ep-8L,
+ 0x2.dfd2c703c0cfff430edfd2c704p-4L,
+ -0x1.6476701181f39edbdb9ce625988p+0L,
+ 0xd.672219167002d3a7a9c886459cp+0L,
+ -0x9.cd9292e6660d55b3f712eb9e08p+4L,
+ 0x8.911a740da740da740da740da74p+8L,
+ -0x8.d0cc570e255bf59ff6eec24b48p+12L,
+ 0xa.8d1044d3708d1c219ee4fdc448p+16L,
+ -0xe.8844d8a169abbc406169abbc4p+20L,
+ 0x1.6d29a0f6433b79890cede624338p+28L,
+ -0x2.88a233b3c8cddaba9809357126p+32L,
+ 0x5.0dde6f27500939a85c40939a86p+36L,
+ -0xb.4005bde03d4642a243581714bp+40L,
+ 0x1.bc8cd6f8f1f755c78753cdb5d6p+48L,
+ -0x4.bbebb143bb94de5a0284fa7ec4p+52L,
+ 0xe.2e1337f5af0bed90b6b0a352d4p+56L,
+ -0x2.e78250162b62405ad3e4bfe61bp+64L,
+ 0xa.5f7eef9e71ac7c80326ab4cc8cp+68L,
+ -0x2.83be0395e550213369924971b2p+76L,
+ };
+
+#define NCOEFF (sizeof (lgamma_coeff) / sizeof (lgamma_coeff[0]))
+
+/* Polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0), where n is
+ the integer end-point of the half-integer interval containing x and
+ x0 is the zero of lgamma in that half-integer interval. Each
+ polynomial is expressed in terms of x-xm, where xm is the midpoint
+ of the interval for which the polynomial applies. */
+
+static const long double poly_coeff[] =
+ {
+ /* Interval [-2.125, -2] (polynomial degree 21). */
+ -0x1.0b71c5c54d42eb6c17f30b7aa9p+0L,
+ -0xc.73a1dc05f34951602554c6d76cp-4L,
+ -0x1.ec841408528b51473e6c42f1c58p-4L,
+ -0xe.37c9da26fc3c9a3c1844c04b84p-4L,
+ -0x1.03cd87c519305703b00b046ce4p-4L,
+ -0xe.ae9ada65e09aa7f1c817c91048p-4L,
+ 0x9.b11855a4864b571b6a4f571c88p-8L,
+ -0xe.f28c133e697a95ba2dabb97584p-4L,
+ 0x2.6ec14a1c586a7ddb6c4be90fe1p-4L,
+ -0xf.57cab973e14496f0900851c0d4p-4L,
+ 0x4.5b0fc25f16b0df37175495c70cp-4L,
+ -0xf.f50e59f1a8fb8c402091e3cd3cp-4L,
+ 0x6.5f5eae1681d1e50e575c3d4d36p-4L,
+ -0x1.0d2422dac7ea8a52db6bf0d14fp+0L,
+ 0x8.820008f221eae5a36e15913bacp-4L,
+ -0x1.1f492eec53b9481ea23a7e944ep+0L,
+ 0xa.cb55b4d662945e8cf1f81ee5b4p-4L,
+ -0x1.3616863983e131d7935700ccd48p+0L,
+ 0xd.43c783ebab66074d18709d5cap-4L,
+ -0x1.51d5dbc56bc85976871c6e51f78p+0L,
+ 0x1.06253af656eb6b2ed998387aabp+0L,
+ -0x1.7d910a0aadc63d7a1ef7690dbb8p+0L,
+ /* Interval [-2.25, -2.125] (polynomial degree 22). */
+ -0xf.2930890d7d675a80c36afb0fd4p-4L,
+ -0xc.a5cfde054eab5c6770daeca684p-4L,
+ 0x3.9c9e0fdebb07cdf89c61d434adp-4L,
+ -0x1.02a5ad35605fcf4af65a67fe8a8p+0L,
+ 0x9.6e9b1185bb48be9de18d8bbeb8p-4L,
+ -0x1.4d8332f3cfbfa116fdf648372cp+0L,
+ 0x1.1c0c8cb4d9f4b1d495142b53ebp+0L,
+ -0x1.c9a6f5ae9130ccfb9b7e39136f8p+0L,
+ 0x1.d7e9307fd58a2e85209d0e83eap+0L,
+ -0x2.921cb3473d96462f22c171712fp+0L,
+ 0x2.e8d59113b6f3fc1ed3b556b62cp+0L,
+ -0x3.cbab931624e3b6cf299cea1213p+0L,
+ 0x4.7d9f0f05d2c4cf91e41ea1f048p+0L,
+ -0x5.ade9cba31affa276fe516135eep+0L,
+ 0x6.dc983a62cf6ddc935ae3c5b9ap+0L,
+ -0x8.8d9ed100b2a7813f82cbd83e3cp+0L,
+ 0xa.6fa0926892835a9a29c9b8db8p+0L,
+ -0xc.ebc90aff4ffe319d70bef0d61p+0L,
+ 0xf.d69cf50ab226bacece014c0b44p+0L,
+ -0x1.389964ac7cfef4578eec028e5c8p+4L,
+ 0x1.7ff0d2090164e25901f97cab3bp+4L,
+ -0x1.e9e6d282da6bd004619d073071p+4L,
+ 0x2.5d719ab6ad4be8b5c32b0fba2ap+4L,
+ /* Interval [-2.375, -2.25] (polynomial degree 24). */
+ -0xd.7d28d505d6181218a25f31d5e4p-4L,
+ -0xe.69649a3040985140cdf946827cp-4L,
+ 0xb.0d74a2827d053a8d4459500f88p-4L,
+ -0x1.924b0922853617cac181b097e48p+0L,
+ 0x1.d49b12bccf0a568582e2dbf8ep+0L,
+ -0x3.0898bb7d8c4093e6360d26bbc5p+0L,
+ 0x4.207a6cac711cb538684f74619ep+0L,
+ -0x6.39ee63ea4fb1dcac86ab337e3cp+0L,
+ 0x8.e2e2556a797b64a1b9328a3978p+0L,
+ -0xd.0e83ac82552ee5596df1706ff4p+0L,
+ 0x1.2e4525e0ce666e48fac68ddcdep+4L,
+ -0x1.b8e350d6a8f6597ed2eb3c2eff8p+4L,
+ 0x2.805cd69b9197ee0089dd1b1c46p+4L,
+ -0x3.a42585423e4d00db075f2d687ep+4L,
+ 0x5.4b4f409f874e2a7dcd8aa4a62ap+4L,
+ -0x7.b3c5829962ca1b95535db9cc4ep+4L,
+ 0xb.33b7b928986ec6b219e2e15a98p+4L,
+ -0x1.04b76dec4115106bb16316d9cd8p+8L,
+ 0x1.7b366d8d46f179d5c5302d6534p+8L,
+ -0x2.2799846ddc54813d40da622b99p+8L,
+ 0x3.2253a862c1078a3ccabac65bebp+8L,
+ -0x4.8d92cebc90a4a29816f4952f4ep+8L,
+ 0x6.9ebb8f9d72c66c80c4f4492e7ap+8L,
+ -0xa.2850a483f9ba0e43f5848b5cd8p+8L,
+ 0xe.e1b6bdce83b27944edab8c428p+8L,
+ /* Interval [-2.5, -2.375] (polynomial degree 25). */
+ -0xb.74ea1bcfff94b2c01afba9daa8p-4L,
+ -0x1.2a82bd590c37538cab143308e3p+0L,
+ 0x1.88020f828b966fec66b8648d16p+0L,
+ -0x3.32279f040eb694970e9db0308bp+0L,
+ 0x5.57ac82517767e68a72142041b4p+0L,
+ -0x9.c2aedcfe22833de438786dc658p+0L,
+ 0x1.12c132f1f5577f99dbfb7ecb408p+4L,
+ -0x1.ea94e26628a3de3557dc349db8p+4L,
+ 0x3.66b4ac4fa582f5cbe7e19d10c6p+4L,
+ -0x6.0cf746a9cf4cbcb0004cb01f66p+4L,
+ 0xa.c102ef2c20d5a313cbfd37f5b8p+4L,
+ -0x1.31ebff06e8f08f58d1c35eacfdp+8L,
+ 0x2.1fd6f0c0e788660ba1f1573722p+8L,
+ -0x3.c6d760404305e75356a86a11d6p+8L,
+ 0x6.b6d18e0c31a2ba4d5b5ac78676p+8L,
+ -0xb.efaf5426343e6b41a823ed6c44p+8L,
+ 0x1.53852db2fe01305b9f336d132d8p+12L,
+ -0x2.5b977cb2b568382e71ca93a36bp+12L,
+ 0x4.310d090a6119c7d85a2786a616p+12L,
+ -0x7.73a518387ef1d4d04917dfb25cp+12L,
+ 0xd.3f965798601aabd24bdaa6e68cp+12L,
+ -0x1.78db20b0b166480c93cf0031198p+16L,
+ 0x2.9be0068b65cf13bd1cf71f0eccp+16L,
+ -0x4.a221230466b9cd51d5b811d6b6p+16L,
+ 0x8.f6f8c13e2b52aa3e30a4ce6898p+16L,
+ -0x1.02145337ff16b44fa7c2adf7f28p+20L,
+ /* Interval [-2.625, -2.5] (polynomial degree 26). */
+ -0x3.d10108c27ebafad533c20eac33p-4L,
+ 0x1.cd557caff7d2b2085f41dbec538p+0L,
+ 0x3.819b4856d399520dad9776ebb9p+0L,
+ 0x6.8505cbad03dc34c5e42e89c4b4p+0L,
+ 0xb.c1b2e653a9e38f82b3997134a8p+0L,
+ 0x1.50a53a38f1481381051544750ep+4L,
+ 0x2.57ae00cbe5232cbeef4e94eb2cp+4L,
+ 0x4.2b156301b8604db82856d5767p+4L,
+ 0x7.6989ed23ca3ca751fc9c32eb88p+4L,
+ 0xd.2dd29765579396f3a456772c44p+4L,
+ 0x1.76e1c3430eb8630991d1aa8a248p+8L,
+ 0x2.9a77bf548873743fe65d025f56p+8L,
+ 0x4.a0d62ed7266389753842d7be74p+8L,
+ 0x8.3a6184dd32d31ec73fc6f2d37cp+8L,
+ 0xe.a0ade153a3bf0247db49e11ae8p+8L,
+ 0x1.a01359fa74d4eaf8858bbc35f68p+12L,
+ 0x2.e3b0a32845cbc135bae4a5216cp+12L,
+ 0x5.23012653815fe88456170a7dc6p+12L,
+ 0x9.21c92dcde748ec199bc9c65738p+12L,
+ 0x1.03c0f3621b4c67d2d86e5e813d8p+16L,
+ 0x1.cdc884edcc9f5404f2708551cb8p+16L,
+ 0x3.35025f0b1624d1ffc86688bf03p+16L,
+ 0x5.b3bd9562ebf2409c5ce99929ep+16L,
+ 0xa.1a229b1986d9f89cb80abccfdp+16L,
+ 0x1.1e69136ebd520146d51837f3308p+20L,
+ 0x2.2d2738c72449db2524171b9271p+20L,
+ 0x4.036e80cc6621b836f94f426834p+20L,
+ /* Interval [-2.75, -2.625] (polynomial degree 24). */
+ -0x6.b5d252a56e8a75458a27ed1c2ep-4L,
+ 0x1.28d60383da3ac721aed3c57949p+0L,
+ 0x1.db6513ada8a66ea77d87d9a796p+0L,
+ 0x2.e217118f9d348a27f7506c4b4fp+0L,
+ 0x4.450112c5cbf725a0fb982fc44cp+0L,
+ 0x6.4af99151eae7810a75a5fceac8p+0L,
+ 0x9.2db598b4a97a7f69ab7be31128p+0L,
+ 0xd.62bef9c22471f5f17955733c6p+0L,
+ 0x1.379f294e412bd6255506135f4a8p+4L,
+ 0x1.c5827349d8865d858d4f85f3c38p+4L,
+ 0x2.93a7e7a75b755bbea1785a1349p+4L,
+ 0x3.bf9bb882afed66a08b22ed7a45p+4L,
+ 0x5.73c737828d2044aca95fdef33ep+4L,
+ 0x7.ee46534920f1c81574db260f0ep+4L,
+ 0xb.891c6b837b513eaf1592fe78ccp+4L,
+ 0x1.0c775d815bf741526a3dd66ded8p+8L,
+ 0x1.867ee44cf11f26455a8924a56bp+8L,
+ 0x2.37fe968baa1018e55cae680f1dp+8L,
+ 0x3.3a2c557f686679eb5d8e960fd1p+8L,
+ 0x4.b1ba0539d4d80cc9174738b992p+8L,
+ 0x6.d3fd80155b6d2211956cb6bc5ap+8L,
+ 0x9.eb5a96b0ee3d9ca523f5fbc1fp+8L,
+ 0xe.6b37429c1acc7dc19ef312dda4p+8L,
+ 0x1.621132d6aa138b203a28e4792fp+12L,
+ 0x2.09610219270e2ce11a985d4d36p+12L,
+ /* Interval [-2.875, -2.75] (polynomial degree 23). */
+ -0x8.a41b1e4f36ff88dc820815607cp-4L,
+ 0xc.da87d3b69dc0f2f9c6f368b8c8p-4L,
+ 0x1.1474ad5c36158a7bea04fd30b28p+0L,
+ 0x1.761ecb90c555df6555b7dbb9ce8p+0L,
+ 0x1.d279bff9ae291caf6c4b17497f8p+0L,
+ 0x2.4e5d00559a6e2b9b5d7e35b575p+0L,
+ 0x2.d57545a75cee8743b1ff6e22b8p+0L,
+ 0x3.8514eee3aac88b89d2d4ddef4ep+0L,
+ 0x4.5235e3b6e1891fd9c975383318p+0L,
+ 0x5.562acdb10eef3c14a780490e3cp+0L,
+ 0x6.8ec8965c76f0b261bc41b5e532p+0L,
+ 0x8.15251aca144a98a1e1c0981388p+0L,
+ 0x9.f08d56ab9e7eee9515a457214cp+0L,
+ 0xc.3dbbeda2620d5be4fe8621ce6p+0L,
+ 0xf.0f5bfd65b3feb6d745a2cdbf9cp+0L,
+ 0x1.28a6ccd8dd27fb90fcaa31d37dp+4L,
+ 0x1.6d0a3a3091c3d64cfd1a3c5769p+4L,
+ 0x1.c1570107e02d5ab0b8bea6d6c98p+4L,
+ 0x2.28fc9b295b583fa469de7acceap+4L,
+ 0x2.a8a4cac0217026bbdbce34f4adp+4L,
+ 0x3.4532c98bce75262ac0ede53edep+4L,
+ 0x4.062fd9ba18e00e55c25a4f0688p+4L,
+ 0x5.22e00e6d9846a3451fad5587f8p+4L,
+ 0x6.5d0f7ce92a0bf928d4a30e92c6p+4L,
+ /* Interval [-3, -2.875] (polynomial degree 22). */
+ -0xa.046d667e468f3e44dcae1afcc8p-4L,
+ 0x9.70b88dcc006c214d8d996fdf7p-4L,
+ 0xa.a8a39421c86d3ff24931a093c4p-4L,
+ 0xd.2f4d1363f324da2b357c850124p-4L,
+ 0xd.ca9aa1a3a5c00de11bf5d7047p-4L,
+ 0xf.cf09c31eeb52a45dfb25e50ebcp-4L,
+ 0x1.04b133a39ed8a096914cc78812p+0L,
+ 0x1.22b547a06edda9447f516a2ee7p+0L,
+ 0x1.2c57fce7db86a91c8d0f12077b8p+0L,
+ 0x1.4aade4894708fb8b78365e9bf88p+0L,
+ 0x1.579c8b7b67ec5179ecc4e9c7dp+0L,
+ 0x1.776820e7fc7361c50e7ef40a88p+0L,
+ 0x1.883ab28c72ef238ada6c480ab18p+0L,
+ 0x1.aa2ef6e1d11b9fcea06a1dcab1p+0L,
+ 0x1.bf4ad50f2dd2aeb02395ea08648p+0L,
+ 0x1.e40206a5477615838e02279dfc8p+0L,
+ 0x1.fdcbcfd4b0777fb173b85d5b398p+0L,
+ 0x2.25e32b3b3c89e833029169a17bp+0L,
+ 0x2.44ce344ff0bda6570fe3d0a76dp+0L,
+ 0x2.70bfba6fa079faf2dbf31d2216p+0L,
+ 0x2.953e22a97725cc179ad21024fap+0L,
+ 0x2.d8ccc51524659a499eee0f267p+0L,
+ 0x3.080fbb09c14936c2171c8a51bcp+0L,
+ };
+
+static const size_t poly_deg[] =
+ {
+ 21,
+ 22,
+ 24,
+ 25,
+ 26,
+ 24,
+ 23,
+ 22,
+ };
+
+static const size_t poly_end[] =
+ {
+ 21,
+ 44,
+ 69,
+ 95,
+ 122,
+ 147,
+ 171,
+ 194,
+ };
+
+/* Compute sin (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_sinpi (long double x)
+{
+ if (x <= 0.25L)
+ return __sinl (M_PIl * x);
+ else
+ return __cosl (M_PIl * (0.5L - x));
+}
+
+/* Compute cos (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cospi (long double x)
+{
+ if (x <= 0.25L)
+ return __cosl (M_PIl * x);
+ else
+ return __sinl (M_PIl * (0.5L - x));
+}
+
+/* Compute cot (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cotpi (long double x)
+{
+ return lg_cospi (x) / lg_sinpi (x);
+}
+
+/* Compute lgamma of a negative argument -48 < X < -2, setting
+ *SIGNGAMP accordingly. */
+
+long double
+__lgamma_negl (long double x, int *signgamp)
+{
+ /* Determine the half-integer region X lies in, handle exact
+ integers and determine the sign of the result. */
+ int i = __floorl (-2 * x);
+ if ((i & 1) == 0 && i == -2 * x)
+ return 1.0L / 0.0L;
+ long double xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
+ i -= 4;
+ *signgamp = ((i & 2) == 0 ? -1 : 1);
+
+ SET_RESTORE_ROUNDL (FE_TONEAREST);
+
+ /* Expand around the zero X0 = X0_HI + X0_LO. */
+ long double x0_hi = lgamma_zeros[i][0], x0_lo = lgamma_zeros[i][1];
+ long double xdiff = x - x0_hi - x0_lo;
+
+ /* For arguments in the range -3 to -2, use polynomial
+ approximations to an adjusted version of the gamma function. */
+ if (i < 2)
+ {
+ int j = __floorl (-8 * x) - 16;
+ long double xm = (-33 - 2 * j) * 0.0625L;
+ long double x_adj = x - xm;
+ size_t deg = poly_deg[j];
+ size_t end = poly_end[j];
+ long double g = poly_coeff[end];
+ for (size_t j = 1; j <= deg; j++)
+ g = g * x_adj + poly_coeff[end - j];
+ return __log1pl (g * xdiff / (x - xn));
+ }
+
+ /* The result we want is log (sinpi (X0) / sinpi (X))
+ + log (gamma (1 - X0) / gamma (1 - X)). */
+ long double x_idiff = fabsl (xn - x), x0_idiff = fabsl (xn - x0_hi - x0_lo);
+ long double log_sinpi_ratio;
+ if (x0_idiff < x_idiff * 0.5L)
+ /* Use log not log1p to avoid inaccuracy from log1p of arguments
+ close to -1. */
+ log_sinpi_ratio = __ieee754_logl (lg_sinpi (x0_idiff)
+ / lg_sinpi (x_idiff));
+ else
+ {
+ /* Use log1p not log to avoid inaccuracy from log of arguments
+ close to 1. X0DIFF2 has positive sign if X0 is further from
+ XN than X is from XN, negative sign otherwise. */
+ long double x0diff2 = ((i & 1) == 0 ? xdiff : -xdiff) * 0.5L;
+ long double sx0d2 = lg_sinpi (x0diff2);
+ long double cx0d2 = lg_cospi (x0diff2);
+ log_sinpi_ratio = __log1pl (2 * sx0d2
+ * (-sx0d2 + cx0d2 * lg_cotpi (x_idiff)));
+ }
+
+ long double log_gamma_ratio;
+ long double y0 = 1 - x0_hi;
+ long double y0_eps = -x0_hi + (1 - y0) - x0_lo;
+ long double y = 1 - x;
+ long double y_eps = -x + (1 - y);
+ /* We now wish to compute LOG_GAMMA_RATIO
+ = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF
+ accurately approximates the difference Y0 + Y0_EPS - Y -
+ Y_EPS. Use Stirling's approximation. First, we may need to
+ adjust into the range where Stirling's approximation is
+ sufficiently accurate. */
+ long double log_gamma_adj = 0;
+ if (i < 18)
+ {
+ int n_up = (19 - i) / 2;
+ long double ny0, ny0_eps, ny, ny_eps;
+ ny0 = y0 + n_up;
+ ny0_eps = y0 - (ny0 - n_up) + y0_eps;
+ y0 = ny0;
+ y0_eps = ny0_eps;
+ ny = y + n_up;
+ ny_eps = y - (ny - n_up) + y_eps;
+ y = ny;
+ y_eps = ny_eps;
+ long double prodm1 = __lgamma_productl (xdiff, y - n_up, y_eps, n_up);
+ log_gamma_adj = -__log1pl (prodm1);
+ }
+ long double log_gamma_high
+ = (xdiff * __log1pl ((y0 - e_hi - e_lo + y0_eps) / e_hi)
+ + (y - 0.5L + y_eps) * __log1pl (xdiff / y) + log_gamma_adj);
+ /* Compute the sum of (B_2k / 2k(2k-1))(Y0^-(2k-1) - Y^-(2k-1)). */
+ long double y0r = 1 / y0, yr = 1 / y;
+ long double y0r2 = y0r * y0r, yr2 = yr * yr;
+ long double rdiff = -xdiff / (y * y0);
+ long double bterm[NCOEFF];
+ long double dlast = rdiff, elast = rdiff * yr * (yr + y0r);
+ bterm[0] = dlast * lgamma_coeff[0];
+ for (size_t j = 1; j < NCOEFF; j++)
+ {
+ long double dnext = dlast * y0r2 + elast;
+ long double enext = elast * yr2;
+ bterm[j] = dnext * lgamma_coeff[j];
+ dlast = dnext;
+ elast = enext;
+ }
+ long double log_gamma_low = 0;
+ for (size_t j = 0; j < NCOEFF; j++)
+ log_gamma_low += bterm[NCOEFF - 1 - j];
+ log_gamma_ratio = log_gamma_high + log_gamma_low;
+
+ return log_sinpi_ratio + log_gamma_ratio;
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c b/sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c
new file mode 100644
index 0000000000..c5fa81be8e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/lgamma_productl.c
@@ -0,0 +1,38 @@
+/* Compute a product of 1 + (T/X), 1 + (T/(X+1)), ....
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+
+long double
+__lgamma_productl (long double t, long double x, long double x_eps, int n)
+{
+ long double x_full = x + x_eps;
+ long double ret = 0;
+ for (int i = 0; i < n; i++)
+ /* FIXME: no extra precision used. */
+ ret += (t / (x_full + i)) * (1 + ret);
+ return ret;
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
index bacb2cc98b..42f5e6a02d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,12 +15,17 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include "gmp.h"
-#include "gmp-impl.h"
#include <ieee754.h>
+#include <errno.h>
#include <float.h>
#include <math.h>
+/* Need to set this when including gmp headers after system headers. */
+#define HAVE_ALLOCA 1
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
/* Convert a multi-precision integer of the needed number of bits (106
for long double) and an integral power of two to a `long double' in
IBM extended format. */
@@ -111,6 +116,14 @@ __mpn_construct_long_double (mp_srcptr frac_ptr, int expt, int sign)
{
hi >>= 1;
u.d[0].ieee.exponent++;
+ if (u.d[0].ieee.exponent == IEEE754_DOUBLE_BIAS + DBL_MAX_EXP)
+ {
+ /* Overflow. The appropriate overflowed result must
+ be produced (if an infinity, that means the low
+ part must be zero). */
+ __set_errno (ERANGE);
+ return (sign ? -LDBL_MAX : LDBL_MAX) * LDBL_MAX;
+ }
}
u.d[1].ieee.negative = !sign;
lo = (1LL << 53) - lo;
diff --git a/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c b/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c
index 1ceca89485..06be1c52d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c
+++ b/sysdeps/ieee754/ldbl-128ibm/printf_fphex.c
@@ -1,5 +1,5 @@
/* Print floating point number in hexadecimal notation according to ISO C99.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c b/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c
index dda7f780fc..aa9a9ba213 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_asinhl.c
@@ -46,11 +46,7 @@ long double __asinhl(long double x)
ix = hx&0x7fffffffffffffffLL;
if(ix>=0x7ff0000000000000LL) return x+x; /* x is inf or NaN */
if(ix< 0x3c70000000000000LL) { /* |x|<2**-56 */
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if(huge+x>one) return x; /* return x inexact except 0 */
}
if(ix>0x4370000000000000LL) { /* |x| > 2**56 */
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_atanl.c b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
index 6ddf4b1c5e..0560d820ae 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_atanl.c
@@ -199,11 +199,7 @@ __atanl (long double x)
if (k <= 0x3c800000) /* |x| <= 2**-55. */
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
/* Raise inexact. */
if (1e300L + x > 0.0)
return x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_ceill.c b/sysdeps/ieee754/ldbl-128ibm/s_ceill.c
index dc4209e9a1..ac649b7215 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_ceill.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_ceill.c
@@ -1,6 +1,6 @@
/* Ceil (round to +inf) long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_erfl.c b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
index f6fcf48cfa..7b761b0afa 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_erfl.c
@@ -106,6 +106,7 @@
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
+#include <fix-int-fp-convert-zero.h>
/* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */
@@ -146,7 +147,6 @@ deval (long double x, const long double *p, int n)
static const long double
tiny = 1e-300L,
- half = 0.5L,
one = 1.0L,
two = 2.0L,
/* 2/sqrt(pi) - 1 */
@@ -805,11 +805,7 @@ __erfl (long double x)
if (x == 0)
return x;
long double ret = 0.0625 * (16.0 * x + (16.0 * efx) * x);
- if (fabsl (ret) < LDBL_MIN)
- {
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
return ret;
}
return x + efx * x;
@@ -843,7 +839,10 @@ __erfcl (long double x)
if (ix >= 0x7ff00000)
{ /* erfc(nan)=nan */
/* erfc(+-inf)=0,2 */
- return (long double) ((hx >> 31) << 1) + one / x;
+ long double ret = (long double) ((hx >> 31) << 1) + one / x;
+ if (FIX_INT_FP_CONVERT_ZERO && ret == 0.0L)
+ return 0.0L;
+ return ret;
}
if (ix < 0x3fd00000) /* |x| <1/4 */
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c b/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c
index 0464f79043..66f75e1c80 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_expm1l.c
@@ -82,8 +82,6 @@ static const long double
C1 = 6.93145751953125E-1L,
C2 = 1.428606820309417232121458176568075500134E-6L,
-/* ln (2^16384 * (1 - 2^-113)) */
- maxlog = 1.1356523406294143949491931077970764891253E4L,
/* ln 2^-114 */
minarg = -7.9018778583833765273564461846232128760607E1L, big = 1e290L;
@@ -105,14 +103,9 @@ __expm1l (long double x)
return __expl (x);
if (ix >= 0x7ff00000)
{
- /* Infinity. */
+ /* Infinity (which must be negative infinity). */
if (((ix - 0x7ff00000) | lx) == 0)
- {
- if (sign)
- return -1.0L;
- else
- return x;
- }
+ return -1.0L;
/* NaN. No invalid exception. */
return x;
}
@@ -121,13 +114,6 @@ __expm1l (long double x)
if ((ix | lx) == 0)
return x;
- /* Overflow. */
- if (x > maxlog)
- {
- __set_errno (ERANGE);
- return (big * big);
- }
-
/* Minimum value. */
if (x < minarg)
return (4.0/big - 1.0L);
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_finitel.c b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
index b562ce60b6..3b9e3de292 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
@@ -34,7 +34,7 @@ ___finitel (long double x)
xhi = ldbl_high (x);
EXTRACT_WORDS64 (hx, xhi);
- hx &= 0x7fffffffffffffffLL;
+ hx &= 0x7ff0000000000000LL;
hx -= 0x7ff0000000000000LL;
return hx >> 63;
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_floorl.c b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
index c911f19247..912230870a 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
index 837444aa4c..eb3ee3cfb8 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2011-2015 Free Software Foundation, Inc.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Flaherty <flaherty@linux.vnet.ibm.com>.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c b/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
index a33c2cf73b..83c3a8dc51 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c
@@ -1,5 +1,5 @@
/* Return classification value corresponding to argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c b/sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c
deleted file mode 100644
index 54e72c9166..0000000000
--- a/sysdeps/ieee754/ldbl-128ibm/s_isinf_nsl.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * __isinf_nsl(x) returns != 0 if x is ±inf, else 0;
- * no branching!
- * slightly dodgy in relying on signed shift right copying sign bit
- */
-
-#include <math.h>
-#include <math_private.h>
-
-int
-__isinf_nsl (long double x)
-{
- double xhi;
- int64_t hx, mask;
-
- xhi = ldbl_high (x);
- EXTRACT_WORDS64 (hx, xhi);
-
- mask = (hx & 0x7fffffffffffffffLL) ^ 0x7ff0000000000000LL;
- mask |= -mask;
- mask >>= 63;
- return ~mask;
-}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c b/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c
index 98f692d706..091513908b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c
index 524340bbf4..860ede1e0b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_llrintl.c
@@ -1,6 +1,6 @@
/* Round to long long int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c
index c8224b01a4..9fba087d5b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_llroundl.c
@@ -1,6 +1,6 @@
/* Round to long long int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c b/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c
index a0e24d7f22..743693bfd6 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_log1pl.c
@@ -117,8 +117,6 @@ static const long double C2 = 1.428606820309417232121458176568075500134E-6L;
static const long double sqrth = 0.7071067811865475244008443621048490392848L;
/* ln (2^16384 * (1 - 2^-113)) */
-static const long double maxlog = 1.1356523406294143949491931077970764891253E4L;
-static const long double big = 2e300L;
static const long double zero = 0.0L;
@@ -149,7 +147,7 @@ __log1pl (long double xm1)
if (x <= 0.0L)
{
if (x == 0.0L)
- return (-1.0L / (x - x));
+ return (-1.0L / 0.0L);
else
return (zero / (x - x));
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
index 22e5fc24c0..3c07c5e8e2 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
@@ -22,6 +22,7 @@
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
+#include <fix-int-fp-convert-zero.h>
long double
__logbl (long double x)
@@ -53,6 +54,8 @@ __logbl (long double x)
if ((hxs ^ lx) < 0 && (lx & 0x7fffffffffffffffLL) != 0)
rhx--;
}
+ if (FIX_INT_FP_CONVERT_ZERO && rhx == 1023)
+ return 0.0L;
return (long double) (rhx - 1023);
}
#ifndef __logbl
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
index c5756cae12..988de70c5a 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_lrintl.c
@@ -1,6 +1,6 @@
/* Round to long int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
index 42790a5bab..aa48f680d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_lroundl.c
@@ -1,6 +1,6 @@
/* Round to long int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
index ef1b3dca1e..08134edd10 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values without raising inexact.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,7 +36,9 @@ __nearbyintl (long double x)
union ibm_extended_long_double u;
u.ld = x;
- if (fabs (u.d[0].d) < TWO52)
+ if (!isfinite (u.d[0].d))
+ return x;
+ else if (fabs (u.d[0].d) < TWO52)
{
double xh = u.d[0].d;
double high = u.d[0].d;
@@ -65,7 +67,7 @@ __nearbyintl (long double x)
}
else if (fabs (u.d[1].d) < TWO52 && u.d[1].d != 0.0)
{
- double high, low, tau;
+ double high = u.d[0].d, low = u.d[1].d, tau;
/* In this case we have to round the low double and handle any
adjustment to the high double that may be caused by rounding
(up). This is complicated by the fact that the high double
@@ -78,8 +80,6 @@ __nearbyintl (long double x)
{
/* If the high/low doubles are the same sign then simply
round the low double. */
- high = u.d[0].d;
- low = u.d[1].d;
}
else if (u.d[1].d < 0.0)
{
@@ -88,8 +88,8 @@ __nearbyintl (long double x)
tau = __nextafter (u.d[0].d, 0.0);
tau = (u.d[0].d - tau) * 2.0;
- high = u.d[0].d - tau;
- low = u.d[1].d + tau;
+ high -= tau;
+ low += tau;
}
low += TWO52;
low -= TWO52;
@@ -100,8 +100,6 @@ __nearbyintl (long double x)
{
/* If the high/low doubles are the same sign then simply
round the low double. */
- high = u.d[0].d;
- low = u.d[1].d;
}
else if (u.d[1].d > 0.0)
{
@@ -109,8 +107,8 @@ __nearbyintl (long double x)
adjust for that. */
tau = __nextafter (u.d[0].d, 0.0);
tau = (u.d[0].d - tau) * 2.0;
- high = u.d[0].d - tau;
- low = u.d[1].d + tau;
+ high -= tau;
+ low += tau;
}
low = TWO52 - low;
low = -(low - TWO52);
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
index bf57cb89d6..515aa1ef5b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c
@@ -24,6 +24,8 @@ static char rcsid[] = "$NetBSD: $";
* Special cases:
*/
+#include <errno.h>
+#include <float.h>
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
@@ -68,6 +70,7 @@ long double __nextafterl(long double x, long double y)
if((hx==0xffefffffffffffffLL)&&(lx==0xfc8ffffffffffffeLL)) {
u = x+x; /* overflow, return -inf */
math_force_eval (u);
+ __set_errno (ERANGE);
return y;
}
if (hx >= 0x7ff0000000000000LL) {
@@ -76,12 +79,13 @@ long double __nextafterl(long double x, long double y)
}
if(ihx <= 0x0360000000000000LL) { /* x <= LDBL_MIN */
u = math_opt_barrier (x);
- x -= __LDBL_DENORM_MIN__;
+ x -= LDBL_TRUE_MIN;
if (ihx < 0x0360000000000000LL
|| (hx > 0 && lx <= 0)
|| (hx < 0 && lx > 1)) {
u = u * u;
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
return x;
}
@@ -107,6 +111,7 @@ long double __nextafterl(long double x, long double y)
if((hx==0x7fefffffffffffffLL)&&(lx==0x7c8ffffffffffffeLL)) {
u = x+x; /* overflow, return +inf */
math_force_eval (u);
+ __set_errno (ERANGE);
return y;
}
if ((uint64_t) hx >= 0xfff0000000000000ULL) {
@@ -115,14 +120,15 @@ long double __nextafterl(long double x, long double y)
}
if(ihx <= 0x0360000000000000LL) { /* x <= LDBL_MIN */
u = math_opt_barrier (x);
- x += __LDBL_DENORM_MIN__;
+ x += LDBL_TRUE_MIN;
if (ihx < 0x0360000000000000LL
|| (hx > 0 && lx < 0 && lx != 0x8000000000000001LL)
|| (hx < 0 && lx >= 0)) {
u = u * u;
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
- if (x == 0.0L) /* handle negative __LDBL_DENORM_MIN__ case */
+ if (x == 0.0L) /* handle negative LDBL_TRUE_MIN case */
x = -0.0L;
return x;
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
index b40cf167f3..d8f4fc6523 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttoward.c
@@ -25,6 +25,7 @@ static char rcsid[] = "$NetBSD: $";
* Special cases:
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
@@ -74,15 +75,14 @@ double __nexttoward(double x, long double y)
}
hy = hx&0x7ff00000;
if(hy>=0x7ff00000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
- /* Force conversion to double. */
- asm ("" : "+m"(x));
- return x;
+ double u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00100000) {
double u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
INSERT_WORDS(x,hx,lx);
return x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
index 19522f4762..7c5d1cc112 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c
@@ -18,6 +18,7 @@
static char rcsid[] = "$NetBSD: $";
#endif
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
@@ -63,15 +64,14 @@ float __nexttowardf(float x, long double y)
}
hy = hx&0x7f800000;
if(hy>=0x7f800000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0)
- /* Force conversion to float. */
- asm ("" : "+m"(x));
- return x;
+ float u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00800000) { /* underflow */
float u = x*x;
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_FLOAT_WORD(x,hx);
return x;
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_remquol.c b/sysdeps/ieee754/ldbl-128ibm/s_remquol.c
index 57c50590c9..20e17cc823 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_remquol.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_remquol.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>, 1999.
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_rintl.c b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
index d00abe860c..8c51ded1d6 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_rintl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_roundl.c b/sysdeps/ieee754/ldbl-128ibm/s_roundl.c
index ed8e00ab71..20813ed366 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_roundl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_roundl.c
@@ -1,6 +1,6 @@
/* Round to int long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c b/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c
index a0d7aa9d63..0c4508835e 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c
@@ -102,8 +102,3 @@ long double __scalbnl (long double x, int n)
x = ldbl_pack (xhi, xlo);
return x*twolm54;
}
-#if IS_IN (libm)
-long_double_symbol (libm, __scalbnl, scalbnl);
-#else
-long_double_symbol (libc, __scalbnl, scalbnl);
-#endif
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c
index e95ad55e32..b4e8256329 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_signbitl.c
@@ -1,5 +1,5 @@
/* Return nonzero value if number is negative.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,18 +18,12 @@
<http://www.gnu.org/licenses/>. */
#include <math.h>
-#include <math_private.h>
#include <math_ldbl_opt.h>
int
___signbitl (long double x)
{
- int64_t e;
- double xhi;
-
- xhi = ldbl_high (x);
- EXTRACT_WORDS64 (e, xhi);
- return e < 0;
+ return __builtin_signbitl (x);
}
#if IS_IN (libm)
long_double_symbol (libm, ___signbitl, __signbitl);
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c
index 8a49c54d6c..fae4020a7b 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_sincosl.c
@@ -1,5 +1,5 @@
/* Compute sine and cosine of argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997 and
Jakub Jelinek <jj@ultra.linux.cz>.
@@ -42,7 +42,7 @@ __sincosl (long double x, long double *sinx, long double *cosx)
{
/* sin(Inf or NaN) is NaN */
*sinx = *cosx = x - x;
- if (__isinf_nsl (x))
+ if (isinf (x))
__set_errno (EDOM);
}
else
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
index c63e25345d..e6457a1c1c 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_tanhl.c
@@ -29,15 +29,16 @@ static char rcsid[] = "$NetBSD: s_tanh.c,v 1.7 1995/05/10 20:48:22 jtc Exp $";
* 2**-57 < x <= 1 : tanh(x) := -----; t = expm1(-2x)
* t + 2
* 2
- * 1 <= x <= 22.0 : tanh(x) := 1- ----- ; t=expm1(2x)
+ * 1 <= x <= 40.0 : tanh(x) := 1- ----- ; t=expm1(2x)
* t + 2
- * 22.0 < x <= INF : tanh(x) := 1.
+ * 40.0 < x <= INF : tanh(x) := 1.
*
* Special cases:
* tanh(NaN) is NaN;
* only tanh(0)=0 is exact for finite argument.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
@@ -61,12 +62,15 @@ long double __tanhl(long double x)
else return one/x-one; /* tanh(NaN) = NaN */
}
- /* |x| < 22 */
- if (ix < 0x4036000000000000LL) { /* |x|<22 */
+ /* |x| < 40 */
+ if (ix < 0x4044000000000000LL) { /* |x|<40 */
if (ix == 0)
return x; /* x == +-0 */
if (ix<0x3c60000000000000LL) /* |x|<2**-57 */
- return x*(one+x); /* tanh(small) = small */
+ {
+ math_check_force_underflow (x);
+ return x; /* tanh(small) = small */
+ }
if (ix>=0x3ff0000000000000LL) { /* |x|>=1 */
t = __expm1l(two*fabsl(x));
z = one - two/(t+two);
@@ -74,7 +78,7 @@ long double __tanhl(long double x)
t = __expm1l(-two*fabsl(x));
z= -t/(t+two);
}
- /* |x| > 22, return +-1 */
+ /* |x| > 40, return +-1 */
} else {
z = one - tiny; /* raised inexact flag */
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_truncl.c b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
index 91dc9753f9..df58b64b53 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
@@ -1,6 +1,6 @@
/* Truncate (toward zero) long double floating-point values.
IBM extended format long double version.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h
new file mode 100644
index 0000000000..d827112446
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/strtod_nan_ldouble.h
@@ -0,0 +1,30 @@
+/* Convert string for NaN payload to corresponding NaN. For ldbl-128ibm.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FLOAT long double
+#define SET_MANTISSA(flt, mant) \
+ do \
+ { \
+ union ibm_extended_long_double u; \
+ u.ld = (flt); \
+ u.d[0].ieee_nan.mantissa0 = (mant) >> 32; \
+ u.d[0].ieee_nan.mantissa1 = (mant); \
+ if ((u.d[0].ieee.mantissa0 | u.d[0].ieee.mantissa1) != 0) \
+ (flt) = u.ld; \
+ } \
+ while (0)
diff --git a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
index 3e2f69e353..a8181740a8 100644
--- a/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,25 +30,19 @@ extern long double ____new_wcstold_l (const wchar_t *, wchar_t **, __locale_t);
# define STRTOF __new_wcstold_l
# define __STRTOF ____new_wcstold_l
# define ____STRTOF_INTERNAL ____wcstold_l_internal
+# define STRTOF_NAN __wcstold_nan
#else
extern long double ____new_strtold_l (const char *, char **, __locale_t);
# define STRTOF __new_strtold_l
# define __STRTOF ____new_strtold_l
# define ____STRTOF_INTERNAL ____strtold_l_internal
+# define STRTOF_NAN __strtold_nan
#endif
extern __typeof (__STRTOF) STRTOF;
libc_hidden_proto (__STRTOF)
libc_hidden_proto (STRTOF)
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
-# define SET_MANTISSA(flt, mant) \
- do { union ibm_extended_long_double u; \
- u.ld = (flt); \
- u.d[0].ieee_nan.mantissa0 = (mant) >> 32; \
- u.d[0].ieee_nan.mantissa1 = (mant); \
- if ((u.d[0].ieee.mantissa0 | u.d[0].ieee.mantissa1) != 0) \
- (flt) = u.ld; \
- } while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c b/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c
index a688577c2f..737c7c73fa 100644
--- a/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/t_sincosl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine and cosine tables.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c
new file mode 100644
index 0000000000..14dc683619
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/tst-strtold-ldbl-128ibm.c
@@ -0,0 +1,85 @@
+/* Test for ldbl-128ibm strtold overflow to infinity (bug 14551).
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fenv.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+test_strtold_value (const char *s, double exp_hi, double exp_lo, int exp_exc,
+ int exp_errno)
+{
+ int result = 0;
+ union { long double ld; double d[2]; } x;
+ feclearexcept (FE_ALL_EXCEPT);
+ errno = 0;
+ x.ld = strtold (s, NULL);
+ int exc = fetestexcept (FE_ALL_EXCEPT);
+ int new_errno = errno;
+ printf ("strtold (\"%s\") returned (%a, %a), exceptions 0x%x, errno %d\n",
+ s, x.d[0], x.d[1], exc, new_errno);
+ if (x.d[0] == exp_hi)
+ printf ("PASS: strtold (\"%s\") high == %a\n", s, exp_hi);
+ else
+ {
+ printf ("FAIL: strtold (\"%s\") high == %a\n", s, exp_hi);
+ result = 1;
+ }
+ if (x.d[1] == exp_lo)
+ printf ("PASS: strtold (\"%s\") low == %a\n", s, exp_lo);
+ else
+ {
+ printf ("FAIL: strtold (\"%s\") low == %a\n", s, exp_lo);
+ result = 1;
+ }
+ if (exc == exp_exc)
+ printf ("PASS: strtold (\"%s\") exceptions 0x%x\n", s, exp_exc);
+ else
+ {
+ printf ("FAIL: strtold (\"%s\") exceptions 0x%x\n", s, exp_exc);
+ result = 1;
+ }
+ if (new_errno == exp_errno)
+ printf ("PASS: strtold (\"%s\") errno %d\n", s, exp_errno);
+ else
+ {
+ printf ("FAIL: strtold (\"%s\") errno %d\n", s, exp_errno);
+ result = 1;
+ }
+ return result;
+}
+
+static int
+do_test (void)
+{
+ int result = 0;
+ result |= test_strtold_value ("0x1.fffffffffffff8p+1023", INFINITY, 0,
+ FE_OVERFLOW | FE_INEXACT, ERANGE);
+ result |= test_strtold_value ("-0x1.fffffffffffff8p+1023", -INFINITY, 0,
+ FE_OVERFLOW | FE_INEXACT, ERANGE);
+ result |= test_strtold_value ("0x1.ffffffffffffffp+1023", INFINITY, 0,
+ FE_OVERFLOW | FE_INEXACT, ERANGE);
+ result |= test_strtold_value ("-0x1.ffffffffffffffp+1023", -INFINITY, 0,
+ FE_OVERFLOW | FE_INEXACT, ERANGE);
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../../../test-skeleton.c"
diff --git a/sysdeps/ieee754/ldbl-128ibm/w_expl.c b/sysdeps/ieee754/ldbl-128ibm/w_expl.c
index fb5c8d3629..c9d44b61dd 100644
--- a/sysdeps/ieee754/ldbl-128ibm/w_expl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/w_expl.c
@@ -2,9 +2,6 @@
#include <math_private.h>
#include <math_ldbl_opt.h>
-static const long double o_thres = 709.78271289338399678773454114191496482L;
-static const long double u_thres = -744.44007192138126231410729844608163411L;
-
long double __expl(long double x) /* wrapper exp */
{
long double z;
@@ -13,9 +10,9 @@ long double __expl(long double x) /* wrapper exp */
return z;
if (isfinite(x))
{
- if (x >= o_thres)
+ if (!isfinite (z))
return __kernel_standard_l(x,x,206); /* exp overflow */
- else if (x <= u_thres)
+ else if (z == 0.0L)
return __kernel_standard_l(x,x,207); /* exp underflow */
}
return z;
diff --git a/sysdeps/ieee754/ldbl-128ibm/w_log1pl.c b/sysdeps/ieee754/ldbl-128ibm/w_log1pl.c
index 279a62a0f4..969fadc205 100644
--- a/sysdeps/ieee754/ldbl-128ibm/w_log1pl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/w_log1pl.c
@@ -1,5 +1,5 @@
/* Wrapper for __log1pl that handles setting errno.
- Copyright (C) 2015 Free Software Foundation, Inc.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/w_scalblnl.c b/sysdeps/ieee754/ldbl-128ibm/w_scalblnl.c
index 32d4a14ca9..7e73c9abf8 100644
--- a/sysdeps/ieee754/ldbl-128ibm/w_scalblnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/w_scalblnl.c
@@ -1,5 +1,5 @@
/* Wrapper for __scalblnl handles setting errno.
- Copyright (C) 2014-2015 Free Software Foundation, Inc.
+ Copyright (C) 2014-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c b/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
index a001b58ca5..da2e929175 100644
--- a/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -80,13 +80,13 @@ compare (const void *p, const void *q)
}
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
long double
__x2y2m1l (long double x, long double y)
{
- double vals[12];
+ double vals[13];
SET_RESTORE_ROUND (FE_TONEAREST);
union ibm_extended_long_double xu, yu;
xu.ld = x;
@@ -105,25 +105,19 @@ __x2y2m1l (long double x, long double y)
vals[8] *= 2.0;
vals[9] *= 2.0;
mul_split (&vals[11], &vals[10], yu.d[1].d, yu.d[1].d);
- if (xu.d[0].d >= 0.75)
- vals[1] -= 1.0;
- else
- {
- vals[1] -= 0.5;
- vals[7] -= 0.5;
- }
- qsort (vals, 12, sizeof (double), compare);
+ vals[12] = -1.0;
+ qsort (vals, 13, sizeof (double), compare);
/* Add up the values so that each element of VALS has absolute value
at most equal to the last set bit of the next nonzero
element. */
- for (size_t i = 0; i <= 10; i++)
+ for (size_t i = 0; i <= 11; i++)
{
add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]);
- qsort (vals + i + 1, 11 - i, sizeof (double), compare);
+ qsort (vals + i + 1, 12 - i, sizeof (double), compare);
}
/* Now any error from this addition will be small. */
- long double retval = (long double) vals[11];
- for (size_t i = 10; i != (size_t) -1; i--)
+ long double retval = (long double) vals[12];
+ for (size_t i = 11; i != (size_t) -1; i--)
retval += (long double) vals[i];
return retval;
}
diff --git a/sysdeps/ieee754/ldbl-64-128/s_scalbnl.c b/sysdeps/ieee754/ldbl-64-128/s_scalbnl.c
index fe2412b97a..15af1b2849 100644
--- a/sysdeps/ieee754/ldbl-64-128/s_scalbnl.c
+++ b/sysdeps/ieee754/ldbl-64-128/s_scalbnl.c
@@ -2,8 +2,3 @@
#undef weak_alias
#define weak_alias(n,a)
#include <sysdeps/ieee754/ldbl-128/s_scalbnl.c>
-#if IS_IN (libm)
-long_double_symbol (libm, __scalbnl, scalbnl);
-#else
-long_double_symbol (libc, __scalbnl, scalbnl);
-#endif
diff --git a/sysdeps/ieee754/ldbl-64-128/strtold_l.c b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
index 3944a43643..a8181740a8 100644
--- a/sysdeps/ieee754/ldbl-64-128/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-64-128/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -30,28 +30,19 @@ extern long double ____new_wcstold_l (const wchar_t *, wchar_t **, __locale_t);
# define STRTOF __new_wcstold_l
# define __STRTOF ____new_wcstold_l
# define ____STRTOF_INTERNAL ____wcstold_l_internal
+# define STRTOF_NAN __wcstold_nan
#else
extern long double ____new_strtold_l (const char *, char **, __locale_t);
# define STRTOF __new_strtold_l
# define __STRTOF ____new_strtold_l
# define ____STRTOF_INTERNAL ____strtold_l_internal
+# define STRTOF_NAN __strtold_nan
#endif
extern __typeof (__STRTOF) STRTOF;
libc_hidden_proto (__STRTOF)
libc_hidden_proto (STRTOF)
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
-#define SET_MANTISSA(flt, mant) \
- do { union ieee854_long_double u; \
- u.d = (flt); \
- u.ieee_nan.mantissa0 = 0; \
- u.ieee_nan.mantissa1 = 0; \
- u.ieee_nan.mantissa2 = (mant) >> 32; \
- u.ieee_nan.mantissa3 = (mant); \
- if ((u.ieee.mantissa0 | u.ieee.mantissa1 \
- | u.ieee.mantissa2 | u.ieee.mantissa3) != 0) \
- (flt) = u.d; \
- } while (0)
#include <strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-64-128/w_log1pl.c b/sysdeps/ieee754/ldbl-64-128/w_log1pl.c
index 279a62a0f4..969fadc205 100644
--- a/sysdeps/ieee754/ldbl-64-128/w_log1pl.c
+++ b/sysdeps/ieee754/ldbl-64-128/w_log1pl.c
@@ -1,5 +1,5 @@
/* Wrapper for __log1pl that handles setting errno.
- Copyright (C) 2015 Free Software Foundation, Inc.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-64-128/w_scalblnl.c b/sysdeps/ieee754/ldbl-64-128/w_scalblnl.c
index 142d80c3e3..05d4dfe05b 100644
--- a/sysdeps/ieee754/ldbl-64-128/w_scalblnl.c
+++ b/sysdeps/ieee754/ldbl-64-128/w_scalblnl.c
@@ -1,5 +1,5 @@
/* Wrapper for __scalblnl handles setting errno.
- Copyright (C) 2014-2015 Free Software Foundation, Inc.
+ Copyright (C) 2014-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/e_asinl.c b/sysdeps/ieee754/ldbl-96/e_asinl.c
index 2973bf071b..f52b931459 100644
--- a/sysdeps/ieee754/ldbl-96/e_asinl.c
+++ b/sysdeps/ieee754/ldbl-96/e_asinl.c
@@ -112,11 +112,7 @@ __ieee754_asinl (long double x)
{ /* |x|<0.5 */
if (ix < 0x3fde8000)
{ /* if |x| < 2**-33 */
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (huge + x > one)
return x; /* return x with inexact if x!=0 */
}
diff --git a/sysdeps/ieee754/ldbl-96/e_atanhl.c b/sysdeps/ieee754/ldbl-96/e_atanhl.c
index 9a957c9065..b99a83c6ee 100644
--- a/sysdeps/ieee754/ldbl-96/e_atanhl.c
+++ b/sysdeps/ieee754/ldbl-96/e_atanhl.c
@@ -55,11 +55,7 @@ __ieee754_atanhl(long double x)
return x/zero;
if(ix<0x3fdf) {
math_force_eval(huge+x);
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
return x; /* x<2**-32 */
}
SET_LDOUBLE_EXP(x,ix);
diff --git a/sysdeps/ieee754/ldbl-96/e_gammal_r.c b/sysdeps/ieee754/ldbl-96/e_gammal_r.c
index 9da5db33f0..8dd7a03918 100644
--- a/sysdeps/ieee754/ldbl-96/e_gammal_r.c
+++ b/sysdeps/ieee754/ldbl-96/e_gammal_r.c
@@ -1,5 +1,5 @@
/* Implementation of gamma function according to ISO C.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -186,6 +186,7 @@ __ieee754_gammal_r (long double x, int *signgamp)
ret = M_PIl / (-x * sinpix
* gammal_positive (-x, &exp2_adj));
ret = __scalbnl (ret, -exp2_adj);
+ math_check_force_underflow_nonneg (ret);
}
}
}
diff --git a/sysdeps/ieee754/ldbl-96/e_hypotl.c b/sysdeps/ieee754/ldbl-96/e_hypotl.c
index d3152f91e5..ee3a07055b 100644
--- a/sysdeps/ieee754/ldbl-96/e_hypotl.c
+++ b/sysdeps/ieee754/ldbl-96/e_hypotl.c
@@ -132,7 +132,9 @@ long double __ieee754_hypotl(long double x, long double y)
t1 = 1.0;
GET_LDOUBLE_EXP(exp,t1);
SET_LDOUBLE_EXP(t1,exp+k);
- return t1*w;
+ w *= t1;
+ math_check_force_underflow_nonneg (w);
+ return w;
} else return w;
}
strong_alias (__ieee754_hypotl, __hypotl_finite)
diff --git a/sysdeps/ieee754/ldbl-96/e_j1l.c b/sysdeps/ieee754/ldbl-96/e_j1l.c
index 46e28dfe11..e8a7349cf4 100644
--- a/sysdeps/ieee754/ldbl-96/e_j1l.c
+++ b/sysdeps/ieee754/ldbl-96/e_j1l.c
@@ -154,11 +154,9 @@ __ieee754_j1l (long double x)
if (huge + x > one) /* inexact if x!=0 necessary */
{
long double ret = 0.5 * x;
- if (fabsl (ret) < LDBL_MIN)
- {
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
+ if (ret == 0 && x != 0)
+ __set_errno (ERANGE);
return ret;
}
}
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 2f3a452f55..92f96921a7 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -289,12 +289,12 @@ __ieee754_jnl (int n, long double x)
ret = b;
}
if (ret == 0)
- ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
- else if (fabsl (ret) < LDBL_MIN)
{
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
+ ret = __copysignl (LDBL_MIN, ret) * LDBL_MIN;
+ __set_errno (ERANGE);
}
+ else
+ math_check_force_underflow (ret);
return ret;
}
strong_alias (__ieee754_jnl, __jnl_finite)
diff --git a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
index 0cc35f9252..9862fe8d5c 100644
--- a/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
+++ b/sysdeps/ieee754/ldbl-96/e_lgammal_r.c
@@ -306,6 +306,8 @@ __ieee754_lgammal_r (long double x, int *signgamp)
}
if (se & 0x8000)
{
+ if (x < -2.0L && x > -33.0L)
+ return __lgamma_negl (x, signgamp);
t = sin_pi (x);
if (t == zero)
return one / fabsl (t); /* -integer */
@@ -428,11 +430,7 @@ __ieee754_lgammal_r (long double x, int *signgamp)
in warnings that it may be used uninitialized although in the
cases where it is used it has always been set. */
DIAG_PUSH_NEEDS_COMMENT;
-#if __GNUC_PREREQ (4, 7)
DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wmaybe-uninitialized");
-#else
- DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wuninitialized");
-#endif
if (se & 0x8000)
r = nadj - r;
DIAG_POP_NEEDS_COMMENT;
diff --git a/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c b/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c
index d05afce623..0d8e64675c 100644
--- a/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c
+++ b/sysdeps/ieee754/ldbl-96/e_rem_pio2l.c
@@ -1,5 +1,5 @@
/* Extended-precision floating point argument reduction.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on quad-precision code by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-96/e_sinhl.c b/sysdeps/ieee754/ldbl-96/e_sinhl.c
index 4978f348bb..095b142621 100644
--- a/sysdeps/ieee754/ldbl-96/e_sinhl.c
+++ b/sysdeps/ieee754/ldbl-96/e_sinhl.c
@@ -36,6 +36,7 @@ static char rcsid[] = "$NetBSD: $";
* only sinhl(0)=0 is exact for finite x.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -58,8 +59,10 @@ __ieee754_sinhl(long double x)
if (jx & 0x8000) h = -h;
/* |x| in [0,25], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x4003 || (ix == 0x4003 && i0 <= 0xc8000000)) { /* |x|<25 */
- if (ix<0x3fdf) /* |x|<2**-32 */
+ if (ix<0x3fdf) { /* |x|<2**-32 */
+ math_check_force_underflow (x);
if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
+ }
t = __expm1l(fabsl(x));
if(ix<0x3fff) return h*(2.0*t-t*t/(t+one));
return h*(t+t/(t+one));
diff --git a/sysdeps/ieee754/ldbl-96/gamma_product.c b/sysdeps/ieee754/ldbl-96/gamma_product.c
index e113e23723..419d11598f 100644
--- a/sysdeps/ieee754/ldbl-96/gamma_product.c
+++ b/sysdeps/ieee754/ldbl-96/gamma_product.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -36,10 +36,7 @@ __gamma_product (double x, double x_eps, int n, double *eps)
for (int i = 1; i < n; i++)
ret *= x_full + i;
-#if FLT_EVAL_METHOD != 0
- volatile
-#endif
- double fret = ret;
+ double fret = math_narrow_eval ((double) ret);
*eps = (ret - fret) / fret;
return fret;
diff --git a/sysdeps/ieee754/ldbl-96/gamma_productl.c b/sysdeps/ieee754/ldbl-96/gamma_productl.c
index 32990b8f1c..849b57d95d 100644
--- a/sysdeps/ieee754/ldbl-96/gamma_productl.c
+++ b/sysdeps/ieee754/ldbl-96/gamma_productl.c
@@ -1,5 +1,5 @@
/* Compute a product of X, X+1, ..., with an error estimate.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/k_cosl.c b/sysdeps/ieee754/ldbl-96/k_cosl.c
index 95d64bd014..08b11b3733 100644
--- a/sysdeps/ieee754/ldbl-96/k_cosl.c
+++ b/sysdeps/ieee754/ldbl-96/k_cosl.c
@@ -1,5 +1,5 @@
/* Extended-precision floating point cosine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on quad-precision cosine by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-96/k_sinl.c b/sysdeps/ieee754/ldbl-96/k_sinl.c
index b7b5ae359d..6ba7ceddc0 100644
--- a/sysdeps/ieee754/ldbl-96/k_sinl.c
+++ b/sysdeps/ieee754/ldbl-96/k_sinl.c
@@ -1,5 +1,5 @@
/* Quad-precision floating point sine on <-pi/4,pi/4>.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on quad-precision sine by Jakub Jelinek <jj@ultra.linux.cz>
@@ -96,11 +96,7 @@ __kernel_sinl(long double x, long double y, int iy)
polynomial of degree 17. */
if (absx < 0x1p-33L)
{
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if (!((int)x)) return x; /* generate inexact */
}
z = x * x;
diff --git a/sysdeps/ieee754/ldbl-96/k_tanl.c b/sysdeps/ieee754/ldbl-96/k_tanl.c
index 31cd236aa2..0c050c112f 100644
--- a/sysdeps/ieee754/ldbl-96/k_tanl.c
+++ b/sysdeps/ieee754/ldbl-96/k_tanl.c
@@ -56,6 +56,8 @@
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
+#include <float.h>
+#include <libc-internal.h>
#include <math.h>
#include <math_private.h>
static const long double
@@ -94,8 +96,13 @@ __kernel_tanl (long double x, long double y, int iy)
{ /* generate inexact */
if (x == 0 && iy == -1)
return one / fabsl (x);
+ else if (iy == 1)
+ {
+ math_check_force_underflow_nonneg (absx);
+ return x;
+ }
else
- return (iy == 1) ? x : -one / x;
+ return -one / x;
}
}
if (absx >= 0.6743316650390625L)
@@ -126,8 +133,15 @@ __kernel_tanl (long double x, long double y, int iy)
{
v = (long double) iy;
w = (v - 2.0 * (x - (w * w / (w + v) - r)));
+ /* SIGN is set for arguments that reach this code, but not
+ otherwise, resulting in warnings that it may be used
+ uninitialized although in the cases where it is used it has
+ always been set. */
+ DIAG_PUSH_NEEDS_COMMENT;
+ DIAG_IGNORE_NEEDS_COMMENT (4.8, "-Wmaybe-uninitialized");
if (sign < 0)
w = -w;
+ DIAG_POP_NEEDS_COMMENT;
return w;
}
if (iy == 1)
diff --git a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c
index 26efea18f6..fe7002f640 100644
--- a/sysdeps/ieee754/ldbl-96/ldbl2mpn.c
+++ b/sysdeps/ieee754/ldbl-96/ldbl2mpn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/lgamma_negl.c b/sysdeps/ieee754/ldbl-96/lgamma_negl.c
new file mode 100644
index 0000000000..99ecf7e85f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/lgamma_negl.c
@@ -0,0 +1,418 @@
+/* lgammal expanding around zeros.
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <float.h>
+#include <math.h>
+#include <math_private.h>
+
+static const long double lgamma_zeros[][2] =
+ {
+ { -0x2.74ff92c01f0d82acp+0L, 0x1.360cea0e5f8ed3ccp-68L },
+ { -0x2.bf6821437b201978p+0L, -0x1.95a4b4641eaebf4cp-64L },
+ { -0x3.24c1b793cb35efb8p+0L, -0xb.e699ad3d9ba6545p-68L },
+ { -0x3.f48e2a8f85fca17p+0L, -0xd.4561291236cc321p-68L },
+ { -0x4.0a139e16656030cp+0L, -0x3.9f0b0de18112ac18p-64L },
+ { -0x4.fdd5de9bbabf351p+0L, -0xd.0aa4076988501d8p-68L },
+ { -0x5.021a95fc2db64328p+0L, -0x2.4c56e595394decc8p-64L },
+ { -0x5.ffa4bd647d0357ep+0L, 0x2.b129d342ce12071cp-64L },
+ { -0x6.005ac9625f233b6p+0L, -0x7.c2d96d16385cb868p-68L },
+ { -0x6.fff2fddae1bbff4p+0L, 0x2.9d949a3dc02de0cp-64L },
+ { -0x7.000cff7b7f87adf8p+0L, 0x3.b7d23246787d54d8p-64L },
+ { -0x7.fffe5fe05673c3c8p+0L, -0x2.9e82b522b0ca9d3p-64L },
+ { -0x8.0001a01459fc9f6p+0L, -0xc.b3cec1cec857667p-68L },
+ { -0x8.ffffd1c425e81p+0L, 0x3.79b16a8b6da6181cp-64L },
+ { -0x9.00002e3bb47d86dp+0L, -0x6.d843fedc351deb78p-64L },
+ { -0x9.fffffb606bdfdcdp+0L, -0x6.2ae77a50547c69dp-68L },
+ { -0xa.0000049f93bb992p+0L, -0x7.b45d95e15441e03p-64L },
+ { -0xa.ffffff9466e9f1bp+0L, -0x3.6dacd2adbd18d05cp-64L },
+ { -0xb.0000006b9915316p+0L, 0x2.69a590015bf1b414p-64L },
+ { -0xb.fffffff70893874p+0L, 0x7.821be533c2c36878p-64L },
+ { -0xc.00000008f76c773p+0L, -0x1.567c0f0250f38792p-64L },
+ { -0xc.ffffffff4f6dcf6p+0L, -0x1.7f97a5ffc757d548p-64L },
+ { -0xd.00000000b09230ap+0L, 0x3.f997c22e46fc1c9p-64L },
+ { -0xd.fffffffff36345bp+0L, 0x4.61e7b5c1f62ee89p-64L },
+ { -0xe.000000000c9cba5p+0L, -0x4.5e94e75ec5718f78p-64L },
+ { -0xe.ffffffffff28c06p+0L, -0xc.6604ef30371f89dp-68L },
+ { -0xf.0000000000d73fap+0L, 0xc.6642f1bdf07a161p-68L },
+ { -0xf.fffffffffff28cp+0L, -0x6.0c6621f512e72e5p-64L },
+ { -0x1.000000000000d74p+4L, 0x6.0c6625ebdb406c48p-64L },
+ { -0x1.0ffffffffffff356p+4L, -0x9.c47e7a93e1c46a1p-64L },
+ { -0x1.1000000000000caap+4L, 0x9.c47e7a97778935ap-64L },
+ { -0x1.1fffffffffffff4cp+4L, 0x1.3c31dcbecd2f74d4p-64L },
+ { -0x1.20000000000000b4p+4L, -0x1.3c31dcbeca4c3b3p-64L },
+ { -0x1.2ffffffffffffff6p+4L, -0x8.5b25cbf5f545ceep-64L },
+ { -0x1.300000000000000ap+4L, 0x8.5b25cbf5f547e48p-64L },
+ { -0x1.4p+4L, 0x7.950ae90080894298p-64L },
+ { -0x1.4p+4L, -0x7.950ae9008089414p-64L },
+ { -0x1.5p+4L, 0x5.c6e3bdb73d5c63p-68L },
+ { -0x1.5p+4L, -0x5.c6e3bdb73d5c62f8p-68L },
+ { -0x1.6p+4L, 0x4.338e5b6dfe14a518p-72L },
+ { -0x1.6p+4L, -0x4.338e5b6dfe14a51p-72L },
+ { -0x1.7p+4L, 0x2.ec368262c7033b3p-76L },
+ { -0x1.7p+4L, -0x2.ec368262c7033b3p-76L },
+ { -0x1.8p+4L, 0x1.f2cf01972f577ccap-80L },
+ { -0x1.8p+4L, -0x1.f2cf01972f577ccap-80L },
+ { -0x1.9p+4L, 0x1.3f3ccdd165fa8d4ep-84L },
+ { -0x1.9p+4L, -0x1.3f3ccdd165fa8d4ep-84L },
+ { -0x1.ap+4L, 0xc.4742fe35272cd1cp-92L },
+ { -0x1.ap+4L, -0xc.4742fe35272cd1cp-92L },
+ { -0x1.bp+4L, 0x7.46ac70b733a8c828p-96L },
+ { -0x1.bp+4L, -0x7.46ac70b733a8c828p-96L },
+ { -0x1.cp+4L, 0x4.2862898d42174ddp-100L },
+ { -0x1.cp+4L, -0x4.2862898d42174ddp-100L },
+ { -0x1.dp+4L, 0x2.4b3f31686b15af58p-104L },
+ { -0x1.dp+4L, -0x2.4b3f31686b15af58p-104L },
+ { -0x1.ep+4L, 0x1.3932c5047d60e60cp-108L },
+ { -0x1.ep+4L, -0x1.3932c5047d60e60cp-108L },
+ { -0x1.fp+4L, 0xa.1a6973c1fade217p-116L },
+ { -0x1.fp+4L, -0xa.1a6973c1fade217p-116L },
+ { -0x2p+4L, 0x5.0d34b9e0fd6f10b8p-120L },
+ { -0x2p+4L, -0x5.0d34b9e0fd6f10b8p-120L },
+ { -0x2.1p+4L, 0x2.73024a9ba1aa36a8p-124L },
+ };
+
+static const long double e_hi = 0x2.b7e151628aed2a6cp+0L;
+static const long double e_lo = -0x1.408ea77f630b0c38p-64L;
+
+/* Coefficients B_2k / 2k(2k-1) of x^-(2k-1) in Stirling's
+ approximation to lgamma function. */
+
+static const long double lgamma_coeff[] =
+ {
+ 0x1.5555555555555556p-4L,
+ -0xb.60b60b60b60b60bp-12L,
+ 0x3.4034034034034034p-12L,
+ -0x2.7027027027027028p-12L,
+ 0x3.72a3c5631fe46aep-12L,
+ -0x7.daac36664f1f208p-12L,
+ 0x1.a41a41a41a41a41ap-8L,
+ -0x7.90a1b2c3d4e5f708p-8L,
+ 0x2.dfd2c703c0cfff44p-4L,
+ -0x1.6476701181f39edcp+0L,
+ 0xd.672219167002d3ap+0L,
+ -0x9.cd9292e6660d55bp+4L,
+ 0x8.911a740da740da7p+8L,
+ -0x8.d0cc570e255bf5ap+12L,
+ 0xa.8d1044d3708d1c2p+16L,
+ -0xe.8844d8a169abbc4p+20L,
+ };
+
+#define NCOEFF (sizeof (lgamma_coeff) / sizeof (lgamma_coeff[0]))
+
+/* Polynomial approximations to (|gamma(x)|-1)(x-n)/(x-x0), where n is
+ the integer end-point of the half-integer interval containing x and
+ x0 is the zero of lgamma in that half-integer interval. Each
+ polynomial is expressed in terms of x-xm, where xm is the midpoint
+ of the interval for which the polynomial applies. */
+
+static const long double poly_coeff[] =
+ {
+ /* Interval [-2.125, -2] (polynomial degree 13). */
+ -0x1.0b71c5c54d42eb6cp+0L,
+ -0xc.73a1dc05f349517p-4L,
+ -0x1.ec841408528b6baep-4L,
+ -0xe.37c9da26fc3b492p-4L,
+ -0x1.03cd87c5178991ap-4L,
+ -0xe.ae9ada65ece2f39p-4L,
+ 0x9.b1185505edac18dp-8L,
+ -0xe.f28c130b54d3cb2p-4L,
+ 0x2.6ec1666cf44a63bp-4L,
+ -0xf.57cb2774193bbd5p-4L,
+ 0x4.5ae64671a41b1c4p-4L,
+ -0xf.f48ea8b5bd3a7cep-4L,
+ 0x6.7d73788a8d30ef58p-4L,
+ -0x1.11e0e4b506bd272ep+0L,
+ /* Interval [-2.25, -2.125] (polynomial degree 13). */
+ -0xf.2930890d7d675a8p-4L,
+ -0xc.a5cfde054eab5cdp-4L,
+ 0x3.9c9e0fdebb0676e4p-4L,
+ -0x1.02a5ad35605f0d8cp+0L,
+ 0x9.6e9b1185d0b92edp-4L,
+ -0x1.4d8332f3d6a3959p+0L,
+ 0x1.1c0c8cacd0ced3eap+0L,
+ -0x1.c9a6f592a67b1628p+0L,
+ 0x1.d7e9476f96aa4bd6p+0L,
+ -0x2.921cedb488bb3318p+0L,
+ 0x2.e8b3fd6ca193e4c8p+0L,
+ -0x3.cb69d9d6628e4a2p+0L,
+ 0x4.95f12c73b558638p+0L,
+ -0x5.d392d0b97c02ab6p+0L,
+ /* Interval [-2.375, -2.25] (polynomial degree 14). */
+ -0xd.7d28d505d618122p-4L,
+ -0xe.69649a304098532p-4L,
+ 0xb.0d74a2827d055c5p-4L,
+ -0x1.924b09228531c00ep+0L,
+ 0x1.d49b12bccee4f888p+0L,
+ -0x3.0898bb7dbb21e458p+0L,
+ 0x4.207a6cad6fa10a2p+0L,
+ -0x6.39ee630b46093ad8p+0L,
+ 0x8.e2e25211a3fb5ccp+0L,
+ -0xd.0e85ccd8e79c08p+0L,
+ 0x1.2e45882bc17f9e16p+4L,
+ -0x1.b8b6e841815ff314p+4L,
+ 0x2.7ff8bf7504fa04dcp+4L,
+ -0x3.c192e9c903352974p+4L,
+ 0x5.8040b75f4ef07f98p+4L,
+ /* Interval [-2.5, -2.375] (polynomial degree 15). */
+ -0xb.74ea1bcfff94b2cp-4L,
+ -0x1.2a82bd590c375384p+0L,
+ 0x1.88020f828b968634p+0L,
+ -0x3.32279f040eb80fa4p+0L,
+ 0x5.57ac825175943188p+0L,
+ -0x9.c2aedcfe10f129ep+0L,
+ 0x1.12c132f2df02881ep+4L,
+ -0x1.ea94e26c0b6ffa6p+4L,
+ 0x3.66b4a8bb0290013p+4L,
+ -0x6.0cf735e01f5990bp+4L,
+ 0xa.c10a8db7ae99343p+4L,
+ -0x1.31edb212b315feeap+8L,
+ 0x2.1f478592298b3ebp+8L,
+ -0x3.c546da5957ace6ccp+8L,
+ 0x7.0e3d2a02579ba4bp+8L,
+ -0xc.b1ea961c39302f8p+8L,
+ /* Interval [-2.625, -2.5] (polynomial degree 16). */
+ -0x3.d10108c27ebafad4p-4L,
+ 0x1.cd557caff7d2b202p+0L,
+ 0x3.819b4856d3995034p+0L,
+ 0x6.8505cbad03dd3bd8p+0L,
+ 0xb.c1b2e653aa0b924p+0L,
+ 0x1.50a53a38f05f72d6p+4L,
+ 0x2.57ae00cbd06efb34p+4L,
+ 0x4.2b1563077a577e9p+4L,
+ 0x7.6989ed790138a7f8p+4L,
+ 0xd.2dd28417b4f8406p+4L,
+ 0x1.76e1b71f0710803ap+8L,
+ 0x2.9a7a096254ac032p+8L,
+ 0x4.a0e6109e2a039788p+8L,
+ 0x8.37ea17a93c877b2p+8L,
+ 0xe.9506a641143612bp+8L,
+ 0x1.b680ed4ea386d52p+12L,
+ 0x3.28a2130c8de0ae84p+12L,
+ /* Interval [-2.75, -2.625] (polynomial degree 15). */
+ -0x6.b5d252a56e8a7548p-4L,
+ 0x1.28d60383da3ac72p+0L,
+ 0x1.db6513ada8a6703ap+0L,
+ 0x2.e217118f9d34aa7cp+0L,
+ 0x4.450112c5cbd6256p+0L,
+ 0x6.4af99151e972f92p+0L,
+ 0x9.2db598b5b183cd6p+0L,
+ 0xd.62bef9c9adcff6ap+0L,
+ 0x1.379f290d743d9774p+4L,
+ 0x1.c58271ff823caa26p+4L,
+ 0x2.93a871b87a06e73p+4L,
+ 0x3.bf9db66103d7ec98p+4L,
+ 0x5.73247c111fbf197p+4L,
+ 0x7.ec8b9973ba27d008p+4L,
+ 0xb.eca5f9619b39c03p+4L,
+ 0x1.18f2e46411c78b1cp+8L,
+ /* Interval [-2.875, -2.75] (polynomial degree 14). */
+ -0x8.a41b1e4f36ff88ep-4L,
+ 0xc.da87d3b69dc0f34p-4L,
+ 0x1.1474ad5c36158ad2p+0L,
+ 0x1.761ecb90c5553996p+0L,
+ 0x1.d279bff9ae234f8p+0L,
+ 0x2.4e5d0055a16c5414p+0L,
+ 0x2.d57545a783902f8cp+0L,
+ 0x3.8514eec263aa9f98p+0L,
+ 0x4.5235e338245f6fe8p+0L,
+ 0x5.562b1ef200b256c8p+0L,
+ 0x6.8ec9782b93bd565p+0L,
+ 0x8.14baf4836483508p+0L,
+ 0x9.efaf35dc712ea79p+0L,
+ 0xc.8431f6a226507a9p+0L,
+ 0xf.80358289a768401p+0L,
+ /* Interval [-3, -2.875] (polynomial degree 13). */
+ -0xa.046d667e468f3e4p-4L,
+ 0x9.70b88dcc006c216p-4L,
+ 0xa.a8a39421c86ce9p-4L,
+ 0xd.2f4d1363f321e89p-4L,
+ 0xd.ca9aa1a3ab2f438p-4L,
+ 0xf.cf09c31f05d02cbp-4L,
+ 0x1.04b133a195686a38p+0L,
+ 0x1.22b54799d0072024p+0L,
+ 0x1.2c5802b869a36ae8p+0L,
+ 0x1.4aadf23055d7105ep+0L,
+ 0x1.5794078dd45c55d6p+0L,
+ 0x1.7759069da18bcf0ap+0L,
+ 0x1.8e672cefa4623f34p+0L,
+ 0x1.b2acfa32c17145e6p+0L,
+ };
+
+static const size_t poly_deg[] =
+ {
+ 13,
+ 13,
+ 14,
+ 15,
+ 16,
+ 15,
+ 14,
+ 13,
+ };
+
+static const size_t poly_end[] =
+ {
+ 13,
+ 27,
+ 42,
+ 58,
+ 75,
+ 91,
+ 106,
+ 120,
+ };
+
+/* Compute sin (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_sinpi (long double x)
+{
+ if (x <= 0.25L)
+ return __sinl (M_PIl * x);
+ else
+ return __cosl (M_PIl * (0.5L - x));
+}
+
+/* Compute cos (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cospi (long double x)
+{
+ if (x <= 0.25L)
+ return __cosl (M_PIl * x);
+ else
+ return __sinl (M_PIl * (0.5L - x));
+}
+
+/* Compute cot (pi * X) for -0.25 <= X <= 0.5. */
+
+static long double
+lg_cotpi (long double x)
+{
+ return lg_cospi (x) / lg_sinpi (x);
+}
+
+/* Compute lgamma of a negative argument -33 < X < -2, setting
+ *SIGNGAMP accordingly. */
+
+long double
+__lgamma_negl (long double x, int *signgamp)
+{
+ /* Determine the half-integer region X lies in, handle exact
+ integers and determine the sign of the result. */
+ int i = __floorl (-2 * x);
+ if ((i & 1) == 0 && i == -2 * x)
+ return 1.0L / 0.0L;
+ long double xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
+ i -= 4;
+ *signgamp = ((i & 2) == 0 ? -1 : 1);
+
+ SET_RESTORE_ROUNDL (FE_TONEAREST);
+
+ /* Expand around the zero X0 = X0_HI + X0_LO. */
+ long double x0_hi = lgamma_zeros[i][0], x0_lo = lgamma_zeros[i][1];
+ long double xdiff = x - x0_hi - x0_lo;
+
+ /* For arguments in the range -3 to -2, use polynomial
+ approximations to an adjusted version of the gamma function. */
+ if (i < 2)
+ {
+ int j = __floorl (-8 * x) - 16;
+ long double xm = (-33 - 2 * j) * 0.0625L;
+ long double x_adj = x - xm;
+ size_t deg = poly_deg[j];
+ size_t end = poly_end[j];
+ long double g = poly_coeff[end];
+ for (size_t j = 1; j <= deg; j++)
+ g = g * x_adj + poly_coeff[end - j];
+ return __log1pl (g * xdiff / (x - xn));
+ }
+
+ /* The result we want is log (sinpi (X0) / sinpi (X))
+ + log (gamma (1 - X0) / gamma (1 - X)). */
+ long double x_idiff = fabsl (xn - x), x0_idiff = fabsl (xn - x0_hi - x0_lo);
+ long double log_sinpi_ratio;
+ if (x0_idiff < x_idiff * 0.5L)
+ /* Use log not log1p to avoid inaccuracy from log1p of arguments
+ close to -1. */
+ log_sinpi_ratio = __ieee754_logl (lg_sinpi (x0_idiff)
+ / lg_sinpi (x_idiff));
+ else
+ {
+ /* Use log1p not log to avoid inaccuracy from log of arguments
+ close to 1. X0DIFF2 has positive sign if X0 is further from
+ XN than X is from XN, negative sign otherwise. */
+ long double x0diff2 = ((i & 1) == 0 ? xdiff : -xdiff) * 0.5L;
+ long double sx0d2 = lg_sinpi (x0diff2);
+ long double cx0d2 = lg_cospi (x0diff2);
+ log_sinpi_ratio = __log1pl (2 * sx0d2
+ * (-sx0d2 + cx0d2 * lg_cotpi (x_idiff)));
+ }
+
+ long double log_gamma_ratio;
+ long double y0 = 1 - x0_hi;
+ long double y0_eps = -x0_hi + (1 - y0) - x0_lo;
+ long double y = 1 - x;
+ long double y_eps = -x + (1 - y);
+ /* We now wish to compute LOG_GAMMA_RATIO
+ = log (gamma (Y0 + Y0_EPS) / gamma (Y + Y_EPS)). XDIFF
+ accurately approximates the difference Y0 + Y0_EPS - Y -
+ Y_EPS. Use Stirling's approximation. First, we may need to
+ adjust into the range where Stirling's approximation is
+ sufficiently accurate. */
+ long double log_gamma_adj = 0;
+ if (i < 8)
+ {
+ int n_up = (9 - i) / 2;
+ long double ny0, ny0_eps, ny, ny_eps;
+ ny0 = y0 + n_up;
+ ny0_eps = y0 - (ny0 - n_up) + y0_eps;
+ y0 = ny0;
+ y0_eps = ny0_eps;
+ ny = y + n_up;
+ ny_eps = y - (ny - n_up) + y_eps;
+ y = ny;
+ y_eps = ny_eps;
+ long double prodm1 = __lgamma_productl (xdiff, y - n_up, y_eps, n_up);
+ log_gamma_adj = -__log1pl (prodm1);
+ }
+ long double log_gamma_high
+ = (xdiff * __log1pl ((y0 - e_hi - e_lo + y0_eps) / e_hi)
+ + (y - 0.5L + y_eps) * __log1pl (xdiff / y) + log_gamma_adj);
+ /* Compute the sum of (B_2k / 2k(2k-1))(Y0^-(2k-1) - Y^-(2k-1)). */
+ long double y0r = 1 / y0, yr = 1 / y;
+ long double y0r2 = y0r * y0r, yr2 = yr * yr;
+ long double rdiff = -xdiff / (y * y0);
+ long double bterm[NCOEFF];
+ long double dlast = rdiff, elast = rdiff * yr * (yr + y0r);
+ bterm[0] = dlast * lgamma_coeff[0];
+ for (size_t j = 1; j < NCOEFF; j++)
+ {
+ long double dnext = dlast * y0r2 + elast;
+ long double enext = elast * yr2;
+ bterm[j] = dnext * lgamma_coeff[j];
+ dlast = dnext;
+ elast = enext;
+ }
+ long double log_gamma_low = 0;
+ for (size_t j = 0; j < NCOEFF; j++)
+ log_gamma_low += bterm[NCOEFF - 1 - j];
+ log_gamma_ratio = log_gamma_high + log_gamma_low;
+
+ return log_sinpi_ratio + log_gamma_ratio;
+}
diff --git a/sysdeps/ieee754/ldbl-96/lgamma_product.c b/sysdeps/ieee754/ldbl-96/lgamma_product.c
new file mode 100644
index 0000000000..e3ba72d8e4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/lgamma_product.c
@@ -0,0 +1,37 @@
+/* Compute a product of 1 + (T/X), 1 + (T/(X+1)), ....
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+
+double
+__lgamma_product (double t, double x, double x_eps, int n)
+{
+ long double x_full = (long double) x + (long double) x_eps;
+ long double ret = 0;
+ for (int i = 0; i < n; i++)
+ ret += (t / (x_full + i)) * (1 + ret);
+ return ret;
+}
diff --git a/sysdeps/ieee754/ldbl-96/lgamma_productl.c b/sysdeps/ieee754/ldbl-96/lgamma_productl.c
new file mode 100644
index 0000000000..de67cbe665
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/lgamma_productl.c
@@ -0,0 +1,82 @@
+/* Compute a product of 1 + (T/X), 1 + (T/(X+1)), ....
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <math.h>
+#include <math_private.h>
+#include <float.h>
+
+/* Calculate X * Y exactly and store the result in *HI + *LO. It is
+ given that the values are small enough that no overflow occurs and
+ large enough (or zero) that no underflow occurs. */
+
+static void
+mul_split (long double *hi, long double *lo, long double x, long double y)
+{
+#ifdef __FP_FAST_FMAL
+ /* Fast built-in fused multiply-add. */
+ *hi = x * y;
+ *lo = __builtin_fmal (x, y, -*hi);
+#elif defined FP_FAST_FMAL
+ /* Fast library fused multiply-add, compiler before GCC 4.6. */
+ *hi = x * y;
+ *lo = __fmal (x, y, -*hi);
+#else
+ /* Apply Dekker's algorithm. */
+ *hi = x * y;
+# define C ((1LL << (LDBL_MANT_DIG + 1) / 2) + 1)
+ long double x1 = x * C;
+ long double y1 = y * C;
+# undef C
+ x1 = (x - x1) + x1;
+ y1 = (y - y1) + y1;
+ long double x2 = x - x1;
+ long double y2 = y - y1;
+ *lo = (((x1 * y1 - *hi) + x1 * y2) + x2 * y1) + x2 * y2;
+#endif
+}
+
+/* Compute the product of 1 + (T / (X + X_EPS)), 1 + (T / (X + X_EPS +
+ 1)), ..., 1 + (T / (X + X_EPS + N - 1)), minus 1. X is such that
+ all the values X + 1, ..., X + N - 1 are exactly representable, and
+ X_EPS / X is small enough that factors quadratic in it can be
+ neglected. */
+
+long double
+__lgamma_productl (long double t, long double x, long double x_eps, int n)
+{
+ long double ret = 0, ret_eps = 0;
+ for (int i = 0; i < n; i++)
+ {
+ long double xi = x + i;
+ long double quot = t / xi;
+ long double mhi, mlo;
+ mul_split (&mhi, &mlo, quot, xi);
+ long double quot_lo = (t - mhi - mlo) / xi - t * x_eps / (xi * xi);
+ /* We want (1 + RET + RET_EPS) * (1 + QUOT + QUOT_LO) - 1. */
+ long double rhi, rlo;
+ mul_split (&rhi, &rlo, ret, quot);
+ long double rpq = ret + quot;
+ long double rpq_eps = (ret - rpq) + quot;
+ long double nret = rpq + rhi;
+ long double nret_eps = (rpq - nret) + rhi;
+ ret_eps += (rpq_eps + nret_eps + rlo + ret_eps * quot
+ + quot_lo + quot_lo * (ret + ret_eps));
+ ret = nret;
+ }
+ return ret + ret_eps;
+}
diff --git a/sysdeps/ieee754/ldbl-96/mpn2ldbl.c b/sysdeps/ieee754/ldbl-96/mpn2ldbl.c
index b219de0fca..6159d7dabf 100644
--- a/sysdeps/ieee754/ldbl-96/mpn2ldbl.c
+++ b/sysdeps/ieee754/ldbl-96/mpn2ldbl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/printf_fphex.c b/sysdeps/ieee754/ldbl-96/printf_fphex.c
index 564f062727..65bf538590 100644
--- a/sysdeps/ieee754/ldbl-96/printf_fphex.c
+++ b/sysdeps/ieee754/ldbl-96/printf_fphex.c
@@ -1,5 +1,5 @@
/* Print floating point number in hexadecimal notation according to ISO C99.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/s_asinhl.c b/sysdeps/ieee754/ldbl-96/s_asinhl.c
index 75e47c71ea..da49ea5988 100644
--- a/sysdeps/ieee754/ldbl-96/s_asinhl.c
+++ b/sysdeps/ieee754/ldbl-96/s_asinhl.c
@@ -45,11 +45,7 @@ long double __asinhl(long double x)
GET_LDOUBLE_EXP(hx,x);
ix = hx&0x7fff;
if(__builtin_expect(ix< 0x3fde, 0)) { /* |x|<2**-34 */
- if (fabsl (x) < LDBL_MIN)
- {
- long double force_underflow = x * x;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (x);
if(huge+x>one) return x; /* return x inexact except 0 */
}
if(__builtin_expect(ix>0x4020,0)) { /* |x| > 2**34 */
diff --git a/sysdeps/ieee754/ldbl-96/s_cbrtl.c b/sysdeps/ieee754/ldbl-96/s_cbrtl.c
index bc3c2abfeb..42849ab517 100644
--- a/sysdeps/ieee754/ldbl-96/s_cbrtl.c
+++ b/sysdeps/ieee754/ldbl-96/s_cbrtl.c
@@ -1,5 +1,5 @@
/* Compute cubic root of double value.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Dirk Alboth <dirka@uni-paderborn.de> and
Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/ldbl-96/s_erfl.c b/sysdeps/ieee754/ldbl-96/s_erfl.c
index c27de812ca..d00adb1000 100644
--- a/sysdeps/ieee754/ldbl-96/s_erfl.c
+++ b/sysdeps/ieee754/ldbl-96/s_erfl.c
@@ -274,11 +274,7 @@ __erfl (long double x)
{
/* Avoid spurious underflow. */
long double ret = 0.0625 * (16.0 * x + (16.0 * efx) * x);
- if (fabsl (ret) < LDBL_MIN)
- {
- long double force_underflow = ret * ret;
- math_force_eval (force_underflow);
- }
+ math_check_force_underflow (ret);
return ret;
}
return x + efx * x;
diff --git a/sysdeps/ieee754/ldbl-96/s_fma.c b/sysdeps/ieee754/ldbl-96/s_fma.c
index 8fd238cfe4..ab45bcfce2 100644
--- a/sysdeps/ieee754/ldbl-96/s_fma.c
+++ b/sysdeps/ieee754/ldbl-96/s_fma.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
@@ -41,7 +41,10 @@ __fma (double x, double y, double z)
/* Ensure correct sign of exact 0 + 0. */
if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
- return x * y + z;
+ {
+ x = math_opt_barrier (x);
+ return x * y + z;
+ }
fenv_t env;
feholdexcept (&env);
diff --git a/sysdeps/ieee754/ldbl-96/s_fmal.c b/sysdeps/ieee754/ldbl-96/s_fmal.c
index eec5a02e0b..f1467fda3d 100644
--- a/sysdeps/ieee754/ldbl-96/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-96/s_fmal.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+ Copyright (C) 2010-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2010.
@@ -68,7 +68,7 @@ __fmal (long double x, long double y, long double z)
if (u.ieee.exponent + v.ieee.exponent
> 0x7fff + IEEE854_LONG_DOUBLE_BIAS)
return x * y;
- /* If x * y is less than 1/4 of LDBL_DENORM_MIN, neither the
+ /* If x * y is less than 1/4 of LDBL_TRUE_MIN, neither the
result nor whether there is underflow depends on its exact
value, only on its sign. */
if (u.ieee.exponent + v.ieee.exponent
@@ -92,8 +92,8 @@ __fmal (long double x, long double y, long double z)
&& w.ieee.mantissa1 == 0
&& w.ieee.mantissa0 == 0x80000000)))
{
- volatile long double force_underflow = x * y;
- (void) force_underflow;
+ long double force_underflow = x * y;
+ math_force_eval (force_underflow);
}
return v.d * 0x1p-65L;
}
@@ -119,7 +119,7 @@ __fmal (long double x, long double y, long double z)
very small, adjust them up to avoid spurious underflows,
rather than down. */
if (u.ieee.exponent + v.ieee.exponent
- <= IEEE854_LONG_DOUBLE_BIAS + LDBL_MANT_DIG)
+ <= IEEE854_LONG_DOUBLE_BIAS + 2 * LDBL_MANT_DIG)
{
if (u.ieee.exponent > v.ieee.exponent)
u.ieee.exponent += 2 * LDBL_MANT_DIG + 2;
@@ -177,7 +177,10 @@ __fmal (long double x, long double y, long double z)
/* Ensure correct sign of exact 0 + 0. */
if (__glibc_unlikely ((x == 0 || y == 0) && z == 0))
- return x * y + z;
+ {
+ x = math_opt_barrier (x);
+ return x * y + z;
+ }
fenv_t env;
feholdexcept (&env);
diff --git a/sysdeps/ieee754/ldbl-96/s_isinf_nsl.c b/sysdeps/ieee754/ldbl-96/s_isinf_nsl.c
deleted file mode 100644
index 9c7868b490..0000000000
--- a/sysdeps/ieee754/ldbl-96/s_isinf_nsl.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Written by Ulrich Drepper <drepper@gmail.com>.
- */
-
-/*
- * __isinf_nsl(x) returns != 0 if x is ±inf, else 0;
- */
-
-#include <math.h>
-#include <math_private.h>
-
-int
-__isinf_nsl (long double x)
-{
- int32_t se,hx,lx;
- GET_LDOUBLE_WORDS(se,hx,lx,x);
- return !(((se & 0x7fff) ^ 0x7fff) | lx | (hx & 0x7fffffff));
-}
diff --git a/sysdeps/ieee754/ldbl-96/s_issignalingl.c b/sysdeps/ieee754/ldbl-96/s_issignalingl.c
index adbee9823c..73646cac0c 100644
--- a/sysdeps/ieee754/ldbl-96/s_issignalingl.c
+++ b/sysdeps/ieee754/ldbl-96/s_issignalingl.c
@@ -1,5 +1,5 @@
/* Test for signaling NaN.
- Copyright (C) 2013-2015 Free Software Foundation, Inc.
+ Copyright (C) 2013-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
diff --git a/sysdeps/ieee754/ldbl-96/s_llrintl.c b/sysdeps/ieee754/ldbl-96/s_llrintl.c
index 070246cb6a..592d51c607 100644
--- a/sysdeps/ieee754/ldbl-96/s_llrintl.c
+++ b/sysdeps/ieee754/ldbl-96/s_llrintl.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,6 +18,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
@@ -35,7 +37,7 @@ __llrintl (long double x)
int32_t se,j0;
u_int32_t i0, i1;
long long int result;
- volatile long double w;
+ long double w;
long double t;
int sx;
@@ -50,8 +52,21 @@ __llrintl (long double x)
result = (((long long int) i0 << 32) | i1) << (j0 - 63);
else
{
- w = two63[sx] + x;
- t = w - two63[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LLONG_MAX + 1 implied by J0 < 63. */
+ if (x > (long double) LLONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LLONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two63[sx] + x;
+ t = w - two63[sx];
+ }
GET_LDOUBLE_WORDS (se, i0, i1, t);
j0 = (se & 0x7fff) - 0x3fff;
diff --git a/sysdeps/ieee754/ldbl-96/s_llroundl.c b/sysdeps/ieee754/ldbl-96/s_llroundl.c
index 8381649269..483199d442 100644
--- a/sysdeps/ieee754/ldbl-96/s_llroundl.c
+++ b/sysdeps/ieee754/ldbl-96/s_llroundl.c
@@ -1,5 +1,5 @@
/* Round long double value to long long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,6 +17,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
@@ -64,7 +66,14 @@ __llroundl (long double x)
++result;
if (j0 > 31)
- result = (result << (j0 - 31)) | (j >> (63 - j0));
+ {
+ result = (result << (j0 - 31)) | (j >> (63 - j0));
+#ifdef FE_INVALID
+ if (sign == 1 && result == LLONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
else
diff --git a/sysdeps/ieee754/ldbl-96/s_lrintl.c b/sysdeps/ieee754/ldbl-96/s_lrintl.c
index 96c6a5ea7d..bd902deb47 100644
--- a/sysdeps/ieee754/ldbl-96/s_lrintl.c
+++ b/sysdeps/ieee754/ldbl-96/s_lrintl.c
@@ -1,6 +1,6 @@
/* Round argument to nearest integral value according to current rounding
direction.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -18,6 +18,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
@@ -35,7 +37,7 @@ __lrintl (long double x)
int32_t se,j0;
u_int32_t i0, i1;
long int result;
- volatile long double w;
+ long double w;
long double t;
int sx;
@@ -46,8 +48,22 @@ __lrintl (long double x)
if (j0 < 31)
{
- w = two63[sx] + x;
- t = w - two63[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LONG_MAX + 1 implied by J0 < 31. */
+ if (sizeof (long int) == 4
+ && x > (long double) LONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two63[sx] + x;
+ t = w - two63[sx];
+ }
GET_LDOUBLE_WORDS (se, i0, i1, t);
j0 = (se & 0x7fff) - 0x3fff;
@@ -59,8 +75,22 @@ __lrintl (long double x)
result = ((long int) i0 << (j0 - 31)) | (i1 << (j0 - 63));
else
{
- w = two63[sx] + x;
- t = w - two63[sx];
+#if defined FE_INVALID || defined FE_INEXACT
+ /* X < LONG_MAX + 1 implied by J0 < 63. */
+ if (sizeof (long int) == 8
+ && x > (long double) LONG_MAX)
+ {
+ /* In the event of overflow we must raise the "invalid"
+ exception, but not "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MAX ? FE_INEXACT : FE_INVALID);
+ }
+ else
+#endif
+ {
+ w = two63[sx] + x;
+ t = w - two63[sx];
+ }
GET_LDOUBLE_WORDS (se, i0, i1, t);
j0 = (se & 0x7fff) - 0x3fff;
@@ -72,8 +102,21 @@ __lrintl (long double x)
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#if defined FE_INVALID || defined FE_INEXACT
+ if (sizeof (long int) == 4
+ && x < (long double) LONG_MIN
+ && x > (long double) LONG_MIN - 1.0L)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ t = __nearbyintl (x);
+ feraiseexcept (t == LONG_MIN ? FE_INEXACT : FE_INVALID);
+ return LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/ldbl-96/s_lroundl.c b/sysdeps/ieee754/ldbl-96/s_lroundl.c
index e34edd307d..3b43d77e72 100644
--- a/sysdeps/ieee754/ldbl-96/s_lroundl.c
+++ b/sysdeps/ieee754/ldbl-96/s_lroundl.c
@@ -1,5 +1,5 @@
/* Round long double value to long int.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -17,6 +17,8 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <fenv.h>
+#include <limits.h>
#include <math.h>
#include <math_private.h>
@@ -49,6 +51,13 @@ __lroundl (long double x)
}
result = j >> (31 - j0);
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
}
}
else if (j0 < (int32_t) (8 * sizeof (long int)) - 1)
@@ -58,19 +67,41 @@ __lroundl (long double x)
else
{
u_int32_t j = i1 + (0x80000000 >> (j0 - 31));
+ unsigned long int ures = i0;
+
if (j < i1)
- ++i0;
+ ++ures;
if (j0 == 31)
- result = (long int) i0;
+ result = ures;
else
- result = ((long int) i0 << (j0 - 31)) | (j >> (63 - j0));
+ {
+ result = (ures << (j0 - 31)) | (j >> (63 - j0));
+#ifdef FE_INVALID
+ if (sizeof (long int) == 8
+ && sign == 1
+ && result == LONG_MIN)
+ /* Rounding brought the value out of range. */
+ feraiseexcept (FE_INVALID);
+#endif
+ }
}
}
else
{
- /* The number is too large. It is left implementation defined
- what happens. */
+ /* The number is too large. Unless it rounds to LONG_MIN,
+ FE_INVALID must be raised and the return value is
+ unspecified. */
+#ifdef FE_INVALID
+ if (sizeof (long int) == 4
+ && x <= (long double) LONG_MIN - 0.5L)
+ {
+ /* If truncation produces LONG_MIN, the cast will not raise
+ the exception, but may raise "inexact". */
+ feraiseexcept (FE_INVALID);
+ return LONG_MIN;
+ }
+#endif
return (long int) x;
}
diff --git a/sysdeps/ieee754/ldbl-96/s_nexttoward.c b/sysdeps/ieee754/ldbl-96/s_nexttoward.c
index f7a8b2165a..3d0382eac9 100644
--- a/sysdeps/ieee754/ldbl-96/s_nexttoward.c
+++ b/sysdeps/ieee754/ldbl-96/s_nexttoward.c
@@ -25,6 +25,7 @@ static char rcsid[] = "$NetBSD: $";
* Special cases:
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <float.h>
@@ -70,15 +71,14 @@ double __nexttoward(double x, long double y)
}
hy = hx&0x7ff00000;
if(hy>=0x7ff00000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0 && FLT_EVAL_METHOD != 1)
- /* Force conversion to double. */
- asm ("" : "+m"(x));
- return x;
+ double u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00100000) {
double u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
INSERT_WORDS(x,hx,lx);
return x;
diff --git a/sysdeps/ieee754/ldbl-96/s_nexttowardf.c b/sysdeps/ieee754/ldbl-96/s_nexttowardf.c
index a96f9da2c2..ae7538942f 100644
--- a/sysdeps/ieee754/ldbl-96/s_nexttowardf.c
+++ b/sysdeps/ieee754/ldbl-96/s_nexttowardf.c
@@ -17,6 +17,7 @@
static char rcsid[] = "$NetBSD: $";
#endif
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <float.h>
@@ -58,15 +59,14 @@ float __nexttowardf(float x, long double y)
}
hy = hx&0x7f800000;
if(hy>=0x7f800000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0)
- /* Force conversion to float. */
- asm ("" : "+m"(x));
- return x;
+ float u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00800000) {
float u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_FLOAT_WORD(x,hx);
return x;
diff --git a/sysdeps/ieee754/ldbl-96/s_remquol.c b/sysdeps/ieee754/ldbl-96/s_remquol.c
index 230d0fa57c..89b2630d46 100644
--- a/sysdeps/ieee754/ldbl-96/s_remquol.c
+++ b/sysdeps/ieee754/ldbl-96/s_remquol.c
@@ -1,5 +1,5 @@
/* Compute remainder and a congruent to the quotient.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/ldbl-96/s_roundl.c b/sysdeps/ieee754/ldbl-96/s_roundl.c
index 560f7afb99..4f35c4847b 100644
--- a/sysdeps/ieee754/ldbl-96/s_roundl.c
+++ b/sysdeps/ieee754/ldbl-96/s_roundl.c
@@ -1,5 +1,5 @@
/* Round long double to integer away from zero.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
diff --git a/sysdeps/ieee754/ldbl-96/s_signbitl.c b/sysdeps/ieee754/ldbl-96/s_signbitl.c
index bbe72a62ea..ee5d77e27a 100644
--- a/sysdeps/ieee754/ldbl-96/s_signbitl.c
+++ b/sysdeps/ieee754/ldbl-96/s_signbitl.c
@@ -1,5 +1,5 @@
/* Return nonzero value if number is negative.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -19,13 +19,8 @@
#include <math.h>
-#include <math_private.h>
-
int
__signbitl (long double x)
{
- int32_t e;
-
- GET_LDOUBLE_EXP (e, x);
- return e & 0x8000;
+ return __builtin_signbitl (x);
}
diff --git a/sysdeps/ieee754/ldbl-96/s_sincosl.c b/sysdeps/ieee754/ldbl-96/s_sincosl.c
index 37067bdaeb..ab32b73e7d 100644
--- a/sysdeps/ieee754/ldbl-96/s_sincosl.c
+++ b/sysdeps/ieee754/ldbl-96/s_sincosl.c
@@ -1,5 +1,5 @@
/* Compute sine and cosine of argument.
- Copyright (C) 1997-2015 Free Software Foundation, Inc.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -42,7 +42,7 @@ __sincosl (long double x, long double *sinx, long double *cosx)
{
/* sin(Inf or NaN) is NaN */
*sinx = *cosx = x - x;
- if (__isinf_nsl (x))
+ if (isinf (x))
__set_errno (EDOM);
}
else
diff --git a/sysdeps/ieee754/ldbl-96/s_tanhl.c b/sysdeps/ieee754/ldbl-96/s_tanhl.c
index 7ec6247315..38edf9f75e 100644
--- a/sysdeps/ieee754/ldbl-96/s_tanhl.c
+++ b/sysdeps/ieee754/ldbl-96/s_tanhl.c
@@ -42,6 +42,7 @@ static char rcsid[] = "$NetBSD: $";
* only tanhl(0)=0 is exact for finite argument.
*/
+#include <float.h>
#include <math.h>
#include <math_private.h>
@@ -69,7 +70,10 @@ long double __tanhl(long double x)
if ((ix|j0|j1) == 0)
return x; /* x == +- 0 */
if (ix<0x3fc8) /* |x|<2**-55 */
+ {
+ math_check_force_underflow (x);
return x*(one+tiny); /* tanh(small) = small */
+ }
if (ix>=0x3fff) { /* |x|>=1 */
t = __expm1l(two*fabsl(x));
z = one - two/(t+two);
diff --git a/sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h b/sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h
new file mode 100644
index 0000000000..2694b5ee34
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/strtod_nan_ldouble.h
@@ -0,0 +1,30 @@
+/* Convert string for NaN payload to corresponding NaN. For ldbl-96.
+ Copyright (C) 1997-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define FLOAT long double
+#define SET_MANTISSA(flt, mant) \
+ do \
+ { \
+ union ieee854_long_double u; \
+ u.d = (flt); \
+ u.ieee_nan.mantissa0 = (mant) >> 32; \
+ u.ieee_nan.mantissa1 = (mant); \
+ if ((u.ieee.mantissa0 | u.ieee.mantissa1) != 0) \
+ (flt) = u.d; \
+ } \
+ while (0)
diff --git a/sysdeps/ieee754/ldbl-96/strtold_l.c b/sysdeps/ieee754/ldbl-96/strtold_l.c
index c082e7472e..b51560e18a 100644
--- a/sysdeps/ieee754/ldbl-96/strtold_l.c
+++ b/sysdeps/ieee754/ldbl-96/strtold_l.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -25,19 +25,13 @@
#ifdef USE_WIDE_CHAR
# define STRTOF wcstold_l
# define __STRTOF __wcstold_l
+# define STRTOF_NAN __wcstold_nan
#else
# define STRTOF strtold_l
# define __STRTOF __strtold_l
+# define STRTOF_NAN __strtold_nan
#endif
#define MPN2FLOAT __mpn_construct_long_double
#define FLOAT_HUGE_VAL HUGE_VALL
-#define SET_MANTISSA(flt, mant) \
- do { union ieee854_long_double u; \
- u.d = (flt); \
- u.ieee_nan.mantissa0 = (mant) >> 32; \
- u.ieee_nan.mantissa1 = (mant); \
- if ((u.ieee.mantissa0 | u.ieee.mantissa1) != 0) \
- (flt) = u.d; \
- } while (0)
#include <stdlib/strtod_l.c>
diff --git a/sysdeps/ieee754/ldbl-96/t_sincosl.c b/sysdeps/ieee754/ldbl-96/t_sincosl.c
index 4efc4d9a02..f00a182061 100644
--- a/sysdeps/ieee754/ldbl-96/t_sincosl.c
+++ b/sysdeps/ieee754/ldbl-96/t_sincosl.c
@@ -1,5 +1,5 @@
/* Extended-precision floating point sine and cosine tables.
- Copyright (C) 1999-2015 Free Software Foundation, Inc.
+ Copyright (C) 1999-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on quad-precision tables by Jakub Jelinek <jj@ultra.linux.cz>
diff --git a/sysdeps/ieee754/ldbl-96/w_expl.c b/sysdeps/ieee754/ldbl-96/w_expl.c
index 3cc165b39d..5c7a1812bc 100644
--- a/sysdeps/ieee754/ldbl-96/w_expl.c
+++ b/sysdeps/ieee754/ldbl-96/w_expl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2011-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@gmail.com>, 2011.
diff --git a/sysdeps/ieee754/ldbl-96/x2y2m1.c b/sysdeps/ieee754/ldbl-96/x2y2m1.c
index a6cc82cb29..4119f42acc 100644
--- a/sysdeps/ieee754/ldbl-96/x2y2m1.c
+++ b/sysdeps/ieee754/ldbl-96/x2y2m1.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -27,8 +27,8 @@
#else
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
double
__x2y2m1 (double x, double y)
diff --git a/sysdeps/ieee754/ldbl-96/x2y2m1l.c b/sysdeps/ieee754/ldbl-96/x2y2m1l.c
index 11757c6af8..733742da04 100644
--- a/sysdeps/ieee754/ldbl-96/x2y2m1l.c
+++ b/sysdeps/ieee754/ldbl-96/x2y2m1l.c
@@ -1,5 +1,5 @@
/* Compute x^2 + y^2 - 1, without large cancellation error.
- Copyright (C) 2012-2015 Free Software Foundation, Inc.
+ Copyright (C) 2012-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -80,32 +80,26 @@ compare (const void *p, const void *q)
}
/* Return X^2 + Y^2 - 1, computed without large cancellation error.
- It is given that 1 > X >= Y >= epsilon / 2, and that either X >=
- 0.75 or Y >= 0.5. */
+ It is given that 1 > X >= Y >= epsilon / 2, and that X^2 + Y^2 >=
+ 0.5. */
long double
__x2y2m1l (long double x, long double y)
{
- long double vals[4];
+ long double vals[5];
SET_RESTORE_ROUNDL (FE_TONEAREST);
mul_split (&vals[1], &vals[0], x, x);
mul_split (&vals[3], &vals[2], y, y);
- if (x >= 0.75L)
- vals[1] -= 1.0L;
- else
- {
- vals[1] -= 0.5L;
- vals[3] -= 0.5L;
- }
- qsort (vals, 4, sizeof (long double), compare);
+ vals[4] = -1.0L;
+ qsort (vals, 5, sizeof (long double), compare);
/* Add up the values so that each element of VALS has absolute value
at most equal to the last set bit of the next nonzero
element. */
- for (size_t i = 0; i <= 2; i++)
+ for (size_t i = 0; i <= 3; i++)
{
add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]);
- qsort (vals + i + 1, 3 - i, sizeof (long double), compare);
+ qsort (vals + i + 1, 4 - i, sizeof (long double), compare);
}
/* Now any error from this addition will be small. */
- return vals[3] + vals[2] + vals[1] + vals[0];
+ return vals[4] + vals[3] + vals[2] + vals[1] + vals[0];
}
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 222122de0b..53091e410c 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -31,7 +31,7 @@ libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \
tanh acosh asinh atanh exp log log10 exp10 pow10 expm1 \
log1p logb exp2 sqrt cbrt fabs floor j0 j1 y0 y1 erf erfc \
lgamma tgamma gamma rint nearbyint round trunc \
- copysign fdim fmax fmin nextafter pow hypot fmod drem \
+ copysign fdim fmax fmin nextafter pow hypot fmod \
remainder ldexp scalbn frexp modf scalbln fma nan sincos \
jn yn ilogb remquo lrint lround llrint llround nexttowardf \
nexttoward conj cacos cacosh casin catan catanh ccos ccosh \
@@ -81,7 +81,6 @@ CFLAGS-nldbl-csinh.c = -fno-builtin-csinhl
CFLAGS-nldbl-csqrt.c = -fno-builtin-csqrtl
CFLAGS-nldbl-ctan.c = -fno-builtin-ctanl
CFLAGS-nldbl-ctanh.c = -fno-builtin-ctanhl
-CFLAGS-nldbl-drem.c = -fno-builtin-dreml
CFLAGS-nldbl-erf.c = -fno-builtin-erfl
CFLAGS-nldbl-erfc.c = -fno-builtin-erfcl
CFLAGS-nldbl-exp.c = -fno-builtin-expl
@@ -125,7 +124,7 @@ CFLAGS-nldbl-nexttoward.c = -fno-builtin-nexttoward -fno-builtin-nexttowardl
CFLAGS-nldbl-nexttowardf.c = -fno-builtin-nexttowardf
CFLAGS-nldbl-pow.c = -fno-builtin-powl
CFLAGS-nldbl-pow10.c = -fno-builtin-pow10l
-CFLAGS-nldbl-remainder.c = -fno-builtin-remainderl
+CFLAGS-nldbl-remainder.c = -fno-builtin-remainderl -fno-builtin-dreml
CFLAGS-nldbl-remquo.c = -fno-builtin-remquol
CFLAGS-nldbl-rint.c = -fno-builtin-rintl
CFLAGS-nldbl-round.c = -fno-builtin-roundl
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index 0198886758..35b7a69945 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -1,5 +1,5 @@
/* *printf* family compatibility routines for IEEE double as long double
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@cygnus.com>, 2006.
@@ -25,7 +25,7 @@
#include <monetary.h>
#include <locale/localeinfo.h>
#include <sys/syslog.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
#include "nldbl-compat.h"
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
index 0d2c8af627..0c3c5ad24d 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
@@ -1,5 +1,5 @@
/* Prototypes for compatibility double == long double entry points.
- Copyright (C) 2006-2015 Free Software Foundation, Inc.
+ Copyright (C) 2006-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@cygnus.com>, 2006.
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-drem.c b/sysdeps/ieee754/ldbl-opt/nldbl-drem.c
deleted file mode 100644
index 1e08ce1d28..0000000000
--- a/sysdeps/ieee754/ldbl-opt/nldbl-drem.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "nldbl-compat.h"
-
-double
-attribute_hidden
-dreml (double x, double y)
-{
- return drem (x, y);
-}
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-remainder.c b/sysdeps/ieee754/ldbl-opt/nldbl-remainder.c
index a8d5bafb5f..581dc78a4d 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-remainder.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-remainder.c
@@ -6,3 +6,5 @@ remainderl (double x, double y)
{
return remainder (x, y);
}
+extern __typeof (remainderl) dreml attribute_hidden;
+weak_alias (remainderl, dreml)
diff --git a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
index 0dce1b1620..ed87a92b96 100644
--- a/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
+++ b/sysdeps/ieee754/ldbl-opt/s_ldexpl.c
@@ -2,8 +2,11 @@
#undef weak_alias
#define weak_alias(n,a)
#include <math/s_ldexpl.c>
+strong_alias (__ldexpl, __ldexpl_2)
#if IS_IN (libm)
long_double_symbol (libm, __ldexpl, ldexpl);
+long_double_symbol (libm, __ldexpl_2, scalbnl);
#else
long_double_symbol (libc, __ldexpl, ldexpl);
+long_double_symbol (libc, __ldexpl_2, scalbnl);
#endif
diff --git a/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c b/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c
index 7eca121701..07e9375b78 100644
--- a/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c
+++ b/sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c
@@ -20,6 +20,7 @@
* Special cases:
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
#include <math_ldbl_opt.h>
@@ -62,15 +63,14 @@ float __nldbl_nexttowardf(float x, double y)
}
hy = hx&0x7f800000;
if(hy>=0x7f800000) {
- x = x+x; /* overflow */
- if (FLT_EVAL_METHOD != 0)
- /* Force conversion to float. */
- asm ("" : "+m"(x));
- return x;
+ float u = x+x; /* overflow */
+ math_force_eval (u);
+ __set_errno (ERANGE);
}
if(hy<0x00800000) {
float u = x*x; /* underflow */
math_force_eval (u); /* raise underflow flag */
+ __set_errno (ERANGE);
}
SET_FLOAT_WORD(x,hx);
return x;
diff --git a/sysdeps/ieee754/ldbl-opt/w_drem.c b/sysdeps/ieee754/ldbl-opt/w_drem.c
deleted file mode 100644
index 788a5d29d6..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_drem.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#include <math/w_drem.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __drem, dreml, GLIBC_2_0);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_dreml.c b/sysdeps/ieee754/ldbl-opt/w_dreml.c
deleted file mode 100644
index d14d7e202c..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_dreml.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/w_dreml.c>
-long_double_symbol (libm, __dreml, dreml);
diff --git a/sysdeps/ieee754/ldbl-opt/w_lgamma.c b/sysdeps/ieee754/ldbl-opt/w_lgamma.c
deleted file mode 100644
index ef801c5505..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_lgamma.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math_ldbl_opt.h>
-#include <math/w_lgamma.c>
-#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
-compat_symbol (libm, __lgamma, lgammal, GLIBC_2_0);
-compat_symbol (libm, __gamma, gammal, GLIBC_2_0);
-#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c b/sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c
new file mode 100644
index 0000000000..f268e65a88
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/w_lgamma_compat.c
@@ -0,0 +1,7 @@
+#include <math_ldbl_opt.h>
+#include <math/w_lgamma_compat.c>
+#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
+strong_alias (__lgamma_compat, __lgammal_dbl_compat)
+compat_symbol (libm, __lgammal_dbl_compat, lgammal, GLIBC_2_0);
+compat_symbol (libm, __gamma, gammal, GLIBC_2_0);
+#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c b/sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c
new file mode 100644
index 0000000000..f60b3d7bcf
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/w_lgamma_compatl.c
@@ -0,0 +1,11 @@
+#include <math_ldbl_opt.h>
+#undef weak_alias
+#define weak_alias(n,a)
+#define USE_AS_COMPAT 1
+#include <math/lgamma-compat.h>
+#undef LGAMMA_OLD_VER
+#define LGAMMA_OLD_VER LONG_DOUBLE_COMPAT_VERSION
+#include <math/w_lgamma_compatl.c>
+#if GAMMA_ALIAS
+long_double_symbol (libm, __gammal, gammal);
+#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_lgammal.c b/sysdeps/ieee754/ldbl-opt/w_lgammal.c
deleted file mode 100644
index 9de7ec8f7f..0000000000
--- a/sysdeps/ieee754/ldbl-opt/w_lgammal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <math_ldbl_opt.h>
-#undef weak_alias
-#define weak_alias(n,a)
-#include <math/w_lgammal.c>
-long_double_symbol (libm, __lgammal, lgammal);
-long_double_symbol (libm, __gammal, gammal);
diff --git a/sysdeps/ieee754/ldbl-opt/w_remainder.c b/sysdeps/ieee754/ldbl-opt/w_remainder.c
index 94d98930f4..dfa7b7f569 100644
--- a/sysdeps/ieee754/ldbl-opt/w_remainder.c
+++ b/sysdeps/ieee754/ldbl-opt/w_remainder.c
@@ -2,4 +2,6 @@
#include <math/w_remainder.c>
#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
compat_symbol (libm, __remainder, remainderl, GLIBC_2_0);
+strong_alias (__remainder, __drem)
+compat_symbol (libm, __drem, dreml, GLIBC_2_0);
#endif
diff --git a/sysdeps/ieee754/ldbl-opt/w_remainderl.c b/sysdeps/ieee754/ldbl-opt/w_remainderl.c
index e450a25bbc..7a344b7709 100644
--- a/sysdeps/ieee754/ldbl-opt/w_remainderl.c
+++ b/sysdeps/ieee754/ldbl-opt/w_remainderl.c
@@ -3,3 +3,5 @@
#define weak_alias(n,a)
#include <math/w_remainderl.c>
long_double_symbol (libm, __remainderl, remainderl);
+strong_alias (__remainderl, __dreml)
+long_double_symbol (libm, __dreml, dreml);
diff --git a/sysdeps/ieee754/s_signgam.c b/sysdeps/ieee754/s_signgam.c
index ee207d6505..9af3a75f1e 100644
--- a/sysdeps/ieee754/s_signgam.c
+++ b/sysdeps/ieee754/s_signgam.c
@@ -1,3 +1,4 @@
#include <math.h>
#include <math_private.h>
-int signgam;
+int __signgam = 0;
+weak_alias (__signgam, signgam)