summaryrefslogtreecommitdiff
path: root/lib/error.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-09 12:41:49 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-09 12:41:49 -0400
commit2ed275821676a0d5baea6c7fd843d71c72c2342c (patch)
tree480297f28e5c42d02a47b3b94027a7abe507d010 /lib/error.c
downloadmips-2ed275821676a0d5baea6c7fd843d71c72c2342c.tar.gz
mips-2ed275821676a0d5baea6c7fd843d71c72c2342c.tar.bz2
mips-2ed275821676a0d5baea6c7fd843d71c72c2342c.zip
initial mips32 (r2000ish mips32r6) assembler
Diffstat (limited to 'lib/error.c')
-rw-r--r--lib/error.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/error.c b/lib/error.c
new file mode 100644
index 0000000..78f75ef
--- /dev/null
+++ b/lib/error.c
@@ -0,0 +1,53 @@
+#include <merror.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+char *current_file = "file.asm";
+
+__attribute__((format(printf, 4, 5)))
+void __log_impl_pos(int line, int column, int type, const char *format, ...)
+{
+ va_list list;
+ va_start(list, format);
+
+ char *t = NULL;
+ switch (type) {
+ case __DEBUG:
+ t = "\033[34mdebug:\033[0m";
+ break;
+ case __WARNING:
+ t = "\033[35mwarning:\033[0m";
+ break;
+ case __ERROR:
+ t = "\033[31merror:\033[0m";
+ break;
+ }
+
+ printf("%s:%d:%d: %s ", current_file, line, column, t);
+ vprintf(format, list);
+ putchar('\n');
+}
+
+__attribute__((format(printf, 2, 3)))
+void __log_impl(int type, const char *format, ...)
+{
+ va_list list;
+ va_start(list, format);
+
+ char *t = NULL;
+ switch (type) {
+ case __DEBUG:
+ t = "\033[34mdebug:\033[0m";
+ break;
+ case __WARNING:
+ t = "\033[35mwarning:\033[0m";
+ break;
+ case __ERROR:
+ t = "\033[31merror:\033[0m";
+ break;
+ }
+
+ printf("%s ", t);
+ vprintf(format, list);
+ putchar('\n');
+}