diff options
author | inmarket <inmarket@ugfx.org> | 2017-01-09 10:24:49 +1000 |
---|---|---|
committer | inmarket <inmarket@ugfx.org> | 2017-01-09 10:24:49 +1000 |
commit | 9216504ce3f825f59494facac637ded42f1cbe04 (patch) | |
tree | f27ed9ccc5fd0a5825a0d00699d2814526375ff3 /src | |
parent | def8fd488fd62c96e42c163fc25ba735a359459e (diff) | |
download | uGFX-9216504ce3f825f59494facac637ded42f1cbe04.tar.gz uGFX-9216504ce3f825f59494facac637ded42f1cbe04.tar.bz2 uGFX-9216504ce3f825f59494facac637ded42f1cbe04.zip |
Ensure stack size produces an aligned stack on platforms where it matters
Diffstat (limited to 'src')
-rw-r--r-- | src/gos/gos.h | 6 | ||||
-rw-r--r-- | src/gos/gos_ecos.h | 2 | ||||
-rw-r--r-- | src/gos/gos_freertos.h | 2 | ||||
-rw-r--r-- | src/gos/gos_rawrtos.h | 2 | ||||
-rw-r--r-- | src/gos/gos_x_threads.h | 2 |
5 files changed, 9 insertions, 5 deletions
diff --git a/src/gos/gos.h b/src/gos/gos.h index 09b278bc..ddca0d94 100644 --- a/src/gos/gos.h +++ b/src/gos/gos.h @@ -65,7 +65,11 @@ * @brief Declare a thread stack * * @param[in] name The name of the stack - * @param[in] sz The size of the stack + * @param[in] sz The size of the stack in bytes + * + * @note The size provided is just a suggestion to the required stack size. + * Many platforms will round the size to ensure correct stack alignment. + * Other platforms may entirely ignore the suggested size. */ #define DECLARE_THREAD_STACK(name, sz) uint8_t name[sz]; diff --git a/src/gos/gos_ecos.h b/src/gos/gos_ecos.h index cd5678df..6aa55a3a 100644 --- a/src/gos/gos_ecos.h +++ b/src/gos/gos_ecos.h @@ -44,7 +44,7 @@ typedef cyg_handle_t gfxThreadHandle; #define NORMAL_PRIORITY (CYGNUM_KERNEL_SCHED_PRIORITIES/2) #define HIGH_PRIORITY 0 -#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[sz]; } name[1] +#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1] #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(cyg_addrword_t param) #define THREAD_RETURN(retval) diff --git a/src/gos/gos_freertos.h b/src/gos/gos_freertos.h index 9b3d1023..92b48024 100644 --- a/src/gos/gos_freertos.h +++ b/src/gos/gos_freertos.h @@ -60,7 +60,7 @@ typedef portBASE_TYPE threadpriority_t; #define HIGH_PRIORITY configMAX_PRIORITIES-1 /* FreeRTOS will allocate the stack when creating the thread, so pass the size instead of a working area */ -#define DECLARE_THREAD_STACK(name, sz) size_t *name = (size_t *)sz +#define DECLARE_THREAD_STACK(name, sz) size_t *name = (size_t *)(sz) #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param) #define THREAD_RETURN(retval) diff --git a/src/gos/gos_rawrtos.h b/src/gos/gos_rawrtos.h index f352d681..e7778d15 100644 --- a/src/gos/gos_rawrtos.h +++ b/src/gos/gos_rawrtos.h @@ -26,7 +26,7 @@ typedef RAW_MUTEX gfxMutex; typedef RAW_TASK_OBJ* gfxThreadHandle; #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param) -#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[sz]; +#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3]; #define THREAD_RETURN(retval) return retval #define gfxHalt(msg) for(;;) diff --git a/src/gos/gos_x_threads.h b/src/gos/gos_x_threads.h index 585585c5..05a08cc2 100644 --- a/src/gos/gos_x_threads.h +++ b/src/gos/gos_x_threads.h @@ -31,7 +31,7 @@ typedef int threadreturn_t; typedef int threadpriority_t; #define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param) -#define DECLARE_THREAD_STACK(name, sz) uint8_t name[sz]; +#define DECLARE_THREAD_STACK(name, sz) uint8_t name[(sz) & ~3]; #define THREAD_RETURN(retval) return retval #define TIME_IMMEDIATE 0 |