diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2025-01-18 22:07:19 +0100 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2025-01-18 22:23:44 +0100 |
| commit | e4892f1bb232bbad0795a94f809f3124620653a9 (patch) | |
| tree | 588e5f69aa996c99b4fc096933e4f1d4776c24be /core/crypto | |
| parent | 47030501abbdb9b09baf34f1ea1ed15f513ccd6d (diff) | |
os/os2: wasi target support
Diffstat (limited to 'core/crypto')
| -rw-r--r-- | core/crypto/rand_generic.odin | 1 | ||||
| -rw-r--r-- | core/crypto/rand_wasi.odin | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/crypto/rand_generic.odin b/core/crypto/rand_generic.odin index ef578f5c0..8266f8ffc 100644 --- a/core/crypto/rand_generic.odin +++ b/core/crypto/rand_generic.odin @@ -5,6 +5,7 @@ #+build !netbsd #+build !darwin #+build !js +#+build !wasi package crypto HAS_RAND_BYTES :: false diff --git a/core/crypto/rand_wasi.odin b/core/crypto/rand_wasi.odin new file mode 100644 index 000000000..9653fb985 --- /dev/null +++ b/core/crypto/rand_wasi.odin @@ -0,0 +1,13 @@ +package crypto + +import "core:fmt" +import "core:sys/wasm/wasi" + +HAS_RAND_BYTES :: true + +@(private) +_rand_bytes :: proc(dst: []byte) { + if err := wasi.random_get(dst); err != nil { + fmt.panicf("crypto: wasi.random_get failed: %v", err) + } +} |