diff options
-rw-r--r-- | make/build.xml | 5 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 22 | ||||
-rw-r--r-- | src/native/common/Platforms.c | 25 |
3 files changed, 50 insertions, 2 deletions
diff --git a/make/build.xml b/make/build.xml index f1a828d..2fe2d69 100644 --- a/make/build.xml +++ b/make/build.xml @@ -457,9 +457,10 @@ <fail message="Requires '${compiler.cfg.id}'" unless="compiler.cfg.id"/> <fail message="Requires '${linker.cfg.id}'" unless="linker.cfg.id"/> - <javah destdir="${src.generated.c}" classpath="${classes}" class="jogamp.common.os.MachineDescriptionRuntime" /> - <javah destdir="${src.generated.c}" classpath="${classes}" class="jogamp.common.jvm.JVMUtil" /> + <javah destdir="${src.generated.c}" classpath="${classes}" class="com.jogamp.common.os.Platform" /> <javah destdir="${src.generated.c}" classpath="${classes}" class="com.jogamp.common.nio.PointerBuffer" /> + <javah destdir="${src.generated.c}" classpath="${classes}" class="jogamp.common.jvm.JVMUtil" /> + <javah destdir="${src.generated.c}" classpath="${classes}" class="jogamp.common.os.MachineDescriptionRuntime" /> <javah destdir="${src.generated.c}/Unix" classpath="${classes}" class="jogamp.common.os.UnixDynamicLinkerImpl" /> <javah destdir="${src.generated.c}/Windows" classpath="${classes}" class="jogamp.common.os.WindowsDynamicLinkerImpl"/> diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 9971cf4..32fc9f4 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -434,6 +434,28 @@ public class Platform extends PlatformPropsImpl { // // time / jitter // + + /** + * Returns the unix based current time in milliseconds, based on <code>gettimeofday(..)</code>. + * <p> + * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}. + * While the named {@link System} methods do provide the required precision, + * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval. + * </p> + * @see #currentTimeMicros() + */ + public static native long currentTimeMillis(); + + /** + * Returns the unix based current time in microseconds, based on <code>gettimeofday(..)</code>. + * <p> + * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}. + * While the named {@link System} methods do provide the required precision, + * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval. + * </p> + * @see #currentTimeMillis() + */ + public static native long currentTimeMicros(); /** * Returns the estimated sleep jitter value in nanoseconds. diff --git a/src/native/common/Platforms.c b/src/native/common/Platforms.c new file mode 100644 index 0000000..f48d020 --- /dev/null +++ b/src/native/common/Platforms.c @@ -0,0 +1,25 @@ + +#include <jni.h> + +#include <assert.h> + +#include <gluegen_stdint.h> + +#include "com_jogamp_common_os_Platform.h" + +#include <sys/time.h> + +JNIEXPORT jlong JNICALL +Java_com_jogamp_common_os_Platform_currentTimeMillis(JNIEnv *env, jclass _unused) { + struct timeval tv; + gettimeofday(&tv,NULL); + return (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + +JNIEXPORT jlong JNICALL +Java_com_jogamp_common_os_Platform_currentTimeMicros(JNIEnv *env, jclass _unused) { + struct timeval tv; + gettimeofday(&tv,NULL); + return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec; +} + |