From: John Hodge (sonata) Date: Fri, 7 Nov 2014 04:15:07 +0000 (+0800) Subject: AcessNative - Add _SysTimestamp (based off gettimeofday) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=617be89866d56ab5f70f2ac9d35c1651aa6bfca2;p=tpg%2Facess2.git AcessNative - Add _SysTimestamp (based off gettimeofday) --- 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; +}