#ifndef _TIMETOOLS_H_
#define _TIMETOOLS_H_
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
int time_get_monotonic(struct timespec *ts);
int time_get_realtime(struct timespec *ts);
int time_timespec_diff(const struct timespec *start,
const struct timespec *end,
struct timespec *diff);
int time_timespec_diff_in_range(const struct timespec *t1,
const struct timespec *t2,
uint64_t range_us,
uint64_t *diff_us);
int time_timespec_to_ns(const struct timespec *value, uint64_t *ns);
int time_timespec_to_us(const struct timespec *value, uint64_t *us);
int time_timespec_to_ms(const struct timespec *value, uint64_t *ms);
int time_ms_to_timespec(const uint64_t *value, struct timespec *ts);
int time_us_to_timespec(const uint64_t *value, struct timespec *ts);
int time_ns_to_timespec(const uint64_t *value, struct timespec *ts);
int time_timespec_diff_now(const struct timespec *value, struct timespec *diff);
int time_timespec_cmp(const struct timespec *t1, const struct timespec *t2);
int time_timespec_add_us(const struct timespec *ts, int64_t delta,
struct timespec *res);
int time_timespec_add_ns(const struct timespec *ts, int64_t delta,
struct timespec *res);
int time_timeval_to_timespec(const struct timeval *tv, struct timespec *ts);
int time_timeval_to_ms(const struct timeval *value, uint32_t *ms);
int time_monotonic_to_realtime_ms(uint64_t mt_ms, uint64_t *rt_ms);
int time_msleep(uint32_t ms);
#ifdef __cplusplus
}
#endif
#endif