Fix stack aligment.

Stack should be 8 byte aligned on ARM.
Fix the automatic correction of the alignment in rt_init_stack,
and make sure that all stacks are aligned by the compiler.
pull/812/head
Per Kristian Gjermshus 2014-12-23 09:31:26 +01:00
parent b170bc702e
commit c59b34f22a
2 changed files with 4 additions and 4 deletions

View File

@ -33,10 +33,10 @@ Thread::Thread(void (*task)(void const *argument), void *argument,
_thread_def.stacksize = stack_size;
#ifndef __MBED_CMSIS_RTOS_CA9
if (stack_pointer != NULL) {
_thread_def.stack_pointer = stack_pointer;
_thread_def.stack_pointer = (uint32_t*)stack_pointer;
_dynamic_stack = false;
} else {
_thread_def.stack_pointer = new unsigned char[stack_size];
_thread_def.stack_pointer = new uint32_t[stack_size/sizeof(uint32_t)];
if (_thread_def.stack_pointer == NULL)
error("Error allocating the stack memory\n");
_dynamic_stack = true;

View File

@ -243,7 +243,7 @@ typedef struct os_thread_def {
os_pthread pthread; ///< start address of thread function
osPriority tpriority; ///< initial thread priority
uint32_t stacksize; ///< stack size requirements in bytes
unsigned char *stack_pointer; ///< pointer to the stack memory block
uint32_t *stack_pointer; ///< pointer to the stack memory block
struct OS_TCB tcb;
} osThreadDef_t;
@ -337,7 +337,7 @@ int32_t osKernelRunning(void);
extern osThreadDef_t os_thread_def_##name
#else // define the object
#define osThreadDef(name, priority, stacksz) \
unsigned char os_thread_def_stack_##name [stacksz]; \
uint32_t os_thread_def_stack_##name [stacksz / sizeof(uint32_t)]; \
osThreadDef_t os_thread_def_##name = \
{ (name), (priority), (stacksz), (os_thread_def_stack_##name)}
#endif