shithub: femtolisp

ref: a9a81aed1f002597ceaa01fa7e2d7ae127e2b9b7
dir: /plan9/platform.h/

View raw version
#include <u.h>
#include <libc.h>
#include <ctype.h>

#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 LC_NUMERIC 0
#define setlocale(x,y)

#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

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 Rune wchar_t;
typedef enum { false, true } bool;
int wcwidth(wchar_t c);