From: jsg Date: Wed, 12 May 2021 02:28:25 +0000 (+0000) Subject: Correct defines for fenv rounding modes and change fenv_t and fexcept_t X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a3d93523efd5a24da9368d9ca3c63025d3f36c08;p=openbsd Correct defines for fenv rounding modes and change fenv_t and fexcept_t from unsigned long long to unsigned int. ok kettenis@ --- diff --git a/lib/libm/arch/riscv64/fenv.c b/lib/libm/arch/riscv64/fenv.c index 56b9545f23b..5143ddf7d60 100644 --- a/lib/libm/arch/riscv64/fenv.c +++ b/lib/libm/arch/riscv64/fenv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fenv.c,v 1.2 2021/05/11 12:05:13 jsg Exp $ */ +/* $OpenBSD: fenv.c,v 1.3 2021/05/12 02:28:25 jsg Exp $ */ /*- * Copyright (c) 2004-2005 David Schultz * All rights reserved. @@ -30,10 +30,6 @@ #include #include -/* We need to be able to map status flag positions to mask flag positions */ -#define _FPUSW_SHIFT 8 -#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT) - #define __get_fcsr(r) asm volatile("frcsr %0" : "=r" (r)) #define __set_fcsr(r) asm volatile("fscsr %0" : "+r" (r)) #define __get_flags(r) asm volatile("frflags %0" : "=r" (r)) @@ -146,7 +142,7 @@ fegetround(void) fenv_t r; __get_frm(r); - return ((r >> _ROUND_SHIFT) & _ROUND_MASK); + return (r & _ROUND_MASK); } DEF_STD(fegetround); diff --git a/sys/arch/riscv64/include/fenv.h b/sys/arch/riscv64/include/fenv.h index 5c52a8183f2..72f7be50cee 100644 --- a/sys/arch/riscv64/include/fenv.h +++ b/sys/arch/riscv64/include/fenv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fenv.h,v 1.1 2021/04/23 02:42:16 drahn Exp $ */ +/* $OpenBSD: fenv.h,v 1.2 2021/05/12 02:28:25 jsg Exp $ */ /* * Copyright (c) 2011 Martynas Venckus @@ -46,23 +46,23 @@ * We use such values that allow direct bitwise operations on FPU registers. */ #define FE_TONEAREST 0x0 -#define FE_UPWARD 0x1 +#define FE_TOWARDZERO 0x1 #define FE_DOWNWARD 0x2 -#define FE_TOWARDZERO 0x3 -#define FE_TONEAREST_MAX 0x4 +#define FE_UPWARD 0x3 +#define FE_TONEARESTFROMZERO 0x4 /* * The following symbol is simply the bitwise-inclusive OR of all floating-point * rounding direction constants defined above. */ -#define _ROUND_MASK (FE_TONEAREST | FE_UPWARD | FE_DOWNWARD | \ - FE_TOWARDZERO) -#define _ROUND_SHIFT 0 +#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_DOWNWARD | \ + FE_UPWARD | FE_TONEARESTFROMZERO) +#define _ROUND_SHIFT 5 /* * fenv_t represents the entire floating-point environment. */ -typedef unsigned long long fenv_t; +typedef unsigned int fenv_t; /* * The following constant represents the default floating-point environment @@ -90,6 +90,6 @@ __END_DECLS * A floating-point control mode is a system variable whose value may be set by * the user to affect the subsequent behavior of floating-point arithmetic. */ -typedef unsigned long long fexcept_t; +typedef unsigned int fexcept_t; #endif /* !_MACHINE_FENV_H_ */