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