]> granicus.if.org Git - python/commitdiff
Issue #18028: Fix aliasing issue in READ_TIMESTAMP() of ceval.c on x86_64,
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 12 Dec 2014 12:17:41 +0000 (13:17 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 12 Dec 2014 12:17:41 +0000 (13:17 +0100)
when Python is configure with --with-tsc. Patch written by Christian Heimes.

Python/ceval.c

index bafb88c160b00465c24ad286d0728c38ec5dc137..118f2b7f2e3f82f845aa3bacbe4ffc79ed50c47f 100644 (file)
@@ -65,9 +65,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