mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Add a function forth_printf() which prints to openbios stdout.
Signed-off-by: Laurent Vivier <Laurent@vivier.eu> git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@628 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
23
libc/extra.c
23
libc/extra.c
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "openbios/config.h"
|
||||
#include "libc/string.h"
|
||||
#include "libc/vsprintf.h"
|
||||
#include "openbios/bindings.h"
|
||||
|
||||
/* strncpy without 0-pad */
|
||||
char *
|
||||
@@ -24,3 +26,24 @@ strncpy_nopad( char *dest, const char *src, size_t n )
|
||||
int len = MIN( n, strlen(src)+1 );
|
||||
return memcpy( dest, src, len );
|
||||
}
|
||||
|
||||
/* printf */
|
||||
|
||||
int forth_printf( const char *fmt, ... )
|
||||
{
|
||||
char buf[512];
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
i = vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
PUSH((ucell)buf);
|
||||
PUSH(i);
|
||||
fword("type");
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user