42#include "../inc/cdefs-compat.h"
45#define __fenv_static static
52#define FE_INVALID 0x0010
53#define FE_DIVBYZERO 0x0008
54#define FE_OVERFLOW 0x0004
55#define FE_UNDERFLOW 0x0002
56#define FE_INEXACT 0x0001
57#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
58 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
64#define FE_TONEAREST (0x00 << _ROUND_SHIFT)
65#define FE_TOWARDZERO (0x01 << _ROUND_SHIFT)
66#define FE_DOWNWARD (0x02 << _ROUND_SHIFT)
67#define FE_UPWARD (0x03 << _ROUND_SHIFT)
68#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
69 FE_UPWARD | FE_TOWARDZERO)
75#define FE_DFL_ENV (&__fe_dfl_env)
77#if !defined(__riscv_float_abi_soft) && !defined(__riscv_float_abi_double)
78#if defined(__riscv_float_abi_single)
79#error single precision floating point ABI not supported
81#error compiler did not set soft/hard float macros
85#ifndef __riscv_float_abi_soft
86#define __rfs(__fcsr) __asm __volatile("csrr %0, fcsr" : "=r" (__fcsr))
87#define __wfs(__fcsr) __asm __volatile("csrw fcsr, %0" :: "r" (__fcsr))
90#ifdef __riscv_float_abi_soft
107 __asm
__volatile(
"csrc fflags, %0" ::
"r"(__excepts));
118 *__flagp = __fcsr & __excepts;
129 __asm
__volatile(
"csrc fflags, %0" ::
"r"(__excepts));
130 __asm
__volatile(
"csrs fflags, %0" ::
"r"(__fcsr & __excepts));
139 __asm
__volatile(
"csrs fflags, %0" ::
"r"(__excepts));
151 return (__fcsr & __excepts);
173 __fcsr &= ~_ROUND_MASK;
224#ifdef __riscv_float_abi_soft
225int feenableexcept(
int __mask);
226int fedisableexcept(
int __mask);
227int fegetexcept(
void);
230feenableexcept(
int __mask)
239fedisableexcept(
int __mask)
__fenv_static int feraiseexcept(int __excepts)
__fenv_static int fesetround(int __round)
__fenv_static int feholdexcept(fenv_t *__envp)
__fenv_static int fetestexcept(int __excepts)
__fenv_static int fegetexceptflag(fexcept_t *__flagp, int __excepts)
__fenv_static int feupdateenv(const fenv_t *__envp)
__BEGIN_DECLS const fenv_t __fe_dfl_env
__fenv_static int fegetround(void)
__fenv_static int fesetenv(const fenv_t *__envp)
__fenv_static int fegetenv(fenv_t *__envp)
__fenv_static int fesetexceptflag(const fexcept_t *__flagp, int __excepts)
__fenv_static int feclearexcept(int __excepts)