1 // Copyright 2009 Segher Boessenkool <segher@kernel.crashing.org>
2 // This code is licensed to you under the terms of the GNU GPL, version 2;
3 // see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
11 static void put(char c)
14 usbgecko_console_putc(c);
18 // __umoddi3() and friends are very big, and more general than we need:
19 // radix is always (very) small, so we can work by much bigger chunks
20 // than single bits, always.
21 static int extract_dig(u64 *x, u32 radix)
27 u32 n = (mod << 16) | (lo >> 16);
30 lo = (mod << 16) | (lo & 0xffff);
34 *x = ((u64)hi << 32) | lo;
39 // This implements conversions %{0}{number}{l,ll}[%cdsux] only.
40 // Field length is obeyed for numbers only.
43 int printf(const char *restrict format, ...)
64 while (*format >= '0' && *format <= '9')
65 prec = 10*prec + (*format++ - '0');
68 while (*format == 'l') {
87 char *s = va_arg(ap, char *);
105 x = va_arg(ap, long);
107 x = va_arg(ap, long long);
110 x = va_arg(ap, unsigned int);
112 x = va_arg(ap, unsigned long);
114 x = va_arg(ap, unsigned long long);
118 if ((long long)x < 0)
125 char *hld = &hold[sizeof hold];
130 int dig = extract_dig(&x, radix);
142 put(zero ? '0' : ' ');