2020-06-27 12:18:26 +02:00
|
|
|
#pragma once
|
2019-11-24 14:35:38 +01:00
|
|
|
|
|
|
|
#include <malloc.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-02-04 15:47:35 +01:00
|
|
|
#define LIMIT(x, min, max) \
|
|
|
|
({ \
|
|
|
|
typeof(x) _x = x; \
|
|
|
|
typeof(min) _min = min; \
|
|
|
|
typeof(max) _max = max; \
|
|
|
|
(((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
|
|
|
|
: (_x)); \
|
|
|
|
})
|
2019-11-24 14:35:38 +01:00
|
|
|
|
2022-02-04 15:47:35 +01:00
|
|
|
#define DegToRad(a) ((a) *0.01745329252f)
|
|
|
|
#define RadToDeg(a) ((a) *57.29577951f)
|
2019-11-24 14:35:38 +01:00
|
|
|
|
2022-02-04 15:47:35 +01:00
|
|
|
#define ALIGN4(x) (((x) + 3) & ~3)
|
|
|
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
2019-11-24 14:35:38 +01:00
|
|
|
|
2020-06-27 12:18:26 +02:00
|
|
|
// those work only in powers of 2
|
2022-02-04 15:47:35 +01:00
|
|
|
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
|
|
|
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
2019-11-24 14:35:38 +01:00
|
|
|
|
|
|
|
|
2022-02-04 15:47:35 +01:00
|
|
|
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
|
|
|
|
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
|
|
|
|
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
|
2019-11-24 14:35:38 +01:00
|
|
|
|
|
|
|
//Needs to have log_init() called beforehand.
|
2020-06-03 19:45:51 +02:00
|
|
|
void dumpHex(const void *data, size_t size);
|
2019-11-24 14:35:38 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2020-06-27 12:18:26 +02:00
|
|
|
#endif
|