sh3eb: only retain the softfp option of the MIPS fenv.h

This commit is contained in:
Lephenixnoir 2020-10-24 12:42:30 +02:00
parent 1b364a5edf
commit 89b463b811
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 1 additions and 187 deletions

View file

@ -40,21 +40,13 @@ typedef uint32_t fenv_t;
typedef uint32_t fexcept_t; typedef uint32_t fexcept_t;
/* Exception flags */ /* Exception flags */
#ifdef __mips_soft_float
#define _FPUSW_SHIFT 16 #define _FPUSW_SHIFT 16
#define FE_INVALID 0x0001 #define FE_INVALID 0x0001
#define FE_DIVBYZERO 0x0002 #define FE_DIVBYZERO 0x0002
#define FE_OVERFLOW 0x0004 #define FE_OVERFLOW 0x0004
#define FE_UNDERFLOW 0x0008 #define FE_UNDERFLOW 0x0008
#define FE_INEXACT 0x0010 #define FE_INEXACT 0x0010
#else
#define _FCSR_CAUSE_SHIFT 10
#define FE_INVALID 0x0040
#define FE_DIVBYZERO 0x0020
#define FE_OVERFLOW 0x0010
#define FE_UNDERFLOW 0x0008
#define FE_INEXACT 0x0004
#endif
#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \ #define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW) FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
@ -75,12 +67,6 @@ extern const fenv_t __fe_dfl_env;
#define _ENABLE_SHIFT 5 #define _ENABLE_SHIFT 5
#define _ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT) #define _ENABLE_MASK (FE_ALL_EXCEPT << _ENABLE_SHIFT)
#ifndef __mips_soft_float
#define __cfc1(__fcsr) __asm __volatile("cfc1 %0, $31" : "=r" (__fcsr))
#define __ctc1(__fcsr) __asm __volatile("ctc1 %0, $31" :: "r" (__fcsr))
#endif
#ifdef __mips_soft_float
int feclearexcept(int __excepts); int feclearexcept(int __excepts);
int fegetexceptflag(fexcept_t *__flagp, int __excepts); int fegetexceptflag(fexcept_t *__flagp, int __excepts);
int fesetexceptflag(const fexcept_t *__flagp, int __excepts); int fesetexceptflag(const fexcept_t *__flagp, int __excepts);
@ -92,184 +78,14 @@ int fegetenv(fenv_t *__envp);
int feholdexcept(fenv_t *__envp); int feholdexcept(fenv_t *__envp);
int fesetenv(const fenv_t *__envp); int fesetenv(const fenv_t *__envp);
int feupdateenv(const fenv_t *__envp); int feupdateenv(const fenv_t *__envp);
#else
__fenv_static inline int
feclearexcept(int __excepts)
{
fexcept_t fcsr;
__excepts &= FE_ALL_EXCEPT;
__cfc1(fcsr);
fcsr &= ~(__excepts | (__excepts << _FCSR_CAUSE_SHIFT));
__ctc1(fcsr);
return (0);
}
__fenv_static inline int
fegetexceptflag(fexcept_t *__flagp, int __excepts)
{
fexcept_t fcsr;
__excepts &= FE_ALL_EXCEPT;
__cfc1(fcsr);
*__flagp = fcsr & __excepts;
return (0);
}
__fenv_static inline int
fesetexceptflag(const fexcept_t *__flagp, int __excepts)
{
fexcept_t fcsr;
__excepts &= FE_ALL_EXCEPT;
__cfc1(fcsr);
fcsr &= ~__excepts;
fcsr |= *__flagp & __excepts;
__ctc1(fcsr);
return (0);
}
__fenv_static inline int
feraiseexcept(int __excepts)
{
fexcept_t fcsr;
__excepts &= FE_ALL_EXCEPT;
__cfc1(fcsr);
fcsr |= __excepts | (__excepts << _FCSR_CAUSE_SHIFT);
__ctc1(fcsr);
return (0);
}
__fenv_static inline int
fetestexcept(int __excepts)
{
fexcept_t fcsr;
__excepts &= FE_ALL_EXCEPT;
__cfc1(fcsr);
return (fcsr & __excepts);
}
__fenv_static inline int
fegetround(void)
{
fexcept_t fcsr;
__cfc1(fcsr);
return (fcsr & _ROUND_MASK);
}
__fenv_static inline int
fesetround(int __round)
{
fexcept_t fcsr;
if (__round & ~_ROUND_MASK)
return (-1);
__cfc1(fcsr);
fcsr &= ~_ROUND_MASK;
fcsr |= __round;
__ctc1(fcsr);
return (0);
}
__fenv_static inline int
fegetenv(fenv_t *__envp)
{
__cfc1(*__envp);
return (0);
}
__fenv_static inline int
feholdexcept(fenv_t *__envp)
{
fexcept_t fcsr;
__cfc1(fcsr);
*__envp = fcsr;
fcsr &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
__ctc1(fcsr);
return (0);
}
__fenv_static inline int
fesetenv(const fenv_t *__envp)
{
__ctc1(*__envp);
return (0);
}
__fenv_static inline int
feupdateenv(const fenv_t *__envp)
{
fexcept_t fcsr;
__cfc1(fcsr);
fesetenv(__envp);
feraiseexcept(fcsr);
return (0);
}
#endif /* !__mips_soft_float */
#if __BSD_VISIBLE #if __BSD_VISIBLE
/* We currently provide no external definitions of the functions below. */ /* We currently provide no external definitions of the functions below. */
#ifdef __mips_soft_float
int feenableexcept(int __mask); int feenableexcept(int __mask);
int fedisableexcept(int __mask); int fedisableexcept(int __mask);
int fegetexcept(void); int fegetexcept(void);
#else
static inline int
feenableexcept(int __mask)
{
fenv_t __old_fcsr, __new_fcsr;
__cfc1(__old_fcsr);
__new_fcsr = __old_fcsr | (__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT;
__ctc1(__new_fcsr);
return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fedisableexcept(int __mask)
{
fenv_t __old_fcsr, __new_fcsr;
__cfc1(__old_fcsr);
__new_fcsr = __old_fcsr & ~((__mask & FE_ALL_EXCEPT) << _ENABLE_SHIFT);
__ctc1(__new_fcsr);
return ((__old_fcsr >> _ENABLE_SHIFT) & FE_ALL_EXCEPT);
}
static inline int
fegetexcept(void)
{
fexcept_t fcsr;
__cfc1(fcsr);
return ((fcsr & _ENABLE_MASK) >> _ENABLE_SHIFT);
}
#endif /* !__mips_soft_float */
#endif /* __BSD_VISIBLE */ #endif /* __BSD_VISIBLE */

View file

@ -39,7 +39,6 @@
*/ */
const fenv_t __fe_dfl_env = 0; const fenv_t __fe_dfl_env = 0;
#ifdef __mips_soft_float
#define __set_env(env, flags, mask, rnd) env = ((flags) \ #define __set_env(env, flags, mask, rnd) env = ((flags) \
| (mask)<<_FPUSW_SHIFT \ | (mask)<<_FPUSW_SHIFT \
| (rnd) << 24) | (rnd) << 24)
@ -48,7 +47,6 @@ const fenv_t __fe_dfl_env = 0;
& FE_ALL_EXCEPT) & FE_ALL_EXCEPT)
#define __env_round(env) (((env) >> 24) & _ROUND_MASK) #define __env_round(env) (((env) >> 24) & _ROUND_MASK)
#include "fenv-softfloat.h" #include "fenv-softfloat.h"
#endif
extern inline int feclearexcept(int __excepts); extern inline int feclearexcept(int __excepts);
extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts); extern inline int fegetexceptflag(fexcept_t *__flagp, int __excepts);