All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][IOEMU] Build fixes for BSD
@ 2008-12-11 17:20 Christoph Egger
  2008-12-11 17:49 ` Ian Jackson
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Egger @ 2008-12-11 17:20 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]


Hi,

Attached patch fixes ioemu build for NetBSD.
All changes (apart from hw/battery_mgmt.h) are from qemu upstream.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>

-- 
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy

[-- Attachment #2: xen_ioemu.diff --]
[-- Type: text/x-diff, Size: 15195 bytes --]

diff --git a/audio/audio.c b/audio/audio.c
index cca77dd..dabbeaf 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -215,7 +215,7 @@ static char *audio_alloc_prefix (const char *s)
         pstrcat (r, len + sizeof (qemu_prefix), s);
 
         for (i = 0; i < len; ++i) {
-            u[i] = CTYPE(toupper, u[i]);
+            u[i] = qemu_toupper(u[i]);
         }
     }
     return r;
@@ -470,7 +470,7 @@ static void audio_process_options (const char *prefix,
 
         /* copy while upper-casing, including trailing zero */
         for (i = 0; i <= preflen; ++i) {
-            optname[i + sizeof (qemu_prefix) - 1] = CTYPE(toupper, prefix[i]);
+            optname[i + sizeof (qemu_prefix) - 1] = qemu_toupper(prefix[i]);
         }
         pstrcat (optname, optlen, "_");
         pstrcat (optname, optlen, opt->name);
diff --git a/block-vvfat.c b/block-vvfat.c
index 52d15ee..d47a6f4 100644
--- a/block-vvfat.c
+++ b/block-vvfat.c
@@ -1052,7 +1052,7 @@ DLOG(if (stderr == NULL) {
 
     i = strrchr(dirname, ':') - dirname;
     assert(i >= 3);
-    if (dirname[i-2] == ':' && CTYPE(isalpha,dirname[i-1]))
+    if (dirname[i-2] == ':' && qemu_isalpha(dirname[i-1]))
 	/* workaround for DOS drive names */
 	dirname += i-1;
     else
@@ -1479,7 +1479,7 @@ static int parse_short_name(BDRVVVFATState* s,
 	if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)
 	    return -1;
 	else if (s->downcase_short_names)
-	    lfn->name[i] = CTYPE(tolower,direntry->name[i]);
+	    lfn->name[i] = qemu_tolower(direntry->name[i]);
 	else
 	    lfn->name[i] = direntry->name[i];
     }
@@ -1492,7 +1492,7 @@ static int parse_short_name(BDRVVVFATState* s,
 	    if (direntry->extension[j] <= ' ' || direntry->extension[j] > 0x7f)
 		return -2;
 	    else if (s->downcase_short_names)
-		lfn->name[i + j] = CTYPE(tolower,direntry->extension[j]);
+		lfn->name[i + j] = qemu_tolower(direntry->extension[j]);
 	    else
 		lfn->name[i + j] = direntry->extension[j];
 	}
diff --git a/block.c b/block.c
index 8eadd6e..0856976 100644
--- a/block.c
+++ b/block.c
@@ -21,6 +21,12 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#include "config-host.h"
+#ifdef _BSD
+/* include native header before sys-queue.h */
+#include <sys/queue.h>
+#endif
+
 #include "qemu-common.h"
 #include "console.h"
 #include "block_int.h"
diff --git a/configure b/configure
index 2ec19d7..5ba7a64 100755
--- a/configure
+++ b/configure
@@ -143,14 +143,15 @@ FreeBSD)
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd pa"
-if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
-    kqemu="yes"
-fi
+oss_lib="-lossaudio"
+aio_lib="-lpthread"
 ;;
 NetBSD)
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
+oss_lib="-lossaudio"
+aio_lib="-lrt -lpthread"
 ;;
 OpenBSD)
 bsd="yes"
@@ -158,6 +159,7 @@ openbsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
 oss_lib="-lossaudio"
+aio_lib="-lpthread"
 ;;
 Darwin)
 bsd="yes"
@@ -168,6 +170,7 @@ audio_drv_list="coreaudio"
 audio_possible_drivers="coreaudio sdl fmod"
 OS_CFLAGS="-mdynamic-no-pic"
 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
+aio_lib="-lpthread"
 ;;
 SunOS)
     solaris="yes"
@@ -500,7 +503,7 @@ fi
 if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
     AIOLIBS=
 elif [ "$bsd" = "yes" ]; then
-    AIOLIBS="-lpthread"
+    AIOLIBS="$aio_lib"
 else
     # Some Linux architectures (e.g. s390) don't imply -lpthread automatically.
     AIOLIBS="-lrt -lpthread"
diff --git a/cutils.c b/cutils.c
index 97d6080..7ebc5b9 100644
--- a/cutils.c
+++ b/cutils.c
@@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr)
     p = str;
     q = val;
     while (*q != '\0') {
-        if (CTYPE(toupper,*p) != CTYPE(toupper,*q))
+        if (qemu_toupper(*p) != qemu_toupper(*q))
             return 0;
         p++;
         q++;
diff --git a/hw/battery_mgmt.h b/hw/battery_mgmt.h
index dd60160..4a4ac8e 100644
--- a/hw/battery_mgmt.h
+++ b/hw/battery_mgmt.h
@@ -25,6 +25,9 @@
 #ifdef CONFIG_STUBDOM
 #define CONFIG_NO_BATTERY_MGMT
 #endif
+#ifdef _BSD /* There's no ioperm(), outb(), inb() */
+#define CONFIG_NO_BATTERY_MGMT
+#endif
 
 enum POWER_MGMT_MODE { PM_MODE_NONE = 0, PM_MODE_PT, PM_MODE_NON_PT };
 enum BATTERY_INFO_TYPE { BATT_NONE, BIF, BST };
diff --git a/monitor.c b/monitor.c
index 842d030..9eab786 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1923,7 +1923,7 @@ static void next(void)
 {
     if (pch != '\0') {
         pch++;
-        while (CTYPE(isspace,*pch))
+        while (qemu_isspace(*pch))
             pch++;
     }
 }
@@ -1982,7 +1982,7 @@ static int64_t expr_unary(void)
                     *q++ = *pch;
                 pch++;
             }
-            while (CTYPE(isspace,*pch))
+            while (qemu_isspace(*pch))
                 pch++;
             *q = 0;
             ret = get_monitor_def(&reg, buf);
@@ -2007,7 +2007,7 @@ static int64_t expr_unary(void)
             expr_error("invalid char in expression");
         }
         pch = p;
-        while (CTYPE(isspace,*pch))
+        while (qemu_isspace(*pch))
             pch++;
         break;
     }
@@ -2101,7 +2101,7 @@ static int get_expr(int64_t *pval, const char **pp)
         *pp = pch;
         return -1;
     }
-    while (CTYPE(isspace,*pch))
+    while (qemu_isspace(*pch))
         pch++;
     *pval = expr_sum();
     *pp = pch;
@@ -2116,7 +2116,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
 
     q = buf;
     p = *pp;
-    while (CTYPE(isspace,*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p == '\0') {
     fail:
@@ -2161,7 +2161,7 @@ static int get_str(char *buf, int buf_size, const char **pp)
         }
         p++;
     } else {
-        while (*p != '\0' && !CTYPE(isspace,*p)) {
+        while (*p != '\0' && !qemu_isspace(*p)) {
             if ((q - buf) < buf_size - 1) {
                 *q++ = *p;
             }
@@ -2207,12 +2207,12 @@ static void monitor_handle_command(const char *cmdline)
     /* extract the command name */
     p = cmdline;
     q = cmdname;
-    while (CTYPE(isspace,*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p == '\0')
         return;
     pstart = p;
-    while (*p != '\0' && *p != '/' && !CTYPE(isspace,*p))
+    while (*p != '\0' && *p != '/' && !qemu_isspace(*p))
         p++;
     len = p - pstart;
     if (len > sizeof(cmdname) - 1)
@@ -2248,7 +2248,7 @@ static void monitor_handle_command(const char *cmdline)
                 int ret;
                 char *str;
 
-                while (CTYPE(isspace,*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*typestr == '?') {
                     typestr++;
@@ -2289,15 +2289,15 @@ static void monitor_handle_command(const char *cmdline)
             {
                 int count, format, size;
 
-                while (CTYPE(isspace,*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*p == '/') {
                     /* format found */
                     p++;
                     count = 1;
-                    if (isdigit(*p)) {
+                    if (qemu_isdigit(*p)) {
                         count = 0;
-                        while (isdigit(*p)) {
+                        while (qemu_isdigit(*p)) {
                             count = count * 10 + (*p - '0');
                             p++;
                         }
@@ -2336,7 +2336,7 @@ static void monitor_handle_command(const char *cmdline)
                         }
                     }
                 next:
-                    if (*p != '\0' && !CTYPE(isspace,*p)) {
+                    if (*p != '\0' && !qemu_isspace(*p)) {
                         term_printf("invalid char in format: '%c'\n", *p);
                         goto fail;
                     }
@@ -2370,7 +2370,7 @@ static void monitor_handle_command(const char *cmdline)
             {
                 int64_t val;
 
-                while (CTYPE(isspace,*p))
+                while (qemu_isspace(*p))
                     p++;
                 if (*typestr == '?' || *typestr == '.') {
                     if (*typestr == '?') {
@@ -2381,7 +2381,7 @@ static void monitor_handle_command(const char *cmdline)
                     } else {
                         if (*p == '.') {
                             p++;
-                            while (CTYPE(isspace,*p))
+                            while (qemu_isspace(*p))
                                 p++;
                             has_arg = 1;
                         } else {
@@ -2426,7 +2426,7 @@ static void monitor_handle_command(const char *cmdline)
                 c = *typestr++;
                 if (c == '\0')
                     goto bad_type;
-                while (CTYPE(isspace,*p))
+                while (qemu_isspace(*p))
                     p++;
                 has_option = 0;
                 if (*p == '-') {
@@ -2451,7 +2451,7 @@ static void monitor_handle_command(const char *cmdline)
         }
     }
     /* check that all arguments were parsed */
-    while (CTYPE(isspace,*p))
+    while (qemu_isspace(*p))
         p++;
     if (*p != '\0') {
         term_printf("%s: extraneous characters at the end of line\n",
@@ -2599,7 +2599,7 @@ static void parse_cmdline(const char *cmdline,
     p = cmdline;
     nb_args = 0;
     for(;;) {
-        while (CTYPE(isspace,*p))
+        while (qemu_isspace(*p))
             p++;
         if (*p == '\0')
             break;
@@ -2633,7 +2633,7 @@ void readline_find_completion(const char *cmdline)
     /* if the line ends with a space, it means we want to complete the
        next arg */
     len = strlen(cmdline);
-    if (len > 0 && CTYPE(isspace,cmdline[len - 1])) {
+    if (len > 0 && qemu_isspace(cmdline[len - 1])) {
         if (nb_args >= MAX_ARGS)
             return;
         args[nb_args++] = qemu_strdup("");
diff --git a/qemu-common.h b/qemu-common.h
index 9f14f69..006998b 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -86,16 +86,21 @@ int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
 time_t mktimegm(struct tm *tm);
 
-#define CTYPE(isfoobar,argumentchar) (isfoobar((unsigned char)(argumentchar)))
-  /* One must not pass a plain `char' to isupper, toupper, et al.  If
-   * it has the top bit set (ie, is negative if your chars are
-   * signed), undefined behaviour results.  The <ctype.h> functions
-   * are defined to take the value of an unsigned char, as an int.
-   * So use this macro.  You may pass toupper et al for isfoobar.
-   * Do not pass EOF as a character to this macro.  If you might have
-   * EOF then you ought to have it in an int representing an unsigned
-   * char, which is safe for the ctype macros directly.  Or test separately.
-   * Obviously don't use this for floating point things like isnan! */
+#define qemu_isalnum(c)		isalnum((unsigned char)(c))
+#define qemu_isalpha(c)		isalpha((unsigned char)(c))
+#define qemu_iscntrl(c)		iscntrl((unsigned char)(c))
+#define qemu_isdigit(c)		isdigit((unsigned char)(c))
+#define qemu_isgraph(c)		isgraph((unsigned char)(c))
+#define qemu_islower(c)		islower((unsigned char)(c))
+#define qemu_isprint(c)		isprint((unsigned char)(c))
+#define qemu_ispunct(c)		ispunct((unsigned char)(c))
+#define qemu_isspace(c)		isspace((unsigned char)(c))
+#define qemu_isupper(c)		isupper((unsigned char)(c))
+#define qemu_isxdigit(c)	isxdigit((unsigned char)(c))
+#define qemu_tolower(c)		tolower((unsigned char)(c))
+#define qemu_toupper(c)		toupper((unsigned char)(c))
+#define qemu_isascii(c)		isascii((unsigned char)(c))
+#define qemu_toascii(c)		toascii((unsigned char)(c))
 
 void *qemu_malloc(size_t size);
 void *qemu_realloc(void *ptr, size_t size);
diff --git a/readline.c b/readline.c
index ad10e1e..e1e963a 100644
--- a/readline.c
+++ b/readline.c
@@ -169,7 +169,7 @@ static void term_backword(void)
 
     /* find first word (backwards) */
     while (start > 0) {
-        if (!CTYPE(isspace,term_cmd_buf[start])) {
+        if (!qemu_isspace(term_cmd_buf[start])) {
             break;
         }
 
@@ -178,7 +178,7 @@ static void term_backword(void)
 
     /* find first space (backwards) */
     while (start > 0) {
-        if (CTYPE(isspace,term_cmd_buf[start])) {
+        if (qemu_isspace(term_cmd_buf[start])) {
             ++start;
             break;
         }
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index b26366f..dda2bd4 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9459,7 +9459,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name)
         p = name;
     check_pvr:
         for (i = 0; i < 8; i++) {
-            if (!CTYPE(isxdigit,*p++))
+            if (!qemu_isxdigit(*p++))
                 break;
         }
         if (i == 8)
diff --git a/usb-linux.c b/usb-linux.c
index 419049e..8fdb1a7 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1048,7 +1048,7 @@ static int get_tag_value(char *buf, int buf_size,
     if (!p)
         return -1;
     p += strlen(tag);
-    while (CTYPE(isspace,*p))
+    while (qemu_isspace(*p))
         p++;
     q = buf;
     while (*p != '\0' && !strchr(stopchars, *p)) {
diff --git a/vl.c b/vl.c
index 5cb54cf..40a7ead 100644
--- a/vl.c
+++ b/vl.c
@@ -57,26 +57,31 @@
 #include <termios.h>
 #include <sys/mman.h>
 #include <sys/ioctl.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <net/if.h>
+#if defined(__NetBSD__)
+#include <net/if_tap.h>
+#endif
+#ifdef __linux__
+#include <linux/if_tun.h>
+#endif
+#include <arpa/inet.h>
 #include <dirent.h>
 #include <netdb.h>
 #include <sys/select.h>
-#include <arpa/inet.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#if !defined(__APPLE__) && !defined(__OpenBSD__)
+#ifdef __FreeBSD__
 #include <libutil.h>
-#endif
-#ifdef __OpenBSD__
-#include <net/if.h>
+#else
+#include <util.h>
 #endif
 #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
 #include <freebsd/stdlib.h>
 #else
 #ifdef __linux__
-#include <linux/if.h>
-#include <linux/if_tun.h>
 #include <pty.h>
 #include <malloc.h>
 #include <linux/rtc.h>
@@ -4035,7 +4040,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)
     if (buf[0] == '\0') {
         saddr->sin_addr.s_addr = 0;
     } else {
-        if (CTYPE(isdigit,buf[0])) {
+        if (qemu_isdigit(buf[0])) {
             if (!inet_aton(buf, &saddr->sin_addr))
                 return -1;
         } else {
@@ -4415,10 +4420,13 @@ static int tap_open(char *ifname, int ifname_size)
 #ifndef TAPGIFNAME
     char *dev;
     struct stat s;
+#else
+    struct ifreq ifr;
 #endif
 
     TFR(fd = open("/dev/tap", O_RDWR));
     if (fd < 0) {
+        fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation %s\n", strerror(errno));
         return -1;
     }
 
@@ -4461,7 +4469,7 @@ int tap_alloc(char *dev, size_t dev_size)
 
     if( *dev ){
        ptr = dev;
-       while( *ptr && !CTYPE(isdigit,(int)*ptr) ) ptr++;
+       while( *ptr && !qemu_isdigit((int)*ptr) ) ptr++;
        ppa = atoi(ptr);
     }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-11 17:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-11 17:20 [PATCH][IOEMU] Build fixes for BSD Christoph Egger
2008-12-11 17:49 ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.