From beb2d1df3a470f2210faee7837d5a5a55532ab11 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 7 Jul 2014 17:02:36 -0700 Subject: [PATCH] ffi: Add some tests to ensure that 64bit integers are handled properly. --- basis/compiler/tests/alien.factor | 15 ++++++++++++++- vm/ffi_test.c | 8 ++++++++ vm/ffi_test.h | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 10be5ff8f9..46fd171a44 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -6,7 +6,8 @@ math memory namespaces namespaces.private parser quotations sequences specialized-arrays stack-checker stack-checker.errors system threads tools.test words alien.complex concurrency.promises alien.data -byte-arrays classes compiler.test libc ; +byte-arrays classes compiler.test libc layouts +math.bitwise ; FROM: alien.c-types => float short ; SPECIALIZED-ARRAY: float SPECIALIZED-ARRAY: char @@ -662,6 +663,18 @@ FUNCTION: short ffi_test_48 ( bool-field-test x ) ; test-struct-11 "f-fastcall" "ffi_test_58" { int int int } alien-invoke gc ; +! Make sure that large longlong/ulonglong are correctly dealt with +FUNCTION: longlong ffi_test_59 ( longlong x ) ; +FUNCTION: ulonglong ffi_test_60 ( ulonglong x ) ; + +[ t ] [ most-positive-fixnum 1 + [ ffi_test_59 ] keep = ] unit-test +[ t ] [ most-positive-fixnum 1 + [ ffi_test_60 ] keep = ] unit-test + +[ -1 ] [ -1 ffi_test_59 ] unit-test +[ -1 ] [ 0xffffffffffffffff ffi_test_59 ] unit-test +[ 0xffffffffffffffff ] [ -1 ffi_test_60 ] unit-test +[ 0xffffffffffffffff ] [ 0xffffffffffffffff ffi_test_60 ] unit-test + ! GCC bugs mingw? [ [ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test diff --git a/vm/ffi_test.c b/vm/ffi_test.c index b89d6c2e6f..3026d51ae9 100644 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -298,3 +298,11 @@ FACTOR_FASTCALL(struct test_struct_11) ffi_test_58(int x, int y, int z) { struct test_struct_11 r = { x + y, y - z }; return r; } + +signed long long ffi_test_59(signed long long x) { + return x; +} + +unsigned long long ffi_test_60(unsigned long long x) { + return x; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index 88e4a4fb50..2b1008cbcd 100644 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -199,3 +199,7 @@ FACTOR_EXPORT FACTOR_FASTCALL(int) FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11) ffi_test_57(int x, int y); FACTOR_EXPORT FACTOR_FASTCALL(struct test_struct_11) ffi_test_58(int x, int y, int z); + +signed long long ffi_test_59(signed long long x); +unsigned long long ffi_test_60(unsigned long long x); +