#include <errno.h>
#include <sys/stat.h>

extern char _end; /* provided by linker script */
static char *heap_ptr = &_end;

void *sbrk(int incr) {
  char *prev = heap_ptr;
  heap_ptr += incr;
  return prev;
}

int write(int fd, const char *buf, int len) { return len; }

int read(int fd, char *buf, int len) { return 0; }
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; }
int lseek(int fd, int offset, int whence) { return 0; }
void _exit(int status) {
  while (1)
    ;
}
void exit(int status) {
  while (1)
    ;
}
int kill(int pid, int sig) {
  errno = EINVAL;
  return -1;
}
int getpid(void) { return 1; }
