summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2014-11-29 19:45:06 (GMT)
committer Chris Young <chris@unsatisfactorysoftware.co.uk>2014-11-29 19:45:06 (GMT)
commitc646a6f4e596f64ab388863122fa02636db96148 (patch)
treeb2e2873b4afd589111aefdaa4a920afc2c1e19f4
parentb662aee6b4a7743ba9ea904ff307ae9d3497bc2d (diff)
downloadlibnsutils-c646a6f4e596f64ab388863122fa02636db96148.tar.gz
libnsutils-c646a6f4e596f64ab388863122fa02636db96148.tar.bz2
Add monotonic timer for AmigaOS 4.0+
-rw-r--r--src/time.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/time.c b/src/time.c
index 736c982..46a0be2 100644
--- a/src/time.c
+++ b/src/time.c
@@ -24,6 +24,8 @@
#include <mach/mach.h>
#include <mach/clock.h>
#include <mach/mach_time.h>
+#elif defined(__amigaos4__)
+#include <proto/timer.h>
#else
#include <sys/time.h>
#endif
@@ -54,6 +56,18 @@ nsuerror nsu_getmonotonic_ms(uint64_t *current_out)
mach_port_deallocate(mach_task_self(), cclock);
current = (mts.tv_sec * 1000) + (mts.tv_nsec / 1000000);
+#elif defined(__amigaos4__)
+ struct TimeVal tv;
+
+ /* NB: The calling task must already have opened timer.device
+ * and obtained the interface.
+ */
+ if (ITimer != NULL) {
+ ITimer->GetUpTime(&tv);
+ current = (tv.Seconds * 1000) + (tv.Microseconds / 1000);
+ } else {
+ current = 0; /* \todo should we be opening timer.device, or printing a warning? */
+ }
#else
#warning "Using dodgy gettimeofday() fallback"
/** \todo Implement this properly! */