PISystemTime toTimespec and PIConditionVariable fix
This commit is contained in:
@@ -212,6 +212,13 @@ PIDateTime PIDateTime::current() {
|
||||
}
|
||||
|
||||
|
||||
void PISystemTime::toTimespec(void * ts) {
|
||||
#ifndef WINDOWS
|
||||
t_cur->tv_sec = seconds;
|
||||
t_cur->tv_nsec = nanoseconds;
|
||||
#endif
|
||||
}
|
||||
|
||||
PISystemTime PISystemTime::abs() const {
|
||||
if (seconds < 0)
|
||||
return PISystemTime(piAbsl(seconds) - 1, 1000000000l - piAbsl(nanoseconds));
|
||||
@@ -255,12 +262,12 @@ PISystemTime PISystemTime::current(bool precise_but_not_system) {
|
||||
timeval tv;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
gettimeofday(&tv, NULL);
|
||||
gettimeofday(&tv, NULL);
|
||||
t_cur.tv_sec = tv.tv_sec;
|
||||
t_cur.tv_nsec = tv.tv_usec * 1000;
|
||||
# else
|
||||
timespec t_cur;
|
||||
clock_gettime(0, &t_cur);
|
||||
clock_gettime(precise_but_not_system ? CLOCK_MONOTONIC : 0, &t_cur);
|
||||
# endif
|
||||
# endif
|
||||
return PISystemTime(t_cur.tv_sec, t_cur.tv_nsec);
|
||||
|
||||
Reference in New Issue
Block a user