2024-11-12 18:52:08 +01:00
|
|
|
lib/nghttp2_time.c | 38 ++++++++++----------------------------
|
|
|
|
1 file changed, 10 insertions(+), 28 deletions(-)
|
2024-02-05 23:52:07 +01:00
|
|
|
|
|
|
|
diff --git a/lib/nghttp2_time.c b/lib/nghttp2_time.c
|
2024-11-12 18:52:08 +01:00
|
|
|
index 148ccfdc..355b225a 100644
|
2024-02-05 23:52:07 +01:00
|
|
|
--- a/lib/nghttp2_time.c
|
|
|
|
+++ b/lib/nghttp2_time.c
|
2024-11-12 18:52:08 +01:00
|
|
|
@@ -30,34 +30,16 @@
|
|
|
|
|
|
|
|
#include <time.h>
|
2023-12-07 19:00:55 +01:00
|
|
|
|
|
|
|
-#if !defined(HAVE_GETTICKCOUNT64) || defined(__CYGWIN__)
|
|
|
|
-static uint64_t time_now_sec(void) {
|
|
|
|
- time_t t = time(NULL);
|
2023-12-07 23:21:11 +01:00
|
|
|
-
|
2023-12-07 19:00:55 +01:00
|
|
|
- if (t == -1) {
|
|
|
|
- return 0;
|
|
|
|
- }
|
2023-12-07 23:21:11 +01:00
|
|
|
-
|
2023-12-07 19:00:55 +01:00
|
|
|
- return (uint64_t)t;
|
2023-12-07 23:21:11 +01:00
|
|
|
+typedef union
|
|
|
|
+{
|
|
|
|
+ unsigned __int64 scalar;
|
|
|
|
+ FILETIME ft_struct;
|
2023-12-07 19:00:55 +01:00
|
|
|
}
|
|
|
|
-#endif /* !HAVE_GETTICKCOUNT64 || __CYGWIN__ */
|
|
|
|
-
|
|
|
|
-#if defined(HAVE_GETTICKCOUNT64) && !defined(__CYGWIN__)
|
|
|
|
-uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; }
|
2024-02-05 23:52:07 +01:00
|
|
|
-#elif defined(HAVE_CLOCK_GETTIME) && defined(HAVE_DECL_CLOCK_MONOTONIC) && \
|
2024-11-12 18:52:08 +01:00
|
|
|
- HAVE_DECL_CLOCK_MONOTONIC
|
2023-12-07 19:00:55 +01:00
|
|
|
-uint64_t nghttp2_time_now_sec(void) {
|
|
|
|
- struct timespec tp;
|
|
|
|
- int rv = clock_gettime(CLOCK_MONOTONIC, &tp);
|
|
|
|
-
|
|
|
|
- if (rv == -1) {
|
|
|
|
- return time_now_sec();
|
|
|
|
- }
|
2023-12-07 23:21:11 +01:00
|
|
|
+ftime_t;
|
|
|
|
|
2023-12-07 19:00:55 +01:00
|
|
|
- return (uint64_t)tp.tv_sec;
|
2023-12-07 23:21:11 +01:00
|
|
|
+uint64_t nghttp2_time_now_sec(void)
|
|
|
|
+{
|
|
|
|
+ ftime_t ftime;
|
|
|
|
+ GetSystemTimeAsFileTime(&(ftime.ft_struct));
|
|
|
|
+ return ftime.scalar / 10000000ULL;
|
|
|
|
}
|
2024-02-05 23:52:07 +01:00
|
|
|
-#else /* (!HAVE_CLOCK_GETTIME || !HAVE_DECL_CLOCK_MONOTONIC) && \
|
|
|
|
- (!HAVE_GETTICKCOUNT64 || __CYGWIN__)) */
|
2023-12-07 19:00:55 +01:00
|
|
|
-uint64_t nghttp2_time_now_sec(void) { return time_now_sec(); }
|
2024-02-05 23:52:07 +01:00
|
|
|
-#endif /* (!HAVE_CLOCK_GETTIME || !HAVE_DECL_CLOCK_MONOTONIC) && \
|
|
|
|
- (!HAVE_GETTICKCOUNT64 || __CYGWIN__)) */
|