diff --git a/basis/math/floats/env/x86/tags.txt b/basis/math/floats/env/x86/tags.txt index ebb74b4d5f..411ecb03f2 100644 --- a/basis/math/floats/env/x86/tags.txt +++ b/basis/math/floats/env/x86/tags.txt @@ -1 +1,2 @@ not loaded +not tested diff --git a/basis/math/floats/env/x86/x86-tests.factor b/basis/math/floats/env/x86/x86-tests.factor new file mode 100644 index 0000000000..928c5021c8 --- /dev/null +++ b/basis/math/floats/env/x86/x86-tests.factor @@ -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 busted-sqrtl ] times + ] collect-fp-exceptions + ] compile-call + +fp-x87-stack-fault+ swap member? +] unit-test diff --git a/basis/math/floats/env/x86/x86.factor b/basis/math/floats/env/x86/x86.factor index 89dd402378..aad37b73cc 100644 --- a/basis/math/floats/env/x86/x86.factor +++ b/basis/math/floats/env/x86/x86.factor @@ -88,7 +88,9 @@ M: sse-env (set-denormal-mode) ( register mode -- register' ) } case ] 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 H{ { +fp-invalid-operation+ HEX: 01 } @@ -96,6 +98,7 @@ CONSTANT: x87-exception>bit { +fp-underflow+ HEX: 10 } { +fp-zero-divide+ HEX: 04 } { +fp-inexact+ HEX: 20 } + { +fp-x87-stack-fault+ HEX: 40 } } CONSTANT: x87-rounding-mode-bits HEX: 0c00