This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __attribute__((aligned(16))) silently ignored


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]