mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-07-15 17:03:49 +00:00

* Make __wasi_linkcount_t a uint64_t (#134) Refs: https://github.com/WebAssembly/WASI/pull/127 * Generate the WASI interface from witx. This replaces the hand-maintained <wasi/core.h> header with a <wasi/api.h> generated from witx. Most of the churn here is caused by upstream WASI renamings; hopefully in the future ABI updates will be less noisy.
25 lines
496 B
C
25 lines
496 B
C
#include <wasi/api.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
|
|
#ifdef _REENTRANT
|
|
#error With threads support, getentropy is not intended to be a cancellation point.
|
|
#endif
|
|
|
|
int __getentropy(void *buffer, size_t len) {
|
|
if (len > 256) {
|
|
errno = EIO;
|
|
return -1;
|
|
}
|
|
|
|
int r = __wasi_random_get(buffer, len);
|
|
|
|
if (r != 0) {
|
|
errno = r;
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
extern __typeof(__getentropy) getentropy __attribute__((weak, alias("__getentropy")));
|