1
0
Fork 0
arena-allocator/src/base.h

48 lines
994 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: linkedlist helpers
#define sll_stack_push(f,n,next) ((n)->next=(f), (f)=(n))
//= 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