1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-02-02 01:44:23 +00:00

Provide a us_to_timeval helper function.

This commit is contained in:
Con Kolivas 2013-08-18 00:27:33 +10:00
parent 53beae814d
commit 2278204ddd
2 changed files with 7 additions and 0 deletions

6
util.c
View File

@ -902,6 +902,12 @@ void timeval_to_spec(struct timespec *spec, const struct timeval *val)
spec->tv_nsec = val->tv_usec * 1000; spec->tv_nsec = val->tv_usec * 1000;
} }
void us_to_timeval(struct timeval *val, int64_t us)
{
val->tv_sec = us / 1000000;
val->tv_usec = us - (val->tv_sec * 1000000);
}
/* Returns the microseconds difference between end and start times as a double */ /* Returns the microseconds difference between end and start times as a double */
double us_tdiff(struct timeval *end, struct timeval *start) double us_tdiff(struct timeval *end, struct timeval *start)
{ {

1
util.h
View File

@ -80,6 +80,7 @@ bool time_less(struct timeval *a, struct timeval *b);
void copy_time(struct timeval *dest, const struct timeval *src); void copy_time(struct timeval *dest, const struct timeval *src);
void timespec_to_val(struct timeval *val, const struct timespec *spec); void timespec_to_val(struct timeval *val, const struct timespec *spec);
void timeval_to_spec(struct timespec *spec, const struct timeval *val); void timeval_to_spec(struct timespec *spec, const struct timeval *val);
void us_to_timeval(struct timeval *val, int64_t us);
double us_tdiff(struct timeval *end, struct timeval *start); double us_tdiff(struct timeval *end, struct timeval *start);
double 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); bool stratum_send(struct pool *pool, char *s, ssize_t len);