[ECOS] Re: Wrong declaration of idle_thread_stack

Eric de Jong list_ericdejong_10@gmx.net
Thu Jan 22 15:33:00 GMT 2004


>> But it might be possible that there are other char arrays within the eCos
source wich require an alignment.

If they require an allignment, they should also have the ALIGN(4) attribute. For
the arm7 processor, the stack, short and long words must also be alligned. Also
when I cast a char to a long it has to be alligned. So your processor is not the
only one.
Your problem with idle_thread_stack is probably hidden for arm users because the
array accidently starts at an 4-byte boundary. I guess there wont be much more
surprises.

>> But in my opinion it is not the best idea to declare char arrays and then
expect that the compiler would align them to a 4 byte boundary

Don't expect it indeed. If a character array is expected to be alligned, for
example because the characters are casted to short or long words, the array must
have the ALIGN attribute (or defined as a union, defined in a structure after a
unsigned long or whatever :) )

However if I define the following structure, I expect the second array to start
on an odd address:

struct Hello
{
    char a[3];
    char b[5];
};

Which is for example a save settings structure in an eeprom.


I'm off for a short holiday now,
happy coding!

Eric



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



More information about the Ecos-discuss mailing list