mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Merge pull request #1961 from jpf91/armFPU
[ARM] Some FPUs do not support exception trapping, disable test
This commit is contained in:
commit
a41c349196
1 changed files with 25 additions and 0 deletions
25
std/math.d
25
std/math.d
|
@ -3786,9 +3786,31 @@ private:
|
||||||
static assert(false, "Architecture not supported");
|
static assert(false, "Architecture not supported");
|
||||||
|
|
||||||
public:
|
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.
|
/// Enable (unmask) specific hardware exceptions. Multiple exceptions may be ORed together.
|
||||||
void enableExceptions(uint exceptions)
|
void enableExceptions(uint exceptions)
|
||||||
{
|
{
|
||||||
|
assert(hasExceptionTraps);
|
||||||
initialize();
|
initialize();
|
||||||
version(ARM)
|
version(ARM)
|
||||||
setControlState(getControlState() | (exceptions & EXCEPTION_MASK));
|
setControlState(getControlState() | (exceptions & EXCEPTION_MASK));
|
||||||
|
@ -3799,6 +3821,7 @@ public:
|
||||||
/// Disable (mask) specific hardware exceptions. Multiple exceptions may be ORed together.
|
/// Disable (mask) specific hardware exceptions. Multiple exceptions may be ORed together.
|
||||||
void disableExceptions(uint exceptions)
|
void disableExceptions(uint exceptions)
|
||||||
{
|
{
|
||||||
|
assert(hasExceptionTraps);
|
||||||
initialize();
|
initialize();
|
||||||
version(ARM)
|
version(ARM)
|
||||||
setControlState(getControlState() & ~(exceptions & EXCEPTION_MASK));
|
setControlState(getControlState() & ~(exceptions & EXCEPTION_MASK));
|
||||||
|
@ -3816,6 +3839,7 @@ public:
|
||||||
/// Return the exceptions which are currently enabled (unmasked)
|
/// Return the exceptions which are currently enabled (unmasked)
|
||||||
@property static uint enabledExceptions()
|
@property static uint enabledExceptions()
|
||||||
{
|
{
|
||||||
|
assert(hasExceptionTraps);
|
||||||
version(ARM)
|
version(ARM)
|
||||||
return (getControlState() & EXCEPTION_MASK);
|
return (getControlState() & EXCEPTION_MASK);
|
||||||
else
|
else
|
||||||
|
@ -3952,6 +3976,7 @@ unittest
|
||||||
}
|
}
|
||||||
ensureDefaults();
|
ensureDefaults();
|
||||||
|
|
||||||
|
if(FloatingPointControl.hasExceptionTraps)
|
||||||
{
|
{
|
||||||
FloatingPointControl ctrl;
|
FloatingPointControl ctrl;
|
||||||
ctrl.enableExceptions(FloatingPointControl.divByZeroException
|
ctrl.enableExceptions(FloatingPointControl.divByZeroException
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue