Index: cpudetect.c =================================================================== --- cpudetect.c (版本 26203) +++ cpudetect.c (工作副本) @@ -105,6 +105,19 @@ } +/* Mask the SSE misaligned exception so as to avoid some mysterious + * crashes; currently only available on AMD K10. + */ +static void mask_misalign_sse() +{ + unsigned mxcsr; + asm volatile ( + "stmxcsr %0\n\t" + "orl $0x20000, %0\n\t" + "ldmxcsr %0\n\t" + :"=m"(mxcsr)); +} + void GetCpuCaps( CpuCaps *caps) { unsigned int regs[4]; @@ -167,6 +180,8 @@ caps->hasMMX2 |= (regs2[3] & (1 << 22 )) >> 22; // 0x400000 caps->has3DNow = (regs2[3] & (1 << 31 )) >> 31; //0x80000000 caps->has3DNowExt = (regs2[3] & (1 << 30 )) >> 30; + if (regs2[2] & (1 << 7)) + mask_misalign_sse(); } if(regs[0]>=0x80000006) {