summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rwxr-xr-xunix/configure13
-rw-r--r--unix/configure.in12
-rw-r--r--unix/tclUnixCompat.c17
4 files changed, 31 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 6694ad6..56dfc9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-05-02 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * generic/configure.in: Better detection and implementation for cpuid
+ * generic/configure: instruction on Intel-derived processors, both
+ * generic/tclUnixCompat.c: 32-bit and 64-bit.
+
2012-04-30 Alexandre Ferrieux <ferrieux@users.sourceforge.net>
* tests/ioCmd.test: Tame deadlocks in broken refchan tests [Bug 3522560]
diff --git a/unix/configure b/unix/configure
index cb4f9f1..f763eeb 100755
--- a/unix/configure
+++ b/unix/configure
@@ -19360,9 +19360,13 @@ int
main ()
{
- int index,ax,bx,cx,dx;
- __asm__ __volatile__ ("cpuid":\
- "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (index));
+ int index,regsPtr[4];
+ __asm__ __volatile__("mov %%ebx, %%edi \n\t"
+ "cpuid \n\t"
+ "mov %%ebx, %%esi \n\t"
+ "mov %%edi, %%ebx \n\t"
+ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
+ : "a"(index));
;
return 0;
@@ -19403,7 +19407,8 @@ fi
echo "$as_me:$LINENO: result: $tcl_cv_cpuid" >&5
echo "${ECHO_T}$tcl_cv_cpuid" >&6
if test $tcl_cv_cpuid = yes; then
- cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
#define HAVE_CPUID 1
_ACEOF
diff --git a/unix/configure.in b/unix/configure.in
index 29dc027..ad82ee0 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -755,12 +755,16 @@ AC_MSG_RESULT([$tcl_ok])
AC_CACHE_CHECK([whether the cpuid instruction is usable], tcl_cv_cpuid, [
AC_TRY_LINK(, [
- int index,ax,bx,cx,dx;
- __asm__ __volatile__ ("cpuid":\
- "=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (index));
+ int index,regsPtr[4];
+ __asm__ __volatile__("mov %%ebx, %%edi \n\t"
+ "cpuid \n\t"
+ "mov %%ebx, %%esi \n\t"
+ "mov %%edi, %%ebx \n\t"
+ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
+ : "a"(index));
], tcl_cv_cpuid=yes, tcl_cv_cpuid=no)])
if test $tcl_cv_cpuid = yes; then
- AC_DEFINE(HAVE_CPUID)
+ AC_DEFINE(HAVE_CPUID, 1, [Is the cpuid instruction usable?])
fi
#--------------------------------------------------------------------
diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c
index a39dbbe..792d6da 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -973,8 +973,7 @@ CopyString(
* Get CPU ID information on an Intel box under UNIX (either Linux or Cygwin)
*
* Results:
- * Returns TCL_OK if successful, TCL_ERROR if CPUID is not supported or
- * fails.
+ * Returns TCL_OK if successful, TCL_ERROR if CPUID is not supported.
*
* Side effects:
* If successful, stores EAX, EBX, ECX and EDX registers after the CPUID
@@ -990,14 +989,14 @@ TclWinCPUID(
{
int status = TCL_ERROR;
-#if defined(HAVE_CPUID) && defined(__CYGWIN__)
- __asm__ __volatile__("pushl %%ebx \n\t" /* save %ebx */
+ /* See: <http://en.wikipedia.org/wiki/CPUID> */
+#if defined(HAVE_CPUID)
+ __asm__ __volatile__("mov %%ebx, %%edi \n\t" /* save %ebx */
"cpuid \n\t"
- "movl %%ebx, %1 \n\t" /* save what cpuid just put in %ebx */
- "popl %%ebx \n\t" /* restore the old %ebx */
- : "=a"(regsPtr[0]), "=r"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
- : "a"(index)
- : "cc");
+ "mov %%ebx, %%esi \n\t" /* save what cpuid just put in %ebx */
+ "mov %%edi, %%ebx \n\t" /* restore the old %ebx */
+ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3])
+ : "a"(index));
status = TCL_OK;
#endif
return status;