1 #define _FP_W_TYPE_SIZE 32
2 #define _FP_W_TYPE unsigned long
3 #define _FP_WS_TYPE signed long
4 #define _FP_I_TYPE long
5
6 #define _FP_MUL_MEAT_S(R,X,Y) \
7 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
8 #define _FP_MUL_MEAT_D(R,X,Y) \
9 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
10 #define _FP_MUL_MEAT_Q(R,X,Y) \
11 _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
12
13 #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y)
14 #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
15 #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
16
17 #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
18 #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
19 #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
20 #define _FP_NANSIGN_S 0
21 #define _FP_NANSIGN_D 0
22 #define _FP_NANSIGN_Q 0
23
24 #define _FP_KEEPNANFRACP 1
25 #define _FP_QNANNEGATEDP 0
26
27 /* Someone please check this. */
28 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
29 do { \
30 if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
31 && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
32 { \
33 R##_s = Y##_s; \
34 _FP_FRAC_COPY_##wc(R,Y); \
35 } \
36 else \
37 { \
38 R##_s = X##_s; \
39 _FP_FRAC_COPY_##wc(R,X); \
40 } \
41 R##_c = FP_CLS_NAN; \
42 } while (0)
43
44 #define _FP_TININESS_AFTER_ROUNDING 0
45
46 #if defined __NO_FPRS__ && !defined _SOFT_FLOAT
47
48 /* Exception flags. We use the bit positions of the appropriate bits
49 in the FPEFSCR. */
50
51 # include <fenv_libc.h>
52 # include <sysdep.h>
53 # include <sys/prctl.h>
54
55 int __feraiseexcept_soft (int);
56 libc_hidden_proto (__feraiseexcept_soft)
57
58 # define FP_EX_INEXACT SPEFSCR_FINXS
59 # define FP_EX_INVALID SPEFSCR_FINVS
60 # define FP_EX_DIVZERO SPEFSCR_FDBZS
61 # define FP_EX_UNDERFLOW SPEFSCR_FUNFS
62 # define FP_EX_OVERFLOW SPEFSCR_FOVFS
63
64 # define _FP_DECL_EX \
65 int _spefscr __attribute__ ((unused)), _ftrapex __attribute__ ((unused)) = 0
66 # define FP_INIT_ROUNDMODE \
67 do \
68 { \
69 int _r; \
70 \
71 _spefscr = fegetenv_register (); \
72 _r = INTERNAL_SYSCALL_CALL (prctl, PR_GET_FPEXC, &_ftrapex); \
73 if (INTERNAL_SYSCALL_ERROR_P (_r)) \
74 _ftrapex = 0; \
75 } \
76 while (0)
77 # define FP_INIT_EXCEPTIONS /* Empty. */
78
79 # define FP_HANDLE_EXCEPTIONS __feraiseexcept_soft (_fex)
80 # define FP_ROUNDMODE (_spefscr & 0x3)
81
82 /* Not correct in general, but sufficient for the uses in soft-fp. */
83 # define FP_TRAPPING_EXCEPTIONS (_ftrapex & PR_FP_EXC_UND \
84 ? FP_EX_UNDERFLOW \
85 : 0)
86
87 #else
88
89 /* Exception flags. We use the bit positions of the appropriate bits
90 in the FPSCR, which also correspond to the FE_* bits. This makes
91 everything easier ;-). */
92 # define FP_EX_INVALID (1 << (31 - 2))
93 # define FP_EX_OVERFLOW (1 << (31 - 3))
94 # define FP_EX_UNDERFLOW (1 << (31 - 4))
95 # define FP_EX_DIVZERO (1 << (31 - 5))
96 # define FP_EX_INEXACT (1 << (31 - 6))
97
98 # define FP_HANDLE_EXCEPTIONS __simulate_exceptions (_fex)
99 # define FP_ROUNDMODE __sim_round_mode_thread
100 # define FP_TRAPPING_EXCEPTIONS \
101 (~__sim_disabled_exceptions_thread & 0x3e000000)
102
103 #endif
104
105 extern __thread int __sim_exceptions_thread attribute_tls_model_ie;
106 libc_hidden_tls_proto (__sim_exceptions_thread, tls_model ("initial-exec"));
107 extern __thread int __sim_disabled_exceptions_thread attribute_tls_model_ie;
108 libc_hidden_tls_proto (__sim_disabled_exceptions_thread,
109 tls_model ("initial-exec"));
110 extern __thread int __sim_round_mode_thread attribute_tls_model_ie;
111 libc_hidden_tls_proto (__sim_round_mode_thread, tls_model ("initial-exec"));
112
113 extern void __simulate_exceptions (int x) attribute_hidden;