riscv: Make feraiseexcept actually raise the given exceptions.
Doing fexcept_t ex = 0; fesetexceptflag(&ex, excepts); has the effect of _clearing_ all the exceptions in excepts. Using fesetexceptflag doesn't make this easier, because we would have to record which exceptions were already raised. So just set the fflags bits in the fcsr register directly.
This commit is contained in:
parent
af39a49700
commit
70dffce551
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: fenv.c,v 1.4 2023/05/07 12:41:47 skrll Exp $ */
|
/* $NetBSD: fenv.c,v 1.5 2024/05/17 02:11:07 riastradh Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__RCSID("$NetBSD: fenv.c,v 1.4 2023/05/07 12:41:47 skrll Exp $");
|
__RCSID("$NetBSD: fenv.c,v 1.5 2024/05/17 02:11:07 riastradh Exp $");
|
||||||
|
|
||||||
#include "namespace.h"
|
#include "namespace.h"
|
||||||
|
|
||||||
|
@ -114,19 +114,15 @@ fegetexceptflag(fexcept_t *flagp, int excepts)
|
||||||
* The standard explicitly allows us to execute an instruction that has the
|
* The standard explicitly allows us to execute an instruction that has the
|
||||||
* exception as a side effect, but we choose to manipulate the status register
|
* exception as a side effect, but we choose to manipulate the status register
|
||||||
* directly.
|
* directly.
|
||||||
*
|
|
||||||
* The validation of input is being deferred to fesetexceptflag().
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
feraiseexcept(int excepts)
|
feraiseexcept(int excepts)
|
||||||
{
|
{
|
||||||
fexcept_t ex = 0;
|
|
||||||
|
|
||||||
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
_DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);
|
||||||
|
|
||||||
excepts &= FE_ALL_EXCEPT;
|
excepts &= FE_ALL_EXCEPT;
|
||||||
fesetexceptflag(&ex, excepts);
|
fcsr_fflags_write(fcsr_fflags_read() | excepts);
|
||||||
/* XXX exception magic XXX */
|
|
||||||
|
|
||||||
/* Success */
|
/* Success */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue