Workaround for use of GetTickCount64() in nghttp2 library.

This commit is contained in:
LoRd_MuldeR 2023-12-07 19:00:55 +01:00
parent eacdcf6cd9
commit 21517a7517
2 changed files with 46 additions and 0 deletions

View File

@ -172,6 +172,7 @@ readonly NGH2_DIR="${BASE_DIR}/nghttp2-${MY_CPU}"
rm -rf "${NGH2_DIR}" && mkdir "${NGH2_DIR}"
tar -xvf "${LIBS_DIR}/.pkg/nghttp2.tar.gz" --strip-components=1 -C "${NGH2_DIR}"
pushd "${NGH2_DIR}"
patch -p1 -b < "${BASE_DIR}/patch/nghttp2_time.diff"
CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I${LIBS_DIR}/include" LDFLAGS="-L${LIBS_DIR}/lib" OPENSSL_CFLAGS="-I${LIBS_DIR}/include" OPENSSL_LIBS="-L${LIBS_DIR}/lib -lssl -lcrypto" ZLIB_CFLAGS="-I${LIBS_DIR}/include" ZLIB_LIBS="-L${LIBS_DIR}/lib -lz" ./configure --prefix="${LIBS_DIR}" --enable-lib-only --disable-threads --disable-shared
make && make install
popd

45
patch/nghttp2_time.diff Normal file
View File

@ -0,0 +1,45 @@
diff --git "a/lib/nghttp2_time.c" "b/lib/nghttp2_time.c"
index 897556f..ab06684 100644
--- "a/lib/nghttp2_time.c"
+++ "b/lib/nghttp2_time.c"
@@ -32,31 +32,15 @@
# include <sysinfoapi.h>
#endif /* HAVE_SYSINFOAPI_H */
-#if !defined(HAVE_GETTICKCOUNT64) || defined(__CYGWIN__)
-static uint64_t time_now_sec(void) {
- time_t t = time(NULL);
+uint64_t nghttp2_time_now_sec(void)
+{
+ FILETIME file_time;
+ ULARGE_INTEGER time_value;
+
+ GetSystemTimeAsFileTime(&file_time);
- if (t == -1) {
- return 0;
- }
+ time_value.LowPart = file_time.dwLowDateTime;
+ time_value.HighPart = file_time.dwHighDateTime;
- return (uint64_t)t;
+ return time_value.QuadPart / 10000000ULL;
}
-#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)
-uint64_t nghttp2_time_now_sec(void) {
- struct timespec tp;
- int rv = clock_gettime(CLOCK_MONOTONIC, &tp);
-
- if (rv == -1) {
- return time_now_sec();
- }
-
- return (uint64_t)tp.tv_sec;
-}
-#else /* (!HAVE_CLOCK_GETTIME || __CYGWIN__) && !HAVE_GETTICKCOUNT64 */
-uint64_t nghttp2_time_now_sec(void) { return time_now_sec(); }
-#endif /* (!HAVE_CLOCK_GETTIME || __CYGWIN__) && !HAVE_GETTICKCOUNT64 */