Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 57002:f594313b9364 legacy-trunk
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.)
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 31 Oct 2009 10:11:28 +0000 |
| parents | 6210dedd2cf7 |
| children | 8f6eee42f810 |
line wrap: on
line diff
--- a/Python/ceval.c Sat Oct 31 09:42:39 2009 +0000 +++ b/Python/ceval.c Sat Oct 31 10:11:28 2009 +0000 @@ -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,
