1 /* Copyright (c) 2017 SiFive Inc. All rights reserved. 2 3 This copyrighted material is made available to anyone wishing to use, 4 modify, copy, or redistribute it subject to the terms and conditions 5 of the FreeBSD License. This program is distributed in the hope that 6 it will be useful, but WITHOUT ANY WARRANTY expressed or implied, 7 including the implied warranties of MERCHANTABILITY or FITNESS FOR 8 A PARTICULAR PURPOSE. A copy of this license is available at 9 http://www.opensource.org/licenses. 10 */ 11 12 #ifndef _FENV_H 13 #define _FENV_H 14 15 #include <sys/cdefs.h> 16 17 _BEGIN_STD_C 18 19 #include <machine/fenv.h> 20 21 #ifndef FE_ALL_EXCEPT 22 #define FE_ALL_EXCEPT 0 23 #endif 24 25 /* Exception */ 26 int feclearexcept(int excepts); 27 int fegetexceptflag(fexcept_t *flagp, int excepts); 28 int feraiseexcept(int excepts); 29 int fesetexceptflag(const fexcept_t *flagp, int excepts); 30 int fetestexcept(int excepts); 31 32 /* Rounding mode */ 33 int fegetround(void); 34 int fesetround(int rounding_mode); 35 36 /* Float environment */ 37 int fegetenv(fenv_t *envp); 38 int feholdexcept(fenv_t *envp); 39 int fesetenv(const fenv_t *envp); 40 int feupdateenv(const fenv_t *envp); 41 42 #if __GNU_VISIBLE 43 int feenableexcept(int); 44 int fedisableexcept(int); 45 int fegetexcept(void); 46 #endif 47 48 /* 49 * Lastly, a FE_DFL_ENV macro must be defined, representing a pointer 50 * to const fenv_t that contains the value of the default floating point 51 * environment. 52 * 53 * NOTE: The extern'ed variable fe_default_env_p is an implementation 54 * detail of this stub. FE_DFL_ENV must point to an instance of 55 * fenv_t with the default fenv_t. The format of fenv_t and where 56 * FE_DFL_ENV is are implementation specific. 57 */ 58 extern fenv_t _fe_dfl_env; 59 #define FE_DFL_ENV ((const fenv_t *) &_fe_dfl_env) 60 61 #ifdef __STDC_WANT_IEC_60559_BFP_EXT__ 62 63 #ifndef FE_DFL_MODE 64 typedef struct { int round, except; } femode_t; 65 #define FE_DFL_MODE ((femode_t *) 0) 66 #endif 67 68 int fegetmode(femode_t *modep); 69 int fesetmode(femode_t *modep); 70 int fesetexcept(int excepts); 71 72 #endif 73 74 _END_STD_C 75 76 #endif 77