diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | kern/printf.c | 29 | ||||
-rw-r--r-- | kern/printf.h | 2 |
3 files changed, 24 insertions, 9 deletions
diff --git a/Makefile.am b/Makefile.am index 913db55..76a192b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -159,7 +159,7 @@ noinst_PROGRAMS += \ clib_routines := memcmp memcpy memmove \ strchr strstr strsep strtok \ htonl htons ntohl ntohs \ - udivdi3 __udivdi3 \ + udivdi3 __udivdi3 __umoddi3 \ __rel_iplt_start __rel_iplt_end \ __ffsdi2 \ _START _start etext _edata end _end # actually ld magic, not libc. diff --git a/kern/printf.c b/kern/printf.c index 1db0d08..13f2dc0 100644 --- a/kern/printf.c +++ b/kern/printf.c @@ -126,11 +126,11 @@ #define isdigit(d) ((d) >= '0' && (d) <= '9') #define Ctod(c) ((c) - '0') -#define MAXBUF (sizeof(long int) * 8) /* enough for binary */ +#define MAXBUF (sizeof(long long int) * 8) /* enough for binary */ void printnum( - unsigned long u, + unsigned long long u, int base, void (*putc)( char, vm_offset_t ), vm_offset_t putc_arg) @@ -178,8 +178,9 @@ void _doprnt( int prec; boolean_t ladjust; char padc; - long n; - unsigned long u; + long long n; + unsigned long long u; + int have_long_long; int plus_sign; int sign_char; boolean_t altfmt, truncate; @@ -218,6 +219,7 @@ void _doprnt( plus_sign = 0; sign_char = 0; altfmt = FALSE; + have_long_long = FALSE; while (TRUE) { c = *fmt; @@ -276,6 +278,10 @@ void _doprnt( if (c == 'l') c = *++fmt; /* need it if sizeof(int) < sizeof(long) */ + if (c == 'l') { + c = *++fmt; /* handle `long long' */ + have_long_long = TRUE; + } truncate = FALSE; @@ -287,7 +293,10 @@ void _doprnt( boolean_t any; int i; - u = va_arg(argp, unsigned long); + if (! have_long_long) + u = va_arg(argp, unsigned long); + else + u = va_arg(argp, unsigned long long); p = va_arg(argp, char *); base = *p++; printnum(u, base, putc, putc_arg); @@ -431,7 +440,10 @@ void _doprnt( goto print_unsigned; print_signed: - n = va_arg(argp, long); + if (! have_long_long) + n = va_arg(argp, long); + else + n = va_arg(argp, long long); if (n >= 0) { u = n; sign_char = plus_sign; @@ -443,7 +455,10 @@ void _doprnt( goto print_num; print_unsigned: - u = va_arg(argp, unsigned long); + if (! have_long_long) + u = va_arg(argp, unsigned long); + else + u = va_arg(argp, unsigned long long); goto print_num; print_num: diff --git a/kern/printf.h b/kern/printf.h index 86857d3..76047f0 100644 --- a/kern/printf.h +++ b/kern/printf.h @@ -35,7 +35,7 @@ extern void _doprnt (const char *fmt, int radix, vm_offset_t putc_arg); -extern void printnum (unsigned long u, int base, +extern void printnum (unsigned long long u, int base, void (*putc)(char, vm_offset_t), vm_offset_t putc_arg); |