undar-lang-fixed-length/vm/libc.h

51 lines
1023 B
C

#ifndef UNDAR_LIBC_H
#define UNDAR_LIBC_H
#include <stddef.h>
#include <stdint.h>
typedef uint8_t u8;
typedef int8_t i8;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint32_t u32;
typedef int32_t i32;
typedef float f32;
#define true 1
#define false 0
#define bool u8
#define nil NULL
#define I8_MIN -128
#define I8_MAX 127
#define U8_MAX 255
#define I16_MIN -32768
#define I16_MAX 32767
#define U16_MAX 65535
#define I32_MIN -2147483648
#define I32_MAX 2147483647
#define U32_MAX 4294967295
#define FIXED_CONST 65536.0f
#define AS_INT(v) ((i32)(v))
#define AS_NAT(v) ((u32)(v))
#define AS_REAL(v) ((i32)(v))
#define FLOAT_TO_REAL(v) (((i32)(v)) * FIXED_CONST)
#define REAL_TO_FLOAT(v) (((f32)(v)) / FIXED_CONST)
#define USED(x) ((void)(x))
void mcpy(void *dest, void *src, u32 n);
i32 scpy(char* to, const char *from, u32 length);
bool seq(const char *s1, const char *s2);
bool sleq(const char *s1, const char *s2, u32 length);
u32 slen(const char *str);
u32 snlen(const char *str, u32 max_len);
#endif