ref: 55c93fc3d47f608104839dbb21b8339a95df4d82
dir: /plan9/platform.h/
#include <u.h> #include <libc.h> #include <ctype.h> #include <mp.h> #define __thread #define LLT_ALLOC(n) malloc(n) #define LLT_REALLOC(p, n) realloc((p), (n)) #define LLT_FREE(x) free(x) #if defined(__amd64__) || \ defined(__arm64__) || \ defined(__mips64__) || \ defined(__power64__) || \ defined(__sparc64__) #define BITS64 #endif #define unsetenv(name) putenv(name, "") #define setenv(name, val, overwrite) putenv(name, val) #define exit(x) exits((x) ? "error" : nil) #define isnan(x) isNaN(x) #define getcwd getwd #define vsnprintf vsnprint #define snprintf snprint #define strcasecmp cistrcmp #define lseek seek #define towupper toupperrune #define towlower tolowerrune #define iswalpha isalpharune #define sqrtf sqrt #define expf exp #define logf log #define sinf sin #define cosf cos #define tanf tan #define asinf asin #define acosf acos #define atanf atan #define signbit(r) ((*(uint64_t*)&(r)) & BIT63) #define isfinite(d) (((*(uint64_t*)&(d))&0x7ff0000000000000ULL) != 0x7ff0000000000000ULL) #define PRId64 "lld" #define PRIu64 "llud" #ifdef BITS64 #define PRIdPTR PRId64 #else #define PRIdPTR "ld" #endif #define INT32_MAX 0x7fffffff #define UINT32_MAX 0xffffffffU #define INT32_MIN (-INT32_MAX-1) #define INT64_MIN ((int64_t)0x8000000000000000LL) #define INT64_MAX 0x7fffffffffffffffLL #define UINT64_MAX 0xffffffffffffffffULL #define PATHSEP '/' #define PATHSEPSTRING "/" #define PATHLISTSEP ':' #define PATHLISTSEPSTRING ":" #define ISPATHSEP(c) ((c) == '/') enum { SEEK_SET, SEEK_CUR, SEEK_END, STDIN_FILENO = 0, STDOUT_FILENO, STDERR_FILENO, }; #define O_RDWR ORDWR #define O_WRONLY OWRITE #define O_RDONLY OREAD #define O_TRUNC OTRUNC #define F_OK 0 #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321 #if defined(__mips__) || \ defined(__power__) || defined(__power64__) || \ defined(__sparc__) || defined(__sparc64__) #define BYTE_ORDER BIG_ENDIAN #else #define BYTE_ORDER LITTLE_ENDIAN #endif #define __unlikely(x) (x) #define __likely(x) (x) #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8) #define bswap_32(x) \ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) #define bswap_64(x) \ (uint64_t)bswap_32((x) & 0xffffffffULL)<<32 | \ (uint64_t)bswap_32(((x)>>32) & 0xffffffffULL) 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 off_t; typedef intptr intptr_t; typedef uintptr uintptr_t; typedef intptr ssize_t; typedef uintptr size_t; typedef enum { false, true } bool; int wcwidth(Rune c); uint32_t __builtin_popcount(uint32_t); uint32_t __builtin_bitreverse32(uint32_t x);