Browse Source

Ensure stack size produces an aligned stack on platforms where it matters

remotes/origin_old/release/v2.9
inmarket 5 years ago
parent
commit
9216504ce3
  1. 6
      src/gos/gos.h
  2. 2
      src/gos/gos_ecos.h
  3. 2
      src/gos/gos_freertos.h
  4. 2
      src/gos/gos_rawrtos.h
  5. 2
      src/gos/gos_x_threads.h

6
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];

2
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)

2
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)

2
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(;;)

2
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

Loading…
Cancel
Save