diff --git a/basis/alien/c-types/c-types.factor b/basis/alien/c-types/c-types.factor index 9cd57f61ab..6067c90f2d 100755 --- a/basis/alien/c-types/c-types.factor +++ b/basis/alien/c-types/c-types.factor @@ -409,10 +409,10 @@ CONSTANT: primitive-types "uchar" define-primitive-type - [ alien-unsigned-4 zero? not ] >>getter - [ [ 1 0 ? ] 2dip set-alien-unsigned-4 ] >>setter - 4 >>size - 4 >>align + [ alien-unsigned-1 zero? not ] >>getter + [ [ 1 0 ? ] 2dip set-alien-unsigned-1 ] >>setter + 1 >>size + 1 >>align "box_boolean" >>boxer "to_boolean" >>unboxer "bool" define-primitive-type diff --git a/basis/compiler/tests/alien.factor b/basis/compiler/tests/alien.factor index 42ed90d64a..f7f24433d7 100755 --- a/basis/compiler/tests/alien.factor +++ b/basis/compiler/tests/alien.factor @@ -588,3 +588,16 @@ FUNCTION: complex-float ffi_test_47 ( complex-float x, complex-double y ) ; C{ 1.0 2.0 } C{ 1.5 1.0 } ffi_test_47 ] unit-test + +! Reported by jedahu +C-STRUCT: bool-field-test + { "char*" "name" } + { "bool" "on" } + { "short" "parents" } ; + +FUNCTION: short ffi_test_48 ( bool-field-test x ) ; + +[ 123 ] [ + "bool-field-test" 123 over set-bool-field-test-parents + ffi_test_48 +] unit-test \ No newline at end of file diff --git a/vm/ffi_test.c b/vm/ffi_test.c index 680b144140..d45ceb4514 100755 --- a/vm/ffi_test.c +++ b/vm/ffi_test.c @@ -319,3 +319,8 @@ _Complex float ffi_test_47(_Complex float x, _Complex double y) { return x + 2 * y; } + +short ffi_test_48(struct bool_field_test x) +{ + return x.parents; +} diff --git a/vm/ffi_test.h b/vm/ffi_test.h index 835f9e942f..af0c0b46a4 100755 --- a/vm/ffi_test.h +++ b/vm/ffi_test.h @@ -1,3 +1,5 @@ +#include + #if defined(i386) || defined(__i386) || defined(__i386__) || defined(WIN32) #define F_STDCALL __attribute__((stdcall)) #else @@ -102,3 +104,11 @@ F_EXPORT _Complex float ffi_test_45(int x); F_EXPORT _Complex double ffi_test_46(int x); F_EXPORT _Complex float ffi_test_47(_Complex float x, _Complex double y); + +struct bool_field_test { + char *name; + bool on; + short parents; +}; + +F_EXPORT short ffi_test_48(struct bool_field_test x);