From owner-svn-src-head@freebsd.org Thu Jul 19 18:44:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F0911045334; Thu, 19 Jul 2018 18:44:12 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E1E274893; Thu, 19 Jul 2018 18:44:12 +0000 (UTC) (envelope-from dim@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 302382D12B; Thu, 19 Jul 2018 18:44:12 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6JIiCil092535; Thu, 19 Jul 2018 18:44:12 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6JIiAQt092528; Thu, 19 Jul 2018 18:44:10 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201807191844.w6JIiAQt092528@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 19 Jul 2018 18:44:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336497 - in head/lib/msun: . ld80 man src X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in head/lib/msun: . ld80 man src X-SVN-Commit-Revision: 336497 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2018 18:44:12 -0000 Author: dim Date: Thu Jul 19 18:44:10 2018 New Revision: 336497 URL: https://svnweb.freebsd.org/changeset/base/336497 Log: Fix powl, cpow, cpowf, and cpowl imports from OpenBSD This is a follow-up to r336299. * lib/msun/Makefile: . Remove polevll.c * lib/msun/ld80/e_powl.c: . Copy contents of polevll.c to here. This is the only consumer of these functions. Make functions 'static inline'. . Make reducl a 'static inline' function. * lib/msun/man/exp.3: . Remove BUGS section that no longer applies. * lib/msun/src/math_private.h: . Remove prototypes of __p1evll() and __polevll() * lib/msun/src/s_cpow.c: * lib/msun/src/s_cpowf.c: * lib/msun/src/s_cpowl.c . Use the CMPLX macro from either C99 or math_private.h (depends of compiler support) instead of the problematic use of complex I. Submitted by: Steve Kargl PR: 229876 MFC after: 1 week Deleted: head/lib/msun/src/polevll.c Modified: head/lib/msun/Makefile head/lib/msun/ld80/e_powl.c head/lib/msun/man/exp.3 head/lib/msun/src/math_private.h head/lib/msun/src/s_cpow.c head/lib/msun/src/s_cpowf.c head/lib/msun/src/s_cpowl.c Modified: head/lib/msun/Makefile ============================================================================== --- head/lib/msun/Makefile Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/Makefile Thu Jul 19 18:44:10 2018 (r336497) @@ -56,7 +56,6 @@ COMMON_SRCS= b_exp.c b_log.c b_tgamma.c \ imprecise.c \ k_cos.c k_cosf.c k_exp.c k_expf.c k_rem_pio2.c k_sin.c k_sinf.c \ k_tan.c k_tanf.c \ - polevll.c \ s_asinh.c s_asinhf.c s_atan.c s_atanf.c s_carg.c s_cargf.c s_cargl.c \ s_cbrt.c s_cbrtf.c s_ceil.c s_ceilf.c s_clog.c s_clogf.c \ s_copysign.c s_copysignf.c s_cos.c s_cosf.c \ Modified: head/lib/msun/ld80/e_powl.c ============================================================================== --- head/lib/msun/ld80/e_powl.c Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/ld80/e_powl.c Thu Jul 19 18:44:10 2018 (r336497) @@ -14,6 +14,52 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +__FBSDID("$FreeBSD$"); + +#include + +#include "math_private.h" + +/* + * Polynomial evaluator: + * P[0] x^n + P[1] x^(n-1) + ... + P[n] + */ +static inline long double +__polevll(long double x, long double *PP, int n) +{ + long double y; + long double *P; + + P = PP; + y = *P++; + do { + y = y * x + *P++; + } while (--n); + + return (y); +} + +/* + * Polynomial evaluator: + * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] + */ +static inline long double +__p1evll(long double x, long double *PP, int n) +{ + long double y; + long double *P; + + P = PP; + n -= 1; + y = x + *P++; + do { + y = y * x + *P++; + } while (--n); + + return (y); +} + /* powl.c * * Power function, long double precision @@ -467,7 +513,7 @@ return( z ); /* Find a multiple of 1/NXT that is within 1/NXT of x. */ -static long double +static inline long double reducl(long double x) { long double t; Modified: head/lib/msun/man/exp.3 ============================================================================== --- head/lib/msun/man/exp.3 Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/man/exp.3 Thu Jul 19 18:44:10 2018 (r336497) @@ -180,16 +180,9 @@ If 0**0 = 1, then then \*(Na**0 = 1 too because x**0 = 1 for all finite and infinite x, i.e., independently of x. .El -.Sh BUGS -To conform with newer C/C++ standards, a stub implementation for -.Nm powl -was committed to the math library, where -.Nm powl -is mapped to -.Nm pow . -Thus, the numerical accuracy is at most that of the 53-bit double -precision implementation. .Sh SEE ALSO +.Xr clog 3 +.Xr cpow 3 .Xr fenv 3 , .Xr ldexp 3 , .Xr log 3 , Modified: head/lib/msun/src/math_private.h ============================================================================== --- head/lib/msun/src/math_private.h Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/src/math_private.h Thu Jul 19 18:44:10 2018 (r336497) @@ -846,7 +846,4 @@ long double __kernel_sinl(long double, long double, in long double __kernel_cosl(long double, long double); long double __kernel_tanl(long double, long double, int); -long double __p1evll(long double, void *, int); -long double __polevll(long double, void *, int); - #endif /* !_MATH_PRIVATE_H_ */ Modified: head/lib/msun/src/s_cpow.c ============================================================================== --- head/lib/msun/src/s_cpow.c Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/src/s_cpow.c Thu Jul 19 18:44:10 2018 (r336497) @@ -60,7 +60,7 @@ cpow(double complex a, double complex z) y = cimag (z); absa = cabs (a); if (absa == 0.0) { - return (0.0 + 0.0 * I); + return (CMPLX(0.0, 0.0)); } arga = carg (a); r = pow (absa, x); @@ -69,6 +69,6 @@ cpow(double complex a, double complex z) r = r * exp (-y * arga); theta = theta + y * log (absa); } - w = r * cos (theta) + (r * sin (theta)) * I; + w = CMPLX(r * cos (theta), r * sin (theta)); return (w); } Modified: head/lib/msun/src/s_cpowf.c ============================================================================== --- head/lib/msun/src/s_cpowf.c Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/src/s_cpowf.c Thu Jul 19 18:44:10 2018 (r336497) @@ -59,7 +59,7 @@ cpowf(float complex a, float complex z) y = cimagf(z); absa = cabsf (a); if (absa == 0.0f) { - return (0.0f + 0.0f * I); + return (CMPLXF(0.0f, 0.0f)); } arga = cargf (a); r = powf (absa, x); @@ -68,6 +68,6 @@ cpowf(float complex a, float complex z) r = r * expf (-y * arga); theta = theta + y * logf (absa); } - w = r * cosf (theta) + (r * sinf (theta)) * I; + w = CMPLXF(r * cosf (theta), r * sinf (theta)); return (w); } Modified: head/lib/msun/src/s_cpowl.c ============================================================================== --- head/lib/msun/src/s_cpowl.c Thu Jul 19 17:49:39 2018 (r336496) +++ head/lib/msun/src/s_cpowl.c Thu Jul 19 18:44:10 2018 (r336497) @@ -59,7 +59,7 @@ cpowl(long double complex a, long double complex z) y = cimagl(z); absa = cabsl(a); if (absa == 0.0L) { - return (0.0L + 0.0L * I); + return (CMPLXL(0.0L, 0.0L)); } arga = cargl(a); r = powl(absa, x); @@ -68,6 +68,6 @@ cpowl(long double complex a, long double complex z) r = r * expl(-y * arga); theta = theta + y * logl(absa); } - w = r * cosl(theta) + (r * sinl(theta)) * I; + w = CMPLXL(r * cosl(theta), r * sinl(theta)); return (w); }