am 2657717f: Merge "We have POSIX clocks."

* commit '2657717f97e0de689aa3d8cae75bb0053607839d':
  We have POSIX clocks.
This commit is contained in:
Elliott Hughes
2014-11-25 23:23:45 +00:00
committed by Android Git Automerger

View File

@@ -60,18 +60,11 @@ static jlong android_os_SystemClock_elapsedRealtime(JNIEnv* env,
static jlong android_os_SystemClock_currentThreadTimeMillis(JNIEnv* env, static jlong android_os_SystemClock_currentThreadTimeMillis(JNIEnv* env,
jobject clazz) jobject clazz)
{ {
#if defined(HAVE_POSIX_CLOCKS)
struct timespec tm; struct timespec tm;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000; return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000LL + tv.tv_usec / 1000;
#endif
} }
/* /*
@@ -80,18 +73,11 @@ static jlong android_os_SystemClock_currentThreadTimeMillis(JNIEnv* env,
static jlong android_os_SystemClock_currentThreadTimeMicro(JNIEnv* env, static jlong android_os_SystemClock_currentThreadTimeMicro(JNIEnv* env,
jobject clazz) jobject clazz)
{ {
#if defined(HAVE_POSIX_CLOCKS)
struct timespec tm; struct timespec tm;
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm);
return tm.tv_sec * 1000000LL + tm.tv_nsec / 1000; return tm.tv_sec * 1000000LL + tm.tv_nsec / 1000;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000LL + tv.tv_nsec / 1000;
#endif
} }
/* /*