summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-12-12 12:19:00 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-12-12 12:19:00 (GMT)
commit2b565bb6f3112644b4b53278513f4fe7f501d536 (patch)
tree0dea0761c5b2b7684df20dd5a6ff003c8e6d2f33 /Python/ceval.c
parente4efc3d913514458d15780e5c3bea3316375562a (diff)
downloadcpython-2b565bb6f3112644b4b53278513f4fe7f501d536.zip
cpython-2b565bb6f3112644b4b53278513f4fe7f501d536.tar.gz
cpython-2b565bb6f3112644b4b53278513f4fe7f501d536.tar.bz2
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 682a1e7..fa6bb60 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -66,9 +66,11 @@ ppc_getcounter(uint64 *v)
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]));
+#define READ_TIMESTAMP(val) do { \
+ unsigned int h, l; \
+ __asm__ __volatile__("rdtsc" : "=a" (l), "=d" (h)); \
+ (val) = ((uint64)l) | (((uint64)h) << 32); \
+ } while(0)
#else