From 96a025c28bf793f0519737c5d61bd77728b14ddf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 23 Feb 2022 16:04:27 -0800 Subject: [PATCH] QRandomGenerator: find getentropy() on macOS It's in . The header exists on Linux and on FreeBSD and declares getrandom(), which we don't use, so it's harmless. Pick-to: 6.3 Change-Id: Ibf4acec0f166495998f7fffd16d69005ab59df3b Reviewed-by: Qt CI Bot Reviewed-by: Allan Sandfeld Jensen --- src/corelib/configure.cmake | 3 +++ src/corelib/global/qrandom.cpp | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 5e6f5ec12a..82bc03a4fd 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -243,6 +243,9 @@ qt_config_compile_test(getentropy LABEL "getentropy()" CODE "#include +#if __has_include() +# include +#endif int main(void) { diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index eb7eca6388..eb9aa542d3 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -53,7 +53,9 @@ # include #endif -#if !QT_CONFIG(getentropy) && (!defined(Q_OS_BSD4) || defined(__GLIBC__)) && !defined(Q_OS_WIN) +#if QT_CONFIG(getentropy) && __has_include() +# include +#elif !QT_CONFIG(getentropy) && (!defined(Q_OS_BSD4) || defined(__GLIBC__)) && !defined(Q_OS_WIN) # include "qdeadlinetimer.h" # include "qhashfunctions.h" #endif // !QT_CONFIG(getentropy)