aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/nwfpe/fpa11.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2005-08-03 14:49:17 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-08-03 14:49:17 -0400
commitf148af2593ef76ac705d1cc6abe48f455c9912cc (patch)
treecd1e0b0959624234ca3489df8888434ffea5050e /arch/arm/nwfpe/fpa11.c
parent1fcf844861eb08ee05e05dba13b5436f2f2e29ed (diff)
[PATCH] ARM: 2837/2: Re: ARM: Make NWFPE preempt safe
Patch from Richard Purdie NWFPE used global variables which meant it wasn't safe for use with preemptive kernels. This patch removes them and communicates the information between functions in a preempt safe manner. Generation of some exceptions was broken and this has also been corrected. Tests with glibc's maths test suite show no change in the results before/after this patch. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/nwfpe/fpa11.c')
-rw-r--r--arch/arm/nwfpe/fpa11.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/arch/arm/nwfpe/fpa11.c b/arch/arm/nwfpe/fpa11.c
index bf61696865ec..7690f731ee87 100644
--- a/arch/arm/nwfpe/fpa11.c
+++ b/arch/arm/nwfpe/fpa11.c
@@ -51,48 +51,42 @@ static void resetFPA11(void)
51 fpa11->fpsr = FP_EMULATOR | BIT_AC; 51 fpa11->fpsr = FP_EMULATOR | BIT_AC;
52} 52}
53 53
54void SetRoundingMode(const unsigned int opcode) 54int8 SetRoundingMode(const unsigned int opcode)
55{ 55{
56 switch (opcode & MASK_ROUNDING_MODE) { 56 switch (opcode & MASK_ROUNDING_MODE) {
57 default: 57 default:
58 case ROUND_TO_NEAREST: 58 case ROUND_TO_NEAREST:
59 float_rounding_mode = float_round_nearest_even; 59 return float_round_nearest_even;
60 break;
61 60
62 case ROUND_TO_PLUS_INFINITY: 61 case ROUND_TO_PLUS_INFINITY:
63 float_rounding_mode = float_round_up; 62 return float_round_up;
64 break;
65 63
66 case ROUND_TO_MINUS_INFINITY: 64 case ROUND_TO_MINUS_INFINITY:
67 float_rounding_mode = float_round_down; 65 return float_round_down;
68 break;
69 66
70 case ROUND_TO_ZERO: 67 case ROUND_TO_ZERO:
71 float_rounding_mode = float_round_to_zero; 68 return float_round_to_zero;
72 break;
73 } 69 }
74} 70}
75 71
76void SetRoundingPrecision(const unsigned int opcode) 72int8 SetRoundingPrecision(const unsigned int opcode)
77{ 73{
78#ifdef CONFIG_FPE_NWFPE_XP 74#ifdef CONFIG_FPE_NWFPE_XP
79 switch (opcode & MASK_ROUNDING_PRECISION) { 75 switch (opcode & MASK_ROUNDING_PRECISION) {
80 case ROUND_SINGLE: 76 case ROUND_SINGLE:
81 floatx80_rounding_precision = 32; 77 return 32;
82 break;
83 78
84 case ROUND_DOUBLE: 79 case ROUND_DOUBLE:
85 floatx80_rounding_precision = 64; 80 return 64;
86 break;
87 81
88 case ROUND_EXTENDED: 82 case ROUND_EXTENDED:
89 floatx80_rounding_precision = 80; 83 return 80;
90 break;
91 84
92 default: 85 default:
93 floatx80_rounding_precision = 80; 86 return 80;
94 } 87 }
95#endif 88#endif
89 return 80;
96} 90}
97 91
98void nwfpe_init_fpa(union fp_state *fp) 92void nwfpe_init_fpa(union fp_state *fp)
@@ -103,8 +97,6 @@ void nwfpe_init_fpa(union fp_state *fp)
103#endif 97#endif
104 memset(fpa11, 0, sizeof(FPA11)); 98 memset(fpa11, 0, sizeof(FPA11));
105 resetFPA11(); 99 resetFPA11();
106 SetRoundingMode(ROUND_TO_NEAREST);
107 SetRoundingPrecision(ROUND_EXTENDED);
108 fpa11->initflag = 1; 100 fpa11->initflag = 1;
109} 101}
110 102