mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 12:34:27 +00:00
Add helper functions to convert timespec to timeval and vice versa.
This commit is contained in:
parent
1bb6dd406a
commit
a6b1c31742
12
util.c
12
util.c
@ -890,6 +890,18 @@ void copy_time(struct timeval *dest, const struct timeval *src)
|
||||
memcpy(dest, src, sizeof(struct timeval));
|
||||
}
|
||||
|
||||
void timespec_to_val(struct timeval *val, const struct timespec *spec)
|
||||
{
|
||||
val->tv_sec = spec->tv_sec;
|
||||
val->tv_usec = spec->tv_nsec / 1000;
|
||||
}
|
||||
|
||||
void timeval_to_spec(struct timespec *spec, const struct timeval *val)
|
||||
{
|
||||
spec->tv_sec = val->tv_sec;
|
||||
spec->tv_nsec = val->tv_usec * 1000;
|
||||
}
|
||||
|
||||
/* Returns the microseconds difference between end and start times as a double */
|
||||
double us_tdiff(struct timeval *end, struct timeval *start)
|
||||
{
|
||||
|
2
util.h
2
util.h
@ -78,6 +78,8 @@ void addtime(struct timeval *a, struct timeval *b);
|
||||
bool time_more(struct timeval *a, struct timeval *b);
|
||||
bool time_less(struct timeval *a, struct timeval *b);
|
||||
void copy_time(struct timeval *dest, const struct timeval *src);
|
||||
void timespec_to_val(struct timeval *val, const struct timespec *spec);
|
||||
void timeval_to_spec(struct timespec *spec, const struct timeval *val);
|
||||
double us_tdiff(struct timeval *end, struct timeval *start);
|
||||
double tdiff(struct timeval *end, struct timeval *start);
|
||||
bool stratum_send(struct pool *pool, char *s, ssize_t len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user