aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2020-03-16 17:20:27 +0800
committerfanquake <fanquake@gmail.com>2020-03-19 11:36:38 +0800
commite90e3e684ffa7b25f0dfb5b45e70bb0c358261fb (patch)
treeeff47e78032a33a1e4807b32c771b784a34437a5 /configure.ac
parenta421e0a22f1230abd69b4661a019bed39b72205f (diff)
downloadbitcoin-e90e3e684ffa7b25f0dfb5b45e70bb0c358261fb.tar.xz
build: fix sysctl() detection on macOS
sysctl() on *BSD takes a "const int *name", whereas sysctl() on macOS it takes an "int *name". So our configure check and sysctl() detection on macOS currently fails: ```bash /usr/include/sys/sysctl.h:759:9: note: candidate function not viable: no known conversion from 'const int [2]' to 'int *' for 1st argument int sysctl(int *, u_int, void *, size_t *, void *, size_t); ``` This change removes the name argument from the sysctl() detection check, meaning we will detect correctly on macOS and *BSD. For consistency we also switch to using the more generic, non-const version of the name parameter in the rest of our usage.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac10
1 files changed, 6 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 758d31192b..23a6417a1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -935,11 +935,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
AC_MSG_CHECKING(for sysctl)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/sysctl.h>]],
- [[ static const int name[2] = {CTL_KERN, KERN_VERSION};
- #ifdef __linux__
+ [[ #ifdef __linux__
#error "Don't use sysctl on Linux, it's deprecated even when it works"
#endif
- sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])],
+ sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0); ]])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL, 1,[Define this symbol if the BSD sysctl() is available]) ],
[ AC_MSG_RESULT(no)]
)
@@ -947,7 +946,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
AC_MSG_CHECKING(for sysctl KERN_ARND)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/sysctl.h>]],
- [[ static const int name[2] = {CTL_KERN, KERN_ARND};
+ [[ #ifdef __linux__
+ #error "Don't use sysctl on Linux, it's deprecated even when it works"
+ #endif
+ static int name[2] = {CTL_KERN, KERN_ARND};
sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL_ARND, 1,[Define this symbol if the BSD sysctl(KERN_ARND) is available]) ],
[ AC_MSG_RESULT(no)]