From 1b5711cc42cf571139757ad1e2082e4c0cc52fa1 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sat, 8 Nov 2014 13:39:47 -0800 Subject: [PATCH] compiler.tests.alien: Add structs with uint and ulonglong pairs and return them from an FFI call. macosx32 seems to be working, hopefully this will break it or confirm that it's working. Linux32 is broken, hopefully this will show how. --- basis/compiler/tests/alien.factor | 25 ++++++++++++++++++++++--- vm/ffi_test.c | 14 ++++++++++++++ vm/ffi_test.h | 14 ++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index bf640477aa..688d422191 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -889,8 +889,27 @@ STRUCT: bool-and-ptr { ptr void* } ; FUNCTION: bool-and-ptr ffi_test_61 ( ) ; + { S{ bool-and-ptr { b t } { ptr f } } -} [ - ffi_test_61 -] unit-test +} [ ffi_test_61 ] unit-test + +STRUCT: uint-pair + { a uint } + { b uint } ; + +FUNCTION: uint-pair ffi_test_62 ( ) ; + +{ + S{ uint-pair { a 0xabcdefab } { b 0x12345678 } } +} [ ffi_test_62 ] unit-test + +STRUCT: ulonglong-pair + { a ulonglong } + { b ulonglong } ; + +FUNCTION: ulonglong-pair ffi_test_63 ( ) ; + +{ + S{ ulonglong-pair { a 0xabcdefabcdefabcd } { b 0x1234567891234567 } } +} [ ffi_test_63 ] unit-test diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 3fbd9a9508..65b24faa71 100644 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -313,3 +313,17 @@ struct bool_and_ptr ffi_test_61() { bap.ptr = NULL; return bap; } + +struct uint_pair ffi_test_62() { + struct uint_pair uip; + uip.a = 0xabcdefab; + uip.b = 0x12345678; + return uip; +} + +struct ulonglong_pair ffi_test_63() { + struct ulonglong_pair ullp; + ullp.a = 0xabcdefabcdefabcd; + ullp.b = 0x1234567891234567; + return ullp; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index b6587730fe..a36d66cf43 100644 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -209,3 +209,17 @@ struct bool_and_ptr { }; FACTOR_EXPORT struct bool_and_ptr ffi_test_61(); + +struct uint_pair { + unsigned int a; + unsigned int b; +}; + +FACTOR_EXPORT struct uint_pair ffi_test_62(); + +struct ulonglong_pair { + unsigned long long a; + unsigned long long b; +}; + +FACTOR_EXPORT struct ulonglong_pair ffi_test_63();