33 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
44 * University Research and Technology
55 * Corporation. All rights reserved.
6- * Copyright (c) 2004-2014 The University of Tennessee and The University
6+ * Copyright (c) 2004-2016 The University of Tennessee and The University
77 * of Tennessee Research Foundation. All rights
88 * reserved.
99 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
3131#include "opal/mca/timer/base/base.h"
3232#include "opal/mca/timer/linux/timer_linux.h"
3333#include "opal/constants.h"
34+ #include "opal/util/show_help.h"
3435
3536static opal_timer_t opal_timer_base_get_cycles_sys_timer (void );
3637static opal_timer_t opal_timer_base_get_usec_sys_timer (void );
3738
38- #if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES )
39+ /**
40+ * Define some sane defaults until we call the _init function.
41+ */
42+ #if OPAL_HAVE_CLOCK_GETTIME
3943static opal_timer_t opal_timer_base_get_cycles_clock_gettime (void );
4044static opal_timer_t opal_timer_base_get_usec_clock_gettime (void );
4145opal_timer_t (* opal_timer_base_get_cycles )(void ) = opal_timer_base_get_cycles_clock_gettime ;
4246opal_timer_t (* opal_timer_base_get_usec )(void ) = opal_timer_base_get_usec_clock_gettime ;
4347#else
4448opal_timer_t (* opal_timer_base_get_cycles )(void ) = opal_timer_base_get_cycles_sys_timer ;
4549opal_timer_t (* opal_timer_base_get_usec )(void ) = opal_timer_base_get_usec_sys_timer ;
46- #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
50+ #endif /* OPAL_HAVE_CLOCK_GETTIME */
4751
4852opal_timer_t opal_timer_linux_freq = {0 };
4953
@@ -159,7 +163,7 @@ int opal_timer_linux_open(void)
159163 int ret = OPAL_SUCCESS ;
160164
161165 if (mca_timer_base_monotonic ) {
162- #if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES )
166+ #if OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC )
163167 struct timespec res ;
164168 if ( 0 == clock_getres (CLOCK_MONOTONIC , & res )) {
165169 opal_timer_linux_freq = 1.e9 ;
@@ -170,17 +174,17 @@ int opal_timer_linux_open(void)
170174#else
171175#if (0 == OPAL_TIMER_MONOTONIC )
172176 /* Monotonic time requested but cannot be found. Complain! */
173- opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , 1 );
177+ opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , true );
174178#endif /* (0 == OPAL_TIMER_MONOTONIC) */
175- #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES ) */
179+ #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC ) */
176180 }
177181 ret = opal_timer_linux_find_freq ();
178182 opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer ;
179183 opal_timer_base_get_usec = opal_timer_base_get_usec_sys_timer ;
180184 return ret ;
181185}
182186
183- #if OPAL_HAVE_CLOCK_GETTIME && ( 0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES )
187+ #if OPAL_HAVE_CLOCK_GETTIME
184188opal_timer_t opal_timer_base_get_usec_clock_gettime (void )
185189{
186190 struct timespec tp ;
@@ -200,7 +204,7 @@ opal_timer_t opal_timer_base_get_cycles_clock_gettime(void)
200204 }
201205 return 0 ;
202206}
203- #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_HAVE_SYS_TIMER_GET_CYCLES) */
207+ #endif /* OPAL_HAVE_CLOCK_GETTIME */
204208
205209opal_timer_t opal_timer_base_get_cycles_sys_timer (void )
206210{
0 commit comments