From 617be89866d56ab5f70f2ac9d35c1651aa6bfca2 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Fri, 7 Nov 2014 12:15:07 +0800 Subject: [PATCH] AcessNative - Add _SysTimestamp (based off gettimeofday) --- AcessNative/ld-acess_src/exports.c | 5 +---- AcessNative/ld-acess_src/exports.h | 2 ++ AcessNative/ld-acess_src/syscalls.c | 8 ++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index 62451ece..8064bb8b 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -254,10 +254,7 @@ int acess__SysLoadModule(const char *Path) // --- Timekeeping --- int64_t acess__SysTimestamp(void) { - // TODO: Better impl - TODO(); -// return now()*1000; - return 0; + return native_timestamp(); } // --- Memory Management --- diff --git a/AcessNative/ld-acess_src/exports.h b/AcessNative/ld-acess_src/exports.h index 788e0d27..94987d0b 100644 --- a/AcessNative/ld-acess_src/exports.h +++ b/AcessNative/ld-acess_src/exports.h @@ -27,6 +27,8 @@ extern uint64_t native_tell(int FD); extern int native_execve(const char *filename, const char *const argv[], const char *const envp[]); extern int native_spawn(const char *filename, const char *const argv[], const char *const envp[]); +extern int64_t native_timestamp(void); + // Syscalls used by the linker extern int acess__SysOpen(const char *Path, unsigned int Flags); extern void acess__SysClose(int FD); diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index 965cc4ae..3341a956 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -13,6 +13,7 @@ # include // posix_spawn #endif #include "request.h" +#include #define assert(cnd) do{ \ if( !(cnd) ) { \ @@ -381,3 +382,10 @@ int native_spawn(const char *filename, const char *const argv[], const char *con return rv; } + +int64_t native_timestamp(void) +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec*1000 + tv.tv_usec / 1000; +} -- 2.20.1