Amiga: add experimental stack swap support.#88
Conversation
4302291 to
bf5e2b0
Compare
|
Updated to borrow the relevant parts from codesets.library, as it has a hand-written inline assembly routine which should be far safer than attempting to use |
bf5e2b0 to
7d6b8ad
Compare
|
MorphOS tested, works. |
21846e0 to
343488c
Compare
|
Resolved a -pedantic warning from converting a function pointer to I haven't been able to test OS 4 or AROS yet. |
|
This should be ready. Please test AROS and fix as necessary, since I can't test it on my end. |
|
The following is needed for 64 bit Aros: (will run-test shortly) diff --git a/src/main_amiga.h b/src/main_amiga.h
index cafd4ef..ff602f0 100644
--- a/src/main_amiga.h
+++ b/src/main_amiga.h
@@ -165,7 +165,11 @@ int main(int argc, char **argv)
struct main_args args;
int ret;
+ #ifdef __AROS__
+ sw.stk_Upper = (APTR)((IPTR)sw.stk_Lower + MIN_STACK_SIZE);
+ #else
sw.stk_Upper = (ULONG)sw.stk_Lower + MIN_STACK_SIZE;
+ #endif
sw.stk_Pointer = (APTR)sw.stk_Upper;
#if 0One thing is that this relies on gcc for m68k, which may be mostly true, |
The software I got this asm fragment from did not have VBCC code, so this may have to be disabled for VBCC builds.
OK, if it works, I can try to patch it in soon. (I don't think xmp uses preprocessor macro style like that, though, it's non-indented almost everywhere.) |
|
Tested x86_64-aros (linux-hosted version) and it works. Adjusted the ifdef indentation. Should I force-push the Q: Should we double the minimum stack size, e.g. 65536 for 64 bits? diff --git a/src/main_amiga.h b/src/main_amiga.h
index 8da843b0..c3927650 100644
--- a/src/main_amiga.h
+++ b/src/main_amiga.h
@@ -32,7 +32,7 @@
#include "common.h"
-#if defined(XMP_AMIGA)
+#if defined(XMP_AMIGA) && !defined(__VBCC__)
#include <proto/exec.h>
@@ -165,7 +165,11 @@ int main(int argc, char **argv)
struct main_args args;
int ret;
+#ifdef __AROS__
+ sw.stk_Upper = (APTR)((IPTR)sw.stk_Lower + MIN_STACK_SIZE);
+#else
sw.stk_Upper = (ULONG)sw.stk_Lower + MIN_STACK_SIZE;
+#endif
sw.stk_Pointer = (APTR)sw.stk_Upper;
#if 0 |
OK, I will patch this in soon.
I don't think that's necessary, because libxmp's stack usage looks something like:
|
Looked at vbcc: we don't have m68k asm for it but it responds to global var diff --git a/src/main_amiga.h b/src/main_amiga.h
index 8da843b..931fec2 100644
--- a/src/main_amiga.h
+++ b/src/main_amiga.h
@@ -52,6 +52,11 @@ const char XMP_USED stack_cookie[] = "$STACK: 32768";
extern int __stack;
int XMP_USED __stack = MIN_STACK_SIZE;
+#if defined(__VBCC__) && !defined(XMP_NO_STACKSWAP)
+/* no m68k asm for vbcc, but it responds to global var `__stack` */
+#define XMP_NO_STACKSWAP
+#endif
+
/* Workbench 2.04 through 3.1: manually set stack size via StackSwap.
* This needs to be performed through inline ASM to be safe.
*
@@ -165,7 +170,11 @@ int main(int argc, char **argv)
struct main_args args;
int ret;
+#ifdef __AROS__
+ sw.stk_Upper = (APTR)((IPTR)sw.stk_Lower + MIN_STACK_SIZE);
+#else
sw.stk_Upper = (ULONG)sw.stk_Lower + MIN_STACK_SIZE;
+#endif
sw.stk_Pointer = (APTR)sw.stk_Upper;
#if 0
OK :) |
* Workbench 2.04 onward: use StackSwap (inline ASM borrowed from codesets.library, LGPL 2.1). * AROS: use NewStackSwap. * MorphOS: use NewPPCStackSwap. * AmigaOS 3.2, 4.x: use a stack cookie. * VBCC: use __stack. Co-authored-by: Özkan Sezer <sezero@users.noreply.github.com>
343488c to
d0ac3ca
Compare
|
OK, I've applied the vbcc and AROS patch.
I slimmed this part down a little bit by combining it into the existing |
Closes #87.
This is an updated version of the patch, but still very much needs testing. It works fine for me with both m68k toolchains I have set up + libnix for Workbench 2.