| /* Syscall stubs for newlib on Kelvin */ | |
| #include <errno.h> | |
| #include <sys/stat.h> | |
| int _close(int file) { return -1; } | |
| int _fstat(int file, struct stat* st) { return 0; } | |
| int _isatty(int file) { | |
| errno = ENOTTY; | |
| return 0; | |
| } | |
| int _lseek(int file, int ptr, int dir) { return 0; } | |
| int _read(int file, char* ptr, int len) { | |
| errno = EBADF; | |
| return -1; | |
| } | |
| int _write(int file, char* ptr, int len) { | |
| errno = EBADF; | |
| return -1; | |
| } | |
| int _open(const char* path, int flags, ...) { return -1; } | |
| void _exit(int status) { | |
| while (1) { | |
| } | |
| } | |
| int _kill(int pid, int sig) { return -1; } | |
| int _getpid(void) { return -1; } | |
| // Based on newlib's nosys sbrk | |
| void* _sbrk(int bytes) { | |
| extern char __heap_end__; | |
| static char* heap_end; | |
| char* prev_heap_end; | |
| if (heap_end == 0) { | |
| heap_end = &__heap_end__; | |
| } | |
| prev_heap_end = heap_end; | |
| heap_end += bytes; | |
| return (void*)prev_heap_end; | |
| } |