aboutsummaryrefslogtreecommitdiff
path: root/osdep.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep.c')
-rw-r--r--osdep.c195
1 files changed, 0 insertions, 195 deletions
diff --git a/osdep.c b/osdep.c
index ffa29fe8e4..c1dd294e6e 100644
--- a/osdep.c
+++ b/osdep.c
@@ -112,13 +112,6 @@ __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; p
return __res; \
}
-int qemu_write(int fd, const void *buf, size_t n)
-{
- QEMU_SYSCALL3(write, fd, buf, n);
-}
-
-
-
/****************************************************************/
/* shmat replacement */
@@ -284,16 +277,6 @@ void *get_mmap_addr(unsigned long size)
#include <malloc.h>
#endif
-int qemu_write(int fd, const void *buf, size_t n)
-{
- int ret;
- ret = write(fd, buf, n);
- if (ret < 0)
- return -errno;
- else
- return ret;
-}
-
void *get_mmap_addr(unsigned long size)
{
return NULL;
@@ -462,181 +445,3 @@ char *qemu_strdup(const char *str)
strcpy(ptr, str);
return ptr;
}
-
-/****************************************************************/
-/* printf support */
-
-static inline int qemu_isdigit(int c)
-{
- return c >= '0' && c <= '9';
-}
-
-#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
-
-/* from BSD ppp sources */
-int qemu_vsnprintf(char *buf, int buflen, const char *fmt, va_list args)
-{
- int c, i, n;
- int width, prec, fillch;
- int base, len, neg;
- unsigned long val = 0;
- const char *f;
- char *str, *buf0;
- char num[32];
- static const char hexchars[] = "0123456789abcdef";
-
- buf0 = buf;
- --buflen;
- while (buflen > 0) {
- for (f = fmt; *f != '%' && *f != 0; ++f)
- ;
- if (f > fmt) {
- len = f - fmt;
- if (len > buflen)
- len = buflen;
- memcpy(buf, fmt, len);
- buf += len;
- buflen -= len;
- fmt = f;
- }
- if (*fmt == 0)
- break;
- c = *++fmt;
- width = prec = 0;
- fillch = ' ';
- if (c == '0') {
- fillch = '0';
- c = *++fmt;
- }
- if (c == '*') {
- width = va_arg(args, int);
- c = *++fmt;
- } else {
- while (qemu_isdigit(c)) {
- width = width * 10 + c - '0';
- c = *++fmt;
- }
- }
- if (c == '.') {
- c = *++fmt;
- if (c == '*') {
- prec = va_arg(args, int);
- c = *++fmt;
- } else {
- while (qemu_isdigit(c)) {
- prec = prec * 10 + c - '0';
- c = *++fmt;
- }
- }
- }
- /* modifiers */
- switch(c) {
- case 'l':
- c = *++fmt;
- break;
- default:
- break;
- }
- str = 0;
- base = 0;
- neg = 0;
- ++fmt;
- switch (c) {
- case 'd':
- i = va_arg(args, int);
- if (i < 0) {
- neg = 1;
- val = -i;
- } else
- val = i;
- base = 10;
- break;
- case 'o':
- val = va_arg(args, unsigned int);
- base = 8;
- break;
- case 'x':
- case 'X':
- val = va_arg(args, unsigned int);
- base = 16;
- break;
- case 'p':
- val = (unsigned long) va_arg(args, void *);
- base = 16;
- neg = 2;
- break;
- case 's':
- str = va_arg(args, char *);
- break;
- case 'c':
- num[0] = va_arg(args, int);
- num[1] = 0;
- str = num;
- break;
- default:
- *buf++ = '%';
- if (c != '%')
- --fmt; /* so %z outputs %z etc. */
- --buflen;
- continue;
- }
- if (base != 0) {
- str = num + sizeof(num);
- *--str = 0;
- while (str > num + neg) {
- *--str = hexchars[val % base];
- val = val / base;
- if (--prec <= 0 && val == 0)
- break;
- }
- switch (neg) {
- case 1:
- *--str = '-';
- break;
- case 2:
- *--str = 'x';
- *--str = '0';
- break;
- }
- len = num + sizeof(num) - 1 - str;
- } else {
- len = strlen(str);
- if (prec > 0 && len > prec)
- len = prec;
- }
- if (width > 0) {
- if (width > buflen)
- width = buflen;
- if ((n = width - len) > 0) {
- buflen -= n;
- for (; n > 0; --n)
- *buf++ = fillch;
- }
- }
- if (len > buflen)
- len = buflen;
- memcpy(buf, str, len);
- buf += len;
- buflen -= len;
- }
- *buf = 0;
- return buf - buf0;
-}
-
-void qemu_vprintf(const char *fmt, va_list ap)
-{
- char buf[1024];
- int len;
-
- len = qemu_vsnprintf(buf, sizeof(buf), fmt, ap);
- qemu_write(1, buf, len);
-}
-
-void qemu_printf(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- qemu_vprintf(fmt, ap);
- va_end(ap);
-}
-