mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-03 15:16:14 +00:00
Kernel: Remove includes to LibC stdarg definitions
We don't actually need the va_list and other stdarg definitions in the kernel, because we actually don't use the "pure" printf interface in any kernel code at all, but we retain the snprintf declaration because the libstdc++ library still need it to be declared and extern'ed.
This commit is contained in:
@@ -20,8 +20,6 @@
|
||||
#include <Kernel/TTY/ConsoleManagement.h>
|
||||
#include <Kernel/kstdio.h>
|
||||
|
||||
#include <LibC/stdarg.h>
|
||||
|
||||
namespace Kernel {
|
||||
extern Atomic<Graphics::Console*> g_boot_console;
|
||||
}
|
||||
@@ -90,49 +88,13 @@ static void console_out(char ch)
|
||||
}
|
||||
}
|
||||
|
||||
static void buffer_putch(char*& bufptr, char ch)
|
||||
{
|
||||
*bufptr++ = ch;
|
||||
}
|
||||
|
||||
// Declare it, so that the symbol is exported, because libstdc++ uses it.
|
||||
// However, *only* libstdc++ uses it, and none of the rest of the Kernel.
|
||||
extern "C" int sprintf(char* buffer, char const* fmt, ...);
|
||||
|
||||
int sprintf(char* buffer, char const* fmt, ...)
|
||||
int sprintf(char*, char const*, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = printf_internal(buffer_putch, buffer, fmt, ap);
|
||||
buffer[ret] = '\0';
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int snprintf(char* buffer, size_t size, char const* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
size_t space_remaining = 0;
|
||||
if (size) {
|
||||
space_remaining = size - 1;
|
||||
} else {
|
||||
space_remaining = 0;
|
||||
}
|
||||
auto sized_buffer_putch = [&](char*& bufptr, char ch) {
|
||||
if (space_remaining) {
|
||||
*bufptr++ = ch;
|
||||
--space_remaining;
|
||||
}
|
||||
};
|
||||
int ret = printf_internal(sized_buffer_putch, buffer, fmt, ap);
|
||||
if (space_remaining) {
|
||||
buffer[ret] = '\0';
|
||||
} else if (size > 0) {
|
||||
buffer[size - 1] = '\0';
|
||||
}
|
||||
va_end(ap);
|
||||
return ret;
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
static inline void internal_dbgputch(char ch)
|
||||
|
||||
Reference in New Issue
Block a user