File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change 24
24
25
25
#include "opal/class/opal_pointer_array.h"
26
26
#include "opal/class/opal_hash_table.h"
27
+ #include "opal/util/clock_gettime.h"
27
28
28
29
static opal_pointer_array_t registered_sources ;
29
30
static bool mca_base_source_initialized = false;
@@ -36,29 +37,23 @@ int mca_base_source_default_source = -1;
36
37
static uint64_t mca_base_source_default_time_source (void )
37
38
{
38
39
uint64_t time_value ;
39
-
40
- #if OPAL_HAVE_CLOCK_GETTIME
41
40
struct timespec current ;
42
41
43
- clock_gettime ( CLOCK_MONOTONIC , & current );
42
+ ( void ) opal_clock_gettime ( & current );
44
43
time_value = 1000000000ul * current .tv_sec + current .tv_nsec ;
45
- #else
46
- struct timeval current ;
47
-
48
- gettimeofday (& current , NULL );
49
- time_value = 1000000ul * current .tv_sec + current .tv_usec ;
50
- #endif
51
44
52
45
return time_value ;
53
46
}
54
47
55
48
static uint64_t mca_base_source_default_time_source_ticks (void )
56
49
{
57
- #if OPAL_HAVE_CLOCK_GETTIME
58
- return 1000000000 ;
59
- #else
60
- return 1000000 ;
61
- #endif
50
+ struct timespec spec ;
51
+ if (0 == opal_clock_getres (& spec )){
52
+ return (uint64_t )(spec .tv_sec + spec .tv_nsec );
53
+ } else {
54
+ /* guess */
55
+ return 1000000 ;
56
+ }
62
57
}
63
58
64
59
/***************************************************************************************************/
You can’t perform that action at this time.
0 commit comments