mirror of
https://git.proxmox.com/git/wasi-libc
synced 2025-08-09 12:09:02 +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 <errno.h>
|
||||||
#include <__macro_PAGESIZE.h>
|
#include <__macro_PAGESIZE.h>
|
||||||
|
|
||||||
/* Bare-bones implementation of sbrk: just call memory.grow. */
|
/* Bare-bones implementation of sbrk. */
|
||||||
void *sbrk(intptr_t increment) {
|
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. */
|
/* We only support page-size increments. */
|
||||||
if (increment % PAGESIZE != 0) {
|
if (increment % PAGESIZE != 0) {
|
||||||
abort();
|
abort();
|
||||||
|
Loading…
Reference in New Issue
Block a user