Skip to contentSkip to conversation

[5889] Make struct iovec universally available

Qemu-devel Applied Anthony Liguori 3 participants 7 messages Dec 5, 2008 – Dec 6, 2008

lore
Share & tools
lore
#0 lore raw

Revision: 5889

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5889
Author:   aliguori
Date:     2008-12-05 20:05:26 +0000 (Fri, 05 Dec 2008)

Log Message:
-----------
Make struct iovec universally available

Vectored IO APIs will require some sort of vector argument. It makes sense to use struct iovec and just define it globally for Windows.

Modified Paths:
--------------
trunk/configure
trunk/hw/virtio.h
trunk/qemu-common.h
trunk/slirp/socket.c
trunk/slirp/socket.h

Modified: trunk/configure
===================================================================

configure +14 -0
@@ -1017,6 +1017,17 @@
   fi
 fi
 
+##########################################
+# iovec probe
+cat > $TMPC <<EOF
+#include <sys/uio.h>
+int main(void) { struct iovec iov; return 0; }
+EOF
+iovec=no
+if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+  iovec=yes
+fi
+
 # Check if tools are available to build documentation.
 if [ -x "`which texi2html 2>/dev/null`" ] && \
    [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -1376,6 +1387,9 @@
 if test "$blobs" = "yes" ; then
   echo "INSTALL_BLOBS=yes" >> $config_mak
 fi
+if test "$iovec" = "yes" ; then
+  echo "#define HAVE_IOVEC 1" >> $config_h
+fi
 
 # XXX: suppress that
 if [ "$bsd" = "yes" ] ; then

Modified: trunk/hw/virtio.h
===================================================================

hw/virtio.h +0 -9
@@ -17,15 +17,6 @@
 #include "hw.h"
 #include "pci.h"
 
-#ifdef _WIN32
-struct iovec {
-    void *iov_base;
-    size_t iov_len;
-};
-#else
-#include <sys/uio.h>
-#endif
-
 /* from Linux's linux/virtio_config.h */
 
 /* Status byte for guest to report progress, and synchronize features. */

Modified: trunk/qemu-common.h
===================================================================

qemu-common.h +9 -1
@@ -16,6 +16,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include "config-host.h"
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
@@ -28,6 +29,14 @@
 #define ENOMEDIUM ENODEV
 #endif
 
+#ifndef HAVE_IOVEC
+#define HAVE_IOVEC
+struct iovec {
+    void *iov_base;
+    size_t iov_len;
+};
+#endif
+
 #ifdef _WIN32
 #define WIN32_LEAN_AND_MEAN
 #define WINVER 0x0501  /* needed for ipv6 bits */
@@ -54,7 +63,6 @@
 /* FIXME: Remove NEED_CPU_H.  */
 #ifndef NEED_CPU_H
 
-#include "config-host.h"
 #include <setjmp.h>
 #include "osdep.h"
 #include "bswap.h"

Modified: trunk/slirp/socket.c
===================================================================

slirp/socket.c +1 -0
@@ -11,6 +11,7 @@
 #ifdef __sun__
 #include <sys/filio.h>
 #endif
+#include "qemu-common.h"
 
 static void sofcantrcvmore(struct socket *so);
 static void sofcantsendmore(struct socket *so);

Modified: trunk/slirp/socket.h
===================================================================

slirp/socket.h +0 -8
@@ -73,14 +73,6 @@
 
 extern struct socket tcb;
 
-
-#if defined(DECLARE_IOVEC) && !defined(HAVE_READV)
-struct iovec {
-	char *iov_base;
-	size_t iov_len;
-};
-#endif
-
 struct socket * solookup _P((struct socket *, struct in_addr, u_int, struct in_addr, u_int));
 struct socket * socreate _P((void));
 void sofree _P((struct socket *));
#1 lore raw

Am 05.12.2008 um 21:05 schrieb Anthony Liguori:

Quoted 45 lines

Revision: 5889

         http://svn.sv.gnu.org/viewvc/? 
view=rev&root=qemu&revision=5889
Author:   aliguori
Date:     2008-12-05 20:05:26 +0000 (Fri, 05 Dec 2008)

Log Message:
-----------
Make struct iovec universally available

Vectored IO APIs will require some sort of vector argument. It makes sense to use struct iovec and just define it globally for Windows.

Modified: trunk/configure
===================================================================

configure +0 -0
@@ -1017,6 +1017,17 @@
  fi

fi

configure +11 -0
+##########################################
+# iovec probe
+cat > $TMPC <<EOF
+#include <sys/uio.h>
+int main(void) { struct iovec iov; return 0; }
+EOF
+iovec=no
+if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+  iovec=yes
+fi
+

# Check if tools are available to build documentation.

if [ -x "`which texi2html 2>/dev/null`" ] && \
   [ -x "`which pod2man 2>/dev/null`" ]; then
configure +0 -0
@@ -1376,6 +1387,9 @@

if test "$blobs" = "yes" ; then
echo "INSTALL_BLOBS=yes" >> $config_mak
fi

configure +3 -0
+if test "$iovec" = "yes" ; then
+  echo "#define HAVE_IOVEC 1" >> $config_h
+fi
Quoted 2 lines

# XXX: suppress that
if [ "$bsd" = "yes" ] ; then

On Mac OS X v10.5 this test results in HAVE_IOVEC 1, but I get the following compilation failure:

gcc -I. -I.. -I/Users/andreas/Q/qemu/target-i386 -I/Users/andreas/Q/qemu -MMD -MT pc.o -MP -DNEED_CPU_H -D__powerpc__ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/Users/andreas/Q/qemu/tcg -I/Users/andreas/Q/qemu/tcg/ppc -I/Users/andreas/Q/qemu/fpu -DHAS_AUDIO -DHAS_AUDIO_CHOICE -I/Users/andreas/Q/qemu/slirp -O2 -g -fno-strict-aliasing -Wall -Wundef -Wendif-labels -Wwrite-strings -mdynamic-no-pic -c -o pc.o /Users/andreas/Q/qemu/hw/pc.c In file included from /Users/andreas/Q/qemu/hw/virtio-blk.h:17,

                 from /Users/andreas/Q/qemu/hw/pc.c:36:

/Users/andreas/Q/qemu/hw/virtio.h:67: error: array type has incomplete element type /Users/andreas/Q/qemu/hw/virtio.h:68: error: array type has incomplete element type /Users/andreas/Q/qemu/hw/pc.c: In function ‘pc_init1’:
/Users/andreas/Q/qemu/hw/pc.c:830: warning: large integer implicitly truncated to unsigned type make[1]: *** [pc.o] Error 1
make: *** [subdir-i386-softmmu] Error 2

It does not go away even if I #define HAVE_IOVEC 0 in config-host.h.

Any ideas?

Andreas

#2 lore raw

Am 06.12.2008 um 11:30 schrieb Andreas Färber:

Quoted 5 lines

On Mac OS X v10.5 this test results in HAVE_IOVEC 1, but I get the following compilation failure:

gcc -I. -I.. -I/Users/andreas/Q/qemu/target-i386 -I/Users/andreas/Q/qemu -MMD -MT pc.o -MP -DNEED_CPU_H -D__powerpc__ -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/Users/andreas/Q/qemu/tcg -I/Users/andreas/Q/qemu/tcg/ppc -I/Users/andreas/Q/qemu/fpu -DHAS_AUDIO -DHAS_AUDIO_CHOICE -I/Users/andreas/Q/qemu/slirp -O2 -g -fno-strict-aliasing -Wall -Wundef -Wendif-labels -Wwrite-strings -mdynamic-no-pic -c -o pc.o /Users/andreas/Q/qemu/hw/pc.c In file included from /Users/andreas/Q/qemu/hw/virtio-blk.h:17,

                from /Users/andreas/Q/qemu/hw/pc.c:36:
Quoted 8 lines

/Users/andreas/Q/qemu/hw/virtio.h:67: error: array type has incomplete element type /Users/andreas/Q/qemu/hw/virtio.h:68: error: array type has incomplete element type /Users/andreas/Q/qemu/hw/pc.c: In function ‘pc_init1’:
/Users/andreas/Q/qemu/hw/pc.c:830: warning: large integer implicitly truncated to unsigned type make[1]: *** [pc.o] Error 1
make: *** [subdir-i386-softmmu] Error 2

It does not go away even if I #define HAVE_IOVEC 0 in config-host.h.

Some more info:
Commenting the #define out leads to:

gcc -O2 -g -fno-strict-aliasing -Wall -Wundef -Wendif-labels -Wwrite-strings -mdynamic-no-pic -I. -I/Users/andreas/Q/qemu -MMD -MP -MT osdep.o -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/Users/andreas/Q/qemu/slirp -c -o osdep.o osdep.c In file included from qemu_socket.h:22,

                 from osdep.c:48:

/usr/include/sys/socket.h:128: error: redefinition of ‘struct iovec’
make: *** [osdep.o] Error 1

If I don't touch config-host.h (i.e., #define HAVE_IOVEC 1) and add #include <sys/socket.h> in virtio.h, then it compiles okay.

Maybe include qemu-socket.h somewhere?

Andreas

#3 lore raw

PATCH 1/1 struct iovec compilation fix

The configure test for struct iovec #includes <sys/uio.h> but qemu-common.h did not.

This fixes compilation of hw/virtio.h on Mac OS X.

---

qemu-common.h +2 -0
index e1546c6..cb5d465 100644
@@ -35,6 +35,8 @@ struct iovec {
     void *iov_base;
     size_t iov_len;
 };
+#else
+#include <sys/uio.h>
 #endif
 
 #ifdef _WIN32
Applied
#4 lore raw

Re: [Qemu-devel] [PATCH] struct iovec compilation fix

Quoted 6 lines · Andreas Färber

The configure test for struct iovec #includes <sys/uio.h> but qemu-common.h did not.

This fixes compilation of hw/virtio.h on Mac OS X.

Thanks, applied.

#5 lore raw

Re: [Qemu-devel] [PATCH] struct iovec compilation fix

Am 06.12.2008 um 20:53 schrieb Blue Swirl:

Quoted 9 lines · Andreas Färber
Quoted 6 lines

The configure test for struct iovec #includes <sys/uio.h> but qemu-common.h did not.

This fixes compilation of hw/virtio.h on Mac OS X.

Thanks, applied.

Thanks, Blue.

You're making me wonder, isn't actually the subject line (following "[PATCH]") of a Git-style patch supposed to be part of (i.e., the first line of) the SVN commit message? Or is that a misunderstanding on my part? Noticed that for r5885ff as well.

Andreas

#6 lore raw

Re: [Qemu-devel] [PATCH] struct iovec compilation fix

Quoted 19 lines · Andreas Färber

Am 06.12.2008 um 20:53 schrieb Blue Swirl:

Quoted 3 lines · Andreas Färber
Quoted 2 lines

The configure test for struct iovec #includes <sys/uio.h> but

qemu-common.h

Quoted 9 lines
Quoted 6 lines

did not.

This fixes compilation of hw/virtio.h on Mac OS X.

Thanks, applied.

Quoted 6 lines

Thanks, Blue.

You're making me wonder, isn't actually the subject line (following
"[PATCH]") of a Git-style patch supposed to be part of (i.e., the first line of) the SVN commit message? Or is that a misunderstanding on my part? Noticed that for r5885ff as well.

I don't know. Sometimes the subject does not tell much or there is a lot of extra garbage. Not in this case, though.