From 2bf170e023bd57ff78207809867e320ee25ca6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Sun, 13 Oct 2024 09:48:15 -0700 Subject: [PATCH] macOS 10.12 has getentropy, in sys/random.h --- wasi/CMakeLists.txt | 2 +- wasi/wasi.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wasi/CMakeLists.txt b/wasi/CMakeLists.txt index be9eb4c..b49d8ae 100644 --- a/wasi/CMakeLists.txt +++ b/wasi/CMakeLists.txt @@ -22,7 +22,7 @@ include(CheckSymbolExists) check_symbol_exists(strndup string.h HAVE_STRNDUP) check_symbol_exists(fcntl fcntl.h HAVE_FCNTL) check_symbol_exists(lstat "sys/stat.h" HAVE_LSTAT) -check_symbol_exists(getentropy unistd.h HAVE_GETENTROPY) +check_symbol_exists(getentropy "unistd.h;sys/random.h" HAVE_GETENTROPY) include(CheckStructHasMember) check_struct_has_member("struct timespec" tv_sec time.h HAVE_TIMESPEC) diff --git a/wasi/wasi.c b/wasi/wasi.c index 4e59b17..dcdcd12 100644 --- a/wasi/wasi.c +++ b/wasi/wasi.c @@ -58,6 +58,16 @@ struct timespec { #include #endif /* HAS_SYSUIO */ +#if HAS_GETENTROPY && defined(__APPLE__) +#include +#ifndef MAC_OS_X_VERSION_10_12 +#define MAC_OS_X_VERSION_10_12 101200 +#endif +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 +#include +#endif +#endif + #ifndef __MSL__ #include #endif