mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-08-05 12:27:43 +00:00
Make sbrk(0) deterministic (#115)
* fix the behavior of sbrk(0) * review changes
This commit is contained in:
parent
b59b83cbc2
commit
d253aa3de2
@ -3,8 +3,14 @@
|
||||
#include <errno.h>
|
||||
#include <__macro_PAGESIZE.h>
|
||||
|
||||
/* Bare-bones implementation of sbrk: just call memory.grow. */
|
||||
/* Bare-bones implementation of sbrk. */
|
||||
void *sbrk(intptr_t increment) {
|
||||
/* sbrk(0) returns the current memory size. */
|
||||
if (increment == 0) {
|
||||
/* The wasm spec doesn't guarantee that memory.grow of 0 always succeeds. */
|
||||
return (void *)(__builtin_wasm_memory_size(0) * PAGESIZE);
|
||||
}
|
||||
|
||||
/* We only support page-size increments. */
|
||||
if (increment % PAGESIZE != 0) {
|
||||
abort();
|
||||
|
Loading…
Reference in New Issue
Block a user