We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b59b83c commit d253aa3Copy full SHA for d253aa3
1 file changed
libc-bottom-half/sources/sbrk.c
@@ -3,8 +3,14 @@
3
#include <errno.h>
4
#include <__macro_PAGESIZE.h>
5
6
-/* Bare-bones implementation of sbrk: just call memory.grow. */
+/* Bare-bones implementation of sbrk. */
7
void *sbrk(intptr_t increment) {
8
+ /* sbrk(0) returns the current memory size. */
9
+ if (increment == 0) {
10
+ /* The wasm spec doesn't guarantee that memory.grow of 0 always succeeds. */
11
+ return (void *)(__builtin_wasm_memory_size(0) * PAGESIZE);
12
+ }
13
+
14
/* We only support page-size increments. */
15
if (increment % PAGESIZE != 0) {
16
abort();
0 commit comments