1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-22 20:44:19 +00:00

Add a timeraddspec helper function.

This commit is contained in:
Con Kolivas 2013-08-18 00:38:29 +10:00
parent 1bcd9a43b1
commit 99cbf09dd1
2 changed files with 11 additions and 0 deletions

10
util.c
View File

@ -914,6 +914,16 @@ void us_to_timespec(struct timespec *spec, int64_t us)
spec->tv_nsec = (us - (spec->tv_sec * 1000000)) * 1000; spec->tv_nsec = (us - (spec->tv_sec * 1000000)) * 1000;
} }
void timeraddspec(struct timespec *a, const struct timespec *b)
{
a->tv_sec += b->tv_sec;
a->tv_nsec += b->tv_nsec;
if (a->tv_nsec >+ 1000000000) {
a->tv_nsec -= 1000000000;
a->tv_sec++;
}
}
/* 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

@ -82,6 +82,7 @@ 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); void us_to_timeval(struct timeval *val, int64_t us);
void us_to_timespec(struct timespec *spec, int64_t us); void us_to_timespec(struct timespec *spec, int64_t us);
void timeraddspec(struct timespec *a, const struct timespec *b);
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);