On Sun, 8 Dec 2019, Liu Hao wrote:

在 2019/12/8 上午6:39, Martin Storsjö 写道:
Signed-off-by: Martin Storsjö <[email protected]>
---
 mingw-w64-crt/math/arm/nearbyint.S  | 17 +++++------------
 mingw-w64-crt/math/arm/nearbyintf.S | 17 +++++------------
 mingw-w64-crt/math/arm/nearbyintl.S | 17 +++++------------
 3 files changed, 15 insertions(+), 36 deletions(-)



`nearbyint()` is specified to be the same as `rint()` except that the
former does not raise the "inexact" exception. Probably this exception
should be disabled before the call to `rint()` [1].

In this context, "raise an exception" means set a bit in the fpu status register (at least on ARM).

On glibc, there's a function feenableexcept, which lets fpu exceptions trigger a signal, but we don't have that in mingw-w64, and even on glibc on arm, such fpu exceptions don't trigger a signal.

Therefore, the "don't raise an exception" in this case is fulfilled by "reset the exception bits to what they were before". (We had that before as well, the vmrs/vmsr instruction pair, but just using a different register.)

Also see e.g. the comment in freebsd's implementation of nearbyint [1].


I know little about ARM assembly. I believe you have had some testsuites
set up for ARM and AArch64. As long as those tests pass, you may push
these patches at your disposal.

Yes, I have some sort of testsuite for it, for all architectures, but it doesn't really test the exception aspect yet.

The other patches look good to me.

Thanks! Will push a bit later.

[1] 
https://github.com/freebsd/freebsd/blob/master/lib/msun/src/s_nearbyint.c#L35-L45

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to