Clean up code

This commit is contained in:
2024-05-05 19:13:24 +05:30
parent b77cc5639c
commit 91af3e14ef
4 changed files with 9 additions and 8 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ build/*
*.out
TAGS
compile_commands.json
.cache/*

View File

@@ -19,10 +19,10 @@
#define ARR_SIZE(xs) (sizeof(xs) / sizeof(xs[0]))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define TERM_GREEN "\e[0;32m"
#define TERM_YELLOW "\e[0;33m"
#define TERM_RED "\e[0;31m"
#define TERM_RESET "\e[0;0m"
#define TERM_GREEN "\033[32m"
#define TERM_YELLOW "\033[33m"
#define TERM_RED "\033[31m"
#define TERM_RESET "\033[0m"
// Flags for program behaviour (usually related to printing)
#ifndef VERBOSE

View File

@@ -184,7 +184,7 @@ void test_lib_base_bytes_to_hword(void)
} tests[] = {{{0, 0, 0, 0}, 0},
{{0xFF, 0xFF, 0xFF, 0xFF}, HWORD_MAX},
{{1, 0, 0, 0}, 1},
{{0, 0, 0, 0b10000000}, 1U << 31},
{{0, 0, 0, 0x80}, 1U << 31},
{{0x89, 0xab, 0xcd, 0xef}, 0xefcdab89}};
const size_t n = size_byte_array_to_string(4);
@@ -216,7 +216,7 @@ void test_lib_base_bytes_to_word(void)
{{0, 0, 0, 0}, 0},
{{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, WORD_MAX},
{{0x01, 0, 0, 0, 0, 0, 0, 0}, 1},
{{0, 0, 0, 0, 0, 0, 0, 0b10000000}, 1LU << 63},
{{0, 0, 0, 0, 0, 0, 0, 0x80}, 1LU << 63},
{{0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}, 0xefcdab8967452301}};
const size_t n = size_byte_array_to_string(8);
@@ -283,7 +283,7 @@ void test_lib_base_word_to_bytes(void)
{0, {0, 0, 0, 0}},
{WORD_MAX, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
{1, {0x01, 0, 0, 0, 0, 0, 0, 0}},
{1LU << 63, {0, 0, 0, 0, 0, 0, 0, 0b10000000}},
{1LU << 63, {0, 0, 0, 0, 0, 0, 0, 0x80}},
{0xefcdab8967452301, {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}}};
for (size_t i = 0; i < ARR_SIZE(tests); ++i)

View File

@@ -191,7 +191,7 @@ void vm_print_heap(vm_t *vm, FILE *fp)
fprintf(fp, "\n");
for (size_t i = 0; i < heap.pages; ++i)
{
fprintf(fp, "\t[%lu]@%p: ", i, cur);
fprintf(fp, "\t[%lu]@%p: ", i, (void *)cur);
if (!cur)
fprintf(fp, "<NIL>\n");
else