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 (c) 2016 Broadcom Limited. All rights reserved.
@@ -158,8 +158,8 @@ int opal_timer_linux_open(void)
158158{
159159 int ret = OPAL_SUCCESS ;
160160
161- if (mca_timer_base_monotonic ) {
162- #if OPAL_HAVE_CLOCK_GETTIME
161+ if (mca_timer_base_monotonic && ! opal_sys_timer_is_monotonic () ) {
162+ #if OPAL_HAVE_CLOCK_GETTIME && ( 0 == OPAL_TIMER_MONOTONIC )
163163 struct timespec res ;
164164 if ( 0 == clock_getres (CLOCK_MONOTONIC , & res )) {
165165 opal_timer_linux_freq = 1.e9 ;
@@ -168,11 +168,9 @@ int opal_timer_linux_open(void)
168168 return ret ;
169169 }
170170#else
171- #if (0 == OPAL_TIMER_MONOTONIC )
172171 /* Monotonic time requested but cannot be found. Complain! */
173- opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , 1 );
174- #endif /* (0 == OPAL_TIMER_MONOTONIC) */
175- #endif
172+ opal_show_help ("help-opal-timer-linux.txt" , "monotonic not supported" , true);
173+ #endif /* OPAL_HAVE_CLOCK_GETTIME && (0 == OPAL_TIMER_MONOTONIC) */
176174 }
177175 ret = opal_timer_linux_find_freq ();
178176 opal_timer_base_get_cycles = opal_timer_base_get_cycles_sys_timer ;
@@ -183,22 +181,20 @@ int opal_timer_linux_open(void)
183181#if OPAL_HAVE_CLOCK_GETTIME
184182opal_timer_t opal_timer_base_get_usec_clock_gettime (void )
185183{
186- struct timespec tp ;
184+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
187185
188- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
189- return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
190- }
191- return 0 ;
186+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
187+
188+ return (tp .tv_sec * 1e6 + tp .tv_nsec /1000 );
192189}
193190
194191opal_timer_t opal_timer_base_get_cycles_clock_gettime (void )
195192{
196- struct timespec tp ;
193+ struct timespec tp = {. tv_sec = 0 , . tv_nsec = 0 } ;
197194
198- if ( 0 == clock_gettime (CLOCK_MONOTONIC , & tp ) ) {
199- return (tp .tv_sec * 1e9 + tp .tv_nsec );
200- }
201- return 0 ;
195+ (void ) clock_gettime (CLOCK_MONOTONIC , & tp );
196+
197+ return (tp .tv_sec * 1e9 + tp .tv_nsec );
202198}
203199#endif /* OPAL_HAVE_CLOCK_GETTIME */
204200
0 commit comments