mirror of
https://github.com/nghttp2/nghttp2.git
synced 2025-12-07 02:28:53 +08:00
Merge pull request #1995 from nghttp2/check-clock-monotonic
Check whether CLOCK_MONOTONIC is declared
This commit is contained in:
@@ -334,6 +334,8 @@ if(NOT HAVE_DECL_INITGROUPS AND HAVE_UNISTD_H)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_DECL_CLOCK_MONOTONIC)
|
||||
|
||||
set(WARNCFLAGS)
|
||||
set(WARNCXXFLAGS)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
/* Define to 1 if you have the `initgroups` function. */
|
||||
#cmakedefine01 HAVE_DECL_INITGROUPS
|
||||
|
||||
/* Define to 1 if you have the `CLOCK_MONOTONIC` defined. */
|
||||
#cmakedefine01 HAVE_DECL_CLOCK_MONOTONIC
|
||||
|
||||
/* Define to 1 to enable debug output. */
|
||||
#cmakedefine DEBUGBUILD 1
|
||||
|
||||
|
||||
@@ -985,6 +985,10 @@ AC_CHECK_DECLS([initgroups], [], [], [[
|
||||
#include <grp.h>
|
||||
]])
|
||||
|
||||
AC_CHECK_DECLS([CLOCK_MONOTONIC], [], [], [[
|
||||
#include <time.h>
|
||||
]])
|
||||
|
||||
save_CFLAGS=$CFLAGS
|
||||
save_CXXFLAGS=$CXXFLAGS
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ static uint64_t time_now_sec(void) {
|
||||
|
||||
#if defined(HAVE_GETTICKCOUNT64) && !defined(__CYGWIN__)
|
||||
uint64_t nghttp2_time_now_sec(void) { return GetTickCount64() / 1000; }
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
#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);
|
||||
@@ -57,6 +58,8 @@ uint64_t nghttp2_time_now_sec(void) {
|
||||
|
||||
return (uint64_t)tp.tv_sec;
|
||||
}
|
||||
#else /* (!HAVE_CLOCK_GETTIME || __CYGWIN__) && !HAVE_GETTICKCOUNT64 */
|
||||
#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 || __CYGWIN__) && !HAVE_GETTICKCOUNT64 */
|
||||
#endif /* (!HAVE_CLOCK_GETTIME || !HAVE_DECL_CLOCK_MONOTONIC) && \
|
||||
(!HAVE_GETTICKCOUNT64 || __CYGWIN__)) */
|
||||
|
||||
Reference in New Issue
Block a user