aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/nwfpe/fpa11_cpdo.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2005-08-03 19:49:17 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-08-03 19:49:17 +0100
commitf148af2593ef76ac705d1cc6abe48f455c9912cc (patch)
treecd1e0b0959624234ca3489df8888434ffea5050e /arch/arm/nwfpe/fpa11_cpdo.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_cpdo.c')
-rw-r--r--arch/arm/nwfpe/fpa11_cpdo.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/arch/arm/nwfpe/fpa11_cpdo.c b/arch/arm/nwfpe/fpa11_cpdo.c
index 1bea67437b6..4a31dfd9406 100644
--- a/arch/arm/nwfpe/fpa11_cpdo.c
+++ b/arch/arm/nwfpe/fpa11_cpdo.c
@@ -24,15 +24,16 @@
#include "fpa11.h"
#include "fpopcode.h"
-unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd);
-unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd);
-unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd);
+unsigned int SingleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
+unsigned int DoubleCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
+unsigned int ExtendedCPDO(struct roundingData *roundData, const unsigned int opcode, FPREG * rFd);
unsigned int EmulateCPDO(const unsigned int opcode)
{
FPA11 *fpa11 = GET_FPA11();
FPREG *rFd;
unsigned int nType, nDest, nRc;
+ struct roundingData roundData;
/* Get the destination size. If not valid let Linux perform
an invalid instruction trap. */
@@ -40,7 +41,9 @@ unsigned int EmulateCPDO(const unsigned int opcode)
if (typeNone == nDest)
return 0;
- SetRoundingMode(opcode);
+ roundData.mode = SetRoundingMode(opcode);
+ roundData.precision = SetRoundingPrecision(opcode);
+ roundData.exception = 0;
/* Compare the size of the operands in Fn and Fm.
Choose the largest size and perform operations in that size,
@@ -63,14 +66,14 @@ unsigned int EmulateCPDO(const unsigned int opcode)
switch (nType) {
case typeSingle:
- nRc = SingleCPDO(opcode, rFd);
+ nRc = SingleCPDO(&roundData, opcode, rFd);
break;
case typeDouble:
- nRc = DoubleCPDO(opcode, rFd);
+ nRc = DoubleCPDO(&roundData, opcode, rFd);
break;
#ifdef CONFIG_FPE_NWFPE_XP
case typeExtended:
- nRc = ExtendedCPDO(opcode, rFd);
+ nRc = ExtendedCPDO(&roundData, opcode, rFd);
break;
#endif
default:
@@ -93,9 +96,9 @@ unsigned int EmulateCPDO(const unsigned int opcode)
case typeSingle:
{
if (typeDouble == nType)
- rFd->fSingle = float64_to_float32(rFd->fDouble);
+ rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
else
- rFd->fSingle = floatx80_to_float32(rFd->fExtended);
+ rFd->fSingle = floatx80_to_float32(&roundData, rFd->fExtended);
}
break;
@@ -104,7 +107,7 @@ unsigned int EmulateCPDO(const unsigned int opcode)
if (typeSingle == nType)
rFd->fDouble = float32_to_float64(rFd->fSingle);
else
- rFd->fDouble = floatx80_to_float64(rFd->fExtended);
+ rFd->fDouble = floatx80_to_float64(&roundData, rFd->fExtended);
}
break;
@@ -121,12 +124,15 @@ unsigned int EmulateCPDO(const unsigned int opcode)
#else
if (nDest != nType) {
if (nDest == typeSingle)
- rFd->fSingle = float64_to_float32(rFd->fDouble);
+ rFd->fSingle = float64_to_float32(&roundData, rFd->fDouble);
else
rFd->fDouble = float32_to_float64(rFd->fSingle);
}
#endif
}
+ if (roundData.exception)
+ float_raise(roundData.exception);
+
return nRc;
}