From 7f5d765c929a4dc2deddb7b68a41a3a841940837 Mon Sep 17 00:00:00 2001 From: Mel Date: Thu, 22 Jan 2026 03:55:02 +0100 Subject: LLVM clang compiler backend Signed-off-by: Mel --- boot/common.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'boot/common.c') diff --git a/boot/common.c b/boot/common.c index e453065..095aaa6 100644 --- a/boot/common.c +++ b/boot/common.c @@ -3,7 +3,7 @@ * are used throughout the bootstrap compiler. * allocation done purely statically. * - * Copyright (c) 2025, Mel G. + * Copyright (c) 2025-2026, Mel G. * * SPDX-License-Identifier: MPL-2.0 */ @@ -127,6 +127,54 @@ unreachable() failure("unreachable code reached"); } +// log out a message with a debug prefix. +// does not print additional \n at the end. +void +log_debug(const ascii* message, ...) +{ + fflush(stdout); + fprintf(stderr, ANSI_BOLD ANSI_CYAN "debug. " ANSI_NO_BOLD); + + va_list args; + va_start(args, message); + vfprintf(stderr, message, args); + va_end(args); + + fprintf(stderr, ANSI_RESET); +} + +// log out a message with a warning prefix. +// does not print additional \n at the end. +void +log_warning(const ascii* message, ...) +{ + fflush(stdout); + fprintf(stderr, ANSI_BOLD ANSI_YELLOW "warning? " ANSI_NO_BOLD); + + va_list args; + va_start(args, message); + vfprintf(stderr, message, args); + va_end(args); + + fprintf(stderr, ANSI_RESET); +} + +// log out a message with an error prefix. +// does not print additional \n at the end. +void +log_error(const ascii* message, ...) +{ + fflush(stdout); + fprintf(stderr, ANSI_BOLD ANSI_RED "error! " ANSI_NO_BOLD); + + va_list args; + va_start(args, message); + vfprintf(stderr, message, args); + va_end(args); + + fprintf(stderr, ANSI_RESET); +} + // for each entry in a linked list. #define FOR_EACH(type, cursor, head) for (type cursor = head; cursor != nil; cursor = cursor->next) -- cgit 1.4.1