2 * Copyright (C) 2015 Virtual Open Systems SAS
3 * Author: Alexander Spyridakis <a.spyridakis@virtualopensystems.com>
5 * printf based on implementation by Kevin Wolf <kwolf@redhat.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * SPDX-License-Identifier: GPL-2.0-only
16 typedef __builtin_va_list
va_list;
17 #define va_start(ap, X) __builtin_va_start(ap, X)
18 #define va_arg(ap, type) __builtin_va_arg(ap, type)
19 #define va_end(ap) __builtin_va_end(ap)
21 static void print_str(char *s
)
28 static void print_num(unsigned long long value
, int base
)
30 char digits
[] = "0123456789abcdef";
32 int i
= sizeof(buf
) - 2, j
;
34 /* Set the buffer to 0. See problem of before. */
35 for (j
= 0; j
< 32; j
++) {
40 buf
[i
--] = digits
[value
% base
];
44 print_str(&buf
[i
+ 1]);
47 void ml_printf(const char *fmt
, ...)
54 unsigned long long val
;
101 val
= va_arg(ap
, unsigned int);
104 val
= va_arg(ap
, unsigned long);
107 val
= va_arg(ap
, unsigned long long);
111 if (alt_form
&& base
== 16) {
115 print_num(val
, base
);
119 str
= va_arg(ap
, char*);