This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: stack base pointer not align to 4 bytes
- From: "Chris Zimman" <czimman at bloomberg dot com>
- To: "Xiaochen Zhou" <zhouxiaochen at h3c dot com>, <ecos-discuss at ecos dot sourceware dot org>
- Date: Fri, 23 May 2008 06:32:31 -0400
- Subject: RE: [ECOS] stack base pointer not align to 4 bytes
- References: <002a01c8bc88$4b75bac0$cec8c8c0@h3c.huawei3com.com>
> 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
access.
An alternative means for specifying alignment is to use
__attribute__((aligned)), eg.
static char g_IC_Stack[IC_STACK_SIZE] __attribute__((aligned(4)));
--Chris
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss