summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSoby Mathew <soby.mathew@arm.com>2017-09-04 11:45:52 +0100
committerSoby Mathew <soby.mathew@arm.com>2017-09-11 15:35:41 +0100
commit2d7e82823dc28ccfa776dc0ecdaeeda8c465bf62 (patch)
treeed0cda0ed2f65b3acdbabd772ef92b32e905f6f5 /common
parent8b6385deb379c1e36e2d729e5c5dd9a5f30bb04f (diff)
Introduce tf_vprintf() and tf_string_print()
This patch introduces tf_vprintf() and tf_string_print() APIs which is needed by the logging framework introduced in a later patch. Change-Id: Ie4240443d0e04e070502b51e371e546dd469fd33 Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Diffstat (limited to 'common')
-rw-r--r--common/tf_printf.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/common/tf_printf.c b/common/tf_printf.c
index c18e2f99..f73842ac 100644
--- a/common/tf_printf.c
+++ b/common/tf_printf.c
@@ -23,8 +23,10 @@
(((lcount) > 1) ? va_arg(args, unsigned long long int) : \
((lcount) ? va_arg(args, unsigned long int) : va_arg(args, unsigned int)))
-static void string_print(const char *str)
+void tf_string_print(const char *str)
{
+ assert(str);
+
while (*str)
putchar(*str++);
}
@@ -64,15 +66,13 @@ static void unsigned_num_print(unsigned long long int unum, unsigned int radix)
* The print exits on all other formats specifiers other than valid
* combinations of the above specifiers.
*******************************************************************/
-void tf_printf(const char *fmt, ...)
+void tf_vprintf(const char *fmt, va_list args)
{
- va_list args;
int l_count;
long long int num;
unsigned long long int unum;
char *str;
- va_start(args, fmt);
while (*fmt) {
l_count = 0;
@@ -94,12 +94,12 @@ loop:
break;
case 's':
str = va_arg(args, char *);
- string_print(str);
+ tf_string_print(str);
break;
case 'p':
unum = (uintptr_t)va_arg(args, void *);
if (unum)
- string_print("0x");
+ tf_string_print("0x");
unsigned_num_print(unum, 16);
break;
@@ -123,13 +123,20 @@ loop:
break;
default:
/* Exit on any other format specifier */
- goto exit;
+ return;
}
fmt++;
continue;
}
putchar(*fmt++);
}
-exit:
- va_end(args);
+}
+
+void tf_printf(const char *fmt, ...)
+{
+ va_list va;
+
+ va_start(va, fmt);
+ tf_vprintf(fmt, va);
+ va_end(va);
}