use of com.oracle.svm.core.posix.headers.Time.timespec in project graal by oracle.
the class PthreadConditionUtils method deadlineTimespecToDelayNanos.
@Uninterruptible(reason = "Called from uninterruptible code.")
public static long deadlineTimespecToDelayNanos(Time.timespec deadlineTimespec) {
timespec currentTimespec = StackValue.get(SizeOf.get(timespec.class));
getAbsoluteTimeNanos(currentTimespec);
return TimeUtils.addOrMaxValue(deadlineTimespec.tv_nsec() - currentTimespec.tv_nsec(), TimeUtils.secondsToNanos((deadlineTimespec.tv_sec() - currentTimespec.tv_sec())));
}
use of com.oracle.svm.core.posix.headers.Time.timespec in project graal by oracle.
the class PthreadConditionUtils method delayNanosToDeadlineTimespec.
/**
* Turn a delay in nanoseconds into a deadline in a Time.timespec.
*/
@Uninterruptible(reason = "Called from uninterruptible code.")
public static void delayNanosToDeadlineTimespec(long delayNanos, Time.timespec result) {
timespec currentTimespec = StackValue.get(SizeOf.get(timespec.class));
getAbsoluteTimeNanos(currentTimespec);
assert delayNanos >= 0;
long sec = TimeUtils.addOrMaxValue(currentTimespec.tv_sec(), TimeUtils.divideNanosToSeconds(delayNanos));
long nsec = currentTimespec.tv_nsec() + TimeUtils.remainderNanosToSeconds(delayNanos);
if (nsec > TimeUtils.nanosPerSecond) {
sec = TimeUtils.addOrMaxValue(sec, 1);
nsec -= TimeUtils.nanosPerSecond;
}
assert nsec < TimeUtils.nanosPerSecond;
result.set_tv_sec(sec);
result.set_tv_nsec(nsec);
}
Aggregations