diff options
Diffstat (limited to 'src/libnetdata/clocks/clocks.h')
-rw-r--r-- | src/libnetdata/clocks/clocks.h | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/libnetdata/clocks/clocks.h b/src/libnetdata/clocks/clocks.h index f989fd6b8..03860d66d 100644 --- a/src/libnetdata/clocks/clocks.h +++ b/src/libnetdata/clocks/clocks.h @@ -4,6 +4,7 @@ #define NETDATA_CLOCKS_H 1 #include "../libnetdata.h" +#include "libnetdata/os/random.h" #ifndef HAVE_CLOCK_GETTIME struct timespec { @@ -18,12 +19,19 @@ struct timespec { typedef uint64_t nsec_t; typedef uint64_t msec_t; typedef uint64_t usec_t; + +typedef int64_t snsec_t; typedef int64_t susec_t; +typedef int64_t smsec_t; + +typedef int64_t stime_t; typedef struct heartbeat { + usec_t step; usec_t realtime; usec_t randomness; size_t statistics_id; + XXH64_hash_t hash; } heartbeat_t; /* Linux value is as good as any other */ @@ -72,6 +80,8 @@ typedef struct heartbeat { #define MSEC_PER_SEC 1000ULL #endif +#define NS100_PER_MS 10000ULL + #define USEC_PER_MS 1000ULL #ifndef HAVE_CLOCK_GETTIME @@ -132,26 +142,24 @@ msec_t timeval_msec(struct timeval *tv); usec_t dt_usec(struct timeval *now, struct timeval *old); susec_t dt_usec_signed(struct timeval *now, struct timeval *old); -void heartbeat_init(heartbeat_t *hb); +void heartbeat_init(heartbeat_t *hb, usec_t step); /* Sleeps until next multiple of tick using monotonic clock. * Returns elapsed time in microseconds since previous heartbeat */ -usec_t heartbeat_next(heartbeat_t *hb, usec_t tick); +usec_t heartbeat_next(heartbeat_t *hb); void heartbeat_statistics(usec_t *min_ptr, usec_t *max_ptr, usec_t *average_ptr, size_t *count_ptr); void sleep_usec_with_now(usec_t usec, usec_t started_ut); #define sleep_usec(usec) sleep_usec_with_now(usec, 0) -void clocks_init(void); - // lower level functions - avoid using directly time_t now_sec(clockid_t clk_id); usec_t now_usec(clockid_t clk_id); int now_timeval(clockid_t clk_id, struct timeval *tv); -collected_number uptime_msec(char *filename); +collected_number uptime_msec(const char *filename); extern usec_t clock_monotonic_resolution; extern usec_t clock_realtime_resolution; |