Merge pull request #1961 from jpf91/armFPU

[ARM] Some FPUs do not support exception trapping, disable test
This commit is contained in:
Martin Nowak 2014-03-14 13:55:46 +01:00
commit a41c349196

View file

@ -3786,9 +3786,31 @@ private:
static assert(false, "Architecture not supported");
public:
/// Returns true if the current FPU supports exception trapping
@property static bool hasExceptionTraps() @safe nothrow
{
version(X86)
return true;
else version(X86_64)
return true;
else version(ARM)
{
auto oldState = getControlState();
// If exceptions are not supported, we set the bit but read it back as zero
// https://sourceware.org/ml/libc-ports/2012-06/msg00091.html
setControlState(oldState | (divByZeroException & EXCEPTION_MASK));
bool result = (getControlState() & EXCEPTION_MASK) != 0;
setControlState(oldState);
return result;
}
else
static assert(false, "Not implemented for this architecture");
}
/// Enable (unmask) specific hardware exceptions. Multiple exceptions may be ORed together.
void enableExceptions(uint exceptions)
{
assert(hasExceptionTraps);
initialize();
version(ARM)
setControlState(getControlState() | (exceptions & EXCEPTION_MASK));
@ -3799,6 +3821,7 @@ public:
/// Disable (mask) specific hardware exceptions. Multiple exceptions may be ORed together.
void disableExceptions(uint exceptions)
{
assert(hasExceptionTraps);
initialize();
version(ARM)
setControlState(getControlState() & ~(exceptions & EXCEPTION_MASK));
@ -3816,6 +3839,7 @@ public:
/// Return the exceptions which are currently enabled (unmasked)
@property static uint enabledExceptions()
{
assert(hasExceptionTraps);
version(ARM)
return (getControlState() & EXCEPTION_MASK);
else
@ -3952,6 +3976,7 @@ unittest
}
ensureDefaults();
if(FloatingPointControl.hasExceptionTraps)
{
FloatingPointControl ctrl;
ctrl.enableExceptions(FloatingPointControl.divByZeroException