Merge "Fix fegetenv and fesetenv for arm"

This commit is contained in:
Andrew Hsieh
2015-05-26 05:01:17 +00:00
committed by Gerrit Code Review

View File

@@ -66,14 +66,50 @@ extern const fenv_t __fe_dfl_env;
static __inline int fegetenv(fenv_t* __envp) {
fenv_t _fpscr;
#if !defined(__SOFTFP__)
#if !defined(__thumb__) || defined(__thumb2__)
__asm__ __volatile__("vmrs %0,fpscr" : "=r" (_fpscr));
#else
/* Switching from thumb1 to arm, do vmrs, then switch back */
__asm__ __volatile__(
".balign 4 \n\t"
"mov ip, pc \n\t"
"bx ip \n\t"
".arm \n\t"
"vmrs %0, fpscr \n\t"
"add ip, pc, #1 \n\t"
"bx ip \n\t"
".thumb \n\t"
: "=r" (_fpscr) : : "ip");
#endif
#else
_fpscr = 0;
#endif
*__envp = _fpscr;
return 0;
}
static __inline int fesetenv(const fenv_t* __envp) {
fenv_t _fpscr = *__envp;
#if !defined(__SOFTFP__)
#if !defined(__thumb__) || defined(__thumb2__)
__asm__ __volatile__("vmsr fpscr,%0" : :"ri" (_fpscr));
#else
/* Switching from thumb1 to arm, do vmsr, then switch back */
__asm__ __volatile__(
".balign 4 \n\t"
"mov ip, pc \n\t"
"bx ip \n\t"
".arm \n\t"
"vmsr fpscr, %0 \n\t"
"add ip, pc, #1 \n\t"
"bx ip \n\t"
".thumb \n\t"
: : "ri" (_fpscr) : "ip");
#endif
#else
_fpscr = _fpscr;
#endif
return 0;
}