28
static int TimeDelta (struct timespec const* x, struct timespec const* y);
28
static int TimeDelta (struct timespec const* x, struct timespec const* y)
30
return ((x->tv_sec - y->tv_sec) * 1000) + ((x->tv_nsec - y->tv_nsec) / 1000000);
33
static void SetTimeStruct(struct timespec* timer, struct timespec* sister = 0, int sister_relation = 0)
35
struct timespec current;
36
clock_gettime(CLOCK_MONOTONIC, ¤t);
40
int diff = TimeDelta(¤t, sister);
42
if (diff < sister_relation)
44
int remove = sister_relation - diff;
45
SetTimeBack(¤t, remove);
49
timer->tv_sec = current.tv_sec;
50
timer->tv_nsec = current.tv_nsec;
53
static void SetTimeBack(struct timespec* timeref, int remove)
55
timeref->tv_sec -= remove / 1000;
56
remove = remove % 1000;
58
if (remove > timeref->tv_nsec / 1000000)
61
timeref->tv_nsec += 1000000000;
63
timeref->tv_nsec -= remove * 1000000;
32
int TimeUtil::TimeDelta (struct timespec const* x, struct timespec const* y)
34
return ((x->tv_sec - y->tv_sec) * 1000) + ((x->tv_nsec - y->tv_nsec) / 1000000);