[macruby-changes] [4952] MacRuby/trunk/compiler.cpp
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 26 14:07:00 PST 2010
Revision: 4952
http://trac.macosforge.org/projects/ruby/changeset/4952
Author: lsansonetti at apple.com
Date: 2010-11-26 14:06:56 -0800 (Fri, 26 Nov 2010)
Log Message:
-----------
32-bit: fix an ABI issue when calling a C function returning a struct that can fit inside a 64-bit integer (such as NSPoint)
Modified Paths:
--------------
MacRuby/trunk/compiler.cpp
Modified: MacRuby/trunk/compiler.cpp
===================================================================
--- MacRuby/trunk/compiler.cpp 2010-11-26 17:01:12 UTC (rev 4951)
+++ MacRuby/trunk/compiler.cpp 2010-11-26 22:06:56 UTC (rev 4952)
@@ -6024,6 +6024,18 @@
ret_type = VoidTy;
}
+#if !__LP64__
+ const Type *small_struct_type = NULL;
+ if (ret_type->getTypeID() == Type::StructTyID
+ && GET_CORE()->get_sizeof(ret_type) == 8) {
+ // We are returning a small struct that can fit inside a 64-bit
+ // integer (such as NSPoint).
+ // TODO: we should probably make this more generic.
+ small_struct_type = ret_type;
+ ret_type = Int64Ty;
+ }
+#endif
+
Value *self_arg = NULL;
if (is_objc) {
// self
@@ -6109,13 +6121,23 @@
}
GetFirstType(types, buf, buf_len);
- ret_type = convert_type(buf);
if (self_arg != NULL && ret_type == VoidTy) {
// If we are calling an Objective-C method that returns void, let's
// return the receiver instead of nil, for convenience purposes.
retval = self_arg;
}
else {
+#if !__LP64__
+ if (small_struct_type != NULL) {
+ Value *slot = new AllocaInst(small_struct_type, "", bb);
+ new StoreInst(retval,
+ new BitCastInst(slot, PointerType::getUnqual(ret_type),
+ "", bb),
+ bb);
+ retval = new LoadInst(slot, "", bb);
+ ret_type = small_struct_type;
+ }
+#endif
retval = compile_conversion_to_ruby(buf, ret_type, retval);
}
ReturnInst::Create(context, retval, bb);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101126/eabc9116/attachment.html>
More information about the macruby-changes
mailing list