From owner-svn-src-all@freebsd.org Fri Aug 11 22:41:26 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 381A0DCC5DE; Fri, 11 Aug 2017 22:41:26 +0000 (UTC) (envelope-from rlibby@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 144D767D95; Fri, 11 Aug 2017 22:41:26 +0000 (UTC) (envelope-from rlibby@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7BMfPGu028266; Fri, 11 Aug 2017 22:41:25 GMT (envelope-from rlibby@FreeBSD.org) Received: (from rlibby@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7BMfP5X028262; Fri, 11 Aug 2017 22:41:25 GMT (envelope-from rlibby@FreeBSD.org) Message-Id: <201708112241.v7BMfP5X028262@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rlibby set sender to rlibby@FreeBSD.org using -f From: Ryan Libby Date: Fri, 11 Aug 2017 22:41:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322418 - head/lib/msun/src X-SVN-Group: head X-SVN-Commit-Author: rlibby X-SVN-Commit-Paths: head/lib/msun/src X-SVN-Commit-Revision: 322418 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Aug 2017 22:41:26 -0000 Author: rlibby Date: Fri Aug 11 22:41:24 2017 New Revision: 322418 URL: https://svnweb.freebsd.org/changeset/base/322418 Log: lib/msun: avoid referring to broken LDBL_MAX LDBL_MAX is broken on i386: https://lists.freebsd.org/pipermail/freebsd-numerics/2012-September/000288.html Gcc has produced +Infinity for LDBL_MAX on i386 and amd64 with -m32 for some time, and newer versions of gcc are now warning that the "floating constant exceeds range of 'long double'". Avoid this by referring to half the value of LDBL_MAX instead. Reviewed by: bde Approved by: markj (mentor) Sponsored by: Dell EMC Isilon Modified: head/lib/msun/src/catrigl.c head/lib/msun/src/math_private.h head/lib/msun/src/s_csqrtl.c Modified: head/lib/msun/src/catrigl.c ============================================================================== --- head/lib/msun/src/catrigl.c Fri Aug 11 22:39:38 2017 (r322417) +++ head/lib/msun/src/catrigl.c Fri Aug 11 22:41:24 2017 (r322418) @@ -307,7 +307,7 @@ clog_for_large_values(long double complex z) ay = t; } - if (ax > LDBL_MAX / 2) + if (ax >= HALF_LDBL_MAX) return (CMPLXL(logl(hypotl(x / m_e, y / m_e)) + 1, atan2l(y, x))); Modified: head/lib/msun/src/math_private.h ============================================================================== --- head/lib/msun/src/math_private.h Fri Aug 11 22:39:38 2017 (r322417) +++ head/lib/msun/src/math_private.h Fri Aug 11 22:41:24 2017 (r322418) @@ -272,6 +272,15 @@ do { \ #define LD80C(m, ex, v) { .e = (v), } #endif +/* + * XXX LDBL_MAX is broken on i386. If the precise value of LDBL_MAX is not + * needed, this may be worked around by instead referring to a proxy, such + * as HALF_LDBL_MAX, below. HALF_LDBL_MAX is approximately LDBL_MAX / 2, + * actually just greater than. Note that 2 * HALF_LDBL_MAX will always + * overflow to infinity, regardless of the precision and rounding modes. + */ +#define HALF_LDBL_MAX __CONCAT(__CONCAT(0x0.8p, LDBL_MAX_EXP), L) + #ifdef FLT_EVAL_METHOD /* * Attempt to get strict C99 semantics for assignment with non-C99 compilers. Modified: head/lib/msun/src/s_csqrtl.c ============================================================================== --- head/lib/msun/src/s_csqrtl.c Fri Aug 11 22:39:38 2017 (r322417) +++ head/lib/msun/src/s_csqrtl.c Fri Aug 11 22:41:24 2017 (r322418) @@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$"); #pragma STDC CX_LIMITED_RANGE ON /* We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). */ -#define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L) +#define THRESH (HALF_LDBL_MAX / 1.207106781186547524400844362104849L) long double complex csqrtl(long double complex z)