Skip to content

Commit a25b131

Browse files
committed
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.) ........
1 parent 5db1051 commit a25b131

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ Extension Modules
312312
Build
313313
-----
314314

315+
- Issue #6603: Change READ_TIMESTAMP macro in ceval.c so that it
316+
compiles correctly under gcc on x86-64. This fixes a reported
317+
problem with the --with-tsc build on x86-64.
318+
315319
- Issue #6802: Fix build issues on MacOSX 10.6
316320

317321
- Issue #6244: Allow detect_tkinter to look for Tcl/Tk 8.6.

Python/ceval.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,29 @@ ppc_getcounter(uint64 *v)
5151
((long*)(v))[1] = tb;
5252
}
5353

54-
#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */
54+
#elif defined(__i386__)
55+
56+
/* this is for linux/x86 (and probably any other GCC/x86 combo) */
5557

5658
#define READ_TIMESTAMP(val) \
5759
__asm__ __volatile__("rdtsc" : "=A" (val))
5860

61+
#elif defined(__x86_64__)
62+
63+
/* for gcc/x86_64, the "A" constraint in DI mode means *either* rax *or* rdx;
64+
not edx:eax as it does for i386. Since rdtsc puts its result in edx:eax
65+
even in 64-bit mode, we need to use "a" and "d" for the lower and upper
66+
32-bit pieces of the result. */
67+
68+
#define READ_TIMESTAMP(val) \
69+
__asm__ __volatile__("rdtsc" : \
70+
"=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1]));
71+
72+
73+
#else
74+
75+
#error "Don't know how to implement timestamp counter for this architecture"
76+
5977
#endif
6078

6179
void dump_tsc(int opcode, int ticked, uint64 inst0, uint64 inst1,

0 commit comments

Comments
 (0)