1 #ifndef _FENV_H 2 #include <math/fenv.h> 3 4 #ifndef _ISOMAC 5 # include <stdbool.h> 6 /* Now define the internal interfaces. */ 7 8 extern int __feclearexcept (int __excepts); 9 extern int __fegetexcept (void); 10 extern int __fegetexceptflag (fexcept_t *__flagp, int __excepts); 11 extern int __feraiseexcept (int __excepts); 12 extern int __fesetexceptflag (const fexcept_t *__flagp, int __excepts); 13 extern int __fegetenv (fenv_t *__envp); 14 extern int __fesetenv (const fenv_t *__envp); 15 extern int __feupdateenv (const fenv_t *__envp); 16 extern __typeof (fegetround) __fegetround __attribute_pure__; 17 extern __typeof (feholdexcept) __feholdexcept; 18 extern __typeof (fesetround) __fesetround; 19 20 libm_hidden_proto (feraiseexcept) 21 libm_hidden_proto (__feraiseexcept) 22 libm_hidden_proto (fegetenv) 23 libm_hidden_proto (__fegetenv) 24 libm_hidden_proto (fegetround) 25 libm_hidden_proto (__fegetround) 26 libm_hidden_proto (fesetenv) 27 libm_hidden_proto (__fesetenv) 28 libm_hidden_proto (fesetround) 29 libm_hidden_proto (__fesetround) 30 libm_hidden_proto (feholdexcept) 31 libm_hidden_proto (__feholdexcept) 32 libm_hidden_proto (feupdateenv) 33 libm_hidden_proto (__feupdateenv) 34 libm_hidden_proto (fetestexcept) 35 libm_hidden_proto (feclearexcept) 36 37 /* Rounding mode context. This allows functions to set/restore rounding mode 38 only when the desired rounding mode is different from the current rounding 39 mode. */ 40 struct rm_ctx 41 { 42 fenv_t env; 43 bool updated_status; 44 }; 45 46 /* Track whether rounding mode macros were defined, since 47 get-rounding-mode.h may define default versions if they weren't. 48 FE_TONEAREST must always be defined (even if no changes of rounding 49 mode are supported, glibc requires it to be defined to represent 50 the default rounding mode). */ 51 # ifndef FE_TONEAREST 52 # error "FE_TONEAREST not defined" 53 # endif 54 # if defined FE_DOWNWARD || defined FE_TOWARDZERO || defined FE_UPWARD 55 # define FE_HAVE_ROUNDING_MODES 1 56 # else 57 # define FE_HAVE_ROUNDING_MODES 0 58 # endif 59 60 /* When no floating-point exceptions are defined in <fenv.h>, make 61 feraiseexcept ignore its argument so that unconditional 62 feraiseexcept calls do not cause errors for undefined exceptions. 63 Define it to expand to a void expression so that any calls testing 64 the result of feraiseexcept do produce errors. */ 65 # if FE_ALL_EXCEPT == 0 66 # define feraiseexcept(excepts) ((void) 0) 67 # define __feraiseexcept(excepts) ((void) 0) 68 # endif 69 70 /* Similarly, most <fenv.h> functions have trivial implementations in 71 the absence of support for floating-point exceptions and rounding 72 modes. */ 73 74 # if !FE_HAVE_ROUNDING_MODES 75 # if FE_ALL_EXCEPT == 0 76 extern inline int fegetenv(fenv_t * __e)77fegetenv (fenv_t *__e) 78 { 79 return 0; 80 } 81 82 extern inline int __fegetenv(fenv_t * __e)83__fegetenv (fenv_t *__e) 84 { 85 return 0; 86 } 87 88 extern inline int feholdexcept(fenv_t * __e)89feholdexcept (fenv_t *__e) 90 { 91 return 0; 92 } 93 94 extern inline int __feholdexcept(fenv_t * __e)95__feholdexcept (fenv_t *__e) 96 { 97 return 0; 98 } 99 100 extern inline int fesetenv(const fenv_t * __e)101fesetenv (const fenv_t *__e) 102 { 103 return 0; 104 } 105 106 extern inline int __fesetenv(const fenv_t * __e)107__fesetenv (const fenv_t *__e) 108 { 109 return 0; 110 } 111 112 extern inline int feupdateenv(const fenv_t * __e)113feupdateenv (const fenv_t *__e) 114 { 115 return 0; 116 } 117 118 extern inline int __feupdateenv(const fenv_t * __e)119__feupdateenv (const fenv_t *__e) 120 { 121 return 0; 122 } 123 # endif 124 125 extern inline int fegetround(void)126fegetround (void) 127 { 128 return FE_TONEAREST; 129 } 130 131 extern inline int __fegetround(void)132__fegetround (void) 133 { 134 return FE_TONEAREST; 135 } 136 137 extern inline int fesetround(int __d)138fesetround (int __d) 139 { 140 return 0; 141 } 142 143 extern inline int __fesetround(int __d)144__fesetround (int __d) 145 { 146 return 0; 147 } 148 # endif 149 150 #endif 151 152 #endif 153