From 00a826330e9988afeab2c602a95973832f9f9c57 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 10 Apr 2014 11:34:43 -0700 Subject: [PATCH] use GetSystemTimeAsFileTime with previous gettimeofday setup --- libraries/shared/src/Systime.cpp | 12 ++++++------ libraries/shared/src/Systime.h | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libraries/shared/src/Systime.cpp b/libraries/shared/src/Systime.cpp index eab02ce2ab..0b2d782bbf 100644 --- a/libraries/shared/src/Systime.cpp +++ b/libraries/shared/src/Systime.cpp @@ -38,21 +38,21 @@ /** Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ #define _W32_FT_OFFSET (116444736000000000ULL) -int __cdecl gettimeofday(struct timeval *__restrict__ tp, - void *__restrict__ tzp __attribute__((unused))) { +int gettimeofday(timeval* p_tv, timezone* p_tz) { + union { unsigned long long ns100; /**time since 1 Jan 1601 in 100ns units */ FILETIME ft; } _now; - if (tp) { + if (p_tv) { GetSystemTimeAsFileTime (&_now.ft); - tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); - tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); + p_tv->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); + p_tv->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); } /** Always return 0 as per Open Group Base Specifications Issue 6. - Do not set errno on error. */ + Do not set errno on error. */ return 0; } diff --git a/libraries/shared/src/Systime.h b/libraries/shared/src/Systime.h index b6eaa70cab..3098f09ecd 100644 --- a/libraries/shared/src/Systime.h +++ b/libraries/shared/src/Systime.h @@ -15,11 +15,12 @@ #include -extern "C" { +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; -int __cdecl gettimeofday(struct timeval *__restrict__, void *__restrict__); - -} +int gettimeofday(struct timeval* p_tv, struct timezone* p_tz); #endif