Kohi Game Engine
defines.h File Reference

This file contains global type definitions which are used throughout the entire engine and applications referencing it. Numeric types are asserted statically to gurantee expected size. More...

Go to the source code of this file.

Data Structures

struct  range
 A range, typically of memory. More...
 

Macros

#define STATIC_ASSERT   static_assert
 Static assertion. More...
 
#define true   1
 True. More...
 
#define false   0
 False. More...
 
#define INVALID_ID_U64   18446744073709551615UL
 Any id set to this should be considered invalid, and not actually pointing to a real object. More...
 
#define INVALID_ID   4294967295U
 
#define INVALID_ID_U16   65535U
 
#define INVALID_ID_U8   255U
 
#define KAPI
 Import/export qualifier. More...
 
#define KCLAMP(value, min, max)
 Clamps value to a range of min and max (inclusive). More...
 
#define KINLINE   static inline
 Inline qualifier. More...
 
#define KNOINLINE
 No-inline qualifier. More...
 
#define GIBIBYTES(amount)   ((amount) * 1024ULL * 1024ULL * 1024ULL)
 Gets the number of bytes from amount of gibibytes (GiB) (1024*1024*1024) More...
 
#define MEBIBYTES(amount)   ((amount) * 1024ULL * 1024ULL)
 Gets the number of bytes from amount of mebibytes (MiB) (1024*1024) More...
 
#define KIBIBYTES(amount)   ((amount) * 1024ULL)
 Gets the number of bytes from amount of kibibytes (KiB) (1024) More...
 
#define GIGABYTES(amount)   ((amount) * 1000ULL * 1000ULL * 1000ULL)
 Gets the number of bytes from amount of gigabytes (GB) (1000*1000*1000) More...
 
#define MEGABYTES(amount)   ((amount) * 1000ULL * 1000ULL)
 Gets the number of bytes from amount of megabytes (MB) (1000*1000) More...
 
#define KILOBYTES(amount)   ((amount) * 1000ULL)
 Gets the number of bytes from amount of kilobytes (KB) (1000) More...
 
#define KMIN(x, y)   (x < y ? x : y)
 
#define KMAX(x, y)   (x > y ? x : y)
 

Typedefs

typedef unsigned char u8
 Unsigned 8-bit integer. More...
 
typedef unsigned short u16
 Unsigned 16-bit integer. More...
 
typedef unsigned int u32
 Unsigned 32-bit integer. More...
 
typedef unsigned long long u64
 Unsigned 64-bit integer. More...
 
typedef signed char i8
 Signed 8-bit integer. More...
 
typedef signed short i16
 Signed 16-bit integer. More...
 
typedef signed int i32
 Signed 32-bit integer. More...
 
typedef signed long long i64
 Signed 64-bit integer. More...
 
typedef float f32
 32-bit floating point number More...
 
typedef double f64
 64-bit floating point number More...
 
typedef int b32
 32-bit boolean type, used for APIs which require it More...
 
typedef _Bool b8
 8-bit boolean type More...
 
typedef struct range range
 A range, typically of memory. More...
 

Functions

 STATIC_ASSERT (sizeof(u8)==1, "Expected u8 to be 1 byte.")
 Assert u8 to be 1 byte. More...
 
 STATIC_ASSERT (sizeof(u16)==2, "Expected u16 to be 2 bytes.")
 Assert u16 to be 2 bytes. More...
 
 STATIC_ASSERT (sizeof(u32)==4, "Expected u32 to be 4 bytes.")
 Assert u32 to be 4 bytes. More...
 
 STATIC_ASSERT (sizeof(u64)==8, "Expected u64 to be 8 bytes.")
 Assert u64 to be 8 bytes. More...
 
 STATIC_ASSERT (sizeof(i8)==1, "Expected i8 to be 1 byte.")
 Assert i8 to be 1 byte. More...
 
 STATIC_ASSERT (sizeof(i16)==2, "Expected i16 to be 2 bytes.")
 Assert i16 to be 2 bytes. More...
 
 STATIC_ASSERT (sizeof(i32)==4, "Expected i32 to be 4 bytes.")
 Assert i32 to be 4 bytes. More...
 
 STATIC_ASSERT (sizeof(i64)==8, "Expected i64 to be 8 bytes.")
 Assert i64 to be 8 bytes. More...
 
 STATIC_ASSERT (sizeof(f32)==4, "Expected f32 to be 4 bytes.")
 Assert f32 to be 4 bytes. More...
 
 STATIC_ASSERT (sizeof(f64)==8, "Expected f64 to be 8 bytes.")
 Assert f64 to be 8 bytes. More...
 
KINLINE u64 get_aligned (u64 operand, u64 granularity)
 
KINLINE range get_aligned_range (u64 offset, u64 size, u64 granularity)
 

Detailed Description

This file contains global type definitions which are used throughout the entire engine and applications referencing it. Numeric types are asserted statically to gurantee expected size.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-01-10

Macro Definition Documentation

◆ false

#define false   0

False.

◆ GIBIBYTES

#define GIBIBYTES (   amount)    ((amount) * 1024ULL * 1024ULL * 1024ULL)

Gets the number of bytes from amount of gibibytes (GiB) (1024*1024*1024)

◆ GIGABYTES

#define GIGABYTES (   amount)    ((amount) * 1000ULL * 1000ULL * 1000ULL)

Gets the number of bytes from amount of gigabytes (GB) (1000*1000*1000)

◆ INVALID_ID

#define INVALID_ID   4294967295U

◆ INVALID_ID_U16

#define INVALID_ID_U16   65535U

◆ INVALID_ID_U64

#define INVALID_ID_U64   18446744073709551615UL

Any id set to this should be considered invalid, and not actually pointing to a real object.

◆ INVALID_ID_U8

#define INVALID_ID_U8   255U

◆ KAPI

#define KAPI

Import/export qualifier.

◆ KCLAMP

#define KCLAMP (   value,
  min,
  max 
)
Value:
((value <= min) ? min : (value >= max) ? max \
: value)

Clamps value to a range of min and max (inclusive).

Parameters
valueThe value to be clamped.
minThe minimum value of the range.
maxThe maximum value of the range.
Returns
The clamped value.

◆ KIBIBYTES

#define KIBIBYTES (   amount)    ((amount) * 1024ULL)

Gets the number of bytes from amount of kibibytes (KiB) (1024)

◆ KILOBYTES

#define KILOBYTES (   amount)    ((amount) * 1000ULL)

Gets the number of bytes from amount of kilobytes (KB) (1000)

◆ KINLINE

#define KINLINE   static inline

Inline qualifier.

◆ KMAX

#define KMAX (   x,
 
)    (x > y ? x : y)

◆ KMIN

#define KMIN (   x,
 
)    (x < y ? x : y)

◆ KNOINLINE

#define KNOINLINE

No-inline qualifier.

◆ MEBIBYTES

#define MEBIBYTES (   amount)    ((amount) * 1024ULL * 1024ULL)

Gets the number of bytes from amount of mebibytes (MiB) (1024*1024)

◆ MEGABYTES

#define MEGABYTES (   amount)    ((amount) * 1000ULL * 1000ULL)

Gets the number of bytes from amount of megabytes (MB) (1000*1000)

◆ STATIC_ASSERT

#define STATIC_ASSERT   static_assert

Static assertion.

◆ true

#define true   1

True.

Typedef Documentation

◆ b32

typedef int b32

32-bit boolean type, used for APIs which require it

◆ b8

typedef _Bool b8

8-bit boolean type

◆ f32

typedef float f32

32-bit floating point number

◆ f64

typedef double f64

64-bit floating point number

◆ i16

typedef signed short i16

Signed 16-bit integer.

◆ i32

typedef signed int i32

Signed 32-bit integer.

◆ i64

typedef signed long long i64

Signed 64-bit integer.

◆ i8

typedef signed char i8

Signed 8-bit integer.

◆ range

typedef struct range range

A range, typically of memory.

◆ u16

typedef unsigned short u16

Unsigned 16-bit integer.

◆ u32

typedef unsigned int u32

Unsigned 32-bit integer.

◆ u64

typedef unsigned long long u64

Unsigned 64-bit integer.

◆ u8

typedef unsigned char u8

Unsigned 8-bit integer.

Function Documentation

◆ get_aligned()

KINLINE u64 get_aligned ( u64  operand,
u64  granularity 
)

◆ get_aligned_range()

KINLINE range get_aligned_range ( u64  offset,
u64  size,
u64  granularity 
)

◆ STATIC_ASSERT() [1/10]

STATIC_ASSERT ( sizeof(f32 = =4,
"Expected f32 to be 4 bytes."   
)

Assert f32 to be 4 bytes.

◆ STATIC_ASSERT() [2/10]

STATIC_ASSERT ( sizeof(f64 = =8,
"Expected f64 to be 8 bytes."   
)

Assert f64 to be 8 bytes.

◆ STATIC_ASSERT() [3/10]

STATIC_ASSERT ( sizeof(i16 = =2,
"Expected i16 to be 2 bytes."   
)

Assert i16 to be 2 bytes.

◆ STATIC_ASSERT() [4/10]

STATIC_ASSERT ( sizeof(i32 = =4,
"Expected i32 to be 4 bytes."   
)

Assert i32 to be 4 bytes.

◆ STATIC_ASSERT() [5/10]

STATIC_ASSERT ( sizeof(i64 = =8,
"Expected i64 to be 8 bytes."   
)

Assert i64 to be 8 bytes.

◆ STATIC_ASSERT() [6/10]

STATIC_ASSERT ( sizeof(i8 = =1,
"Expected i8 to be 1 byte."   
)

Assert i8 to be 1 byte.

◆ STATIC_ASSERT() [7/10]

STATIC_ASSERT ( sizeof(u16 = =2,
"Expected u16 to be 2 bytes."   
)

Assert u16 to be 2 bytes.

◆ STATIC_ASSERT() [8/10]

STATIC_ASSERT ( sizeof(u32 = =4,
"Expected u32 to be 4 bytes."   
)

Assert u32 to be 4 bytes.

◆ STATIC_ASSERT() [9/10]

STATIC_ASSERT ( sizeof(u64 = =8,
"Expected u64 to be 8 bytes."   
)

Assert u64 to be 8 bytes.

◆ STATIC_ASSERT() [10/10]

STATIC_ASSERT ( sizeof(u8 = =1,
"Expected u8 to be 1 byte."   
)

Assert u8 to be 1 byte.