Skip to content

Commit

Permalink
printf: Update to add removed spinlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsuki committed Dec 19, 2023
1 parent c144d1c commit f0de8f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 0 additions & 2 deletions kernel/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ override INTERNALCFLAGS := \
-Wno-unused-function \
-Wno-unused-variable \
-Wno-unused-parameter \
-DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES=1 \
-DPRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD=1 \
-DPRINTF_SUPPORT_DECIMAL_SPECIFIERS=0 \
-DPRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS=0 \
-Ifreestanding_headers \
Expand Down
18 changes: 16 additions & 2 deletions kernel/c/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,26 @@ void putchar_(char c) {
putchar_func(c);
}

int printf_panic(char *fmt, ...) {
void klock__Lock_acquire(void *);
void klock__Lock_release(void *);
extern char printf_lock;

int printf(const char *fmt, ...) {
va_list l;
va_start(l, fmt);
klock__Lock_acquire(&printf_lock);
int ret = vprintf_(fmt, l);
klock__Lock_release(&printf_lock);
va_end(l);
return ret;
}

int printf_panic(const char *fmt, ...) {
va_list l;
va_start(l, fmt);
void (*old_func)(char) = putchar_func;
putchar_func = _putchar_panic;
int ret = vprintf(fmt, l);
int ret = vprintf_(fmt, l);
va_end(l);
putchar_func = old_func;
return ret;
Expand Down

0 comments on commit f0de8f6

Please sign in to comment.