mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Libmaxsi now offers printf to user-space programs.
This commit is contained in:
parent
9db2c88aca
commit
ea396ddd69
2 changed files with 37 additions and 8 deletions
|
@ -44,10 +44,14 @@ namespace Maxsi
|
|||
size_t WriteAt(int FileDesc, const void* Buffer, size_t BufferSize, intmax_t Position);
|
||||
}
|
||||
|
||||
// TODO: This namespace is hereby deprecated as it was stupid. Delete it soon.
|
||||
namespace StdOut
|
||||
{
|
||||
size_t Print(const char* Message);
|
||||
}
|
||||
|
||||
size_t Print(const char* msg);
|
||||
size_t PrintF(const char* format, ...);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,24 +25,49 @@
|
|||
#include "platform.h"
|
||||
#include "syscall.h"
|
||||
#include "io.h"
|
||||
#include "format.h"
|
||||
|
||||
namespace Maxsi
|
||||
{
|
||||
DEFN_SYSCALL1(size_t, SysPrint, 4, const char*);
|
||||
|
||||
size_t Print(const char* Message)
|
||||
{
|
||||
return SysPrint(Message);
|
||||
}
|
||||
|
||||
// TODO: This namespace is hereby deprecated as it was stupid. Delete it soon.
|
||||
namespace StdOut
|
||||
{
|
||||
DEFN_SYSCALL1(size_t, SysPrint, 4, const char*);
|
||||
|
||||
size_t Print(const char* Message)
|
||||
{
|
||||
return SysPrint(Message);
|
||||
}
|
||||
}
|
||||
|
||||
size_t PrintCallback(void* user, const char* string, size_t stringlen)
|
||||
{
|
||||
return SysPrint(string);
|
||||
}
|
||||
|
||||
size_t PrintF(const char* format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
size_t result = Maxsi::Format::Virtual(PrintCallback, NULL, format, list);
|
||||
va_end(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef LIBMAXSI_LIBC
|
||||
extern "C" int printf(const char* /*restrict*/ format, ...)
|
||||
{
|
||||
// TODO: The format string is currently being ignored!
|
||||
return Print(format);
|
||||
}
|
||||
#endif
|
||||
extern "C" int printf(const char* /*restrict*/ format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
size_t result = Maxsi::Format::Virtual(PrintCallback, NULL, format, list);
|
||||
va_end(list);
|
||||
return (int) result;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue