1 #ifndef _LINUX_MATH_EMU_H
2 #define _LINUX_MATH_EMU_H
3
4 #include <linux/sched.h>
5
6 struct info {
7 long ___orig_eip;
8 long ___ret_from_system_call;
9 long ___ebx;
10 long ___ecx;
11 long ___edx;
12 long ___esi;
13 long ___edi;
14 long ___ebp;
15 long ___eax;
16 long ___ds;
17 long ___es;
18 long ___fs;
19 long ___gs;
20 long ___orig_eax;
21 long ___eip;
22 long ___cs;
23 long ___eflags;
24 long ___esp;
25 long ___ss;
26 };
27
28 #define EAX (info->___eax)
29 #define EBX (info->___ebx)
30 #define ECX (info->___ecx)
31 #define EDX (info->___edx)
32 #define ESI (info->___esi)
33 #define EDI (info->___edi)
34 #define EBP (info->___ebp)
35 #define ESP (info->___esp)
36 #define EIP (info->___eip)
37 #define ORIG_EIP (info->___orig_eip)
38 #define EFLAGS (info->___eflags)
39 #define DS (*(unsigned short *) &(info->___ds))
40 #define ES (*(unsigned short *) &(info->___es))
41 #define FS (*(unsigned short *) &(info->___fs))
42 #define CS (*(unsigned short *) &(info->___cs))
43 #define SS (*(unsigned short *) &(info->___ss))
44
45 void __math_abort(struct info *, unsigned int);
46
47 #define math_abort(x,y) \
48 (((volatile void (*)(struct info *,unsigned int)) __math_abort)((x),(y)))
49
50
51
52
53
54
55
56
57 typedef struct {
58 long a,b;
59 short exponent;
60 } temp_real;
61
62 typedef struct {
63 short m0,m1,m2,m3;
64 short exponent;
65 } temp_real_unaligned;
66
67 #define real_to_real(a,b) \
68 ((*(long long *) (b) = *(long long *) (a)),((b)->exponent = (a)->exponent))
69
70 typedef struct {
71 long a,b;
72 } long_real;
73
74 typedef long short_real;
75
76 typedef struct {
77 long a,b;
78 short sign;
79 } temp_int;
80
81 struct swd {
82 int ie:1;
83 int de:1;
84 int ze:1;
85 int oe:1;
86 int ue:1;
87 int pe:1;
88 int sf:1;
89 int ir:1;
90 int c0:1;
91 int c1:1;
92 int c2:1;
93 int top:3;
94 int c3:1;
95 int b:1;
96 };
97
98 #define I387 (current->tss.i387)
99 #define SWD (*(struct swd *) &I387.swd)
100 #define ROUNDING ((I387.cwd >> 10) & 3)
101 #define PRECISION ((I387.cwd >> 8) & 3)
102
103 #define BITS24 0
104 #define BITS53 2
105 #define BITS64 3
106
107 #define ROUND_NEAREST 0
108 #define ROUND_DOWN 1
109 #define ROUND_UP 2
110 #define ROUND_0 3
111
112 #define CONSTZ (temp_real_unaligned) {0x0000,0x0000,0x0000,0x0000,0x0000}
113 #define CONST1 (temp_real_unaligned) {0x0000,0x0000,0x0000,0x8000,0x3FFF}
114 #define CONSTPI (temp_real_unaligned) {0xC235,0x2168,0xDAA2,0xC90F,0x4000}
115 #define CONSTLN2 (temp_real_unaligned) {0x79AC,0xD1CF,0x17F7,0xB172,0x3FFE}
116 #define CONSTLG2 (temp_real_unaligned) {0xF799,0xFBCF,0x9A84,0x9A20,0x3FFD}
117 #define CONSTL2E (temp_real_unaligned) {0xF0BC,0x5C17,0x3B29,0xB8AA,0x3FFF}
118 #define CONSTL2T (temp_real_unaligned) {0x8AFE,0xCD1B,0x784B,0xD49A,0x4000}
119
120 #define set_IE() (I387.swd |= 1)
121 #define set_DE() (I387.swd |= 2)
122 #define set_ZE() (I387.swd |= 4)
123 #define set_OE() (I387.swd |= 8)
124 #define set_UE() (I387.swd |= 16)
125 #define set_PE() (I387.swd |= 32)
126
127 #define set_C0() (I387.swd |= 0x0100)
128 #define set_C1() (I387.swd |= 0x0200)
129 #define set_C2() (I387.swd |= 0x0400)
130 #define set_C3() (I387.swd |= 0x4000)
131
132
133
134 char * ea(struct info * __info, unsigned short __code);
135
136
137
138 void frndint(const temp_real * __a, temp_real * __b);
139 void short_to_temp(const short_real * __a, temp_real * __b);
140 void long_to_temp(const long_real * __a, temp_real * __b);
141 void temp_to_short(const temp_real * __a, short_real * __b);
142 void temp_to_long(const temp_real * __a, long_real * __b);
143 void real_to_int(const temp_real * __a, temp_int * __b);
144 void int_to_real(const temp_int * __a, temp_real * __b);
145
146
147
148 void get_short_real(temp_real *, struct info *, unsigned short);
149 void get_long_real(temp_real *, struct info *, unsigned short);
150 void get_temp_real(temp_real *, struct info *, unsigned short);
151 void get_short_int(temp_real *, struct info *, unsigned short);
152 void get_long_int(temp_real *, struct info *, unsigned short);
153 void get_longlong_int(temp_real *, struct info *, unsigned short);
154 void get_BCD(temp_real *, struct info *, unsigned short);
155 void put_short_real(const temp_real *, struct info *, unsigned short);
156 void put_long_real(const temp_real *, struct info *, unsigned short);
157 void put_temp_real(const temp_real *, struct info *, unsigned short);
158 void put_short_int(const temp_real *, struct info *, unsigned short);
159 void put_long_int(const temp_real *, struct info *, unsigned short);
160 void put_longlong_int(const temp_real *, struct info *, unsigned short);
161 void put_BCD(const temp_real *, struct info *, unsigned short);
162
163
164
165 void fadd(const temp_real *, const temp_real *, temp_real *);
166
167
168
169 void fmul(const temp_real *, const temp_real *, temp_real *);
170
171
172
173 void fdiv(const temp_real *, const temp_real *, temp_real *);
174
175
176
177 void fsqrt(const temp_real *, temp_real *);
178
179
180
181 void fcom(const temp_real *, const temp_real *);
182 void fucom(const temp_real *, const temp_real *);
183 void ftst(const temp_real *);
184
185 #endif