[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: MySql broken on older 486 and other cpuid less CPUs. Does this qualify as RC?



tag 410474 +patch
thanks

On Thu, Apr 05, 2007, Florian Weimer wrote:

> Document it in the release notes, please.  It's not worth risking
> stability for the majority of users for this kind of bug.
> 
> Anyway, is there any particular reason why upstream (or you) don't use
> the Intel-recommended way for detection of CPUID support?  A library
> twiddling with SIGILL isn't a terribly good idea.

   Here's a patch that uses the recommended method.

Cheers,
-- 
Sam.
--- ./extra/yassl/taocrypt/src/misc.cpp.orig	2007-04-06 00:02:10 +0200
+++ ./extra/yassl/taocrypt/src/misc.cpp	2007-04-06 00:04:49 +0200
@@ -192,27 +192,29 @@ bool HaveCpuId()
     }
     return true;
 #else
-    typedef void (*SigHandler)(int);
+    word32 eax, ebx;
 
-    SigHandler oldHandler = signal(SIGILL, SigIllHandler);
-    if (oldHandler == SIG_ERR)
-        return false;
+    __asm__ __volatile
+    (
+        "pushf\n\t"
+        "pushf\n\t"
+        "pop %0\n\t"
+        "movl %0,%1\n\t"
+        "xorl $0x200000,%0\n\t"
+        "push %0\n\t"
+        "popf\n\t"
+        "pushf\n\t"
+        "pop %0\n\t"
+        "popf"
+        : "=r" (eax), "=r" (ebx)
+        :
+        : "cc"
+    );
 
-    bool result = true;
-    if (setjmp(s_env))
-        result = false;
-    else 
-        __asm__ __volatile
-        (
-            // save ebx in case -fPIC is being used
-            "push %%ebx; mov $0, %%eax; cpuid; pop %%ebx"
-            : 
-            :
-            : "%eax", "%ecx", "%edx" 
-        );
+    if (eax == ebx)
+        return false;
 
-    signal(SIGILL, oldHandler);
-    return result;
+    return true;
 #endif
 }
 

Reply to: