Print this page
12208 dboot_printf(): support %u
*** 19,28 ****
--- 19,29 ----
* CDDL HEADER END
*/
/*
* Copyright (c) 2012 Gary Mills
+ * Copyright 2020 Joyent, Inc.
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
*** 91,101 ****
++s;
}
}
static void
! dboot_putnum(uint64_t x, uint_t is_signed, uint8_t base)
{
char buffer[64]; /* digits in reverse order */
int i;
if (is_signed && (int64_t)x < 0) {
--- 92,102 ----
++s;
}
}
static void
! dboot_putnum(uint64_t x, boolean_t is_signed, uint8_t base)
{
char buffer[64]; /* digits in reverse order */
int i;
if (is_signed && (int64_t)x < 0) {
*** 112,131 ****
while (i >= 0)
bcons_putchar(buffer[i--]);
}
/*
! * very primitive printf - only does %s, %d, %x, %lx, or %%
*/
static void
do_dboot_printf(char *fmt, va_list args)
{
char *s;
uint64_t x;
uint8_t base;
uint8_t size;
- uint_t is_signed = 1;
if (fmt == NULL) {
dboot_puts("dboot_printf(): 1st arg is NULL\n");
return;
}
--- 113,131 ----
while (i >= 0)
bcons_putchar(buffer[i--]);
}
/*
! * Very primitive printf - only does a subset of the standard format characters.
*/
static void
do_dboot_printf(char *fmt, va_list args)
{
char *s;
uint64_t x;
uint8_t base;
uint8_t size;
if (fmt == NULL) {
dboot_puts("dboot_printf(): 1st arg is NULL\n");
return;
}
*** 157,167 ****
dboot_puts(s);
break;
case 'p':
x = va_arg(args, ulong_t);
! dboot_putnum(x, !is_signed, 16);
break;
case 'l':
if (size == 0)
size = sizeof (long);
--- 157,167 ----
dboot_puts(s);
break;
case 'p':
x = va_arg(args, ulong_t);
! dboot_putnum(x, B_FALSE, 16);
break;
case 'l':
if (size == 0)
size = sizeof (long);
*** 174,186 ****
x = va_arg(args, int);
else if (size == sizeof (long))
x = va_arg(args, long);
else
x = va_arg(args, long long);
! dboot_putnum(x, is_signed, 10);
break;
case 'b':
base = 2;
goto unsigned_num;
case 'o':
--- 174,190 ----
x = va_arg(args, int);
else if (size == sizeof (long))
x = va_arg(args, long);
else
x = va_arg(args, long long);
! dboot_putnum(x, B_TRUE, 10);
break;
+ case 'u':
+ base = 10;
+ goto unsigned_num;
+
case 'b':
base = 2;
goto unsigned_num;
case 'o':
*** 190,204 ****
case 'x':
base = 16;
unsigned_num:
if (size == 0)
x = va_arg(args, uint_t);
! else if (size == sizeof (long))
x = va_arg(args, ulong_t);
else
x = va_arg(args, unsigned long long);
! dboot_putnum(x, !is_signed, base);
break;
default:
dboot_puts("dboot_printf(): unknown % escape\n");
}
--- 194,208 ----
case 'x':
base = 16;
unsigned_num:
if (size == 0)
x = va_arg(args, uint_t);
! else if (size == sizeof (ulong_t))
x = va_arg(args, ulong_t);
else
x = va_arg(args, unsigned long long);
! dboot_putnum(x, B_FALSE, base);
break;
default:
dboot_puts("dboot_printf(): unknown % escape\n");
}