diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:11 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:11 -0500 |
commit | 3d0d14f983b55a570b976976284df4c434af3223 (patch) | |
tree | 864f11c0ce5ee1e15acdd196018b79d0d0e2685d /arch/x86/math-emu/fpu_aux.c | |
parent | a4ec1effce83796209a0258602b0cf50026d86f2 (diff) |
x86: lindent arch/i386/math-emu
lindent these files:
errors lines of code errors/KLOC
arch/x86/math-emu/ 2236 9424 237.2
arch/x86/math-emu/ 128 8706 14.7
no other changes. No code changed:
text data bss dec hex filename
5589802 612739 3833856 10036397 9924ad vmlinux.before
5589802 612739 3833856 10036397 9924ad vmlinux.after
the intent of this patch is to ease the automated tracking of kernel
code quality - it's just much easier for us to maintain it if every file
in arch/x86 is supposed to be clean.
NOTE: it is a known problem of lindent that it causes some style damage
of its own, but it's a safe tool (well, except for the gcc array range
initializers extension), so we did the bulk of the changes via lindent,
and did the manual fixups in a followup patch.
the resulting math-emu code has been tested by Thomas Gleixner on a real
386 DX CPU as well, and it works fine.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/math-emu/fpu_aux.c')
-rw-r--r-- | arch/x86/math-emu/fpu_aux.c | 211 |
1 files changed, 97 insertions, 114 deletions
diff --git a/arch/x86/math-emu/fpu_aux.c b/arch/x86/math-emu/fpu_aux.c index 20886cfb9f76..491e737ce547 100644 --- a/arch/x86/math-emu/fpu_aux.c +++ b/arch/x86/math-emu/fpu_aux.c | |||
@@ -16,34 +16,34 @@ | |||
16 | #include "status_w.h" | 16 | #include "status_w.h" |
17 | #include "control_w.h" | 17 | #include "control_w.h" |
18 | 18 | ||
19 | |||
20 | static void fnop(void) | 19 | static void fnop(void) |
21 | { | 20 | { |
22 | } | 21 | } |
23 | 22 | ||
24 | static void fclex(void) | 23 | static void fclex(void) |
25 | { | 24 | { |
26 | partial_status &= ~(SW_Backward|SW_Summary|SW_Stack_Fault|SW_Precision| | 25 | partial_status &= |
27 | SW_Underflow|SW_Overflow|SW_Zero_Div|SW_Denorm_Op| | 26 | ~(SW_Backward | SW_Summary | SW_Stack_Fault | SW_Precision | |
28 | SW_Invalid); | 27 | SW_Underflow | SW_Overflow | SW_Zero_Div | SW_Denorm_Op | |
29 | no_ip_update = 1; | 28 | SW_Invalid); |
29 | no_ip_update = 1; | ||
30 | } | 30 | } |
31 | 31 | ||
32 | /* Needs to be externally visible */ | 32 | /* Needs to be externally visible */ |
33 | void finit(void) | 33 | void finit(void) |
34 | { | 34 | { |
35 | control_word = 0x037f; | 35 | control_word = 0x037f; |
36 | partial_status = 0; | 36 | partial_status = 0; |
37 | top = 0; /* We don't keep top in the status word internally. */ | 37 | top = 0; /* We don't keep top in the status word internally. */ |
38 | fpu_tag_word = 0xffff; | 38 | fpu_tag_word = 0xffff; |
39 | /* The behaviour is different from that detailed in | 39 | /* The behaviour is different from that detailed in |
40 | Section 15.1.6 of the Intel manual */ | 40 | Section 15.1.6 of the Intel manual */ |
41 | operand_address.offset = 0; | 41 | operand_address.offset = 0; |
42 | operand_address.selector = 0; | 42 | operand_address.selector = 0; |
43 | instruction_address.offset = 0; | 43 | instruction_address.offset = 0; |
44 | instruction_address.selector = 0; | 44 | instruction_address.selector = 0; |
45 | instruction_address.opcode = 0; | 45 | instruction_address.opcode = 0; |
46 | no_ip_update = 1; | 46 | no_ip_update = 1; |
47 | } | 47 | } |
48 | 48 | ||
49 | /* | 49 | /* |
@@ -54,151 +54,134 @@ void finit(void) | |||
54 | #define fsetpm fnop | 54 | #define fsetpm fnop |
55 | 55 | ||
56 | static FUNC const finit_table[] = { | 56 | static FUNC const finit_table[] = { |
57 | feni, fdisi, fclex, finit, | 57 | feni, fdisi, fclex, finit, |
58 | fsetpm, FPU_illegal, FPU_illegal, FPU_illegal | 58 | fsetpm, FPU_illegal, FPU_illegal, FPU_illegal |
59 | }; | 59 | }; |
60 | 60 | ||
61 | void finit_(void) | 61 | void finit_(void) |
62 | { | 62 | { |
63 | (finit_table[FPU_rm])(); | 63 | (finit_table[FPU_rm]) (); |
64 | } | 64 | } |
65 | 65 | ||
66 | |||
67 | static void fstsw_ax(void) | 66 | static void fstsw_ax(void) |
68 | { | 67 | { |
69 | *(short *) &FPU_EAX = status_word(); | 68 | *(short *)&FPU_EAX = status_word(); |
70 | no_ip_update = 1; | 69 | no_ip_update = 1; |
71 | } | 70 | } |
72 | 71 | ||
73 | static FUNC const fstsw_table[] = { | 72 | static FUNC const fstsw_table[] = { |
74 | fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal, | 73 | fstsw_ax, FPU_illegal, FPU_illegal, FPU_illegal, |
75 | FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal | 74 | FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal |
76 | }; | 75 | }; |
77 | 76 | ||
78 | void fstsw_(void) | 77 | void fstsw_(void) |
79 | { | 78 | { |
80 | (fstsw_table[FPU_rm])(); | 79 | (fstsw_table[FPU_rm]) (); |
81 | } | 80 | } |
82 | 81 | ||
83 | |||
84 | static FUNC const fp_nop_table[] = { | 82 | static FUNC const fp_nop_table[] = { |
85 | fnop, FPU_illegal, FPU_illegal, FPU_illegal, | 83 | fnop, FPU_illegal, FPU_illegal, FPU_illegal, |
86 | FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal | 84 | FPU_illegal, FPU_illegal, FPU_illegal, FPU_illegal |
87 | }; | 85 | }; |
88 | 86 | ||
89 | void fp_nop(void) | 87 | void fp_nop(void) |
90 | { | 88 | { |
91 | (fp_nop_table[FPU_rm])(); | 89 | (fp_nop_table[FPU_rm]) (); |
92 | } | 90 | } |
93 | 91 | ||
94 | |||
95 | void fld_i_(void) | 92 | void fld_i_(void) |
96 | { | 93 | { |
97 | FPU_REG *st_new_ptr; | 94 | FPU_REG *st_new_ptr; |
98 | int i; | 95 | int i; |
99 | u_char tag; | 96 | u_char tag; |
100 | 97 | ||
101 | if ( STACK_OVERFLOW ) | 98 | if (STACK_OVERFLOW) { |
102 | { FPU_stack_overflow(); return; } | 99 | FPU_stack_overflow(); |
103 | 100 | return; | |
104 | /* fld st(i) */ | ||
105 | i = FPU_rm; | ||
106 | if ( NOT_EMPTY(i) ) | ||
107 | { | ||
108 | reg_copy(&st(i), st_new_ptr); | ||
109 | tag = FPU_gettagi(i); | ||
110 | push(); | ||
111 | FPU_settag0(tag); | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | if ( control_word & CW_Invalid ) | ||
116 | { | ||
117 | /* The masked response */ | ||
118 | FPU_stack_underflow(); | ||
119 | } | 101 | } |
120 | else | ||
121 | EXCEPTION(EX_StackUnder); | ||
122 | } | ||
123 | 102 | ||
124 | } | 103 | /* fld st(i) */ |
104 | i = FPU_rm; | ||
105 | if (NOT_EMPTY(i)) { | ||
106 | reg_copy(&st(i), st_new_ptr); | ||
107 | tag = FPU_gettagi(i); | ||
108 | push(); | ||
109 | FPU_settag0(tag); | ||
110 | } else { | ||
111 | if (control_word & CW_Invalid) { | ||
112 | /* The masked response */ | ||
113 | FPU_stack_underflow(); | ||
114 | } else | ||
115 | EXCEPTION(EX_StackUnder); | ||
116 | } | ||
125 | 117 | ||
118 | } | ||
126 | 119 | ||
127 | void fxch_i(void) | 120 | void fxch_i(void) |
128 | { | 121 | { |
129 | /* fxch st(i) */ | 122 | /* fxch st(i) */ |
130 | FPU_REG t; | 123 | FPU_REG t; |
131 | int i = FPU_rm; | 124 | int i = FPU_rm; |
132 | FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i); | 125 | FPU_REG *st0_ptr = &st(0), *sti_ptr = &st(i); |
133 | long tag_word = fpu_tag_word; | 126 | long tag_word = fpu_tag_word; |
134 | int regnr = top & 7, regnri = ((regnr + i) & 7); | 127 | int regnr = top & 7, regnri = ((regnr + i) & 7); |
135 | u_char st0_tag = (tag_word >> (regnr*2)) & 3; | 128 | u_char st0_tag = (tag_word >> (regnr * 2)) & 3; |
136 | u_char sti_tag = (tag_word >> (regnri*2)) & 3; | 129 | u_char sti_tag = (tag_word >> (regnri * 2)) & 3; |
137 | 130 | ||
138 | if ( st0_tag == TAG_Empty ) | 131 | if (st0_tag == TAG_Empty) { |
139 | { | 132 | if (sti_tag == TAG_Empty) { |
140 | if ( sti_tag == TAG_Empty ) | 133 | FPU_stack_underflow(); |
141 | { | 134 | FPU_stack_underflow_i(i); |
142 | FPU_stack_underflow(); | 135 | return; |
143 | FPU_stack_underflow_i(i); | 136 | } |
144 | return; | 137 | if (control_word & CW_Invalid) { |
138 | /* Masked response */ | ||
139 | FPU_copy_to_reg0(sti_ptr, sti_tag); | ||
140 | } | ||
141 | FPU_stack_underflow_i(i); | ||
142 | return; | ||
145 | } | 143 | } |
146 | if ( control_word & CW_Invalid ) | 144 | if (sti_tag == TAG_Empty) { |
147 | { | 145 | if (control_word & CW_Invalid) { |
148 | /* Masked response */ | 146 | /* Masked response */ |
149 | FPU_copy_to_reg0(sti_ptr, sti_tag); | 147 | FPU_copy_to_regi(st0_ptr, st0_tag, i); |
148 | } | ||
149 | FPU_stack_underflow(); | ||
150 | return; | ||
150 | } | 151 | } |
151 | FPU_stack_underflow_i(i); | 152 | clear_C1(); |
152 | return; | ||
153 | } | ||
154 | if ( sti_tag == TAG_Empty ) | ||
155 | { | ||
156 | if ( control_word & CW_Invalid ) | ||
157 | { | ||
158 | /* Masked response */ | ||
159 | FPU_copy_to_regi(st0_ptr, st0_tag, i); | ||
160 | } | ||
161 | FPU_stack_underflow(); | ||
162 | return; | ||
163 | } | ||
164 | clear_C1(); | ||
165 | |||
166 | reg_copy(st0_ptr, &t); | ||
167 | reg_copy(sti_ptr, st0_ptr); | ||
168 | reg_copy(&t, sti_ptr); | ||
169 | |||
170 | tag_word &= ~(3 << (regnr*2)) & ~(3 << (regnri*2)); | ||
171 | tag_word |= (sti_tag << (regnr*2)) | (st0_tag << (regnri*2)); | ||
172 | fpu_tag_word = tag_word; | ||
173 | } | ||
174 | 153 | ||
154 | reg_copy(st0_ptr, &t); | ||
155 | reg_copy(sti_ptr, st0_ptr); | ||
156 | reg_copy(&t, sti_ptr); | ||
157 | |||
158 | tag_word &= ~(3 << (regnr * 2)) & ~(3 << (regnri * 2)); | ||
159 | tag_word |= (sti_tag << (regnr * 2)) | (st0_tag << (regnri * 2)); | ||
160 | fpu_tag_word = tag_word; | ||
161 | } | ||
175 | 162 | ||
176 | void ffree_(void) | 163 | void ffree_(void) |
177 | { | 164 | { |
178 | /* ffree st(i) */ | 165 | /* ffree st(i) */ |
179 | FPU_settagi(FPU_rm, TAG_Empty); | 166 | FPU_settagi(FPU_rm, TAG_Empty); |
180 | } | 167 | } |
181 | 168 | ||
182 | |||
183 | void ffreep(void) | 169 | void ffreep(void) |
184 | { | 170 | { |
185 | /* ffree st(i) + pop - unofficial code */ | 171 | /* ffree st(i) + pop - unofficial code */ |
186 | FPU_settagi(FPU_rm, TAG_Empty); | 172 | FPU_settagi(FPU_rm, TAG_Empty); |
187 | FPU_pop(); | 173 | FPU_pop(); |
188 | } | 174 | } |
189 | 175 | ||
190 | |||
191 | void fst_i_(void) | 176 | void fst_i_(void) |
192 | { | 177 | { |
193 | /* fst st(i) */ | 178 | /* fst st(i) */ |
194 | FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); | 179 | FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); |
195 | } | 180 | } |
196 | 181 | ||
197 | |||
198 | void fstp_i(void) | 182 | void fstp_i(void) |
199 | { | 183 | { |
200 | /* fstp st(i) */ | 184 | /* fstp st(i) */ |
201 | FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); | 185 | FPU_copy_to_regi(&st(0), FPU_gettag0(), FPU_rm); |
202 | FPU_pop(); | 186 | FPU_pop(); |
203 | } | 187 | } |
204 | |||