aboutsummaryrefslogtreecommitdiff
path: root/lib/msun/riscv/fenv.h
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2018-04-19 20:36:15 +0000
committerBrooks Davis <brooks@FreeBSD.org>2018-04-19 20:36:15 +0000
commit3b05ffaf6fc768425b18cd88e8091ef0681abfaf (patch)
tree7e65783af9a82b5e43807a8fd73111c1af5ae16e /lib/msun/riscv/fenv.h
parent85a9931516322e8df9218071e994f2f45b544461 (diff)
Replace SOFTFLOAT with __riscv_float_abi_*.
With SOFTFLOAT, libc and libm were built correctly, but any program including fenv.h itself assumed it was on a hardfloat systen and emitted inline fpu instructions for fedisableexcept() and friends. Unlike r315424 which did this for MIPS, I've used riscv_float_abi_soft and riscv_float_abi_double macros as appropriate rather than using __riscv_float_abi_soft exclusively. This ensures that attempts to use an unsupported hardfloat ABI will fail. Reviewed by: br Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D10039
Notes
Notes: svn path=/head/; revision=332792
Diffstat (limited to 'lib/msun/riscv/fenv.h')
-rw-r--r--lib/msun/riscv/fenv.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/msun/riscv/fenv.h b/lib/msun/riscv/fenv.h
index e66aa1c57753..f9d840d156fa 100644
--- a/lib/msun/riscv/fenv.h
+++ b/lib/msun/riscv/fenv.h
@@ -73,12 +73,20 @@ __BEGIN_DECLS
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
-#ifndef SOFTFLOAT
+#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)
+#if defined(__riscv_float_abi_single)
+#error single precision floating point ABI not supported
+#else
+#error compiler did not set soft/hard float macros
+#endif
+#endif
+
+#ifndef __riscv_float_abi_soft
#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))
#define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))
#endif
-#ifdef SOFTFLOAT
+#ifdef __riscv_float_abi_soft
int feclearexcept(int __excepts);
int fegetexceptflag(fexcept_t *__flagp, int __excepts);
int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
@@ -206,13 +214,13 @@ feupdateenv(const fenv_t *__envp)
return (0);
}
-#endif /* !SOFTFLOAT */
+#endif /* !__riscv_float_abi_soft */
#if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */
-#ifdef SOFTFLOAT
+#ifdef __riscv_float_abi_soft
int feenableexcept(int __mask);
int fedisableexcept(int __mask);
int fegetexcept(void);
@@ -243,7 +251,7 @@ fegetexcept(void)
return (0);
}
-#endif /* !SOFTFLOAT */
+#endif /* !__riscv_float_abi_soft */
#endif /* __BSD_VISIBLE */