non-std functions for fenv.g

This commit is contained in:
bumbread 2022-06-10 23:34:51 +11:00
parent caef55ef67
commit 6f57efcaa9
2 changed files with 36 additions and 0 deletions

View File

@ -103,3 +103,23 @@ int feupdateenv(fenv_t const *envp) {
feraiseexcept(excepts); feraiseexcept(excepts);
return 0; return 0;
} }
int _feenabletraps(int excepts) {
if((excepts & FE_ALL_EXCEPT) != excepts) {
return 1;
}
fexcept_t csr = _mm_getcsr();
csr &= ~fe_masks(excepts);
_mm_setcsr(csr);
return 0;
}
int _fedisabletraps(int excepts) {
if((excepts & FE_ALL_EXCEPT) != excepts) {
return 1;
}
fexcept_t csr = _mm_getcsr();
csr |= fe_masks(excepts);
_mm_setcsr(csr);
return 0;
}

View File

@ -30,16 +30,32 @@ typedef unsigned fenv_t;
extern fenv_t _fe_dfl_env; extern fenv_t _fe_dfl_env;
#define FE_DFL_ENV (&_fe_dfl_env) #define FE_DFL_ENV (&_fe_dfl_env)
// Exceptions
int feclearexcept(int excepts); int feclearexcept(int excepts);
int fegetexceptflag(fexcept_t *flagp, int excepts); int fegetexceptflag(fexcept_t *flagp, int excepts);
int feraiseexcept(int excepts); int feraiseexcept(int excepts);
int fesetexceptflag(const fexcept_t *flagp, int excepts); int fesetexceptflag(const fexcept_t *flagp, int excepts);
int fetestexcept(int excepts); int fetestexcept(int excepts);
// Rounding behaviour
int fegetround(void); int fegetround(void);
int fesetround(int round); int fesetround(int round);
// Environment
int fegetenv(fenv_t *env); int fegetenv(fenv_t *env);
int fesetenv(fenv_t *env); int fesetenv(fenv_t *env);
int feholdexcept(fenv_t *envp); int feholdexcept(fenv_t *envp);
int feupdateenv(fenv_t const *envp); int feupdateenv(fenv_t const *envp);
// Non-standard functions
int _feenabletraps(int excepts);
int _fedisabletraps(int excepts);
#if defined(_CIABATTA_EXT)
#define feenabletraps _feenabletraps
#define _fedisabletraps _fedisabletraps
#endif