From 095e62b86fbd9568ddaae04aa8d15888b8487983 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Tue, 31 Oct 2023 21:23:00 +0000 Subject: Introduced signed versions of common types For each type T there is the signed version s_T --- lib/base.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/base.h b/lib/base.h index 537792f..64d8f74 100644 --- a/lib/base.h +++ b/lib/base.h @@ -28,16 +28,22 @@ #define VERBOSE 0 #endif -typedef uint64_t u64; +typedef uint8_t u8; +typedef int8_t i8; typedef uint32_t u32; typedef int32_t i32; +typedef uint64_t u64; typedef int64_t i64; + typedef float f32; typedef double f64; -typedef uint8_t byte; +typedef u8 byte; +typedef i8 s_byte; typedef u32 hword; +typedef i32 s_hword; typedef u64 word; +typedef i64 s_word; typedef union { @@ -59,8 +65,10 @@ typedef enum #define DWORD(WORD) ((data_t){.as_word = (WORD)}) #define WORD_SAFE_SUB(W, SUB) ((W) > (SUB) ? ((W) - (SUB)) : 0) -#define HWORD_SIZE sizeof(hword) -#define WORD_SIZE sizeof(word) +#define HWORD_SIZE sizeof(hword) +#define SHWORD_SIZE sizeof(s_hword) +#define WORD_SIZE sizeof(word) +#define SWORD_SIZE sizeof(s_word) // Macros to extract the nth byte or nth hword from a word #define WORD_NTH_BYTE(WORD, N) (((WORD) >> ((N)*8)) & 0xff) -- cgit v1.2.3-13-gbd6f