2013-12-17 18:19:04 +00:00
|
|
|
/*
|
2014-01-14 18:17:09 +00:00
|
|
|
* Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
|
2013-12-17 18:19:04 +00:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2013-12-17 18:19:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2013-12-12 16:46:30 +00:00
|
|
|
/* Choose max of 128 chars for now. */
|
2013-12-17 18:19:04 +00:00
|
|
|
#define PRINT_BUFFER_SIZE 128
|
|
|
|
int printf(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
char buf[PRINT_BUFFER_SIZE];
|
2013-12-12 16:46:30 +00:00
|
|
|
int count;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
2013-12-17 18:19:04 +00:00
|
|
|
vsnprintf(buf, sizeof(buf) - 1, fmt, args);
|
2013-12-12 16:46:30 +00:00
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
/* Use putchar directly as 'puts()' adds a newline. */
|
2013-12-17 18:19:04 +00:00
|
|
|
buf[PRINT_BUFFER_SIZE - 1] = '\0';
|
2013-12-12 16:46:30 +00:00
|
|
|
count = 0;
|
|
|
|
while (buf[count])
|
|
|
|
{
|
|
|
|
if (putchar(buf[count]) != EOF) {
|
|
|
|
count++;
|
|
|
|
} else {
|
|
|
|
count = EOF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
2013-12-17 18:19:04 +00:00
|
|
|
}
|