android_device_lenovo_msm89.../libshims/bionic/bionic_time_conversions.cpp
LuK1337 ef5e484d7b land: Add libc hax for camera
* See : https://review.lineageos.org/#/c/1170/

Change-Id: I040c3023f81322140d153cb14be9578457777ac2
2017-06-27 19:27:41 +02:00

17 lines
436 B
C++

#include "private/bionic_time_conversions.h"
#define NS_PER_S 1000000000
bool timespec_from_absolute_timespec(timespec& ts, const timespec& abs_ts, clockid_t clock) {
clock_gettime(clock, &ts);
ts.tv_sec = abs_ts.tv_sec - ts.tv_sec;
ts.tv_nsec = abs_ts.tv_nsec - ts.tv_nsec;
if (ts.tv_nsec < 0) {
ts.tv_sec--;
ts.tv_nsec += NS_PER_S;
}
if (ts.tv_nsec < 0 || ts.tv_sec < 0) {
return false;
}
return true;
}