]> gitweb.factorcode.org Git - factor.git/commitdiff
ffi: Add some tests to ensure that 64bit integers are handled properly.
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 8 Jul 2014 00:02:36 +0000 (17:02 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 8 Jul 2014 00:02:36 +0000 (17:02 -0700)
basis/compiler/tests/alien.factor
vm/ffi_test.c
vm/ffi_test.h

index 10be5ff8f975f239400402731ebee0a1954de74b..46fd171a4441882c6fd4c641eee529258921359d 100755 (executable)
@@ -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
index b89d6c2e6fca8212fa456777654eb40d2321bcde..3026d51ae9d7c2b99db379d7e19fd1c708ab2a3d 100644 (file)
@@ -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;
+}
index 88e4a4fb502cc54e096cb8b1cbb593511a2f158f..2b1008cbcd8fbeef7c4ad5819f508f900fcd7e52 100644 (file)
@@ -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);
+