Stack declaration attribute aligned vs. .align

Discussion to talk about software related topics only.
Post Reply
Watzlavick
Posts: 22
Joined: Mon Jan 27, 2014 7:19 pm

Stack declaration attribute aligned vs. .align

Post 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
roland.ames

Re: Stack declaration attribute aligned vs. .align

Post 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.
Watzlavick
Posts: 22
Joined: Mon Jan 27, 2014 7:19 pm

Re: Stack declaration attribute aligned vs. .align

Post 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
Post Reply