#include <palacios/vmm_sprintf.h>
-#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 */
struct snprintf_arg {
- char *str;
- size_t remain;
+ char *str;
+ size_t remain;
};
+
+#if defined(CONFIG_BUILT_IN_STDIO) && \
+ ( defined(CONFIG_BUILT_IN_SPRINTF) || \
+ defined(CONFIG_BUILT_IN_SNPRINTF) || \
+ defined(CONFIG_BUILT_IN_VSPRINTF) || \
+ defined(CONFIG_BUILT_IN_VSNPRINTF) || \
+ defined(CONFIG_BUILT_IN_VSNRPRINTF ))
+
static char * ksprintn(char * nbuf, uint64_t num, int base, int *len, int upper);
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).
*/
#endif
-#if NEED_VSPRINTF
+#ifdef CONFIG_BUILT_IN_VSPRINTF
/*
* Scaled down version of vsprintf(3).
*/
#endif
-#if NEED_SNPRINTF
+#ifdef CONFIG_BUILT_IN_SNPRINTF
/*
* Scaled down version of snprintf(3).
*/
#endif
-#if NEED_VSNPRINTF
+#ifdef CONFIG_BUILT_IN_VSNPRINTF
/*
* Scaled down version of vsnprintf(3).
*/
#endif
-#if NEED_VSNRPRINTF
+#ifdef CONFIG_BUILT_IN_VSNRPRINTF
/*
* Kernel version which takes radix argument vsnprintf(3).
*/
#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) {
* 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;
}
-#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)
+#endif // CONFIG_BUILT_IN_STDIO
-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)
+ V3_Print("%s", hdr);
+
+ if ((flags & HD_OMIT_COUNT) == 0)
+ V3_Print("%04x ", i);
+
+ if ((flags & HD_OMIT_HEX) == 0) {
+ for (j = 0; j < cols; j++) {
+ k = i + j;
+ if (k < length)
+ V3_Print("%c%02x", delim, cp[k]);
+ else
+ V3_Print(" ");
+ }
+ }
- 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) {
+ V3_Print(" |");
+ for (j = 0; j < cols; j++) {
+ k = i + j;
+ if (k >= length)
+ V3_Print(" ");
+ else if (cp[k] >= ' ' && cp[k] <= '~')
+ V3_Print("%c", cp[k]);
+ else
+ V3_Print(".");
+ }
+ V3_Print("|");
}
+ V3_Print("\n");
+ }
}