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