Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b881dd

Browse files
committed
Issue #18028: Fix aliasing issue in READ_TIMESTAMP() of ceval.c on x86_64,
when Python is configure with --with-tsc. Patch written by Christian Heimes.
1 parent 437ffbd commit 0b881dd

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

Python/ceval.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ ppc_getcounter(uint64 *v)
6565
even in 64-bit mode, we need to use "a" and "d" for the lower and upper
6666
32-bit pieces of the result. */
6767

68-
#define READ_TIMESTAMP(val) \
69-
__asm__ __volatile__("rdtsc" : \
70-
"=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1]));
68+
#define READ_TIMESTAMP(val) do { \
69+
unsigned int h, l; \
70+
__asm__ __volatile__("rdtsc" : "=a" (l), "=d" (h)); \
71+
(val) = ((uint64)l) | (((uint64)h) << 32); \
72+
} while(0)
7173

7274

7375
#else

0 commit comments

Comments
 (0)