|
Packit |
6c4009 |
#define _FP_W_TYPE_SIZE 32
|
|
Packit |
6c4009 |
#define _FP_W_TYPE unsigned long
|
|
Packit |
6c4009 |
#define _FP_WS_TYPE signed long
|
|
Packit |
6c4009 |
#define _FP_I_TYPE long
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FP_MUL_MEAT_S(R,X,Y) \
|
|
Packit |
6c4009 |
_FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
|
|
Packit |
6c4009 |
#define _FP_MUL_MEAT_D(R,X,Y) \
|
|
Packit |
6c4009 |
_FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
|
|
Packit |
6c4009 |
#define _FP_MUL_MEAT_Q(R,X,Y) \
|
|
Packit |
6c4009 |
_FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y)
|
|
Packit |
6c4009 |
#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
|
|
Packit |
6c4009 |
#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
|
|
Packit |
6c4009 |
#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
|
|
Packit |
6c4009 |
#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
|
|
Packit |
6c4009 |
#define _FP_NANSIGN_S 0
|
|
Packit |
6c4009 |
#define _FP_NANSIGN_D 0
|
|
Packit |
6c4009 |
#define _FP_NANSIGN_Q 0
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FP_KEEPNANFRACP 1
|
|
Packit |
6c4009 |
#define _FP_QNANNEGATEDP 0
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Someone please check this. */
|
|
Packit |
6c4009 |
#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
|
|
Packit |
6c4009 |
do { \
|
|
Packit |
6c4009 |
if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
|
|
Packit |
6c4009 |
&& !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
R##_s = Y##_s; \
|
|
Packit |
6c4009 |
_FP_FRAC_COPY_##wc(R,Y); \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
else \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
R##_s = X##_s; \
|
|
Packit |
6c4009 |
_FP_FRAC_COPY_##wc(R,X); \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
R##_c = FP_CLS_NAN; \
|
|
Packit |
6c4009 |
} while (0)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FP_TININESS_AFTER_ROUNDING 0
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#if defined __NO_FPRS__ && !defined _SOFT_FLOAT
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Exception flags. We use the bit positions of the appropriate bits
|
|
Packit |
6c4009 |
in the FPEFSCR. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# include <fenv_libc.h>
|
|
Packit |
6c4009 |
# include <sysdep.h>
|
|
Packit |
6c4009 |
# include <sys/prctl.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
int __feraiseexcept_soft (int);
|
|
Packit |
6c4009 |
libc_hidden_proto (__feraiseexcept_soft)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define FP_EX_INEXACT SPEFSCR_FINXS
|
|
Packit |
6c4009 |
# define FP_EX_INVALID SPEFSCR_FINVS
|
|
Packit |
6c4009 |
# define FP_EX_DIVZERO SPEFSCR_FDBZS
|
|
Packit |
6c4009 |
# define FP_EX_UNDERFLOW SPEFSCR_FUNFS
|
|
Packit |
6c4009 |
# define FP_EX_OVERFLOW SPEFSCR_FOVFS
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define _FP_DECL_EX \
|
|
Packit |
6c4009 |
int _spefscr __attribute__ ((unused)), _ftrapex __attribute__ ((unused)) = 0
|
|
Packit |
6c4009 |
# define FP_INIT_ROUNDMODE \
|
|
Packit |
6c4009 |
do \
|
|
Packit |
6c4009 |
{ \
|
|
Packit |
6c4009 |
int _r; \
|
|
Packit |
6c4009 |
INTERNAL_SYSCALL_DECL (_err); \
|
|
Packit |
6c4009 |
\
|
|
Packit |
6c4009 |
_spefscr = fegetenv_register (); \
|
|
Packit |
6c4009 |
_r = INTERNAL_SYSCALL (prctl, _err, 2, PR_GET_FPEXC, &_ftrapex); \
|
|
Packit |
6c4009 |
if (INTERNAL_SYSCALL_ERROR_P (_r, _err)) \
|
|
Packit |
6c4009 |
_ftrapex = 0; \
|
|
Packit |
6c4009 |
} \
|
|
Packit |
6c4009 |
while (0)
|
|
Packit |
6c4009 |
# define FP_INIT_EXCEPTIONS /* Empty. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define FP_HANDLE_EXCEPTIONS __feraiseexcept_soft (_fex)
|
|
Packit |
6c4009 |
# define FP_ROUNDMODE (_spefscr & 0x3)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Not correct in general, but sufficient for the uses in soft-fp. */
|
|
Packit |
6c4009 |
# define FP_TRAPPING_EXCEPTIONS (_ftrapex & PR_FP_EXC_UND \
|
|
Packit |
6c4009 |
? FP_EX_UNDERFLOW \
|
|
Packit |
6c4009 |
: 0)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Exception flags. We use the bit positions of the appropriate bits
|
|
Packit |
6c4009 |
in the FPSCR, which also correspond to the FE_* bits. This makes
|
|
Packit |
6c4009 |
everything easier ;-). */
|
|
Packit |
6c4009 |
# define FP_EX_INVALID (1 << (31 - 2))
|
|
Packit |
6c4009 |
# define FP_EX_OVERFLOW (1 << (31 - 3))
|
|
Packit |
6c4009 |
# define FP_EX_UNDERFLOW (1 << (31 - 4))
|
|
Packit |
6c4009 |
# define FP_EX_DIVZERO (1 << (31 - 5))
|
|
Packit |
6c4009 |
# define FP_EX_INEXACT (1 << (31 - 6))
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
# define FP_HANDLE_EXCEPTIONS __simulate_exceptions (_fex)
|
|
Packit |
6c4009 |
# define FP_ROUNDMODE __sim_round_mode_thread
|
|
Packit |
6c4009 |
# define FP_TRAPPING_EXCEPTIONS \
|
|
Packit |
6c4009 |
(~__sim_disabled_exceptions_thread & 0x3e000000)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extern __thread int __sim_exceptions_thread attribute_tls_model_ie;
|
|
Packit |
6c4009 |
libc_hidden_tls_proto (__sim_exceptions_thread, tls_model ("initial-exec"));
|
|
Packit |
6c4009 |
extern __thread int __sim_disabled_exceptions_thread attribute_tls_model_ie;
|
|
Packit |
6c4009 |
libc_hidden_tls_proto (__sim_disabled_exceptions_thread,
|
|
Packit |
6c4009 |
tls_model ("initial-exec"));
|
|
Packit |
6c4009 |
extern __thread int __sim_round_mode_thread attribute_tls_model_ie;
|
|
Packit |
6c4009 |
libc_hidden_tls_proto (__sim_round_mode_thread, tls_model ("initial-exec"));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
extern void __simulate_exceptions (int x) attribute_hidden;
|