From 3996919f5eb1baa5dad989cb0bdbbabbdbf99bcc Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sat, 17 Apr 2021 19:17:28 +0100 Subject: [PATCH] Fix a few cmake configure-time checks. A couple of actual checks were missing (elf_aux_info, sysctlbyname). Several more were accidentally left out of cmake.h.in, meaning they wouldn't be propagated from cmake's variable space into the actual compilation. And a handful of checks in the C source were still using the autotools-style 'if defined' in place of the cmake-style "it's always 0 or 1" plain #if. --- cmake/cmake.h.in | 7 +++++++ cmake/platforms/unix.cmake | 2 ++ unix/uxmisc.c | 2 +- unix/uxutils.h | 4 ++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmake/cmake.h.in b/cmake/cmake.h.in index 3ddf25fc..f051c759 100644 --- a/cmake/cmake.h.in +++ b/cmake/cmake.h.in @@ -16,6 +16,11 @@ #cmakedefine NOT_X_WINDOWS +#cmakedefine01 HAVE_ASM_HWCAP_H +#cmakedefine01 HAVE_SYS_AUXV_H +#cmakedefine01 HAVE_SYS_SYSCTL_H +#cmakedefine01 HAVE_SYS_TYPES_H +#cmakedefine01 HAVE_GLOB_H #cmakedefine01 HAVE_FUTIMES #cmakedefine01 HAVE_GETADDRINFO #cmakedefine01 HAVE_POSIX_OPENPT @@ -28,6 +33,8 @@ #cmakedefine01 HAVE_SETPWENT #cmakedefine01 HAVE_ENDPWENT #cmakedefine01 HAVE_GETAUXVAL +#cmakedefine01 HAVE_ELF_AUX_INFO +#cmakedefine01 HAVE_SYSCTLBYNAME #cmakedefine01 HAVE_CLOCK_MONOTONIC #cmakedefine01 HAVE_CLOCK_GETTIME #cmakedefine01 HAVE_SO_PEERCRED diff --git a/cmake/platforms/unix.cmake b/cmake/platforms/unix.cmake index 1bd905c6..c09d5d8f 100644 --- a/cmake/platforms/unix.cmake +++ b/cmake/platforms/unix.cmake @@ -34,6 +34,8 @@ check_symbol_exists(dirfd "sys/types.h;dirent.h" HAVE_DIRFD) check_symbol_exists(setpwent "sys/types.h;pwd.h" HAVE_SETPWENT) check_symbol_exists(endpwent "sys/types.h;pwd.h" HAVE_ENDPWENT) check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL) +check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_ELF_AUX_INFO) +check_symbol_exists(sysctlbyname "sys/types.h;sys/sysctl.h" HAVE_SYSCTLBYNAME) check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC) check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME) diff --git a/unix/uxmisc.c b/unix/uxmisc.c index 57df7b7a..876725bd 100644 --- a/unix/uxmisc.c +++ b/unix/uxmisc.c @@ -24,7 +24,7 @@ unsigned long getticks(void) * need a decent number of them to fit into a 32-bit word so it * can be used for keepalives. */ -#if defined HAVE_CLOCK_GETTIME && defined HAVE_DECL_CLOCK_MONOTONIC +#if HAVE_CLOCK_GETTIME && HAVE_CLOCK_MONOTONIC { /* Use CLOCK_MONOTONIC if available, so as to be unconfused if * the system clock changes. */ diff --git a/unix/uxutils.h b/unix/uxutils.h index 8c70a8a1..fcb7e9b7 100644 --- a/unix/uxutils.h +++ b/unix/uxutils.h @@ -30,9 +30,9 @@ #include #endif -#if defined HAVE_GETAUXVAL +#if HAVE_GETAUXVAL /* No code needed: getauxval has just the API we want already */ -#elif defined HAVE_ELF_AUX_INFO +#elif HAVE_ELF_AUX_INFO /* Implement the simple getauxval API in terms of FreeBSD elf_aux_info */ static inline u_long getauxval(int which) {