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