diff --git a/basis/compiler/generator/generator.factor b/basis/compiler/generator/generator.factor index 46be0d5962..da120ce432 100755 --- a/basis/compiler/generator/generator.factor +++ b/basis/compiler/generator/generator.factor @@ -325,12 +325,16 @@ M: single-float-regs reg-size drop 4 ; M: double-float-regs reg-size drop 8 ; +M: stack-params reg-size drop "void*" heap-size ; + GENERIC: reg-class-variable ( register-class -- symbol ) M: reg-class reg-class-variable ; M: float-regs reg-class-variable drop float-regs ; +M: stack-params reg-class-variable drop stack-params ; + GENERIC: inc-reg-class ( register-class -- ) M: reg-class inc-reg-class diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 18f7f67787..e44ae681ff 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -279,7 +279,7 @@ FUNCTION: double ffi_test_35 test-struct-11 x int y ; C-STRUCT: test-struct-12 { "int" "a" } { "double" "x" } ; -: make-struct-12 +: make-struct-12 ( x -- alien ) "test-struct-12" [ set-test-struct-12-x ] keep ; @@ -380,3 +380,24 @@ FUNCTION: int ffi_test_37 ( void* func ) ; [ 1 ] [ callback-9 ffi_test_37 ] unit-test [ 7 ] [ callback-9 ffi_test_37 ] unit-test + +C-STRUCT: test_struct_13 +{ "float" "x1" } +{ "float" "x2" } +{ "float" "x3" } +{ "float" "x4" } +{ "float" "x5" } +{ "float" "x6" } ; + +: make-test-struct-13 ( -- alien ) + "test_struct_13" + 1.0 over set-test_struct_13-x1 + 2.0 over set-test_struct_13-x2 + 3.0 over set-test_struct_13-x3 + 4.0 over set-test_struct_13-x4 + 5.0 over set-test_struct_13-x5 + 6.0 over set-test_struct_13-x6 ; + +FUNCTION: int ffi_test_39 ( long a, long b, test_struct_13 s ) ; + +[ 21 ] [ 12347 12347 make-test-struct-13 ffi_test_39 ] unit-test diff --git a/basis/cpu/architecture/architecture.factor b/basis/cpu/architecture/architecture.factor index d15c5a30ab..fc11e0a731 100755 --- a/basis/cpu/architecture/architecture.factor +++ b/basis/cpu/architecture/architecture.factor @@ -150,6 +150,8 @@ HOOK: %alien-indirect cpu ( -- ) M: stack-params param-reg drop ; +M: stack-params param-regs drop f ; + GENERIC: v>operand ( obj -- operand ) M: integer v>operand tag-fixnum ; diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 5cdfbb2a9e..44a14f21f5 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -274,4 +274,9 @@ unsigned long long ffi_test_38(unsigned long long x, unsigned long long y) return x * y; } - +int ffi_test_39(long a, long b, struct test_struct_13 s) +{ + printf("ffi_test_39(%ld,%ld,%f,%f,%f,%f,%f,%f)\n",a,b,s.x1,s.x2,s.x3,s.x4,s.x5,s.x6); + if(a != b) abort(); + return s.x1 + s.x2 + s.x3 + s.x4 + s.x5 + s.x6; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index 0f51092d25..779cb97857 100755 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -67,3 +67,7 @@ DLLEXPORT void ffi_test_36_point_5(void); DLLEXPORT int ffi_test_37(int (*f)(int, int, int)); DLLEXPORT unsigned long long ffi_test_38(unsigned long long x, unsigned long long y); + +struct test_struct_13 { float x1, x2, x3, x4, x5, x6; }; + +DLLEXPORT int ffi_test_39(long a, long b, struct test_struct_13 s);