soft-fp: support after-rounding tininess detection.
[glibc.git] / sysdeps / sparc / fpu / fenv_private.h
blob8690879ddca00ccd9fb42bfe30c5251c6319de62
1 #ifndef FENV_PRIVATE_H
2 #define FENV_PRIVATE_H 1
4 #include <fenv.h>
6 static __always_inline void
7 libc_feholdexcept (fenv_t *e)
9 fenv_t etmp;
10 __fenv_stfsr(etmp);
11 *(e) = etmp;
12 etmp = etmp & ~((0x1f << 23) | FE_ALL_EXCEPT);
13 __fenv_ldfsr(etmp);
16 static __always_inline void
17 libc_fesetround (int r)
19 fenv_t etmp;
20 __fenv_stfsr(etmp);
21 etmp = (etmp & ~__FE_ROUND_MASK) | (r);
22 __fenv_ldfsr(etmp);
25 static __always_inline void
26 libc_feholdexcept_setround (fenv_t *e, int r)
28 fenv_t etmp;
29 __fenv_stfsr(etmp);
30 *(e) = etmp;
31 etmp = etmp & ~((0x1f << 23) | FE_ALL_EXCEPT);
32 etmp = (etmp & ~__FE_ROUND_MASK) | (r);
33 __fenv_ldfsr(etmp);
36 static __always_inline int
37 libc_fetestexcept (int e)
39 fenv_t etmp;
40 __fenv_stfsr(etmp);
41 return etmp & (e) & FE_ALL_EXCEPT;
44 static __always_inline void
45 libc_fesetenv (fenv_t *e)
47 __fenv_ldfsr(*e);
50 static __always_inline int
51 libc_feupdateenv_test (fenv_t *e, int ex)
53 fenv_t etmp;
55 __fenv_stfsr(etmp);
56 etmp &= FE_ALL_EXCEPT;
58 __fenv_ldfsr(*e);
60 __feraiseexcept (etmp);
62 return etmp & ex;
65 static __always_inline void
66 libc_feupdateenv (fenv_t *e)
68 libc_feupdateenv_test (e, 0);
71 static __always_inline void
72 libc_feholdsetround (fenv_t *e, int r)
74 fenv_t etmp;
75 __fenv_stfsr(etmp);
76 *(e) = etmp;
77 etmp = (etmp & ~__FE_ROUND_MASK) | (r);
78 __fenv_ldfsr(etmp);
81 static __always_inline void
82 libc_feresetround (fenv_t *e)
84 fenv_t etmp;
85 __fenv_stfsr(etmp);
86 etmp = (etmp & ~__FE_ROUND_MASK) | (*e & __FE_ROUND_MASK);
87 __fenv_ldfsr(etmp);
90 #define libc_feholdexceptf libc_feholdexcept
91 #define libc_fesetroundf libc_fesetround
92 #define libc_feholdexcept_setroundf libc_feholdexcept_setround
93 #define libc_fetestexceptf libc_fetestexcept
94 #define libc_fesetenvf libc_fesetenv
95 #define libc_feupdateenv_testf libc_feupdateenv_test
96 #define libc_feupdateenvf libc_feupdateenv
97 #define libc_feholdsetroundf libc_feholdsetround
98 #define libc_feresetroundf libc_feresetround
99 #define libc_feholdexcept libc_feholdexcept
100 #define libc_fesetround libc_fesetround
101 #define libc_feholdexcept_setround libc_feholdexcept_setround
102 #define libc_fetestexcept libc_fetestexcept
103 #define libc_fesetenv libc_fesetenv
104 #define libc_feupdateenv_test libc_feupdateenv_test
105 #define libc_feupdateenv libc_feupdateenv
106 #define libc_feholdsetround libc_feholdsetround
107 #define libc_feresetround libc_feresetround
108 #define libc_feholdexceptl libc_feholdexcept
109 #define libc_fesetroundl libc_fesetround
110 #define libc_feholdexcept_setroundl libc_feholdexcept_setround
111 #define libc_fetestexceptl libc_fetestexcept
112 #define libc_fesetenvl libc_fesetenv
113 #define libc_feupdateenv_testl libc_feupdateenv_test
114 #define libc_feupdateenvl libc_feupdateenv
115 #define libc_feholdsetroundl libc_feholdsetround
116 #define libc_feresetroundl libc_feresetround
118 #endif /* FENV_PRIVATE_H */