Use cross-platform APIs for getting time
CLOCK_THREAD_CPUTIME_ID is not defined for macOs. Bug: 117921091 Test: m libandroid_runtime on mac Change-Id: I26af05d73ecd104d3569bf286a1f56cb0e9d08ca
This commit is contained in:
@@ -29,10 +29,8 @@
|
||||
#include "jni.h"
|
||||
#include "core_jni_helpers.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <utils/SystemClock.h>
|
||||
#include <utils/Timers.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -49,11 +47,7 @@ static_assert(std::is_same<decltype(elapsedRealtimeNano()), int64_t>::value,
|
||||
*/
|
||||
static jlong android_os_SystemClock_currentThreadTimeMillis()
|
||||
{
|
||||
struct timespec tm;
|
||||
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
|
||||
|
||||
return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000;
|
||||
return nanoseconds_to_milliseconds(systemTime(SYSTEM_TIME_THREAD));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -61,11 +55,7 @@ static jlong android_os_SystemClock_currentThreadTimeMillis()
|
||||
*/
|
||||
static jlong android_os_SystemClock_currentThreadTimeMicro()
|
||||
{
|
||||
struct timespec tm;
|
||||
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
|
||||
|
||||
return tm.tv_sec * 1000000LL + tm.tv_nsec / 1000;
|
||||
return nanoseconds_to_microseconds(systemTime(SYSTEM_TIME_THREAD));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user