8 #if defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
9 static double g_time_mult = 0.0;
11 void ABTD_time_init(
void)
13 #if defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
14 mach_timebase_info_data_t info;
15 mach_timebase_info(&info);
16 g_time_mult = 1.0e-9 * ((double)info.numer / (
double)info.denom);
21 void ABTD_time_get(ABTD_time *p_time)
23 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
24 int ret = clock_gettime(CLOCK_REALTIME, p_time);
25 ABTI_ASSERT(ret == 0);
26 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
27 *p_time = mach_absolute_time();
28 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
29 int ret = gettimeofday(p_time, NULL);
30 ABTI_ASSERT(ret == 0);
35 double ABTD_time_read_sec(ABTD_time *p_time)
39 #if defined(ABT_CONFIG_USE_CLOCK_GETTIME)
40 secs = ((double)p_time->tv_sec) + 1.0e-9 * ((double)p_time->tv_nsec);
41 #elif defined(ABT_CONFIG_USE_MACH_ABSOLUTE_TIME)
42 if (g_time_mult == 0.0)
44 secs = *p_time * g_time_mult;
45 #elif defined(ABT_CONFIG_USE_GETTIMEOFDAY)
46 secs = ((double)p_time->tv_sec) + 1.0e-6 * ((double)p_time->tv_usec);