changeset 18:beafc56094bc

- fix for arm/thumb on some platforms (e.g. nintendo ds) to keep compiler from overwriting return values in caller-cleanup code
author cslag
date Sat, 01 Aug 2015 19:50:49 +0200
parents 17b10cc8ce8b
children 9ceb368cc0ed
files dyncall/dyncall_callvm_arm32_thumb.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dyncall/dyncall_callvm_arm32_thumb.c	Sat Aug 01 19:13:21 2015 +0200
+++ b/dyncall/dyncall_callvm_arm32_thumb.c	Sat Aug 01 19:50:49 2015 +0200
@@ -154,7 +154,11 @@
 void dc_callvm_call_arm32_thumb(DCCallVM* in_self, DCpointer target)
 {
   DCCallVM_arm32_thumb* self = (DCCallVM_arm32_thumb*)in_self;
-  dcCall_arm32_thumb(target, dcVecData(&self->mVecHead), dcVecSize(&self->mVecHead));
+  // This cast is needed in order for the cleanup code in the caller (this very function) to not
+  // overwrite and use r0 and r1, as we want to pass them back. On some platforms (FreeBSD/arm, Nintendo DS
+  // the compiler generates cleanup code that writes to those registers by assuming dcCall_arm32_arm didn't
+  // use them.
+  ((DClonglong(*)(DCpointer, DCpointer, DCsize))&dcCall_arm32_thumb)(target, dcVecData(&self->mVecHead), dcVecSize(&self->mVecHead));
 }