From: Julien P. <jul...@in...> - 2007-02-11 20:07:56
|
Hi, I know this issue has already been discussed, but I would like to know if there is now a better solution than the one that I am using: current mingw does not enforce stack alignment on 16 bit boundaries (the functions just keep it aligned if it was aligned on entry). As my code relies very heavily on SSE, this leads to crashes if I do not realign the stack pointer on 16 bits boundaries. Right now I'm using this trick, which works with gcc 3.4 as long as the optimization level is not too high : void aligned_foo() { __m128 bar; assert(&bar & 0xf); // die if not correctly aligned } void unaligned_foo() __attribute__((noinline)) { (void)__builtin_return_address(1); // to force call frame asm volatile ("andl $-16, %%esp" ::: "%esp"); aligned_foo(); } This has to be done in each entry point of my code (which is a DLL), in each thread proc, each event handler etc. Since gcc uses spontaneously "movaps" instructions in some surprising places, I really have to protect every function which may be called from a non "16-bit aligned" place. So I would really like to find a better solution, is there a patch or something ? Will gcc 4 provide a switch for enforcing the stack alignment ? Thanks in advance, Julien |