From nobody Sat Aug 9 17:29:14 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bznvG4qLbz64jdy; Sat, 09 Aug 2025 17:29:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bznvG2vnyz3w0j; Sat, 09 Aug 2025 17:29:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754760554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JNHTRnoPyV4mKHgrs/qMzNWdsn8C5vCyRbA11WWfQFY=; b=jZJWsr5k3KEbtrpN+vnzuGSP+PFHZ4sfo2otdshnaF/Dv+pEElxwN1wGaBCkbOHbnVQp+K PcfIORVe3qHJ3qoyxf1NaD5Ljd4L1VOEa0/ANrnMkL2V774oz2X6lZhzjQSP8gE82rcBj1 33dWSFulGPp81r0s6zdyy2ScQdBLL6nmCBBiy/9dIpIMFpYkKkk55x+9NtAUy+roxNiKID TWmkDwG6S4Op/NUFBdpzEOPy69Z/Dm6IjQUgMyEhjTzN1L1n1/LCno4Wkt6CqH/a/7awEK TO2KjS4JGMO0OQDYP4AnpDAdInvqMGAnaTcQxOSBBOtR1JZOXKEkytFN/yjemw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754760554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JNHTRnoPyV4mKHgrs/qMzNWdsn8C5vCyRbA11WWfQFY=; b=w7hCDiKGRzPlWGCmYc88EoL5FIcL5ouKBpFKRDx40RzxxIHBkvUlnmD8ka4VFAdfOXobZf GGf6S88Ub+XHmlQ1Pyn8V6RiRXBgOHuyhq4sFQn+gf2Fq48RYAW5i5ieRCLNNhe2ipe6j7 Z4R7W15BFfdo0PHsUh0NJn3jvT0mBUgI9EFVL8Ad/ZPgz6LqUHpRhdK9w+rP7DHdb36Ywn 6gr8PD0I1jaUoRGWNh6CD7LKCTbYGmbKaMe9+wL1SYxXJR/KIIiDfD4w1zKdOD/Ld7+scO xKJIFqwoyK3JumeBG1bTXZnpdeklNdjlHrAZ2p/UjVghHjaxdjOH2RdeVDVI0Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754760554; a=rsa-sha256; cv=none; b=TPU49it9jpZ1wOuxDzHLUPxgtmVPY7I1IoKSvQTikwUXbJa3jrB6d+7xi0Z0HzoIQ+66Yw TDuPTM70tRq/GPmZMoJbmJSe1Qv994t7+wxBT5+b/ofUAkUaxJDqmVxzVgEw4gh8TPNCnc SyLoYraj5FAfTHP332krSK0mc/5n1HCacr2f40Ra0naJ8uqC5Kibj+549KUtIqjahppKV2 CeGAn4fUE27TjoLQr3rMYQUdHReXHH6BHxT0uRxHjSUhio4gMyncIngyxKybzcFwNXoIQ7 pMbkWGcmz8lwk/upJ6TGxHpHz0QBZYghs+/VyoC3HgTopRi6AsTJxoLIQv4JwA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bznvG2Sd8zWBL; Sat, 09 Aug 2025 17:29:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 579HTEBU067904; Sat, 9 Aug 2025 17:29:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 579HTEMD067901; Sat, 9 Aug 2025 17:29:14 GMT (envelope-from git) Date: Sat, 9 Aug 2025 17:29:14 GMT Message-Id: <202508091729.579HTEMD067901@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: a1d051bc878d - main - Updates for ccosh[f] and csinh[f] List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a1d051bc878decc761b37cf8771ead100cc05768 Auto-Submitted: auto-generated The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=a1d051bc878decc761b37cf8771ead100cc05768 commit a1d051bc878decc761b37cf8771ead100cc05768 Author: Steve Kargl AuthorDate: 2025-08-09 17:28:07 +0000 Commit: Dimitry Andric CommitDate: 2025-08-09 17:28:07 +0000 Updates for ccosh[f] and csinh[f] * lib/msun/src/s_ccosh.c: . Update Copyright years. . sin() and cos() are needed at the same time, so use sincos() to compute values. This does argument reduction once instead of twice. . Replace '* 0.5' with '/ 2'. This reduces diff with s_ccoshf.c. . For (LDBL_MANT_DIG == 53), add weak references for ccoshl and ccosl. * lib/msun/src/s_ccoshf.c: . Update Copyright years. . sin() and cos() are needed at the same time, so use sincos() to compute values. This does argument reduction once instead of twice. . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c. * lib/msun/src/s_csinh.c: . Update Copyright years. . sin() and cos() are needed at the same time, so use sincos() to compute values. This does argument reduction once instead of twice. . Replace '* 0.5' with '/ 2'. This reduces diff with s_csinhf.c. . For (LDBL_MANT_DIG == 53), add weak references for csinhl and csinl. * lib/msun/src/s_csinhf.c: . Update Copyright years. . sin() and cos() are needed at the same time, so use sincos() to compute values. This does argument reduction once instead of twice. . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c. PR: 288740 MFC after: 1 week --- lib/msun/src/s_ccosh.c | 23 ++++++++++++++++------- lib/msun/src/s_ccoshf.c | 18 +++++++++++------- lib/msun/src/s_csinh.c | 23 ++++++++++++++++------- lib/msun/src/s_csinhf.c | 18 +++++++++++------- 4 files changed, 54 insertions(+), 28 deletions(-) diff --git a/lib/msun/src/s_ccosh.c b/lib/msun/src/s_ccosh.c index 3d46c993c6f1..14a8931742dc 100644 --- a/lib/msun/src/s_ccosh.c +++ b/lib/msun/src/s_ccosh.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl + * Copyright (c) 2005-2025 Bruce D. Evans and Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ static const double huge = 0x1p1023; double complex ccosh(double complex z) { - double x, y, h; + double c, h, s, x, y; int32_t hx, hy, ix, iy, lx, ly; x = creal(z); @@ -64,14 +64,16 @@ ccosh(double complex z) if (ix < 0x7ff00000 && iy < 0x7ff00000) { if ((iy | ly) == 0) return (CMPLX(cosh(x), x * y)); + + sincos(y, &s, &c); if (ix < 0x40360000) /* |x| < 22: normal case */ - return (CMPLX(cosh(x) * cos(y), sinh(x) * sin(y))); + return (CMPLX(cosh(x) * c, sinh(x) * s)); /* |x| >= 22, so cosh(x) ~= exp(|x|) */ if (ix < 0x40862e42) { /* x < 710: exp(|x|) won't overflow */ - h = exp(fabs(x)) * 0.5; - return (CMPLX(h * cos(y), copysign(h, x) * sin(y))); + h = exp(fabs(x)) / 2; + return (CMPLX(h * c, copysign(h, x) * s)); } else if (ix < 0x4096bbaa) { /* x < 1455: scale to avoid overflow */ z = __ldexp_cexp(CMPLX(fabs(x), y), -1); @@ -79,7 +81,7 @@ ccosh(double complex z) } else { /* x >= 1455: the result always overflows */ h = huge * x; - return (CMPLX(h * h * cos(y), h * sin(y))); + return (CMPLX(h * h * c, h * s)); } } @@ -129,7 +131,9 @@ ccosh(double complex z) if (ix == 0x7ff00000 && lx == 0) { if (iy >= 0x7ff00000) return (CMPLX(INFINITY, x * (y - y))); - return (CMPLX(INFINITY * cos(y), x * sin(y))); + + sincos(y, &s, &c); + return (CMPLX(INFINITY * c, x * s)); } /* @@ -154,3 +158,8 @@ ccos(double complex z) /* ccos(z) = ccosh(I * z) */ return (ccosh(CMPLX(-cimag(z), creal(z)))); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(ccosh, ccoshl); +__weak_reference(ccos, ccosl); +#endif diff --git a/lib/msun/src/s_ccoshf.c b/lib/msun/src/s_ccoshf.c index aeb2dec23677..fa41fdf4c4ea 100644 --- a/lib/msun/src/s_ccoshf.c +++ b/lib/msun/src/s_ccoshf.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl + * Copyright (c) 2005-2025 Bruce D. Evans and Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,7 +40,7 @@ static const float huge = 0x1p127; float complex ccoshf(float complex z) { - float x, y, h; + float c, h, s, x, y; int32_t hx, hy, ix, iy; x = crealf(z); @@ -55,14 +55,16 @@ ccoshf(float complex z) if (ix < 0x7f800000 && iy < 0x7f800000) { if (iy == 0) return (CMPLXF(coshf(x), x * y)); + + sincosf(y, &s, &c); if (ix < 0x41100000) /* |x| < 9: normal case */ - return (CMPLXF(coshf(x) * cosf(y), sinhf(x) * sinf(y))); + return (CMPLXF(coshf(x) * c, sinhf(x) * s)); /* |x| >= 9, so cosh(x) ~= exp(|x|) */ if (ix < 0x42b17218) { /* x < 88.7: expf(|x|) won't overflow */ - h = expf(fabsf(x)) * 0.5F; - return (CMPLXF(h * cosf(y), copysignf(h, x) * sinf(y))); + h = expf(fabsf(x)) / 2; + return (CMPLXF(h * c, copysignf(h, x) * s)); } else if (ix < 0x4340b1e7) { /* x < 192.7: scale to avoid overflow */ z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); @@ -70,7 +72,7 @@ ccoshf(float complex z) } else { /* x >= 192.7: the result always overflows */ h = huge * x; - return (CMPLXF(h * h * cosf(y), h * sinf(y))); + return (CMPLXF(h * h * c, h * s)); } } @@ -86,7 +88,9 @@ ccoshf(float complex z) if (ix == 0x7f800000) { if (iy >= 0x7f800000) return (CMPLXF(INFINITY, x * (y - y))); - return (CMPLXF(INFINITY * cosf(y), x * sinf(y))); + + sincosf(y, &s, &c); + return (CMPLXF(INFINITY * c, x * s)); } return (CMPLXF(((long double)x * x) * (y - y), diff --git a/lib/msun/src/s_csinh.c b/lib/msun/src/s_csinh.c index e7ed10e7d885..11c2ec345094 100644 --- a/lib/msun/src/s_csinh.c +++ b/lib/msun/src/s_csinh.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl + * Copyright (c) 2005-2025 Bruce D. Evans and Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ static const double huge = 0x1p1023; double complex csinh(double complex z) { - double x, y, h; + double c, h, s, x, y; int32_t hx, hy, ix, iy, lx, ly; x = creal(z); @@ -64,14 +64,16 @@ csinh(double complex z) if (ix < 0x7ff00000 && iy < 0x7ff00000) { if ((iy | ly) == 0) return (CMPLX(sinh(x), y)); + + sincos(y, &s, &c); if (ix < 0x40360000) /* |x| < 22: normal case */ - return (CMPLX(sinh(x) * cos(y), cosh(x) * sin(y))); + return (CMPLX(sinh(x) * c, cosh(x) * s)); /* |x| >= 22, so cosh(x) ~= exp(|x|) */ if (ix < 0x40862e42) { /* x < 710: exp(|x|) won't overflow */ - h = exp(fabs(x)) * 0.5; - return (CMPLX(copysign(h, x) * cos(y), h * sin(y))); + h = exp(fabs(x)) / 2; + return (CMPLX(copysign(h, x) * c, h * s)); } else if (ix < 0x4096bbaa) { /* x < 1455: scale to avoid overflow */ z = __ldexp_cexp(CMPLX(fabs(x), y), -1); @@ -79,7 +81,7 @@ csinh(double complex z) } else { /* x >= 1455: the result always overflows */ h = huge * x; - return (CMPLX(h * cos(y), h * h * sin(y))); + return (CMPLX(h * c, h * h * s)); } } @@ -128,7 +130,9 @@ csinh(double complex z) if (ix == 0x7ff00000 && lx == 0) { if (iy >= 0x7ff00000) return (CMPLX(x, y - y)); - return (CMPLX(x * cos(y), INFINITY * sin(y))); + + sincos(y, &s, &c); + return (CMPLX(x * c, INFINITY * s)); } /* @@ -154,3 +158,8 @@ csin(double complex z) z = csinh(CMPLX(cimag(z), creal(z))); return (CMPLX(cimag(z), creal(z))); } + +#if (LDBL_MANT_DIG == 53) +__weak_reference(csinh, csinhl); +__weak_reference(csin, csinl); +#endif diff --git a/lib/msun/src/s_csinhf.c b/lib/msun/src/s_csinhf.c index c4392755c482..fcfc011a2484 100644 --- a/lib/msun/src/s_csinhf.c +++ b/lib/msun/src/s_csinhf.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2005 Bruce D. Evans and Steven G. Kargl + * Copyright (c) 2005-2025 Bruce D. Evans and Steven G. Kargl * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -40,7 +40,7 @@ static const float huge = 0x1p127; float complex csinhf(float complex z) { - float x, y, h; + float c, h, s, x, y; int32_t hx, hy, ix, iy; x = crealf(z); @@ -55,14 +55,16 @@ csinhf(float complex z) if (ix < 0x7f800000 && iy < 0x7f800000) { if (iy == 0) return (CMPLXF(sinhf(x), y)); + + sincosf(y, &s, &c); if (ix < 0x41100000) /* |x| < 9: normal case */ - return (CMPLXF(sinhf(x) * cosf(y), coshf(x) * sinf(y))); + return (CMPLXF(sinhf(x) * c, coshf(x) * s)); /* |x| >= 9, so cosh(x) ~= exp(|x|) */ if (ix < 0x42b17218) { /* x < 88.7: expf(|x|) won't overflow */ - h = expf(fabsf(x)) * 0.5F; - return (CMPLXF(copysignf(h, x) * cosf(y), h * sinf(y))); + h = expf(fabsf(x)) / 2; + return (CMPLXF(copysignf(h, x) * c, h * s)); } else if (ix < 0x4340b1e7) { /* x < 192.7: scale to avoid overflow */ z = __ldexp_cexpf(CMPLXF(fabsf(x), y), -1); @@ -70,7 +72,7 @@ csinhf(float complex z) } else { /* x >= 192.7: the result always overflows */ h = huge * x; - return (CMPLXF(h * cosf(y), h * h * sinf(y))); + return (CMPLXF(h * c, h * h * s)); } } @@ -86,7 +88,9 @@ csinhf(float complex z) if (ix == 0x7f800000) { if (iy >= 0x7f800000) return (CMPLXF(x, y - y)); - return (CMPLXF(x * cosf(y), INFINITY * sinf(y))); + + sincosf(y, &s, &c); + return (CMPLXF(x * c, INFINITY * s)); } return (CMPLXF(((long double)x + x) * (y - y),