mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-10 12:41:02 +00:00
cgtimer_sub is now the same since cgtimer_t should be the same on all platforms.
This commit is contained in:
parent
ab917082fc
commit
ec881c41a4
32
util.c
32
util.c
@ -880,6 +880,17 @@ static int timespec_to_ms(struct timespec *ts)
|
|||||||
return ts->tv_sec * 1000 + ts->tv_nsec / 1000000;
|
return ts->tv_sec * 1000 + ts->tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* These are cgminer specific sleep functions that use an absolute nanosecond
|
/* These are cgminer specific sleep functions that use an absolute nanosecond
|
||||||
* resolution timer to avoid poor usleep accuracy and overruns. */
|
* resolution timer to avoid poor usleep accuracy and overruns. */
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -923,17 +934,6 @@ 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--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is a cgminer gettimeofday wrapper. Since we always call gettimeofday
|
/* This is a cgminer gettimeofday wrapper. Since we always call gettimeofday
|
||||||
* with tz set to NULL, and windows' default resolution is only 15ms, this
|
* with tz set to NULL, and windows' default resolution is only 15ms, this
|
||||||
* gives us higher resolution times on windows. */
|
* gives us higher resolution times on windows. */
|
||||||
@ -1021,16 +1021,6 @@ int cgtimer_to_ms(cgtimer_t *cgt)
|
|||||||
{
|
{
|
||||||
return timespec_to_ms(cgt);
|
return timespec_to_ms(cgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
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--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void cgsleep_ms(int ms)
|
void cgsleep_ms(int ms)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user