kiba-engine
Macros
defines.h File Reference

Global typedefs and macros. More...

#include <kiba/core/config.h>
#include <kiba/core/log.h>
#include <kiba/core/types.h>
#include <kiba/core/version.h>
Include dependency graph for defines.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KB_NULL   NULL
 Value of an invalid ptr (nullptr).
 
#define UNUSED(x)   (void) x
 Mark parameter as unused.
 
#define TYPE_OF(x)   __typeof__(x)
 Call to typeof operator.
 
#define ALIGN_OF(x)   _Alignof(x)
 Get alignment of type.
 
#define KB_MIN(x, y)   ((x) < (y) ? (x) : (y))
 Ternary to get the minimum of two numbers. More...
 
#define KB_MAX(x, y)   ((x) > (y) ? (x) : (y))
 Ternary to get the maximum of two numbers. More...
 
#define KB_CLAMP(x, min, max)   ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
 Clamp an input value to a certain range. More...
 
#define KB_FLAGS_ALL_SET(value, flags)   (((value) & (flags)) == (flags))
 Check if all flags are set inside value. More...
 
#define KB_FLAGS_ANY_SET(value, flags)   (((value) & (flags)) != 0)
 Check if any of the flags are set inside value.
 
#define KB_UBIT(n)   ((u64) 1 << n)
 Get unsigned value with the n-th bit set to 1. All other bits are 0.
 
#define KB_IBIT(n)   ((i64) 1 << n)
 Get signed value with the n-th bit set to 1. All other bits are 0.
 

Detailed Description

Global typedefs and macros.

Contains includes for logging and more concise typedefs for all datatypes. Additionally includes platform and build type specific macros.

Definition in file defines.h.

Macro Definition Documentation

◆ KB_CLAMP

#define KB_CLAMP (   x,
  min,
  max 
)    ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))

Clamp an input value to a certain range.

  • min will be returned if the value is smaller than x
  • max will be returned if the value is greater than x
  • x will be returned if the value is inside the range [min,max]
Warning
Do not use any expressions with potential side effects for any of the operands. They MAY be called more than once!

Definition at line 55 of file defines.h.

◆ KB_FLAGS_ALL_SET

#define KB_FLAGS_ALL_SET (   value,
  flags 
)    (((value) & (flags)) == (flags))

Check if all flags are set inside value.

Warning
flags is evaluated twice!

Definition at line 62 of file defines.h.

◆ KB_MAX

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

Ternary to get the maximum of two numbers.

Warning
Do not use any expressions with potential side effects for any of the operands. They MAY be called more than once!

Definition at line 43 of file defines.h.

◆ KB_MIN

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

Ternary to get the minimum of two numbers.

Warning
Do not use any expressions with potential side effects for any of the operands. They MAY be called more than once!

Definition at line 35 of file defines.h.