summaryrefslogtreecommitdiff
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2009-10-31 10:11:28 +0000
committerMark Dickinson <dickinsm@gmail.com>2009-10-31 10:11:28 +0000
commit504a151c825a28e85f81a94c8acbe6b865d66912 (patch)
treec0f25304faa5960953fbc2f02e1594ff9bbb9bdc /Python/ceval.c
parent09823a2e215bea1bde9941766f8d11c0aee26b76 (diff)
downloadcpython-git-504a151c825a28e85f81a94c8acbe6b865d66912.tar.gz
Issue #6603: Fix --with-tsc build failures on x86-64 that resulted
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.)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index ea4bd053c6..dd820f2985 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,