Skip to content
Browse files

Modify STRUCTURE-BY-VALUE-P and include test cases

  • Loading branch information...
1 parent 8046d28 commit bb8a25db3c56eb96cdb6dffc9fa07e7ac30af3dd @crlf0710 crlf0710 committed Jan 18, 2013
Showing with 27 additions and 1 deletion.
  1. +3 −1 src/functions.lisp
  2. +18 −0 tests/fsbv.lisp
  3. +6 −0 tests/libfsbv.c
View
4 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."
View
18 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)
View
6 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;
+}

0 comments on commit bb8a25d

Please sign in to comment.
Something went wrong with that request. Please try again.