summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authormsvensson@pilot.blaudden <>2007-04-11 22:07:24 +0200
committermsvensson@pilot.blaudden <>2007-04-11 22:07:24 +0200
commit941c411dd0ad5c6a066363426093c0cce6429b4e (patch)
tree2e88c03f9cf181eaa80fcf12dc661b74b8cc4a1b /extra
parent4e17e06a5b620238488eaa1c1d24aa82b80e04a7 (diff)
downloadmariadb-git-941c411dd0ad5c6a066363426093c0cce6429b4e.tar.gz
Bug#21765 Illegal Instruction crash on pre-pentium when using YASSL
- Import patch with different method of detecting if machine has cpuid instruction
Diffstat (limited to 'extra')
-rw-r--r--extra/yassl/taocrypt/src/misc.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp
index 726d9e630e6..402645c93fd 100644
--- a/extra/yassl/taocrypt/src/misc.cpp
+++ b/extra/yassl/taocrypt/src/misc.cpp
@@ -192,27 +192,32 @@ bool HaveCpuId()
}
return true;
#else
- typedef void (*SigHandler)(int);
-
- SigHandler oldHandler = signal(SIGILL, SigIllHandler);
- if (oldHandler == SIG_ERR)
- return false;
-
- bool result = true;
- if (setjmp(s_env))
- result = false;
- else
+ word32 eax, ebx;
__asm__ __volatile
(
- // save ebx in case -fPIC is being used
- "push %%ebx; mov $0, %%eax; cpuid; pop %%ebx"
- :
+ /* Put EFLAGS in eax and ebx */
+ "pushf;"
+ "pushf;"
+ "pop %0;"
+ "movl %0,%1;"
+
+ /* Flip the cpuid bit and store back in EFLAGS */
+ "xorl $0x200000,%0;"
+ "push %0;"
+ "popf;"
+
+ /* Read EFLAGS again */
+ "pushf;"
+ "pop %0;"
+ "popf"
+ : "=r" (eax), "=r" (ebx)
:
- : "%eax", "%ecx", "%edx"
+ : "cc"
);
- signal(SIGILL, oldHandler);
- return result;
+ if (eax == ebx)
+ return false;
+ return true;
#endif
}