mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-25 14:04:25 +00:00
Provide cgtimer_sub helper functions.
This commit is contained in:
parent
9dc63cee53
commit
903d007cb4
16
util.c
16
util.c
@ -930,6 +930,17 @@ int cgtimer_to_ms(cgtimer_t *cgt)
|
|||||||
{
|
{
|
||||||
return timespec_to_ms(cgt);
|
return timespec_to_ms(cgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Subtracts b from a and stores it in res. */
|
||||||
|
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
|
||||||
|
{
|
||||||
|
res->tv_sec = a->tv_sec - b->tv_sec;
|
||||||
|
res->tv_nsec = a->tv_nsec - b->tv_nsec;
|
||||||
|
if (res->tv_nsec < 0) {
|
||||||
|
res->tv_nsec += 1000000000;
|
||||||
|
res->tv_sec--;
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void cgtimer_time(cgtimer_t *ts_start)
|
void cgtimer_time(cgtimer_t *ts_start)
|
||||||
{
|
{
|
||||||
@ -975,6 +986,11 @@ int cgtimer_to_ms(cgtimer_t *cgt)
|
|||||||
{
|
{
|
||||||
return timeval_to_ms(cgt);
|
return timeval_to_ms(cgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res)
|
||||||
|
{
|
||||||
|
timersub(a, b, res);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void cgsleep_ms(int ms)
|
void cgsleep_ms(int ms)
|
||||||
|
1
util.h
1
util.h
@ -91,6 +91,7 @@ void cgtimer_time(cgtimer_t *ts_start);
|
|||||||
void cgsleep_ms_r(cgtimer_t *ts_start, int ms);
|
void cgsleep_ms_r(cgtimer_t *ts_start, int ms);
|
||||||
void cgsleep_us_r(cgtimer_t *ts_start, int64_t us);
|
void cgsleep_us_r(cgtimer_t *ts_start, int64_t us);
|
||||||
int cgtimer_to_ms(cgtimer_t *cgt);
|
int cgtimer_to_ms(cgtimer_t *cgt);
|
||||||
|
void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res);
|
||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user