Update of /cvsroot/hoc/hoc/HOC_cbits
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11386/HOC_cbits
Modified Files:
FFICallInterface.h FFICallInterface.m
Log Message:
Deal with structure returns in a way that works for x86, too.
Index: FFICallInterface.h
===================================================================
RCS file: /cvsroot/hoc/hoc/HOC_cbits/FFICallInterface.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FFICallInterface.h 27 Feb 2004 12:21:34 -0000 1.3
+++ FFICallInterface.h 17 Mar 2006 04:54:45 -0000 1.4
@@ -3,3 +3,5 @@
ffi_cif * allocCif();
ffi_abi defaultABI();
ffi_type * allocStructType(ffi_type **elements);
+
+int cifIsStret(ffi_cif *cif);
Index: FFICallInterface.m
===================================================================
RCS file: /cvsroot/hoc/hoc/HOC_cbits/FFICallInterface.m,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FFICallInterface.m 12 May 2004 02:22:43 -0000 1.3
+++ FFICallInterface.m 17 Mar 2006 04:54:45 -0000 1.4
@@ -1,5 +1,5 @@
#include "FFICallInterface.h"
-
+#include <stdlib.h>
ffi_cif * allocCif()
{
@@ -20,3 +20,20 @@
return theStruct;
}
+
+int cifIsStret(ffi_cif *cif)
+{
+ if(cif->rtype->type == FFI_TYPE_STRUCT)
+ {
+#ifdef __i386__
+ // on Darwin/x86, structs 8 bytes and smaller are returned
+ // in registers, and we have to use objc_msgSend and not
+ // objc_msgSend_stret.
+ return cif->rtype->size > 8;
+#else
+ return 1;
+#endif
+ }
+ else
+ return 0;
+}
|