lib/nghttp2_time.c | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/lib/nghttp2_time.c b/lib/nghttp2_time.c index 947b544..db18869 100644 --- a/lib/nghttp2_time.c +++ b/lib/nghttp2_time.c @@ -28,36 +28,16 @@ # include #endif /* HAVE_WINDOWS_H */ -#include - -#if !defined(HAVE_GETTICKCOUNT64) || defined(__CYGWIN__) -static uint64_t time_now_sec(void) { - time_t t = time(NULL); - - if (t == -1) { - return 0; - } - - return (uint64_t)t; +typedef union +{ + unsigned __int64 scalar; + FILETIME ft_struct; } -#endif /* !HAVE_GETTICKCOUNT64 || __CYGWIN__ */ - -#if defined(HAVE_GETTICKCOUNT64) && !defined(__CYGWIN__) -uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; } -#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_DECL_CLOCK_MONOTONIC) && \ - HAVE_DECL_CLOCK_MONOTONIC -uint64_t nghttp2_time_now_sec(void) { - struct timespec tp; - int rv = clock_gettime(CLOCK_MONOTONIC, &tp); - - if (rv == -1) { - return time_now_sec(); - } +ftime_t; - return (uint64_t)tp.tv_sec; +uint64_t nghttp2_time_now_sec(void) +{ + ftime_t ftime; + GetSystemTimeAsFileTime(&(ftime.ft_struct)); + return ftime.scalar / 10000000ULL; } -#else /* (!HAVE_CLOCK_GETTIME || !HAVE_DECL_CLOCK_MONOTONIC) && \ - (!HAVE_GETTICKCOUNT64 || __CYGWIN__)) */ -uint64_t nghttp2_time_now_sec(void) { return time_now_sec(); } -#endif /* (!HAVE_CLOCK_GETTIME || !HAVE_DECL_CLOCK_MONOTONIC) && \ - (!HAVE_GETTICKCOUNT64 || __CYGWIN__)) */