Add integer casting macros

This commit is contained in:
RichardG867
2025-09-19 20:09:14 -03:00
parent 25146643f9
commit 80ebd5a92e

View File

@@ -79,6 +79,15 @@
#define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x)) #define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x))
#define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x)) #define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x))
#define AS_U8(x) (*((uint8_t *) &(x)))
#define AS_U16(x) (*((uint16_t *) &(x)))
#define AS_U32(x) (*((uint32_t *) &(x)))
#define AS_U64(x) (*((uint64_t *) &(x)))
#define AS_I8(x) (*((int8_t *) &(x)))
#define AS_I16(x) (*((int16_t *) &(x)))
#define AS_I32(x) (*((int32_t *) &(x)))
#define AS_I64(x) (*((int64_t *) &(x)))
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
# define UNLIKELY(x) __builtin_expect((x), 0) # define UNLIKELY(x) __builtin_expect((x), 0)
# define LIKELY(x) __builtin_expect((x), 1) # define LIKELY(x) __builtin_expect((x), 1)