19#define GBAL_UNUSED __attribute__((unused))
27#define MAX_BASE36 0x81BF0FFF
35#define SIGN(x) ((x > 0) - (x < 0))
43#define NUM_ELEM_IN_ARR(arr) (sizeof(arr) / sizeof((arr)[0]))
45#define INT_MAX_DIGITS 11
46#define UINT_MAX_DIGITS 10
47#define UINT8_MAX_DIGITS 3
48#define BASE36_MAX_DIGITS 6
52#define ONE_B 1000000000
60#define SUFFIXED_NUM_MIN_REQ_CHARS 4
63#define LOG_ERROR(...) MGBA_FUNC_ERROR(__VA_ARGS__)
66#define LOG_ERROR(...) ((void)(0))
76#define GBAL_RETURN_IF_NULL_VOID(param) \
79 if ((param) == NULL) \
81 LOG_ERROR("Unexpected value: %s == NULL", #param); \
95#define GBAL_RETURN_IF_NULL_RET(param, ret_val) \
98 if ((param) == NULL) \
100 LOG_ERROR("Unexpected value: %s == NULL", #param); \
172 char out_str_buff[UINT_MAX_DIGITS + 1]
Interface to interact with the mgba logger.
uint16_t u16_protected_mult(uint16_t a, uint16_t b)
Avoid overflow when multiplying two u16 integers.
uint32_t u32_protected_add(uint32_t a, uint32_t b)
Avoid overflow when adding two u32 integers.
static int u32_get_digits(uint32_t n)
Get the number of digits in a 32-bit unsigned number https://stackoverflow.com/questions/1068849/how-...
uint32_t base36_to_u32(const char b36_str[])
Convert a base-36 string representation to a 32-bit unsigned integer. Since we are dealing with base-...
uint16_t u16_protected_add(uint16_t a, uint16_t b)
Avoid overflow when adding two u16 integers.
void truncate_uint_to_suffixed_str(uint32_t num, int num_req_chars, char out_str_buff[UINT_MAX_DIGITS+1])
Truncate an unsigned number into a suffixed string representation e.g. 12000 -> "12K" The least signi...
uint32_t u32_protected_mult(uint32_t a, uint32_t b)
Avoid overflow when multiplying two u32 integers.
void u32_to_base36(uint32_t n, char b36_str[])
Convert a 32-bit unsigned integer to its base-36 string representation. This will perform 6 divisions...