From 5a419deabba93d9fea3f6af2c921a76d2dc9927c Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 13 Feb 2024 16:50:13 +0100 Subject: Move *eq() macros to common.h --- src/c8asm/assembler.c | 7 ------- src/c8asm/common.h | 6 ++++-- src/c8asm/parser.c | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/c8asm/assembler.c b/src/c8asm/assembler.c index 6160397..353d904 100644 --- a/src/c8asm/assembler.c +++ b/src/c8asm/assembler.c @@ -30,7 +30,6 @@ struct labels { size_t len, cap; }; -static bool u8eq(struct u8view, struct u8view); static void pushlabel(struct labels *, struct label); static uint16_t getaddr(struct raw_addr); static struct label *getlabel(struct u8view); @@ -38,12 +37,6 @@ static struct label *getlabel(struct u8view); static size_t i; static struct labels locals, globals; -bool -u8eq(struct u8view x, struct u8view y) -{ - return x.len == y.len && memcmp(x.p, y.p, x.len) == 0; -} - struct label * getlabel(struct u8view sv) { diff --git a/src/c8asm/common.h b/src/c8asm/common.h index 36a7036..165e6bc 100644 --- a/src/c8asm/common.h +++ b/src/c8asm/common.h @@ -6,8 +6,10 @@ #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) -#define lengthof(a) (sizeof(a) / sizeof(*(a))) -#define streq(x, y) (!strcmp(x, y)) +#define lengthof(a) (sizeof(a) / sizeof(*(a))) +#define memeq(x, y, n) (!memcmp(x, y, n)) +#define streq(x, y) (!strcmp(x, y)) +#define u8eq(x, y) (!u8cmp(x, y)) extern size_t filesize; extern const char *filename; diff --git a/src/c8asm/parser.c b/src/c8asm/parser.c index 03d190d..357a082 100644 --- a/src/c8asm/parser.c +++ b/src/c8asm/parser.c @@ -23,7 +23,6 @@ #define E_TOOLARGE "expected %s but got out-of-range integer ā€˜%.*sā€™" #define die_with_off(P, ...) die_with_off(filename, (P)-baseptr, __VA_ARGS__) -#define memeq(X, Y, N) (!memcmp(X, Y, N)) enum numsize { NS_NIBBLE = 0xF, -- cgit v1.2.3