summaryrefslogtreecommitdiffstats
path: root/src/java/com
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-07 01:02:19 +0100
committerSven Gothel <[email protected]>2023-03-07 01:02:19 +0100
commit1842451b0e49ac1899ed3ab3515021a6077aff92 (patch)
treeccbd7423b0127c89b687a4fd251e461bb5841a5a /src/java/com
parentb773048aee7ebfb00b7ae7b45ef9f49e88ebc5a4 (diff)
Clock: Consider return code on failed native clock_gettime(..) call; Add Win32 clock_gettime() implementation.
Consider return code on failed native clock_gettime(..) call - Return Instant.EPOCH for all Instant variations (essentially 0) - Return 0 for all 'long' variations (ms, ns) Add Win32 clock_gettime() implementation. - Source: https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-libraries/winpthreads/src/clock.c - Public Domain within mingw-w64, included here to simplify linkage. - Tested on Win10 64bit w/ TestTextRendererNEWT00, all values are OK
Diffstat (limited to 'src/java/com')
-rw-r--r--src/java/com/jogamp/common/os/Clock.java27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/java/com/jogamp/common/os/Clock.java b/src/java/com/jogamp/common/os/Clock.java
index 03a0040..9380442 100644
--- a/src/java/com/jogamp/common/os/Clock.java
+++ b/src/java/com/jogamp/common/os/Clock.java
@@ -32,8 +32,11 @@ public class Clock {
Platform.initSingleton(); // loads native gluegen_rt library
{
final long[/*2*/] val = { 0, 0 };
- getMonotonicStartupTimeImpl(val);
- t0 = Instant.ofEpochSecond(val[0], val[1]);
+ if( getMonotonicStartupTimeImpl(val) ) {
+ t0 = Instant.ofEpochSecond(val[0], val[1]);
+ } else {
+ t0 = Instant.EPOCH;
+ }
}
}
@@ -59,10 +62,13 @@ public class Clock {
*/
public static Instant getMonotonicTime() {
final long[/*2*/] val = { 0, 0 };
- getMonotonicTimeImpl(val);
- return Instant.ofEpochSecond(val[0], val[1]);
+ if( getMonotonicTimeImpl(val) ) {
+ return Instant.ofEpochSecond(val[0], val[1]);
+ } else {
+ return Instant.EPOCH;
+ }
}
- private static native void getMonotonicTimeImpl(final long[/*2*/] val);
+ private static native boolean getMonotonicTimeImpl(final long[/*2*/] val);
/**
* Returns current wall-clock real-time since Unix Epoch `00:00:00 UTC on 1970-01-01`.
@@ -80,10 +86,13 @@ public class Clock {
*/
public static Instant getWallClockTime() {
final long[/*2*/] val = { 0, 0 };
- getWallClockTimeImpl(val);
- return Instant.ofEpochSecond(val[0], val[1]);
+ if( getWallClockTimeImpl(val) ) {
+ return Instant.ofEpochSecond(val[0], val[1]);
+ } else {
+ return Instant.EPOCH;
+ }
}
- private static native void getWallClockTimeImpl(final long[/*2*/] val);
+ private static native boolean getWallClockTimeImpl(final long[/*2*/] val);
/**
* Returns the monotonic startup time since module startup as used in {@link #currentNanos()} and {@link #getMonotonicNanos()}.
@@ -91,7 +100,7 @@ public class Clock {
* @see #getMonotonicNanos()
*/
public static Instant getMonotonicStartupTime() { return t0; }
- private static native void getMonotonicStartupTimeImpl(final long[/*2*/] val);
+ private static native boolean getMonotonicStartupTimeImpl(final long[/*2*/] val);
/**
* Returns current monotonic nanoseconds since start of this application.