X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_sprintf.c;h=cc8b79e5b6824d8051ec3188f5c52876eafe4cd3;hb=4c0aeefed7dec96dd1f70c2f8f3cc3db45abb621;hp=837cb6bea39d296c1d519d67e770ea2fa43077b9;hpb=3dd047dc0f70231ea93e5b3b40a9142a391bf507;p=palacios.git diff --git a/palacios/src/palacios/vmm_sprintf.c b/palacios/src/palacios/vmm_sprintf.c index 837cb6b..cc8b79e 100644 --- a/palacios/src/palacios/vmm_sprintf.c +++ b/palacios/src/palacios/vmm_sprintf.c @@ -66,11 +66,6 @@ #include -#define NEED_SPRINTF 1 -#define NEED_SNPRINTF 1 -#define NEED_VSPRINTF 1 -#define NEED_VSNPRINTF 1 -#define NEED_VSNRPRINTF 1 typedef addr_t ptrdiff_t; /* ptr1 - ptr2 */ @@ -86,8 +81,8 @@ static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; struct snprintf_arg { - char *str; - size_t remain; + char *str; + size_t remain; }; @@ -96,7 +91,7 @@ static void snprintf_func(int ch, void * arg); static int kvprintf(char const * fmt, void (*func)(int, void *), void * arg, int radix, va_list ap); -#if NEED_SPRINTF +#ifdef CONFIG_BUILT_IN_SPRINTF /* * Scaled down version of sprintf(3). */ @@ -113,7 +108,7 @@ int sprintf(char * buf, const char * cfmt, ...) { #endif -#if NEED_VSPRINTF +#ifdef CONFIG_BUILT_IN_VSPRINTF /* * Scaled down version of vsprintf(3). */ @@ -127,7 +122,7 @@ int vsprintf(char * buf, const char * cfmt, va_list ap) { #endif -#if NEED_SNPRINTF +#ifdef CONFIG_BUILT_IN_SNPRINTF /* * Scaled down version of snprintf(3). */ @@ -143,7 +138,7 @@ int snprintf(char * str, size_t size, const char * format, ...) { #endif -#if NEED_VSNPRINTF +#ifdef CONFIG_BUILT_IN_VSNPRINTF /* * Scaled down version of vsnprintf(3). */ @@ -162,7 +157,7 @@ int vsnprintf(char * str, size_t size, const char * format, va_list ap) { #endif -#if NEED_VSNRPRINTF +#ifdef CONFIG_BUILT_IN_VSNRPRINTF /* * Kernel version which takes radix argument vsnprintf(3). */ @@ -181,9 +176,7 @@ int vsnrprintf(char * str, size_t size, int radix, const char * format, va_list #endif -static void -snprintf_func(int ch, void *arg) -{ +static void snprintf_func(int ch, void *arg) { struct snprintf_arg *const info = arg; if (info->remain >= 2) { @@ -198,9 +191,7 @@ snprintf_func(int ch, void *arg) * written in the buffer (i.e., the first character of the string). * The buffer pointed to by `nbuf' must have length >= MAXNBUF. */ -static char * -ksprintn(char *nbuf, uint64_t num, int base, int *lenp, int upper) -{ +static char * ksprintn(char *nbuf, uint64_t num, int base, int *lenp, int upper) { char *p, c; p = nbuf; @@ -554,63 +545,56 @@ number: } -#define HD_COLUMN_MASK 0xff -#define HD_DELIM_MASK 0xff00 -#define HD_OMIT_COUNT (1 << 16) -#define HD_OMIT_HEX (1 << 17) -#define HD_OMIT_CHARS (1 << 18) -void -v3_hexdump(const void *ptr, int length, const char *hdr, int flags) -{ - int i, j, k; - int cols; - const unsigned char *cp; - char delim; - - if ((flags & HD_DELIM_MASK) != 0) - delim = (flags & HD_DELIM_MASK) >> 8; - else - delim = ' '; - - if ((flags & HD_COLUMN_MASK) != 0) - cols = flags & HD_COLUMN_MASK; - else - cols = 16; - - cp = ptr; - for (i = 0; i < length; i+= cols) { - if (hdr != NULL) - PrintDebug("%s", hdr); - - if ((flags & HD_OMIT_COUNT) == 0) - PrintDebug("%04x ", i); - - if ((flags & HD_OMIT_HEX) == 0) { - for (j = 0; j < cols; j++) { - k = i + j; - if (k < length) - PrintDebug("%c%02x", delim, cp[k]); - else - PrintDebug(" "); - } - } +void v3_hexdump(const void * ptr, int length, const char * hdr, int flags) { + int i, j, k; + int cols; + const unsigned char *cp; + char delim; + + if ((flags & HD_DELIM_MASK) != 0) + delim = (flags & HD_DELIM_MASK) >> 8; + else + delim = ' '; + + if ((flags & HD_COLUMN_MASK) != 0) + cols = flags & HD_COLUMN_MASK; + else + cols = 16; + + cp = ptr; + for (i = 0; i < length; i+= cols) { + if (hdr != NULL) + PrintDebug("%s", hdr); + + if ((flags & HD_OMIT_COUNT) == 0) + PrintDebug("%04x ", i); + + if ((flags & HD_OMIT_HEX) == 0) { + for (j = 0; j < cols; j++) { + k = i + j; + if (k < length) + PrintDebug("%c%02x", delim, cp[k]); + else + PrintDebug(" "); + } + } - if ((flags & HD_OMIT_CHARS) == 0) { - PrintDebug(" |"); - for (j = 0; j < cols; j++) { - k = i + j; - if (k >= length) - PrintDebug(" "); - else if (cp[k] >= ' ' && cp[k] <= '~') - PrintDebug("%c", cp[k]); - else - PrintDebug("."); - } - PrintDebug("|"); - } - PrintDebug("\n"); + if ((flags & HD_OMIT_CHARS) == 0) { + PrintDebug(" |"); + for (j = 0; j < cols; j++) { + k = i + j; + if (k >= length) + PrintDebug(" "); + else if (cp[k] >= ' ' && cp[k] <= '~') + PrintDebug("%c", cp[k]); + else + PrintDebug("."); + } + PrintDebug("|"); } + PrintDebug("\n"); + } }