]> gitweb.factorcode.org Git - factor.git/commitdiff
add fastcall functions to ffi tests
authorJoe Groff <arcata@gmail.com>
Thu, 1 Apr 2010 09:22:42 +0000 (02:22 -0700)
committerJoe Groff <arcata@gmail.com>
Thu, 1 Apr 2010 09:22:42 +0000 (02:22 -0700)
basis/compiler/tests/alien.factor
vm/ffi_test.c
vm/ffi_test.h

index 71efe8a929593b3fa37b8cb7acecd71555a61412..08ff47ee5a06dda0a529ab03597c9c7f09109b5f 100755 (executable)
@@ -22,6 +22,8 @@ IN: compiler.tests.alien
 "f-cdecl" libfactor-ffi-tests-path cdecl add-library
 
 "f-stdcall" libfactor-ffi-tests-path stdcall add-library
+
+"f-fastcall" libfactor-ffi-tests-path fastcall add-library
 >>
 
 LIBRARY: f-cdecl
@@ -603,3 +605,23 @@ FUNCTION: void this_does_not_exist ( ) ;
 : assembly-test-1 ( -- ) void { } cdecl [ ] alien-assembly ;
 
 [ ] [ assembly-test-1 ] unit-test
+
+LIBRARY: f-fastcall
+
+FUNCTION: int ffi_test_49 ( int x ) ;
+FUNCTION: int ffi_test_50 ( int x, int y ) ;
+FUNCTION: int ffi_test_51 ( int x, int y, int z ) ;
+FUNCTION: int ffi_test_52 ( int x, float y, int z ) ;
+FUNCTION: int ffi_test_53 ( int x, float y, int z, int w ) ;
+FUNCTION: int ffi_test_54 ( test-struct-11 x, int y ) ;
+FUNCTION: int ffi_test_55 ( int x, int y, int z ) ;
+FUNCTION: int ffi_test_56 ( int x, int y, int z ) ;
+
+[ 4 ] [ 3 ffi_test_49 ] unit-test
+[ 8 ] [ 3 4 ffi_test_50 ] unit-test
+[ 13 ] [ 3 4 5 ffi_test_51 ] unit-test
+[ 13 ] [ 3 4.0 5 ffi_test_52 ] unit-test
+[ 19 ] [ 3 4.0 5 6 ffi_test_53 ] unit-test
+[ 13 ] [ 3 4 test-struct-11 <struct> 5 ffi_test_54 ] unit-test
+[ 19 ] [ 3 4 test-struct-11 <struct> 5 6 ffi_test_55 ] unit-test
+[ 26 ] [ 3 4 test-struct-11 <struct> 5 6 7 ffi_test_56 ] unit-test
index 11f7498f307445737de372a1c8cb7a45d1a69692..6ad9a26b276665ff0e9a40f454f52dde2188b522 100755 (executable)
@@ -329,3 +329,27 @@ short ffi_test_48(struct bool_field_test x)
 }
 
 #endif
+
+FACTOR_FASTCALL(int) ffi_test_49(int x) { return x + 1; }
+FACTOR_FASTCALL(int) ffi_test_50(int x, int y) { return x + y + 1; }
+FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z) { return x + y + z + 1; }
+FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z) { return x + y + z + 1; }
+FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w)
+{
+       return x + y + z + w + 1;
+}
+
+FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y)
+{
+       return x.x + x.y + y + 1;
+}
+
+FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z)
+{
+       return x.x + x.y + y + z + 1;
+}
+
+FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w)
+{
+       return x.x + x.y + y + z + w + 1;
+}
index c61c95d6df835517b1202fdce9e5290851f0e0a8..0ee593a26e1c04e13eca023bd11453789203c524 100755 (executable)
@@ -1,9 +1,12 @@
 #if defined(_MSC_VER)
        #define FACTOR_STDCALL(return_type) return_type __stdcall
+       #define FACTOR_FASTCALL(return_type) return_type __fastcall
 #elif defined(i386) || defined(__i386) || defined(__i386__)
        #define FACTOR_STDCALL(return_type) __attribute__((stdcall)) return_type
+       #define FACTOR_FASTCALL(return_type) __attribute__((fastcall)) return_type
 #else
        #define FACTOR_STDCALL(return_type) return_type
+       #define FACTOR_FASTCALL(return_type) return_type
 #endif
 
 #if defined(__APPLE__)
@@ -119,3 +122,12 @@ struct bool_field_test {
 FACTOR_EXPORT short ffi_test_48(struct bool_field_test x);
 
 #endif
+
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_49(int x);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_50(int x, int y);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_51(int x, int y, int z);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_52(int x, float y, int z);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_53(int x, float y, int z, int w);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_54(test_struct_11 x, int y);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_55(test_struct_11 x, int y, int z);
+FACTOR_EXPORT FACTOR_FASTCALL(int) ffi_test_56(test_struct_11 x, int y, int z, int w);