github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/cmd/wazero/testdata/wasi_random_get.wat (about)

     1  (module $listener
     2    (import "wasi_snapshot_preview1" "random_get"
     3      (func $wasi.random_get (param $buf i32) (param $buf_len i32) (result (;errno;) i32)))
     4  
     5    (memory 1 1) ;; Memory is needed for WASI
     6  
     7    ;; _start is a special function defined by a WASI Command that runs like a main function would.
     8    ;;
     9    ;; See https://github.com/WebAssembly/WASI/blob/snapshot-01/design/application-abi.md#current-unstable-abi
    10    (func $main (export "_start")
    11        ;; generate 1000 bytes of random data starting at address 0
    12        (call $wasi.random_get
    13            (i32.const 0)
    14            (i32.const 1000)
    15        )
    16        drop
    17    )
    18  )