summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-02 21:39:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-02 21:39:10 (GMT)
commitb01b765d7b57559048e606b7a01156a807b26b9c (patch)
tree8835c59d6164b82f15ea847bacc04e7a074b666c
parentfc2fcb8cf98f705a260551269c44f3c2ea80bc6c (diff)
parent99557b6c57a524f31c81cde6d39cc2a5e51983f3 (diff)
downloadtcl-b01b765d7b57559048e606b7a01156a807b26b9c.zip
tcl-b01b765d7b57559048e606b7a01156a807b26b9c.tar.gz
tcl-b01b765d7b57559048e606b7a01156a807b26b9c.tar.bz2
Better detection and implementation for cpuid instruction on Intel-derived processors, both 32-bit and 64-bit
-rw-r--r--ChangeLog6
-rwxr-xr-xunix/configure14
-rw-r--r--unix/configure.in12
-rw-r--r--unix/tclUnixCompat.c17
4 files changed, 31 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 58750bd..22793e9 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-27 Donal K. Fellows <dkf@users.sf.net>
* library/init.tcl (auto_execok): Allow shell builtins to be detected
diff --git a/unix/configure b/unix/configure
index 1a0d882..4898cfb 100755
--- a/unix/configure
+++ b/unix/configure
@@ -9339,13 +9339,17 @@ else
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; }
EOF
-if { (eval echo configure:9349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:9353: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
tcl_cv_cpuid=yes
else
@@ -9394,7 +9398,7 @@ if test "`uname -s`" = "Darwin" ; then
if test "`uname -s`" = "Darwin" ; then
echo $ac_n "checking how to package libraries""... $ac_c" 1>&6
-echo "configure:9398: checking how to package libraries" >&5
+echo "configure:9402: checking how to package libraries" >&5
# Check whether --enable-framework or --disable-framework was given.
if test "${enable_framework+set}" = set; then
enableval="$enable_framework"
diff --git a/unix/configure.in b/unix/configure.in
index c04c735..869fbaa 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -571,12 +571,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 1043115..6e2666b 100644
--- a/unix/tclUnixCompat.c
+++ b/unix/tclUnixCompat.c
@@ -675,8 +675,7 @@ TclpGetHostByAddr(const char *addr, int length, int type)
* 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
@@ -692,14 +691,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;