Skip to content

Commit 403f472

Browse files
authored
wasi: Tweak the configuration for nuttx and explain why (#3451)
1 parent 5bc38f7 commit 403f472

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

  • core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/ssp_config.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,17 @@
2626

2727
// On Linux, prefer to use getrandom, though it isn't available in
2828
// GLIBC before 2.25.
29-
#if (defined(__linux__) || defined(ESP_PLATFORM) || defined(__COSMOPOLITAN__)) \
30-
&& (!defined(__GLIBC__) || __GLIBC__ > 2 \
31-
|| (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25))
29+
//
30+
// NuttX has arc4random_buf, getrandom, and /dev/urandom.
31+
// We prefer getrandom here because it has the best chance to be usable.
32+
// - Our /dev/urandom usage (keep the open descriptor in a global variable)
33+
// is not compatible with NuttX flat memory model.
34+
// - arc4random_buf is only available with CONFIG_CRYPTO_RANDOM_POOL=y.
35+
#if defined(__NuttX__) \
36+
|| ((defined(__linux__) || defined(ESP_PLATFORM) \
37+
|| defined(__COSMOPOLITAN__)) \
38+
&& (!defined(__GLIBC__) || __GLIBC__ > 2 \
39+
|| (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)))
3240
#define CONFIG_HAS_GETRANDOM 1
3341
#else
3442
#define CONFIG_HAS_GETRANDOM 0

0 commit comments

Comments
 (0)