#ifndef MINIMALSYS_H #define MINIMALSYS_H #include "int.h" void exit(int8_t status); #define STDIN 0 #define STDOUT 1 #define STDERR 2 intptr_t write(int32_t fd, const void* buf, intptr_t size); intptr_t read(int32_t fd, const void* buf, intptr_t size); #define O_RDONLY 00 #define O_WRONLY 01 #define O_RDWR 02 #define AT_FDCWD -100 #if defined(__mips__) // linux/arch/mips/include/uapi/asm/fcntl.h #define O_APPEND 0x0008 #define O_CREAT 0x0100 /* not fcntl */ #define O_TRUNC 0x0200 /* not fcntl */ #define O_EXCL 0x0400 /* not fcntl */ #define O_NOCTTY 0x0800 /* not fcntl */ #else // linux/include/uapi/asm-generic/fcntl.h #define O_CREAT 1<<6 #define O_EXCL 1<<7 #define O_NOCTTY 1<<8 #define O_TRUNC 1<<9 #define O_APPEND 1<<10 #endif int32_t openat(int32_t fd, const char* filename, uint32_t flags, uint32_t mode); #define open(...) openat(AT_FDCWD, __VA_ARGS__, 0) #define openc(...) openat(AT_FDCWD, __VA_ARGS__) int close(unsigned int fd); int fsync(unsigned int fd); uint32_t fork(); // Provide memset for clang void *memset(void* s, int c, unsigned long n) { int8_t* mem = s; for(long int i = 0; i < n; ++i) mem[i] = c; return s; } #endif // !MINIMALSYS_H