[ECOS] stack base pointer not align to 4 bytes

Xiaochen Zhou zhouxiaochen@h3c.com
Mon May 26 01:44:00 GMT 2008

Hi Chris,

I think the best way to solve the issue should adjust the stack alignment automaticly by kernel. For most of ecos users do not care the stack alignment. If they create their own applications with the template of package/example/twothreads.c(or serial.c, simple-alarm.c), I don't how many hidden bugs in ecos world!

Xiaochen Zhou

----- Original Message ----- 
From: "Chris Zimman" <czimman@bloomberg.com>
To: "Xiaochen Zhou" <zhouxiaochen@h3c.com>; <ecos-discuss@ecos.sourceware.org>
Sent: Friday, May 23, 2008 6:32 PM
Subject: RE: [ECOS] stack base pointer not align to 4 bytes

> If I change the line static char g_IC_Stack[IC_STACK_SIZE]; ---------->
> static int g_IC_Stack[IC_STACK_SIZE/4]; everything is OK.
> I think this is my fault, but when I grep the eCos source tree, thera
> are many files using stack definition like me( for example:
> net/tcpip/current/src/ecos/support.c). And the kernel source
> code(Cyg_HardwareThread::attach_stack()) did not adjust the alignment
> automaticly.
> My fault or eCos fault? Thanks!

It's not really a 'fault' either way, but if you have it declared as char,
it's definitely not guaranteed to be word aligned.  I think the examples you
point out in eCos are probably bugs, at least on platforms that need aligned

An alternative means for specifying alignment is to use
__attribute__((aligned)), eg.

static char g_IC_Stack[IC_STACK_SIZE] __attribute__((aligned(4)));


Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list