1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

* align tcb on 32bit boundary

This commit is contained in:
Kaspar Schleiser 2010-11-09 17:01:52 +01:00
parent b1c61e446f
commit 9122445c27

View File

@ -84,7 +84,18 @@ int thread_create(char *stack, int stacksize, char priority, int flags, void (*f
/* allocate our thread control block at the top of our stackspace */
int total_stacksize = stacksize;
stacksize -= sizeof(tcb);
tcb *cb = (tcb*) (stack + stacksize);
/* align tcb address on 32bit boundary */
unsigned int tcb_address = (unsigned int) stack + stacksize;
if ( tcb_address & 1 ) {
tcb_address--;
stacksize--;
}
if ( tcb_address & 2 ) {
tcb_address-=2;
stacksize-=2;
}
tcb *cb = (tcb*) tcb_address;
if (priority >= SCHED_PRIO_LEVELS) {
return -EINVAL;