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$
@@ -153,8 +153,8 @@ int opal_timer_linux_open(void)
153153{
154154 int ret = OPAL_SUCCESS ;
155155
156- if (mca_timer_base_monotonic ) {
157- #if OPAL_HAVE_CLOCK_GETTIME
156+ if (mca_timer_base_monotonic && ! opal_sys_timer_is_monotonic () ) {
157+ #if OPAL_HAVE_CLOCK_GETTIME && ( 0 == OPAL_TIMER_MONOTONIC )
158158 struct timespec res ;
159159 if ( 0 == clock_getres (CLOCK_MONOTONIC , & res )) {
160160 opal_timer_linux_freq = 1.e9 ;
@@ -163,11 +163,9 @@ int opal_timer_linux_open(void)
163163 return ret ;
164164 }
165165#else
166- #if (0 == OPAL_TIMER_MONOTONIC )
167166 /* Monotonic time requested but cannot be found. Complain! */
168- opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , 1 );
169- #endif /* (0 == OPAL_TIMER_MONOTONIC) */
170- #endif
167+ opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , true);
168+ #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
171169 }
172170 ret = opal_timer_linux_find_freq ();
173171 opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer ;
@@ -178,22 +176,20 @@ int opal_timer_linux_open(void)
178176#if OPAL_HAVE_CLOCK_GETTIME
179177opal_timer_t opal_timer_base_get_usec_clock_gettime (void )
180178{
181- struct timespec tp ;
179+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
182180
183- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
184- return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
185- }
186- return 0 ;
181+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
182+
183+ return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
187184}
188185
189186opal_timer_t opal_timer_base_get_cycles_clock_gettime (void )
190187{
191- struct timespec tp ;
188+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
192189
193- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
194- return (tp .tv_sec * 1e9 + tp .tv_nsec );
195- }
196- return 0 ;
190+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
191+
192+ return (tp .tv_sec * 1e9 + tp .tv_nsec );
197193}
198194#endif /* OPAL_HAVE_CLOCK_GETTIME */
199195
0 commit comments