diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-20 13:57:49 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-20 13:57:49 -0800 |
commit | 7cad64ba5c02c6efa80b6686f27439133d103978 (patch) | |
tree | aad7eb29f6dfda773da8946b239ab1c95b4e9cc5 /tests/runner.py | |
parent | 3d2d7c27ded744e69587b84a393c8fe5327fd78e (diff) |
handle bitcasts of doubles to i64s and vice versa properly
Diffstat (limited to 'tests/runner.py')
-rwxr-xr-x | tests/runner.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/runner.py b/tests/runner.py index 217a34bf..4db17431 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -702,6 +702,48 @@ if 'benchmark' not in str(sys.argv) and 'sanity' not in str(sys.argv): self.do_run(src, '*1,1,0,0,1,0*\n') + def test_i64_double(self): + if Settings.USE_TYPED_ARRAYS != 2: return self.skip('full i64 stuff only in ta2') + src = r''' + #include <stdio.h> + + typedef long long int64; + #define JSDOUBLE_HI32_SIGNBIT 0x80000000 + + bool JSDOUBLE_IS_NEGZERO(double d) + { + union { + struct { + unsigned int lo, hi; + } s; + double d; + } x; + if (d != 0) + return false; + x.d = d; + return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0; + } + + bool JSINT64_IS_NEGZERO(int64 l) + { + union { + int64 i; + double d; + } x; + if (l != 0) + return false; + x.i = l; + return x.d == -0; + } + + int main(int argc, char * argv[]) { + printf("*%d,%d,%d,%d*\n", JSDOUBLE_IS_NEGZERO(0), JSDOUBLE_IS_NEGZERO(-0), JSDOUBLE_IS_NEGZERO(-1), JSDOUBLE_IS_NEGZERO(+1)); + printf("*%d,%d,%d,%d*\n", JSINT64_IS_NEGZERO(0), JSINT64_IS_NEGZERO(-0), JSINT64_IS_NEGZERO(-1), JSINT64_IS_NEGZERO(+1)); + return 0; + } + ''' + self.do_run(src, '*0,0,0,0*\n*1,1,0,0*\n') # same as gcc + def test_unaligned(self): if Settings.QUANTUM_SIZE == 1: return self.skip('No meaning to unaligned addresses in q1') |