#At file:///home/malff/BZR-TREE/mysql-6.0-perf/ based on revid:marc.alff@stripped
2844 Marc Alff 2009-03-31
Bug#44000 Nanoseconds on OS X
Implemented the missing nanoseconds timer on Mac OS X.
modified:
include/my_rdtsc.h
mysys/my_rdtsc.c
=== modified file 'include/my_rdtsc.h'
--- a/include/my_rdtsc.h 2009-03-10 18:43:35 +0000
+++ b/include/my_rdtsc.h 2009-03-31 22:32:32 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
+/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -141,6 +141,7 @@ C_MODE_END
#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386 22
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64 23
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32 24
+#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME 25
#endif
=== modified file 'mysys/my_rdtsc.c'
--- a/mysys/my_rdtsc.c 2009-02-28 01:58:30 +0000
+++ b/mysys/my_rdtsc.c 2009-03-31 22:32:32 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Sun Microsystems, Inc
+/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -94,6 +94,10 @@
#include <ia64intrin.h> /* for __GetReg */
#endif
+#if defined(__APPLE__) && defined(__MACH__)
+#include <mach/mach_time.h>
+#endif
+
#if defined(__SUNPRO_CC) && defined(__sparcv9) && defined(_LP64) && !defined(__SunOS_5_7)
extern "C" ulonglong my_timer_cycles_il_sparc64();
#elif defined(__SUNPRO_CC) && defined(__sparcv8plus) && defined(_ILP32) && !defined(__SunOS_5_7)
@@ -254,6 +258,15 @@ ulonglong my_timer_nanoseconds(void)
NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm);
return (ulonglong) tm;
}
+#elif defined(__APPLE__) && defined(__MACH__)
+ {
+ ulonglong tm;
+ static mach_timebase_info_data_t timebase_info= {0,0};
+ if (timebase_info.denom == 0)
+ (void) mach_timebase_info(&timebase_info);
+ tm= mach_absolute_time();
+ return (tm * timebase_info.numer) / timebase_info.denom;
+ }
#else
return 0;
#endif
@@ -552,6 +565,8 @@ void my_timer_init(MY_TIMER_INFO *mti)
mti->nanoseconds_routine= MY_TIMER_ROUTINE_GETHRTIME;
#elif defined(__NETWARE__)
mti->nanoseconds_routine= MY_TIMER_ROUTINE_NXGETTIME;
+#elif defined(__APPLE__) && defined(__MACH__)
+ mti->nanoseconds_routine= MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME;
#else
mti->nanoseconds_routine= 0;
#endif
| Thread |
|---|
| • bzr commit into mysql-6.0-perf branch (marc.alff:2844) Bug#44000 | Marc Alff | 1 Apr |