mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
tiny-printf: Support vsnprintf()
Add a simple implementation of this function, to allow logging to be enabled in the SPL or TPL for systems that rely on the tiny printf() implementation. To keep the code size small, - The function is built only when logging is enabled, as it (currently) is not needed otherwise; and - Like the existing implementation of snprintf(), its buffer-size parameter is ignored. Signed-off-by: Simon South <simon@simonsouth.net>
This commit is contained in:
parent
54b6abae3a
commit
9b3fbb2b43
1 changed files with 16 additions and 0 deletions
|
@ -366,6 +366,22 @@ int sprintf(char *buf, const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if CONFIG_IS_ENABLED(LOG)
|
||||
/* Note that size is ignored */
|
||||
int vsnprintf(char *buf, size_t size, const char *fmt, va_list va)
|
||||
{
|
||||
struct printf_info info;
|
||||
int ret;
|
||||
|
||||
info.outstr = buf;
|
||||
info.putc = putc_outstr;
|
||||
ret = _vprintf(&info, fmt, va);
|
||||
*info.outstr = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Note that size is ignored */
|
||||
int snprintf(char *buf, size_t size, const char *fmt, ...)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue