Skip to content

Commit

Permalink
Merge pull request #102 from turbolent/macos-getentropy
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Oct 13, 2024
2 parents 4c53309 + 2bf170e commit 042b592
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion wasi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions wasi/wasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ struct timespec {
#include <sys/uio.h>
#endif /* HAS_SYSUIO */

#if HAS_GETENTROPY && defined(__APPLE__)
#include <AvailabilityMacros.h>
#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 <sys/random.h>
#endif
#endif

#ifndef __MSL__
#include <sys/stat.h>
#endif
Expand Down

0 comments on commit 042b592

Please sign in to comment.