summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS4
-rw-r--r--Python/ceval.c20
2 files changed, 23 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index c5ad099..3593e3e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -130,6 +130,10 @@ Tests
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.
+
- Issue #6802: Fix build issues on MacOSX 10.6
- Issue #6801 : symmetric_difference_update also accepts |.
diff --git a/Python/ceval.c b/Python/ceval.c
index b5b5c27..8a24f11 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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,