]>
Commit | Line | Data |
---|---|---|
3de10437 DJ |
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 | |
2848b105 | 25 | #define _FP_QNANNEGATEDP 0 |
3de10437 DJ |
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 | ||
3c8325fb JM |
44 | #if defined __NO_FPRS__ && !defined _SOFT_FLOAT |
45 | ||
46 | /* Exception flags. We use the bit positions of the appropriate bits | |
47 | in the FPEFSCR. */ | |
48 | ||
49 | # include <fenv_libc.h> | |
50 | # include <sysdep.h> | |
51 | # include <sys/prctl.h> | |
52 | ||
53 | int __feraiseexcept_soft (int); | |
54 | libc_hidden_proto (__feraiseexcept_soft) | |
55 | ||
56 | # define FP_EX_INEXACT SPEFSCR_FINXS | |
57 | # define FP_EX_INVALID SPEFSCR_FINVS | |
58 | # define FP_EX_DIVZERO SPEFSCR_FDBZS | |
59 | # define FP_EX_UNDERFLOW SPEFSCR_FUNFS | |
60 | # define FP_EX_OVERFLOW SPEFSCR_FOVFS | |
61 | ||
62 | # define _FP_DECL_EX \ | |
63 | int _spefscr __attribute__ ((unused)), _ftrapex __attribute__ ((unused)) = 0 | |
64 | # define FP_INIT_ROUNDMODE \ | |
65 | do \ | |
66 | { \ | |
67 | int _r; \ | |
68 | INTERNAL_SYSCALL_DECL (_err); \ | |
69 | \ | |
70 | _spefscr = fegetenv_register (); \ | |
71 | _r = INTERNAL_SYSCALL (prctl, _err, 2, PR_GET_FPEXC, &_ftrapex); \ | |
72 | if (INTERNAL_SYSCALL_ERROR_P (_r, _err)) \ | |
73 | _ftrapex = 0; \ | |
74 | } \ | |
75 | while (0) | |
76 | # define FP_INIT_EXCEPTIONS /* Empty. */ | |
77 | ||
78 | # define FP_HANDLE_EXCEPTIONS __feraiseexcept_soft (_fex) | |
79 | # define FP_ROUNDMODE (_spefscr & 0x3) | |
80 | ||
81 | /* Not correct in general, but sufficient for the uses in soft-fp. */ | |
82 | # define FP_TRAPPING_EXCEPTIONS (_ftrapex & PR_FP_EXC_UND \ | |
83 | ? FP_EX_UNDERFLOW \ | |
84 | : 0) | |
85 | ||
86 | #else | |
87 | ||
3de10437 DJ |
88 | /* Exception flags. We use the bit positions of the appropriate bits |
89 | in the FPSCR, which also correspond to the FE_* bits. This makes | |
90 | everything easier ;-). */ | |
3c8325fb JM |
91 | # define FP_EX_INVALID (1 << (31 - 2)) |
92 | # define FP_EX_OVERFLOW (1 << (31 - 3)) | |
93 | # define FP_EX_UNDERFLOW (1 << (31 - 4)) | |
94 | # define FP_EX_DIVZERO (1 << (31 - 5)) | |
95 | # define FP_EX_INEXACT (1 << (31 - 6)) | |
96 | ||
97 | # define FP_HANDLE_EXCEPTIONS __simulate_exceptions (_fex) | |
98 | # define FP_ROUNDMODE __sim_round_mode | |
99 | # define FP_TRAPPING_EXCEPTIONS (~__sim_disabled_exceptions & 0x3e000000) | |
100 | ||
101 | #endif | |
3de10437 | 102 | |
3f8b479f AO |
103 | /* FIXME: these variables should be thread specific (see bugzilla bug |
104 | 15483) and ideally preserved across signal handlers, like hardware | |
105 | FP status words, but the latter is quite difficult to accomplish in | |
106 | userland. */ | |
107 | ||
3de10437 DJ |
108 | extern int __sim_exceptions; |
109 | libc_hidden_proto (__sim_exceptions); | |
110 | extern int __sim_disabled_exceptions; | |
111 | libc_hidden_proto (__sim_disabled_exceptions); | |
112 | extern int __sim_round_mode; | |
113 | libc_hidden_proto (__sim_round_mode); | |
114 | ||
115 | extern void __simulate_exceptions (int x) attribute_hidden; |