Author: bde Date: Tue Jul 17 12:01:59 2018 New Revision: 336412 URL: https://svnweb.freebsd.org/changeset/base/336412
Log: Minor cleanups to csqrt*(), mostly in comments. Remove the STDC CX_LIMITED_RANGE pragma and its verbose comment. We still don't have any C99 compilers (that support fenv pragmas), and if we did then there are thousands of other places in libm that would need to use them more than here. The other cleanups are smaller. Modified: head/lib/msun/src/s_csqrt.c head/lib/msun/src/s_csqrtf.c head/lib/msun/src/s_csqrtl.c Modified: head/lib/msun/src/s_csqrt.c ============================================================================== --- head/lib/msun/src/s_csqrt.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrt.c Tue Jul 17 12:01:59 2018 (r336412) @@ -35,16 +35,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - -/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ +/* For avoiding overflow for components >= DBL_MAX / (1 + sqrt(2)). */ #define THRESH 0x1.a827999fcef32p+1022 double complex Modified: head/lib/msun/src/s_csqrtf.c ============================================================================== --- head/lib/msun/src/s_csqrtf.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrtf.c Tue Jul 17 12:01:59 2018 (r336412) @@ -34,21 +34,15 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - float complex csqrtf(float complex z) { - float a = crealf(z), b = cimagf(z); double t; + float a, b; + a = creal(z); + b = cimag(z); + /* Handle special cases. */ if (z == 0) return (CMPLXF(0, b)); @@ -82,9 +76,9 @@ csqrtf(float complex z) */ if (a >= 0) { t = sqrt((a + hypot(a, b)) * 0.5); - return (CMPLXF(t, b / (2.0 * t))); + return (CMPLXF(t, b / (2 * t))); } else { t = sqrt((-a + hypot(a, b)) * 0.5); - return (CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b))); + return (CMPLXF(fabsf(b) / (2 * t), copysignf(t, b))); } } Modified: head/lib/msun/src/s_csqrtl.c ============================================================================== --- head/lib/msun/src/s_csqrtl.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrtl.c Tue Jul 17 12:01:59 2018 (r336412) @@ -36,24 +36,17 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" /* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. + * THRESH is now calculated portably (up to 113-bit precision). However, + * the denormal threshold is hard-coded for a 15-bit exponent with the usual + * bias. s_logl.c and e_hypotl have less hard-coding but end up requiring + * the same for the exponent and more for the mantissa. */ -#pragma STDC CX_LIMITED_RANGE ON - -/* - * We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). - * Rather than determining the fully precise value at which we might - * overflow, just use a threshold of approximately LDBL_MAX / 4. - */ #if LDBL_MAX_EXP != 0x4000 #error "Unsupported long double format" -#else -#define THRESH 0x1p16382L #endif + +/* For avoiding overflow for components >= LDBL_MAX / (1 + sqrt(2)). */ +#define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L) long double complex csqrtl(long double complex z) _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"