Kernel: Shell TTY_PRINT is now function instead of macro
This makes functions uses way less stack
This commit is contained in:
		
							parent
							
								
									370a958379
								
							
						
					
					
						commit
						8e5e5f819f
					
				| 
						 | 
				
			
			@ -15,23 +15,23 @@
 | 
			
		|||
#include <fcntl.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
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	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 const char* mode_string(Inode::Mode mode)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue