Gah... hit the wrong reply button so here we go again for some.
On Sun, Oct 21, 2012 at 10:06 AM, Joris Huizer joris_huizer@yahoo.com wrote:
On 10/21/2012 05:49 PM, James Eder wrote:
On Sat, Oct 20, 2012 at 7:06 PM, Chris Robinson chris.kcat@gmail.com wrote:
On 10/20/2012 05:40 PM, James Eder wrote:
- /* Intel says we need a zeroed 16-byte aligned buffer */
- char buffer[512 + 16];
- XMM_SAVE_AREA32 *state = (XMM_SAVE_AREA32 *)(((ULONG_PTR)buffer +
& ~15);
- memset(buffer, 0, sizeof(buffer));
- __asm__ __volatile__( "fxsave %0" : "=m" (*state) : "m" (*state) );
Wouldn't this be simpler?
DECLSPEC_ALIGN(16) XMM_SAVE_AREA32 state; memset(state, 0, sizeof(state)); __asm__ __volatile__("fxsave %0" : "=m" (*&state) : "m" (*&state));
May also want to make sure the two structs are packed.
I used that alignment method because I saw it done that way other places in Wine. I figured there must have been a good reason for doing it that way (issue with some build environments?) but perhaps I'm being paranoid.
I would think the construct is necessary when allocating memory (the allocation functions don't allow to require a certain alignment as far as I know) That might be where you saw this being done?
I was going off of save_fpux in dlls/ntdll/signal_i386.c:
static inline void save_fpux( CONTEXT *context ) { #ifdef __GNUC__ /* we have to enforce alignment by hand */ char buffer[sizeof(XMM_SAVE_AREA32) + 16]; XMM_SAVE_AREA32 *state = (XMM_SAVE_AREA32 *)(((ULONG_PTR)buffer + 15) & ~15);
__asm__ __volatile__( "fxsave %0" : "=m" (*state) ); context->ContextFlags |= CONTEXT_EXTENDED_REGISTERS; memcpy( context->ExtendedRegisters, state, sizeof(*state) ); #endif }