math.floats.env: detect +fp-x87-stack-fault+ during collect-fp-exceptions block
parent
42b858b3f0
commit
8347a9ead8
|
@ -1 +1,2 @@
|
||||||
not loaded
|
not loaded
|
||||||
|
not tested
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
USING: math.floats.env math.floats.env.x86 tools.test
|
||||||
|
alien.c-types alien.syntax classes.struct compiler.test
|
||||||
|
math kernel sequences ;
|
||||||
|
IN: math.floats.env.x86.tests
|
||||||
|
|
||||||
|
! the sqrtl function is really long double sqrtl ( long double x )
|
||||||
|
! calling it as if it had a void return leaves the return value on
|
||||||
|
! the x87 stack, so 9 calls will be guaranteed to cause a stack
|
||||||
|
! fault
|
||||||
|
STRUCT: fake-long-double { x char[20] } ;
|
||||||
|
FUNCTION-ALIAS: busted-sqrtl
|
||||||
|
void sqrtl ( fake-long-double x ) ;
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
9 [ fake-long-double <struct> busted-sqrtl ] times
|
||||||
|
] collect-fp-exceptions
|
||||||
|
] compile-call
|
||||||
|
+fp-x87-stack-fault+ swap member?
|
||||||
|
] unit-test
|
|
@ -88,7 +88,9 @@ M: sse-env (set-denormal-mode) ( register mode -- register' )
|
||||||
} case
|
} case
|
||||||
] curry change-mxcsr ; inline
|
] curry change-mxcsr ; inline
|
||||||
|
|
||||||
CONSTANT: x87-exception-bits HEX: 3f
|
SINGLETON: +fp-x87-stack-fault+
|
||||||
|
|
||||||
|
CONSTANT: x87-exception-bits HEX: 7f
|
||||||
CONSTANT: x87-exception>bit
|
CONSTANT: x87-exception>bit
|
||||||
H{
|
H{
|
||||||
{ +fp-invalid-operation+ HEX: 01 }
|
{ +fp-invalid-operation+ HEX: 01 }
|
||||||
|
@ -96,6 +98,7 @@ CONSTANT: x87-exception>bit
|
||||||
{ +fp-underflow+ HEX: 10 }
|
{ +fp-underflow+ HEX: 10 }
|
||||||
{ +fp-zero-divide+ HEX: 04 }
|
{ +fp-zero-divide+ HEX: 04 }
|
||||||
{ +fp-inexact+ HEX: 20 }
|
{ +fp-inexact+ HEX: 20 }
|
||||||
|
{ +fp-x87-stack-fault+ HEX: 40 }
|
||||||
}
|
}
|
||||||
|
|
||||||
CONSTANT: x87-rounding-mode-bits HEX: 0c00
|
CONSTANT: x87-rounding-mode-bits HEX: 0c00
|
||||||
|
|
Loading…
Reference in New Issue