File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change 42
42
#include " swift/Runtime/Mutex.h"
43
43
#include " ../SwiftShims/Random.h"
44
44
45
+ #ifdef __wasi__
46
+ #include < algorithm> // std::min
47
+ #endif
48
+
45
49
#if defined(__APPLE__)
46
50
47
51
SWIFT_RUNTIME_STDLIB_API
@@ -84,7 +88,7 @@ void swift::swift_stdlib_random(void *buf, __swift_size_t nbytes) {
84
88
if (getrandom_available) {
85
89
actual_nbytes = WHILE_EINTR (syscall (__NR_getrandom, buf, nbytes, 0 ));
86
90
}
87
- #elif __has_include(<sys/random.h>) && (defined(__CYGWIN__) || defined(__Fuchsia__))
91
+ #elif __has_include(<sys/random.h>) && (defined(__CYGWIN__) || defined(__Fuchsia__) || defined(__wasi__) )
88
92
__swift_size_t getentropy_nbytes = std::min (nbytes, __swift_size_t {256 });
89
93
90
94
if (0 == getentropy (buf, getentropy_nbytes)) {
You can’t perform that action at this time.
0 commit comments