From 941c411dd0ad5c6a066363426093c0cce6429b4e Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.blaudden" <> Date: Wed, 11 Apr 2007 22:07:24 +0200 Subject: Bug#21765 Illegal Instruction crash on pre-pentium when using YASSL - Import patch with different method of detecting if machine has cpuid instruction --- extra/yassl/taocrypt/src/misc.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'extra') 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 } -- cgit v1.2.1