ref: ce3af9e03b554081f6689a541438f32cdd2c44c5
dir: /plan9/platform.h/
#pragma once
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <mp.h>
#ifdef NDEBUG
#undef assert
#define assert(x)
#define static_assert(a,b)
#else
#define static_assert_cat(a, b) a##b
#define static_assert_name(line) static_assert_cat(static_assert_, line)
#define static_assert(must_be_true, message) \
static const void *static_assert_name(__LINE__) \
[must_be_true ? 2 : -1] = { \
message, \
static_assert_name(__LINE__), \
}
#endif
#define __os_name__ "plan9"
static int
fl_popcount(u32int w)
{
w -= (w >> 1) & 0x55555555U;
w = (w & 0x33333333U) + ((w >> 2) & 0x33333333U);
w = (w + (w >> 4)) & 0x0F0F0F0FU;
w = (w * 0x01010101U) >> 24;
return w;
}
int fl_clz(unsigned int x);
#if defined(__amd64__) || \
defined(__arm64__) || \
defined(__mips64__) || \
defined(__power64__) || \
defined(__sparc64__)
#define BITS64
#define PRIdPTR PRId64
#define PRIuPTR PRIu64
#else
#define PRIdPTR "ld"
#define PRIuPTR "lud"
#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 vdprintf fprint
#define snprintf snprint
#define strcasecmp cistrcmp
#define lseek seek
#define towupper toupperrune
#define towlower tolowerrune
#define iswalpha isalpharune
#define signbit(r) ((*(uint64_t*)&(r)) & (1ULL<<63))
#define isfinite(d) (((*(uint64_t*)&(d))&0x7ff0000000000000ULL) != 0x7ff0000000000000ULL)
#define PRIu32 "ud"
#define PRIx32 "x"
#define PRId64 "lld"
#define PRIu64 "llud"
#define PRIx64 "llx"
#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 ULONG_MAX UINT32_MAX
#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
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);
int ftruncate(int f, off_t sz);
#include "cc.h"
#include "mem.h"