diff --git a/src/functions.lisp b/src/functions.lisp index bb138de4e599416f3fd9b2ae32ec881930dadb39..7131f6674ffc36c4468606534e1c47c93ad8072b 100644 --- a/src/functions.lisp +++ b/src/functions.lisp @@ -90,7 +90,9 @@ (defun structure-by-value-p (ctype) "A structure or union is to be called or returned by value." - (member (alexandria:ensure-car ctype) '(:struct :union))) + (typep (follow-typedefs (parse-type ctype)) + '(or foreign-struct-type foreign-union-type + #+cffi::no-long-long emulated-llong-type))) (defun fn-call-by-value-p (argument-types return-type) "One or more structures in the arguments or return from the function are called by value." diff --git a/tests/fsbv.lisp b/tests/fsbv.lisp index 98bce145abe6065f7012f5ef5825486b5ca2bd7f..13a7b0c828d5e4e39aec87a13f2524961cc7ab25 100644 --- a/tests/fsbv.lisp +++ b/tests/fsbv.lisp @@ -65,3 +65,21 @@ 8 10 5.0d0) + +;;; Typedef fsbv test + +(defcfun ("sumpair" sumpair2) :int + (p struct-pair-typedef1)) + +(deftest fsbv.5 + (sumpair2 '(1 . 2)) + 3) + +;;; Test ulonglong on no-long-long implementations. + +(defcfun "ullsum" :unsigned-long-long + (a :unsigned-long-long) (b :unsigned-long-long)) + +(deftest fsbv.6 + (ullsum #x10DEADBEEF #x2300000000) + #x33DEADBEEF) diff --git a/tests/libfsbv.c b/tests/libfsbv.c index c5aa0ca6b3e5e8d807e028f818ad0d4c5db93d36..e6f30453d6ddb8885633b786021a4f2ed7eafb1d 100644 --- a/tests/libfsbv.c +++ b/tests/libfsbv.c @@ -97,3 +97,9 @@ struct struct_pair_double doublepairdouble (struct struct_pair_double pd) ret.dbl = 2*pd.dbl; return ret; } + +DLLEXPORT +unsigned long long ullsum (unsigned long long a, unsigned long long b) +{ + return a + b; +}