print.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/inttypes.h>
/*
* Printn prints a number n in base b.
* We don't use recursion to avoid deep stacks.
*/
static void
{
char prbuf[65];
char *cp;
do {
*cp++ = "0123456789abcdef"[n%b];
n /= b;
width--;
} while (n);
while (width-- > 0)
do {
}
/*
* This routine is highly specific to amd64, and is essentially a
* complete kludge which allows amd64 to print using the 64-bit regs
* from an LP64 kernel.
*
* The worst part about it is the assumptions around decoding string
* pointers -- we assume that the top bits of the string pointer can
* be discarded yet still remain as a valid address.
*
* cell size == sizeof (long long)
*/
static void
const char *fmt,
void (*put)(void *, int),
void *arg)
{
char *s;
int64_t l;
loop:
while ((c = *fmt++) != '%') {
if (c == '\0')
goto out;
}
c = *fmt++;
pad = '0';
ells++;
switch (c) {
case 'd':
case 'D':
b = 10;
if (ells == 0)
else if (ells == 1)
else
if (l < 0) {
width--;
ul = -l;
} else
ul = l;
goto number;
case 'p':
ells = 1;
/*FALLTHROUGH*/
case 'x':
case 'X':
b = 16;
goto u_number;
case 'u':
b = 10;
goto u_number;
case 'o':
case 'O':
b = 8;
if (ells == 0)
else if (ells == 1)
else
break;
case 'c':
for (i = 24; i >= 0; i -= 8)
if ((c = ((b >> i) & 0x7f)) != 0)
break;
/*
* Yuck. We're encoding the assumption that a valid 32-bit pointer
* can be obtained by simply truncating the 64-bit pointer.
*/
case 's':
while ((c = *s++) != 0)
break;
case '%':
break;
default:
break;
}
goto loop;
out:
;
}
struct strbuf {
char *sb_base;
char *sb_ptr;
};
static void
{
if (c == '\n')
else
}
static int
{
int count;
sb->sb_maxsize = n;
/*
* Ensure there's a trailing NULL to terminate the string
*/
if (sb->sb_maxsize == 0)
return (count);
}
/*
* Specialized vsnprintf() that is used to print arguments from
* an environment where the native argument size is 64-bit
*/
int
{
}
int
{
int r;
return (r);
}
struct amd64buf {
char *vb_base;
char *vb_ptr;
};
void
{
printf("amd64_panic: ");
printf("\n");
}
void
amd64_panic(const char *fmt, ...)
{
}
void
amd64_warning(const char *fmt, ...)
{
printf("amd64 warning: ");
printf("\n");
}