|
|
6e8c2f |
diff -up Python-2.7.2/Python/ceval.c.tsc-on-ppc Python-2.7.2/Python/ceval.c
|
|
|
6e8c2f |
--- Python-2.7.2/Python/ceval.c.tsc-on-ppc 2011-08-23 14:59:48.051300849 -0400
|
|
|
6e8c2f |
+++ Python-2.7.2/Python/ceval.c 2011-08-23 15:33:25.412162902 -0400
|
|
|
6e8c2f |
@@ -37,24 +37,42 @@ typedef unsigned long long uint64;
|
|
|
6e8c2f |
*/
|
|
|
6e8c2f |
#if defined(__ppc__) || defined (__powerpc__)
|
|
|
6e8c2f |
|
|
|
6e8c2f |
-#define READ_TIMESTAMP(var) ppc_getcounter(&var)
|
|
|
6e8c2f |
+#if defined( __powerpc64__) || defined(__LP64__)
|
|
|
6e8c2f |
+/* 64-bit PowerPC */
|
|
|
6e8c2f |
+#define READ_TIMESTAMP(var) ppc64_getcounter(&var)
|
|
|
6e8c2f |
+static void
|
|
|
6e8c2f |
+ppc64_getcounter(uint64 *v)
|
|
|
6e8c2f |
+{
|
|
|
6e8c2f |
+ /* On 64-bit PowerPC we can read the 64-bit timebase directly into a
|
|
|
6e8c2f |
+ 64-bit register */
|
|
|
6e8c2f |
+ uint64 timebase;
|
|
|
6e8c2f |
+#ifdef _ARCH_PWR4
|
|
|
6e8c2f |
+ asm volatile ("mfspr %0,268" : "=r" (timebase));
|
|
|
6e8c2f |
+#else
|
|
|
6e8c2f |
+ asm volatile ("mftb %0" : "=r" (timebase));
|
|
|
6e8c2f |
+#endif
|
|
|
6e8c2f |
+ *v = timebase;
|
|
|
6e8c2f |
+}
|
|
|
6e8c2f |
+
|
|
|
6e8c2f |
+#else
|
|
|
6e8c2f |
+/* 32-bit PowerPC */
|
|
|
6e8c2f |
+#define READ_TIMESTAMP(var) ppc32_getcounter(&var)
|
|
|
6e8c2f |
|
|
|
6e8c2f |
static void
|
|
|
6e8c2f |
-ppc_getcounter(uint64 *v)
|
|
|
6e8c2f |
+ppc32_getcounter(uint64 *v)
|
|
|
6e8c2f |
{
|
|
|
6e8c2f |
- register unsigned long tbu, tb, tbu2;
|
|
|
6e8c2f |
+ union { long long ll; long ii[2]; } u;
|
|
|
6e8c2f |
+ long tmp;
|
|
|
6e8c2f |
|
|
|
6e8c2f |
loop:
|
|
|
6e8c2f |
- asm volatile ("mftbu %0" : "=r" (tbu) );
|
|
|
6e8c2f |
- asm volatile ("mftb %0" : "=r" (tb) );
|
|
|
6e8c2f |
- asm volatile ("mftbu %0" : "=r" (tbu2));
|
|
|
6e8c2f |
- if (__builtin_expect(tbu != tbu2, 0)) goto loop;
|
|
|
6e8c2f |
-
|
|
|
6e8c2f |
- /* The slightly peculiar way of writing the next lines is
|
|
|
6e8c2f |
- compiled better by GCC than any other way I tried. */
|
|
|
6e8c2f |
- ((long*)(v))[0] = tbu;
|
|
|
6e8c2f |
- ((long*)(v))[1] = tb;
|
|
|
6e8c2f |
+ asm volatile ("mftbu %0" : "=r" (u.ii[0]) );
|
|
|
6e8c2f |
+ asm volatile ("mftb %0" : "=r" (u.ii[1]) );
|
|
|
6e8c2f |
+ asm volatile ("mftbu %0" : "=r" (tmp));
|
|
|
6e8c2f |
+ if (__builtin_expect(u.ii[0] != tmp, 0)) goto loop;
|
|
|
6e8c2f |
+
|
|
|
6e8c2f |
+ *v = u.ll;
|
|
|
6e8c2f |
}
|
|
|
6e8c2f |
+#endif /* powerpc 32/64 bit */
|
|
|
6e8c2f |
|
|
|
6e8c2f |
#elif defined(__i386__)
|
|
|
6e8c2f |
|