diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-29 16:57:56 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-29 16:57:56 +0000 |
commit | 08d544d2f410357dc5fb484c3e9d476f60091079 (patch) | |
tree | 089e7e1f6d0b8a8cfcf3555ee48fec59478e03b4 | |
parent | d1df00f6a8f70d2013dc741524a3a967717ddae2 (diff) | |
download | ChibiOS-08d544d2f410357dc5fb484c3e9d476f60091079.tar.gz ChibiOS-08d544d2f410357dc5fb484c3e9d476f60091079.tar.bz2 ChibiOS-08d544d2f410357dc5fb484c3e9d476f60091079.zip |
Fixed bug 3495487.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4004 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/ports/GCC/SIMIA32/chcore.h | 11 | ||||
-rw-r--r-- | readme.txt | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/os/ports/GCC/SIMIA32/chcore.h b/os/ports/GCC/SIMIA32/chcore.h index d7fe957a1..1dcab09d1 100644 --- a/os/ports/GCC/SIMIA32/chcore.h +++ b/os/ports/GCC/SIMIA32/chcore.h @@ -98,6 +98,12 @@ struct context { #define APUSH(p, a) (p) -= sizeof(void *), *(void **)(p) = (void*)(a)
+/* Darwin requires the stack to be aligned to a 16-byte boundary at
+ * the time of a call instruction (in case the called function needs
+ * to save MMX registers). This aligns to 'mod' module 16, so that we'll end
+ * up with the right alignment after pushing the args. */
+#define AALIGN(p, mask, mod) p = (void *)((((uintptr_t)(p) - mod) & ~mask) + mod)
+
/**
* Platform dependent part of the @p chThdCreateI() API.
* This code usually setup the context switching frame represented by a
@@ -105,6 +111,9 @@ struct context { */
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
uint8_t *esp = (uint8_t *)workspace + wsize; \
+ APUSH(esp, 0); \
+ uint8_t *savebp = esp; \
+ AALIGN(esp, 15, 8); \
APUSH(esp, arg); \
APUSH(esp, pf); \
APUSH(esp, 0); \
@@ -113,7 +122,7 @@ struct context { ((struct intctx *)esp)->ebx = 0; \
((struct intctx *)esp)->edi = 0; \
((struct intctx *)esp)->esi = 0; \
- ((struct intctx *)esp)->ebp = 0; \
+ ((struct intctx *)esp)->ebp = savebp; \
tp->p_ctx.esp = (struct intctx *)esp; \
}
diff --git a/readme.txt b/readme.txt index 4da234769..5280a83b5 100644 --- a/readme.txt +++ b/readme.txt @@ -79,6 +79,8 @@ *****************************************************************************
*** 2.5.0 ***
+- FIX: Fixed stack misalignment on Posix-MacOSX (bug 3495487)(backported
+ in 2.2.9 and 2.4.1).
- FIX: Fixed STM8S HSI clock initialization error (bug 3489727)(backported to
2.2.9 and 2.4.1).
- FIX: Fixed MMC over SPI driver performs an unnecessary SPI read (bug
|