austern 02/11/07 15:57:05
Modified: live/gcc3/gcc Tag: pre-import-2002-10-21 timevar.c
Log:
Change timing so it uses PPC intrinsics: probably more accurate and
lower cost.
Revision Changes Path
No revision
No revision
1.10.2.1 +20 -3 src/live/gcc3/gcc/timevar.c
Index: timevar.c
===================================================================
RCS file: /cvs/Darwin/src/live/gcc3/gcc/timevar.c,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- timevar.c 2002/08/02 10:05:34 1.10
+++ timevar.c 2002/11/07 23:57:03 1.10.2.1
@@ -88,8 +88,22 @@
information). */
/* APPLE LOCAL begin Mach time */
/* On Darwin, prefer getrusage, plus Mach absolute time for the wall
- clock time. */
-#ifdef HAVE_MACH_TIME
+ clock time. Use PPC intrinsics if possible. */
+#if defined(__APPLE__) && defined(__POWERPC__) && defined(HAVE_MACH_TIME)
+# include <ppc_intrinsics.h>
+# define HAVE_WALL_TIME
+# define USE_PPC_INTRINSICS
+inline double ppc_intrinsic_time()
+{
+ unsigned long hi, lo;
+ do
+ {
+ hi = __mftbu();
+ lo = __mftb();
+ } while (hi != __mftbu());
+ return (hi * 0x100000000ull + lo) * timeBaseRatio;
+}
+#elif HAVE_MACH_TIME
# define USE_GETRUSAGE
# define USE_MACH_TIME
# define HAVE_USER_TIME
@@ -231,6 +245,9 @@
#ifdef USE_MACH_TIME
now->wall = mach_absolute_time() * timeBaseRatio;
#endif
+#ifdef USE_PPC_INTRINSICS
+ now->wall = ppc_intrinsic_time();
+#endif
/* APPLE LOCAL end Mach time */
}
}
@@ -272,7 +289,7 @@
clocks_to_msec = CLOCKS_TO_MSEC;
#endif
/* APPLE LOCAL begin Mach time */
-#ifdef USE_MACH_TIME
+#if defined(USE_MACH_TIME) || defined(USE_PPC_INTRINSICS)
mach_timebase_info(&tbase);
timeBaseRatio = ((double) tbase.numer / (double) tbase.denom) * 1e-9;
#endif