summaryrefslogtreecommitdiffstats
path: root/src/native
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-15 06:09:02 +0200
committerSven Gothel <[email protected]>2013-08-15 06:09:02 +0200
commit77687335f7fae3727c902c678b9525e6f4631da1 (patch)
treeff12b83bc96597acc07fef71ce236a5da594bc30 /src/native
parent0fa150687e97bb6768ccd7755cd69af9d30b2f1c (diff)
Platform: Add accurate currentTimeMillis() and currentTimeMicros() native methods, based on 'gettimeofday(..)'
Diffstat (limited to 'src/native')
-rw-r--r--src/native/common/Platforms.c25
1 files changed, 25 insertions, 0 deletions
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;
+}
+