44 lines
905 B
C
44 lines
905 B
C
#ifndef BASE_H
|
|
#define BASE_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define internal static
|
|
|
|
typedef uint8_t u8;
|
|
typedef uint16_t u16;
|
|
typedef uint32_t u32;
|
|
typedef uint64_t u64;
|
|
|
|
typedef int8_t i8;
|
|
typedef int16_t i16;
|
|
typedef int32_t i32;
|
|
typedef int64_t i64;
|
|
|
|
typedef uint8_t b8;
|
|
typedef uint8_t b16;
|
|
typedef uint8_t b32;
|
|
typedef uint8_t b64;
|
|
|
|
#define KB(b) ((b) << 10)
|
|
#define MB(b) ((b) << 20)
|
|
|
|
#define Glue_(A,B) A##B
|
|
#define Glue(A,B) Glue_(A,B)
|
|
|
|
#define STATEMENT(S) do{ S } while(0)
|
|
#define ASSERT(c) STATEMENT( if (!(c)){ (*(volatile int*)0 = 0); } )
|
|
#define STATIC_ASSERT(c,l) typedef u8 Glue(l,__LINE__) [(c)?1:-1]
|
|
|
|
//= rhjr: memory helpers
|
|
|
|
#define memory_zero(s,z) memset((s), 0, (z))
|
|
#define memory_zero_struct(s) memory_zero((s), sizeof(*(s)))
|
|
|
|
#define memory_copy(dst, src, length) memmove((dst), (src), (length))
|
|
|
|
#endif // BASE_H
|