freebsd-skq/lib
Dimitry Andric 83fa0a287f The fdlibm hypot() implementations shouldn't potentially left-shift
negative numbers (invoking undefined behavior)

Summary:
Various paths through hypot(x, y) will multiply x and y by a power of
two, perform the calculation in a range where IEEE-754 provides greater
precision, then undo the multiplication to determine the true result.
Undoing that multiplication is implemented as t1*w, where t1=2**k.

2**k is often computed by taking the high word of 1.0, then adding k<<20
(for doubles or long doubles) or k<<23 (for floats) to it, then
overwriting that high word. But when k is negative this left-shifts a
negative value -- and that's undefined behavior in many editions of C
and C++.

This patch should fix all hypot implementations to compute 2**k without
triggering this particular bit of undefined behavior.

Test Plan: I've only very lightly tested out the hypot(double, double)
change, in SpiderMonkey's JavaScript engine, for consistency with prior
behavior.  The other functions' changes have more or less only been
eyeballed.  Careful examination appreciated!  Do note, however, that an
error in any of these changes would most likely produce a value that is
incorrect by a factor of two, so any mistake would most likely be
glaring if invoked.

Submitted by:	Jeff Walden <jwalden@mit.edu>
Obtained from:	https://github.com/freebsd/freebsd/pull/414
Reviewed by:	dim, lwhsu
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D22354
2019-11-26 22:01:09 +00:00
..
atf Another round of attempting to squelch -Wdeprecated-declarations, which 2019-09-17 06:07:08 +00:00
clang Add explanatory comments for the different SRCS_xxx variables used in 2019-11-20 18:12:01 +00:00
csu csu: Fix dynamiclib/init_test:jcr_test on !HAVE_CTORS archs 2019-11-08 14:28:39 +00:00
geom Fix grammar in gpart.8. 2019-11-18 19:05:52 +00:00
googletest Another round of attempting to squelch -Wdeprecated-declarations, which 2019-09-17 06:07:08 +00:00
lib80211 [lib80211] add initial VHT (11ac) channel ranges for FCC. 2019-09-05 15:55:24 +00:00
libalias pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libarchive Whitespace cleanup, no functional change 2019-09-19 13:25:19 +00:00
libauditd pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libbe Commit missing file from r354116 2019-10-26 19:20:59 +00:00
libbearssl
libbegemot
libblacklist
libblocksruntime
libbluetooth pkgbase: Put libbluetooth in the bluetooth package 2019-09-05 14:11:16 +00:00
libbsdstat
libbsm
libbsnmp Avoid the use of the non-portable -D argument to ls. 2019-09-11 17:01:31 +00:00
libbz2
libc [PowerPC] Fix typo in _ctx_start on ppc32 2019-11-23 23:41:21 +00:00
libc_nonshared
libc++ Merge ^/head r352764 through r353315. 2019-10-08 18:17:02 +00:00
libc++experimental Rework CXXSTD setting via r345708 2019-04-22 18:38:54 +00:00
libcalendar pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libcam pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libcapsicum pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libcasper cap_sysctl: correct typo from r347534-ish 2019-10-23 03:23:14 +00:00
libclang_rt libclang_rt: enable on powerpc* 2019-11-23 19:35:09 +00:00
libcom_err pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libcompat
libcompiler_rt Fix llvm-libunwind userspace build on ARM 2019-11-05 03:20:40 +00:00
libcrypt pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libcuse Implement flag for telling cuse(3) clients if the peer is running in 32-bit 2019-04-18 19:04:07 +00:00
libcxxrt Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it around 2019-10-06 04:19:49 +00:00
libdevctl pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libdevdctl Another round of attempting to squelch -Wdeprecated-declarations, which 2019-09-17 06:07:08 +00:00
libdevinfo pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libdevstat pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libdl
libdpv pkgbase: Add a FreeBSD-dpv package 2019-07-19 15:10:53 +00:00
libdwarf
libedit Update libedit to a snapshot from 2019-09-10 2019-09-13 06:50:02 +00:00
libefivar
libelf pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libelftc libelftc: Add MLINKS. 2019-05-30 19:18:01 +00:00
libevent
libexecinfo libexecinfo test: Don't strip installed test 2019-10-29 18:24:36 +00:00
libexpat MFV r355071: libbsdxml (expat) 2.2.9. 2019-11-25 07:48:16 +00:00
libfetch pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libfigpar pkgbase: Add a FreeBSD-dpv package 2019-07-19 15:10:53 +00:00
libgcc_eh Re-add ALLOW_MIPS_SHARED_TEXTREL, sprinkle it around 2019-10-06 04:19:49 +00:00
libgcc_s Fix llvm-libunwind userspace build on ARM 2019-11-05 03:20:40 +00:00
libgeom pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libgpio pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libgssapi pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libiconv_modules
libifconfig
libipsec libipsec: correct a typo 2019-11-09 21:59:29 +00:00
libipt Update Intel Processor Trace decoder library. 2019-10-10 12:46:34 +00:00
libjail pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libkiconv pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libkvm kvm: fix types for cross-debugging 2019-11-08 14:51:09 +00:00
libldns
liblzma
libmagic MFV r354582: file 5.37. 2019-11-10 17:00:23 +00:00
libmd pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libmemstat pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libmilter
libmp pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libmt pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libnetbsd
libnetgraph pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libngatm pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libnv pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libomp When building libomp for i386, clang 9.0.0 produces a new warning about 2019-09-08 10:00:21 +00:00
libopenbsd
libopencsd Install the libopencsd version header (other headers now depend on it). 2019-10-11 09:18:45 +00:00
libopie
libpam pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libpathconv
libpcap pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libpe
libpjdlog pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libpmc libpmc: Forgot regex.h 2019-11-08 17:27:20 +00:00
libpmcstat
libproc pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libprocstat pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libradius pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libregex Further normalize copyright notices 2019-09-26 16:19:22 +00:00
librpcsec_gss
librpcsvc pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
librss
librt pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
librtld_db pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libsbuf pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libsdp
libsecureboot Initialize verbosity and debug level from env 2019-10-24 19:50:18 +00:00
libsm
libsmb
libsmdb
libsmutil
libsqlite3
libstats Introduce stats(3), a flexible statistics gathering API. 2019-10-07 19:05:05 +00:00
libstdbuf
libstdthreads
libsysdecode libsysdecode: decode PROT_MAX flags 2019-09-30 19:03:43 +00:00
libtacplus pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libtelnet
libthr libthr: Add missing END() directive for umtx_op_err (amd64) 2019-10-23 18:27:30 +00:00
libthread_db mips: hide regnum definitions behind _KERNEL/_WANT_MIPS_REGNUM 2019-08-22 21:43:21 +00:00
libucl Connect the libucl(3) manual page to the build. 2019-10-09 15:35:22 +00:00
libufs pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libugidfw pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libulog pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libunbound
libusb libusb: LIBUSB_DEBUG environment variable override of libusb_set_debug 2019-10-02 15:19:39 +00:00
libusbhid pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libutil pkgbase: Put a lot of binaries and lib in FreeBSD-runtime 2019-09-05 14:13:08 +00:00
libveriexec
libvgl Fix copying planar bitmaps when the horizontal start and end are both not 2019-05-03 13:06:46 +00:00
libvmmapi
libwrap pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libxo Import libxo-1.3.1: 2019-11-07 18:06:44 +00:00
liby
libypclnt pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libz Remove obsolete, non-use of CLANG_NO_IAS. 2019-10-18 00:00:17 +00:00
libzstd Update to Zstandard 1.4.2 2019-08-08 16:54:22 +00:00
msun The fdlibm hypot() implementations shouldn't potentially left-shift 2019-11-26 22:01:09 +00:00
ncurses Fix .depend files to work for build tools. 2019-06-15 17:08:13 +00:00
ofed Rework CXXSTD setting via r345708 2019-04-22 18:38:54 +00:00
tests
Makefile libclang_rt: enable on powerpc* 2019-11-23 19:35:09 +00:00
Makefile.inc