< prev index next >

src/share/vm/prims/jvm.cpp

Print this page




 287 JVM_END
 288 
 289 
 290 // java.lang.System //////////////////////////////////////////////////////////////////////
 291 
 292 
 293 JVM_LEAF(jlong, JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored))
 294   JVMWrapper("JVM_CurrentTimeMillis");
 295   return os::javaTimeMillis();
 296 JVM_END
 297 
 298 JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored))
 299   JVMWrapper("JVM_NanoTime");
 300   return os::javaTimeNanos();
 301 JVM_END
 302 
 303 // The function below is actually exposed by sun.misc.VM and not
 304 // java.lang.System, but we choose to keep it here so that it stays next
 305 // to JVM_CurrentTimeMillis and JVM_NanoTime
 306 
 307 const jlong MAX_DIFF_SECS = 0x0100000000;   //  2^32
 308 const jlong MIN_DIFF_SECS = -MAX_DIFF_SECS; // -2^32
 309 
 310 JVM_LEAF(jlong, JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs))
 311   JVMWrapper("JVM_GetNanoTimeAdjustment");
 312   jlong seconds;
 313   jlong nanos;
 314 
 315   os::javaTimeSystemUTC(seconds, nanos);
 316 
 317   // We're going to verify that the result can fit in a long.
 318   // For that we need the difference in seconds between 'seconds'
 319   // and 'offset_secs' to be such that:
 320   //     |seconds - offset_secs| < (2^63/10^9)
 321   // We're going to approximate 10^9 ~< 2^30 (1000^3 ~< 1024^3)
 322   // which makes |seconds - offset_secs| < 2^33
 323   // and we will prefer +/- 2^32 as the maximum acceptable diff
 324   // as 2^32 has a more natural feel than 2^33...
 325   //
 326   // So if |seconds - offset_secs| >= 2^32 - we return a special
 327   // sentinel value (-1) which the caller should take as an




 287 JVM_END
 288 
 289 
 290 // java.lang.System //////////////////////////////////////////////////////////////////////
 291 
 292 
 293 JVM_LEAF(jlong, JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored))
 294   JVMWrapper("JVM_CurrentTimeMillis");
 295   return os::javaTimeMillis();
 296 JVM_END
 297 
 298 JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored))
 299   JVMWrapper("JVM_NanoTime");
 300   return os::javaTimeNanos();
 301 JVM_END
 302 
 303 // The function below is actually exposed by sun.misc.VM and not
 304 // java.lang.System, but we choose to keep it here so that it stays next
 305 // to JVM_CurrentTimeMillis and JVM_NanoTime
 306 
 307 const jlong MAX_DIFF_SECS = 0x0100000000LL; //  2^32
 308 const jlong MIN_DIFF_SECS = -MAX_DIFF_SECS; // -2^32
 309 
 310 JVM_LEAF(jlong, JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs))
 311   JVMWrapper("JVM_GetNanoTimeAdjustment");
 312   jlong seconds;
 313   jlong nanos;
 314 
 315   os::javaTimeSystemUTC(seconds, nanos);
 316 
 317   // We're going to verify that the result can fit in a long.
 318   // For that we need the difference in seconds between 'seconds'
 319   // and 'offset_secs' to be such that:
 320   //     |seconds - offset_secs| < (2^63/10^9)
 321   // We're going to approximate 10^9 ~< 2^30 (1000^3 ~< 1024^3)
 322   // which makes |seconds - offset_secs| < 2^33
 323   // and we will prefer +/- 2^32 as the maximum acceptable diff
 324   // as 2^32 has a more natural feel than 2^33...
 325   //
 326   // So if |seconds - offset_secs| >= 2^32 - we return a special
 327   // sentinel value (-1) which the caller should take as an


< prev index next >