aboutsummaryrefslogtreecommitdiffstats
path: root/os/common/ports/SIMIA32/chcore.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/common/ports/SIMIA32/chcore.c')
-rw-r--r--os/common/ports/SIMIA32/chcore.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/os/common/ports/SIMIA32/chcore.c b/os/common/ports/SIMIA32/chcore.c
index 73e91fa0a..83a1574a9 100644
--- a/os/common/ports/SIMIA32/chcore.c
+++ b/os/common/ports/SIMIA32/chcore.c
@@ -25,7 +25,11 @@
* @{
*/
+#if defined(WIN32)
#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
#include "ch.h"
@@ -110,11 +114,18 @@ void _port_thread_start(msg_t (*pf)(void *), void *p) {
* @return The realtime counter value.
*/
rtcnt_t port_rt_get_counter_value(void) {
+#if defined(WIN32)
LARGE_INTEGER n;
QueryPerformanceCounter(&n);
return (rtcnt_t)(n.QuadPart / 1000LL);
+#else
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return ((rtcnt_t)tv.tv_sec * (rtcnt_t)1000000) + (rtcnt_t)tv.tv_usec;
+#endif
}
/** @} */