1212 * All rights reserved.
1313 * Copyright (c) 2015 Research Organization for Information Science
1414 * and Technology (RIST). All rights reserved.
15- * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
15+ * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
1616 * reserved.
1717 * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
1818 * $COPYRIGHT$
@@ -155,8 +155,8 @@ int opal_timer_linux_open(void)
155155{
156156 int ret = OPAL_SUCCESS ;
157157
158- if (mca_timer_base_monotonic ) {
159- #if OPAL_HAVE_CLOCK_GETTIME
158+ if (mca_timer_base_monotonic && ! opal_sys_timer_is_monotonic () ) {
159+ #if OPAL_HAVE_CLOCK_GETTIME && ( 0 == OPAL_TIMER_MONOTONIC )
160160 struct timespec res ;
161161 if ( 0 == clock_getres (CLOCK_MONOTONIC , & res )) {
162162 opal_timer_linux_freq = 1.e9 ;
@@ -165,11 +165,9 @@ int opal_timer_linux_open(void)
165165 return ret ;
166166 }
167167#else
168- #if (0 == OPAL_TIMER_MONOTONIC )
169168 /* Monotonic time requested but cannot be found. Complain! */
170- opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , 1 );
171- #endif /* (0 == OPAL_TIMER_MONOTONIC) */
172- #endif
169+ opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , true);
170+ #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
173171 }
174172 ret = opal_timer_linux_find_freq ();
175173 opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer ;
@@ -180,22 +178,20 @@ int opal_timer_linux_open(void)
180178#if OPAL_HAVE_CLOCK_GETTIME
181179opal_timer_t opal_timer_base_get_usec_clock_gettime (void )
182180{
183- struct timespec tp ;
181+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
184182
185- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
186- return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
187- }
188- return 0 ;
183+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
184+
185+ return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
189186}
190187
191188opal_timer_t opal_timer_base_get_cycles_clock_gettime (void )
192189{
193- struct timespec tp ;
190+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
194191
195- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
196- return (tp .tv_sec * 1e9 + tp .tv_nsec );
197- }
198- return 0 ;
192+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
193+
194+ return (tp .tv_sec * 1e9 + tp .tv_nsec );
199195}
200196#endif /* OPAL_HAVE_CLOCK_GETTIME */
201197
0 commit comments