integer overflow/underflow stuff
This commit is contained in:
@@ -185,6 +185,13 @@
|
||||
|
||||
#define stmnt(S) do{ S }while(0)
|
||||
|
||||
#ifndef STATIC_ASSERT
|
||||
#define STATIC_ASSERT3(cond, msg) typedef char static_assertion_##msg[(!!(cond))*2-1]
|
||||
#define STATIC_ASSERT2(cond, line) STATIC_ASSERT3(cond, static_assertion_at_line_##line)
|
||||
#define STATIC_ASSERT1(cond, line) STATIC_ASSERT2(cond, line)
|
||||
#define STATIC_ASSERT(cond) STATIC_ASSERT1(cond, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(assertBreak)
|
||||
# define assertBreak() (*(volatile int*)0 = 0)
|
||||
#endif
|
||||
@@ -260,6 +267,17 @@ typedef const char* str;
|
||||
typedef float f32;
|
||||
typedef double f64;
|
||||
|
||||
STATIC_ASSERT(sizeof(u8) == 1);
|
||||
STATIC_ASSERT(sizeof(i8) == 1);
|
||||
STATIC_ASSERT(sizeof(u16) == 2);
|
||||
STATIC_ASSERT(sizeof(i16) == 2);
|
||||
STATIC_ASSERT(sizeof(u32) == 4);
|
||||
STATIC_ASSERT(sizeof(i32) == 4);
|
||||
STATIC_ASSERT(sizeof(u64) == 8);
|
||||
STATIC_ASSERT(sizeof(i64) == 8);
|
||||
STATIC_ASSERT(sizeof(f32) == 4);
|
||||
STATIC_ASSERT(sizeof(f64) == 8);
|
||||
|
||||
//typedef long double f80; only returning 8 bytes on my mac for some reason
|
||||
/*
|
||||
printf("u8 %d\n", (int)sizeof(u8) * 8);
|
||||
@@ -625,6 +643,9 @@ fn void u32ReverseArray(u32 arr[], u32 size);
|
||||
fn Vec2f32 vec2Add(Vec2 a, Vec2 b);
|
||||
fn Vec2f32 vec2Subtract(Vec2 a, Vec2 b);
|
||||
fn Vec2f32 vec2FromHexCube(Vec2 map_center, XYZ cube, f32 size, f32 border_thickness);
|
||||
fn i32 i32Middle(i32 x, i32 y);
|
||||
fn u32 u32Middle(u32 x, u32 y);
|
||||
fn u64 u64SafeMul(u64 x, u64 y);
|
||||
|
||||
///// MEMORY (Arenas)
|
||||
#define ARENA_MAX GB(1)
|
||||
|
||||
Reference in New Issue
Block a user