1
0
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:
Con Kolivas 2013-08-18 00:19:47 +10:00
parent 1bb6dd406a
commit a6b1c31742
2 changed files with 14 additions and 0 deletions

12
util.c
View File

@ -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
View File

@ -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);