* [PATCH] Cygwin: fix return value of sqrtl on negative infinity
@ 2020-10-27 14:10 Ken Brown
2020-10-27 14:15 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2020-10-27 14:10 UTC (permalink / raw)
To: cygwin-patches
The return value is now -NaN.
This fixes a bug in the mingw-w64 code that was imported into Cygwin.
The fix is consistent with Posix and Linux. It is also consistent
with the current mingw-w64 code, with one exception: The mingw-w64
code sets errno to EDOM if the input is -NaN, but this appears to
differ from Posix and Linux.
Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
---
winsup/cygwin/math/sqrt.def.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
index cf8b5cbe6..3d1a00908 100644
--- a/winsup/cygwin/math/sqrt.def.h
+++ b/winsup/cygwin/math/sqrt.def.h
@@ -73,8 +73,11 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
if (x_class == FP_ZERO)
return __FLT_CST (-0.0);
+ if (x_class == FP_NAN)
+ return x;
+
errno = EDOM;
- return x;
+ return -__FLT_NAN;
}
else if (x_class == FP_ZERO)
return __FLT_CST (0.0);
--
2.28.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Cygwin: fix return value of sqrtl on negative infinity
2020-10-27 14:10 [PATCH] Cygwin: fix return value of sqrtl on negative infinity Ken Brown
@ 2020-10-27 14:15 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2020-10-27 14:15 UTC (permalink / raw)
To: cygwin-patches
On Oct 27 10:10, Ken Brown via Cygwin-patches wrote:
> The return value is now -NaN.
>
> This fixes a bug in the mingw-w64 code that was imported into Cygwin.
> The fix is consistent with Posix and Linux. It is also consistent
> with the current mingw-w64 code, with one exception: The mingw-w64
> code sets errno to EDOM if the input is -NaN, but this appears to
> differ from Posix and Linux.
>
> Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
> ---
> winsup/cygwin/math/sqrt.def.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
> index cf8b5cbe6..3d1a00908 100644
> --- a/winsup/cygwin/math/sqrt.def.h
> +++ b/winsup/cygwin/math/sqrt.def.h
> @@ -73,8 +73,11 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
> if (x_class == FP_ZERO)
> return __FLT_CST (-0.0);
>
> + if (x_class == FP_NAN)
> + return x;
> +
> errno = EDOM;
> - return x;
> + return -__FLT_NAN;
> }
> else if (x_class == FP_ZERO)
> return __FLT_CST (0.0);
> --
> 2.28.0
LGTM
Thanks,
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-27 14:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 14:10 [PATCH] Cygwin: fix return value of sqrtl on negative infinity Ken Brown
2020-10-27 14:15 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).