4 #if __HAVE_68881__ || __mcffpu__
6 static unsigned getsr()
9 __asm__
__volatile__ ("fmove.l %%fpsr,%0" : "=dm"(v
));
13 static void setsr(unsigned v
)
15 __asm__
__volatile__ ("fmove.l %0,%%fpsr" : : "dm"(v
));
18 static unsigned getcr()
21 __asm__
__volatile__ ("fmove.l %%fpcr,%0" : "=dm"(v
));
25 static void setcr(unsigned v
)
27 __asm__
__volatile__ ("fmove.l %0,%%fpcr" : : "dm"(v
));
30 int feclearexcept(int mask
)
32 if (mask
& ~FE_ALL_EXCEPT
) return -1;
33 setsr(getsr() & ~mask
);
37 int feraiseexcept(int mask
)
39 if (mask
& ~FE_ALL_EXCEPT
) return -1;
40 setsr(getsr() | mask
);
44 int fetestexcept(int mask
)
46 return getsr() & mask
;
51 return getcr() & FE_UPWARD
;
54 hidden
int __fesetround(int r
)
56 setcr((getcr() & ~FE_UPWARD
) | r
);
60 int fegetenv(fenv_t
*envp
)
62 envp
->__control_register
= getcr();
63 envp
->__status_register
= getsr();
64 __asm__
__volatile__ ("fmove.l %%fpiar,%0"
65 : "=dm"(envp
->__instruction_address
));
69 int fesetenv(const fenv_t
*envp
)
71 static const fenv_t default_env
= { 0 };
72 if (envp
== FE_DFL_ENV
)
74 setcr(envp
->__control_register
);
75 setsr(envp
->__status_register
);
76 __asm__
__volatile__ ("fmove.l %0,%%fpiar"
77 : : "dm"(envp
->__instruction_address
));