#ifndef __plan9_stdlib_h__ #define __plan9_stdlib_h__ #include #include #include /* FIXME WRONG */ #define round(x) ((vlong)(x)) #define lrint(x) ((vlong)(x)) enum { FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, }; #define fesetround(x) do{}while(0) #define signbit(x) 0 static char *environ[1] = {0}; static double trunc(double x) { return (vlong)x; } static double acosh(double) { return 0.0; } static double asinh(double) { return 0.0; } static double atanh(double) { return 0.0; } static double expm1(double x) { return 0.0; } static double log1p(double x) { return 0.0; } static double log2(double x) { return 0.0; } static double cbrt(double x) { return 0.0; } #define _Atomic(x) long static int errno = 0; #define pclose fclose #define popen fopen #define lseek seek #define isatty(x) 0 #define rename(a,b) (-1) #define signal(...) (-1); #define ioctl(...) (-1) #define PATH_MAX 4096 #define getcwd getwd #define strerror(...) "" static int mkdir(char *p, int mode) { int f; if((f = create(p, OREAD, DMDIR | mode)) < 0) return -1; close(f); return 0; } struct winsize { int ws_row, ws_col; }; struct termios { int c_iflag, c_oflag, c_lflag, c_cflag; int c_cc[1]; }; typedef int sighandler_t; enum { SIG_DFL, SIG_IGN, VMIN = 0, VTIME = 0, TCSANOW, IGNBRK, BRKINT, PARMRK, ISTRIP, INLCR, IGNCR, ICRNL, IXON, OPOST, ECHO, ECHONL, ICANON, IEXTEN, CSIZE, PARENB, CS8, }; #define tcsetattr(...) (-1) #define tcgetattr(...) (-1) enum { EINVAL = -1, EIO = -2, EACCES = -3, EEXIST = -4, ENOSPC = -5, ENOSYS = -6, EBUSY = -7, ENOENT = -8, EPERM = -9, EPIPE = -10, EBADF = -11, EISDIR = -12, }; #define NAN NaN() #define isnan isNaN #define isfinite(x) (!isInf(x, 1) && !isInf(x, -1)) #define fmin(x,y) ((x)<(y)?(x):(y)) #define fmax(x,y) ((x)>(y)?(x):(y)) typedef s8int int8_t; typedef s16int int16_t; typedef s32int int32_t; typedef s64int int64_t; typedef u8int uint8_t; typedef u16int uint16_t; typedef u32int uint32_t; typedef u64int uint64_t; typedef vlong ssize_t; typedef uvlong size_t; typedef intptr intptr_t; typedef uintptr uintptr_t; #define LONG_MAX 0x7fffffffL #define INT32_MIN ((s32int)0x80000000) #define INT64_MIN ((s64int)0x8000000000000000ULL) #define INT32_MAX 0x7fffffff #define UINT32_MAX 0xffffffffU #define INT64_MAX 0x7fffffffffffffffLL #define UINT64_MAX 0xffffffffffffffffULL #define SIZE_MAX UINT64_MAX #define PRId64 "lld" #define PRIx64 "llx" #define __attribute__(...) #define __builtin_expect(x, n) (x) int __builtin_ctz(unsigned int x); int __builtin_ctzll(unsigned long long x); int __builtin_clz(unsigned int x); int __builtin_clzll(unsigned long long x); #define exit(x) exits(x == 0 ? nil : "error") static size_t malloc_usable_size(void *) { return 0; } typedef uvlong clock_t; uvlong clock(void); #define CLOCKS_PER_SEC 1000000000ULL #define setenv(k,v,x) putenv(k,v) #define unsetenv(k) putenv(k,"") long atomic_fetch_add(long *i, long v); long atomic_fetch_sub(long *i, long v); long atomic_fetch_and(long *i, long v); long atomic_fetch_or(long *i, long v); long atomic_fetch_xor(long *i, long v); long atomic_exchange(long *i, long v); #define atomic_load(p) *(p) #define atomic_store(p,x) *(p) = x #define atomic_compare_exchange_strong(a,b,c) 0 #define CONFIG_VERSION "NEIN.NEIN.NEIN" #define CONFIG_BIGNUM 1 #endif