first commit
This commit is contained in:
61
base.h
Normal file
61
base.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef BASE_H
|
||||
#define BASE_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
Base types
|
||||
------------------------------------------------------------ */
|
||||
|
||||
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 i8 b8;
|
||||
typedef int b32;
|
||||
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
/* ------------------------------------------------------------
|
||||
Size helpers
|
||||
------------------------------------------------------------ */
|
||||
|
||||
#define KiB(x) ((u64)(x) * 1024ULL)
|
||||
#define MiB(x) (KiB(x) * 1024ULL)
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
Min / Max helpers
|
||||
------------------------------------------------------------ */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
Alignment helpers
|
||||
------------------------------------------------------------ */
|
||||
|
||||
#define ALIGN_UP_POW2(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
Assert
|
||||
------------------------------------------------------------ */
|
||||
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
||||
#endif // Base.h
|
||||
Reference in New Issue
Block a user