[Python-checkins] r75984 - in python/branches/py3k: Misc/NEWS Python/ceval.c

mark.dickinson python-checkins at python.org
Sat Oct 31 11:18:44 CET 2009


Author: mark.dickinson
Date: Sat Oct 31 11:18:44 2009
New Revision: 75984

Log:
Merged revisions 75982 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r75982 | mark.dickinson | 2009-10-31 10:11:28 +0000 (Sat, 31 Oct 2009) | 5 lines
  
  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.)
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/ceval.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Oct 31 11:18:44 2009
@@ -312,6 +312,10 @@
 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 #6244: Allow detect_tkinter to look for Tcl/Tk 8.6.

Modified: python/branches/py3k/Python/ceval.c
==============================================================================
--- python/branches/py3k/Python/ceval.c	(original)
+++ python/branches/py3k/Python/ceval.c	Sat Oct 31 11:18:44 2009
@@ -51,11 +51,29 @@
 	((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,


More information about the Python-checkins mailing list