2023-07-25 14:26:29 +02:00
|
|
|
#include <time.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
#include "generated_headers/android_os_SystemClock.h"
|
|
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_android_os_SystemClock_elapsedRealtime(JNIEnv *env, jclass this)
|
|
|
|
|
{
|
2023-10-08 15:30:18 +02:00
|
|
|
struct timespec t;
|
|
|
|
|
clock_gettime(CLOCK_BOOTTIME, &t);
|
|
|
|
|
jlong ret = t.tv_sec * 1000 + lround(t.tv_nsec / 1e6);
|
2024-02-22 14:25:29 +01:00
|
|
|
return ret;
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
2023-07-25 14:26:29 +02:00
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_android_os_SystemClock_uptimeMillis(JNIEnv *env, jclass this)
|
|
|
|
|
{
|
2024-02-22 14:25:29 +01:00
|
|
|
struct timespec now;
|
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
|
|
|
|
return now.tv_sec * 1000 + lround(now.tv_nsec / 1e6);
|
2023-07-25 14:26:29 +02:00
|
|
|
}
|
2024-06-15 22:32:01 +02:00
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_android_os_SystemClock_elapsedRealtimeNanos(JNIEnv *env, jclass this)
|
|
|
|
|
{
|
|
|
|
|
struct timespec t;
|
|
|
|
|
clock_gettime(CLOCK_BOOTTIME, &t);
|
|
|
|
|
return t.tv_sec * 1000000000 + t.tv_nsec;
|
|
|
|
|
}
|