#include #include extern char _end; /* provided by linker script */ static char *heap_ptr = &_end; // Required for Newlib's malloc/calloc/realloc. // Although AOT/Interp use wasm_runtime_malloc instead, // it's still necessary for snprintf/vsnprintf. void *sbrk(int incr) { char *prev = heap_ptr; heap_ptr += incr; return prev; } // Required to exist for AOT/Interp, but don't need to be implemented. // We don't have files/consoles/serial ports/whatever. int read(int fd, char *buf, int len) { return 0; } int write(int fd, const char *buf, int len) { return len; } int close(int fd) { return -1; } int fstat(int fd, struct stat *st) { st->st_mode = S_IFCHR; return 0; } int isatty(int fd) { return 1; } // Required to exist for C/AOT/Interp int lseek(int fd, int offset, int whence) { return 0; } // Required to exist for AOT/Interp. // We don't have processes, so those can be stubs. void _exit(int status) { while (1) ; } int kill(int pid, int sig) { errno = EINVAL; return -1; } int getpid(void) { return 1; } // Not required? Why do I have this? // void exit(int status) { // while (1) // ; // }