Page 1 of 1

Stack declaration attribute aligned vs. .align

Posted: Thu Oct 23, 2014 6:26 pm
by Watzlavick
In the examples, the following code is used for stack alignment:
asm( " .align 4 " );
DWORD MyTaskStk[USER_TASK_STK_SIZE] __attribute__( ( aligned( 4 ) ) );

Are both directives needed? I would think the .asm one isn't needed since the aligned attribute does the same thing. I saw some notes about older versions of GCC not working correctly so is that the reason?

-Bob

Re: Stack declaration attribute aligned vs. .align

Posted: Thu Oct 23, 2014 7:18 pm
by roland.ames
I cannot find any examples that use

Code: Select all

asm( " .align 4 " );
DWORD MyTaskStk[USER_TASK_STK_SIZE] __attribute__( ( aligned( 4 ) ) );


but you are right that you should not need both forms of alignment.

You can always use the macros defined in ucos.h and documented in uCOSLibrary.pdf:
OSSimpleTaskCreate( function, priority );
OSSimpleTaskCreatewName( function, priority, name );

these macros should force the stack alignment to be correct. Examining the macro definitons in ucos.h, there is no asm(" .align 4") line

ps I am referring to the latest release 2.6.8, but I don't think this has changed for a while.

Re: Stack declaration attribute aligned vs. .align

Posted: Thu Oct 23, 2014 8:43 pm
by Watzlavick
I guess it wasn't in the shipping examples but in the Example for OSTaskCreate in the uC/OS manual. Thanks for the info.

-Bob