Kernel: Shell TTY_PRINT is now function instead of macro

This makes functions uses way less stack
This commit is contained in:
Bananymous 2023-04-12 00:18:58 +03:00
parent 370a958379
commit 8e5e5f819f
1 changed files with 14 additions and 14 deletions

View File

@ -15,23 +15,23 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#define TTY_PRINT(...) \
do { \
BAN::String message_ = BAN::String::formatted(__VA_ARGS__); \
MUST(Process::current()->write(STDOUT_FILENO, message_.data(), message_.size())); \
} while (false)
#define TTY_PRINTLN(...) \
do { \
TTY_PRINT(__VA_ARGS__); \
MUST(Process::current()->write(STDOUT_FILENO, "\n", 1)); \
} while (false)
namespace Kernel namespace Kernel
{ {
template<typename... Args>
static void TTY_PRINT(Args&&... args)
{
BAN::String message = BAN::String::formatted(BAN::forward<Args>(args)...);
MUST(Process::current()->write(STDOUT_FILENO, message.data(), message.size()));
}
template<typename... Args>
static void TTY_PRINTLN(Args&&... args)
{
TTY_PRINT(BAN::forward<Args>(args)...);
MUST(Process::current()->write(STDOUT_FILENO, "\n", 1));
}
static auto s_default_prompt = "\\[\e[32m\\]user\\[\e[m\\]:\\[\e[34m\\]\\w\\[\e[m\\]# "sv; static auto s_default_prompt = "\\[\e[32m\\]user\\[\e[m\\]:\\[\e[34m\\]\\w\\[\e[m\\]# "sv;
static const char* mode_string(Inode::Mode mode) static const char* mode_string(Inode::Mode mode)