This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((aligned(16))) silently ignored
- From: Brian Dessent <brian at dessent dot net>
- To: Cristiano Di Buduo <cristiano_di_buduo at hotmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 02 May 2008 16:22:24 -0700
- Subject: Re: __attribute__((aligned(16))) silently ignored
- References: <BLU119-W67593F79223CAB6AEEBD4DDDA0@phx.gbl>
- Reply-to: gcc-help at gcc dot gnu dot org
Cristiano Di Buduo wrote:
> Sorry, of course I meant WindowProc.
I am guessing that what's happening here is that since you are in a
callback from the operating system, the calling frame has violated gcc's
assumption that %esp will always be aligned to 16 at function entry.
gcc aligns %esp once at program startup and then ensures that it stays
aligned at each function call, so that prologues of functions that have
aligned data don't have to contain code to align it every time. But if
the calling frame doesn't maintain this convention then it all falls
apart.
You can use __attribute__((force_align_arg_pointer)) on the function to
tell gcc not to assume that the incoming %esp is 16 byte aligned and to
instead insert the slower explicit alignment code in the prologue.
However, this attribute wasn't added until gcc 4.2 so if you're using
the Cygwin system compiler (currently based on 3.4) it won't work.
Brian