X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-time.c;h=ddca2c9ebb80d732c5697fdc97f2fa6858ddcdee;hb=eeb5d4c670b18885d4f575136e348df324c46de8;hp=5cc82fccb55e082f6ecd6b198f1321eed06eda95;hpb=883a0ae745bf33b35d44bb730d5714936a2141f7;p=mono.git diff --git a/mono/utils/mono-time.c b/mono/utils/mono-time.c index 5cc82fccb55..ddca2c9ebb8 100644 --- a/mono/utils/mono-time.c +++ b/mono/utils/mono-time.c @@ -1,4 +1,5 @@ -/* +/** + * \file * Time utility functions. * Author: Paolo Molaro () * Copyright (C) 2008 Novell, Inc. @@ -142,7 +143,16 @@ gint64 mono_100ns_ticks (void) { struct timeval tv; -#ifdef CLOCK_MONOTONIC +#if defined(PLATFORM_MACOSX) + /* http://developer.apple.com/library/mac/#qa/qa1398/_index.html */ + static mach_timebase_info_data_t timebase; + guint64 now = mach_absolute_time (); + if (timebase.denom == 0) { + mach_timebase_info (&timebase); + timebase.denom *= 100; /* we return 100ns ticks */ + } + return now * timebase.numer / timebase.denom; +#elif defined(CLOCK_MONOTONIC) struct timespec tspec; static struct timespec tspec_freq = {0}; static int can_use_clock = 0; @@ -156,16 +166,6 @@ mono_100ns_ticks (void) return ((gint64)tspec.tv_sec * MTICKS_PER_SEC + tspec.tv_nsec / 100); } } - -#elif defined(PLATFORM_MACOSX) - /* http://developer.apple.com/library/mac/#qa/qa1398/_index.html */ - static mach_timebase_info_data_t timebase; - guint64 now = mach_absolute_time (); - if (timebase.denom == 0) { - mach_timebase_info (&timebase); - timebase.denom *= 100; /* we return 100ns ticks */ - } - return now * timebase.numer / timebase.denom; #endif if (gettimeofday (&tv, NULL) == 0) return ((gint64)tv.tv_sec * 1000000 + tv.tv_usec) * 10;