/** * Returns the current timestamp with microsecond precision via a system call to {@code * gettimeofday}, through JNR C library. * * @return the current timestamp with microsecond precision. * @throws UnsupportedOperationException if JNR C library is not loaded or {@code gettimeofday} is * not available. * @throws IllegalStateException if the call to {@code gettimeofday} did not complete with return * code 0. */ public static long currentTimeMicros() { if (!isGettimeofdayAvailable()) throw new UnsupportedOperationException( "JNR C library not loaded or gettimeofday not available"); LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) throw new IllegalStateException("Call to gettimeofday failed with result " + res); return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
/** * Returns the current timestamp with microsecond precision * via a system call to {@code gettimeofday}, through JNR C library. * * @return the current timestamp with microsecond precision. * @throws UnsupportedOperationException if JNR C library is not loaded or {@code gettimeofday} is not available. * @throws IllegalStateException if the call to {@code gettimeofday} did not complete with return code 0. */ public static long currentTimeMicros() { if (!isGettimeofdayAvailable()) throw new UnsupportedOperationException("JNR C library not loaded or gettimeofday not available"); LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) throw new IllegalStateException("Call to gettimeofday failed with result " + res); return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
/** * Returns the current timestamp with microsecond precision * via a system call to {@code gettimeofday}, through JNR C library. * * @return the current timestamp with microsecond precision. * @throws UnsupportedOperationException if JNR C library is not loaded or {@code gettimeofday} is not available. * @throws IllegalStateException if the call to {@code gettimeofday} did not complete with return code 0. */ public static long currentTimeMicros() { if (!isGettimeofdayAvailable()) throw new UnsupportedOperationException("JNR C library not loaded or gettimeofday not available"); LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) throw new IllegalStateException("Call to gettimeofday failed with result " + res); return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
/** * The current time in microseconds, as returned by libc.gettimeofday(); can only be used if * {@link #isCurrentTimeMicrosAvailable()} is true. */ public static long currentTimeMicros() { if (!isCurrentTimeMicrosAvailable()) { throw new IllegalStateException( "Native call not available. " + "Check isCurrentTimeMicrosAvailable() before calling this method."); } LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) { throw new IllegalStateException("Call to libc.gettimeofday() failed with result " + res); } return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
/** * Returns the current timestamp with microsecond precision * via a system call to {@code gettimeofday}, through JNR C library. * * @return the current timestamp with microsecond precision. * @throws UnsupportedOperationException if JNR C library is not loaded or {@code gettimeofday} is not available. * @throws IllegalStateException if the call to {@code gettimeofday} did not complete with return code 0. */ public static long currentTimeMicros() { if (!isGettimeofdayAvailable()) throw new UnsupportedOperationException("JNR C library not loaded or gettimeofday not available"); LibCLoader.Timeval tv = new LibCLoader.Timeval(LibCLoader.LIB_C_RUNTIME); int res = LibCLoader.LIB_C.gettimeofday(tv, null); if (res != 0) throw new IllegalStateException("Call to gettimeofday failed with result " + res); return tv.tv_sec.get() * 1000000 + tv.tv_usec.get(); }
@Override public long currentTimeMicros() { final Timeval timeval = new Timeval(this.runtime); this.libc.gettimeofday(timeval, null); return timeval.tv_sec.get() * MILLION + timeval.tv_usec.get(); }
protected Timespec(jnr.ffi.Runtime runtime) { super(runtime); tv_sec = new time_t(); if(!Platform.IS_WINDOWS) { tv_nsec = new SignedLong(); } else { tv_nsec = new Signed64(); } }
protected Timespec(jnr.ffi.Runtime runtime) { super(runtime); tv_sec = new time_t(); if(!Platform.IS_WINDOWS) { tv_nsec = new SignedLong(); } else { tv_nsec = new Signed64(); } }