]> granicus.if.org Git - python/commitdiff
Issue #6603: Fix --with-tsc build failures on x86-64 that resulted
authorMark Dickinson <dickinsm@gmail.com>
Sat, 31 Oct 2009 10:11:28 +0000 (10:11 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sat, 31 Oct 2009 10:11:28 +0000 (10:11 +0000)
from a gcc inline assembler peculiarity. (gcc's "A" constraint
apparently means 'rax or rdx' in 64-bit mode, not edx:eax
or rdx:rax as one might expect.)

Misc/NEWS
Python/ceval.c

index e2695053427982d372ac4b0d88f651dea3311339..3fc935838635b62086efa48c40f94576deca1af5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1345,6 +1345,10 @@ Tools/Demos
 Build
 -----
 
+- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it
+  compiles correctly under gcc on x86-64.  This fixes a reported
+  problem with the --with-tsc build on x86-64.
+
 - Add 2 new options to ``--with-universal-archs`` on MacOSX:
   ``intel`` builds a distribution with ``i386`` and ``x86_64`` architectures,
   while ``3-way`` builds a distribution with the ``ppc``, ``i386``
index ea4bd053c6bdaaefe5a0fde972788d8a72d61aae..dd820f298512df684c4534e4dc89e1f99b3ac9f8 100644 (file)
@@ -51,11 +51,29 @@ ppc_getcounter(uint64 *v)
        ((long*)(v))[1] = tb;
 }
 
-#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */
+#elif defined(__i386__)
+
+/* this is for linux/x86 (and probably any other GCC/x86 combo) */
 
 #define READ_TIMESTAMP(val) \
      __asm__ __volatile__("rdtsc" : "=A" (val))
 
+#elif defined(__x86_64__)
+
+/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx;
+   not edx:eax as it does for i386.  Since rdtsc puts its result in edx:eax
+   even in 64-bit mode, we need to use "a" and "d" for the lower and upper
+   32-bit pieces of the result. */
+
+#define READ_TIMESTAMP(val) \
+    __asm__ __volatile__("rdtsc" : \
+                         "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1]));
+
+
+#else
+
+#error "Don't know how to implement timestamp counter for this architecture"
+
 #endif
 
 void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,