Skip to contentSkip to conversation

usb: Support compilation without poll.h

PATCH In review Stefan Weil 3 participants 4 messages Mar 22, 2016 – May 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: Support compilation without poll.h

This is a hack to support compilation with Mingw-w64 which provides a libusb-1.0 package, but no poll.h.

---

v2: Modified after feedback from Gerd.

 hw/usb/host-libusb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
hw/usb/host-libusb.c +12 -1
index 5e7ec45..236bb2a 100644
@@ -34,7 +34,9 @@
  */
 
 #include "qemu/osdep.h"
+#ifndef CONFIG_WIN32
 #include <poll.h>
+#endif
 #include <libusb.h>
 
 #include "qemu-common.h"
@@ -203,6 +205,8 @@ static const char *err_names[] = {
 static libusb_context *ctx;
 static uint32_t loglevel;
 
+#ifndef CONFIG_WIN32
+
 static void usb_host_handle_fd(void *opaque)
 {
     struct timeval tv = { 0, 0 };
@@ -222,9 +226,13 @@ static void usb_host_del_fd(int fd, void *user_data)
     qemu_set_fd_handler(fd, NULL, NULL, NULL);
 }
 
+#endif /* !CONFIG_WIN32 */
+
 static int usb_host_init(void)
 {
+#ifndef CONFIG_WIN32
     const struct libusb_pollfd **poll;
+#endif
     int i, rc;
 
     if (ctx) {
@@ -235,7 +243,9 @@ static int usb_host_init(void)
         return -1;
     }
     libusb_set_debug(ctx, loglevel);
-
+#ifdef CONFIG_WIN32
+    /* FIXME: add support for Windows. */
+#else
     libusb_set_pollfd_notifiers(ctx, usb_host_add_fd,
                                 usb_host_del_fd,
                                 ctx);
@@ -246,6 +256,7 @@ static int usb_host_init(void)
         }
     }
     free(poll);
+#endif
     return 0;
 }
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 2 lines · Stefan Weil

This is a hack to support compilation with Mingw-w64 which provides a libusb-1.0 package, but no poll.h.

Added to usb patch queue.

#2 lore raw
In reply to Stefan Weil
Quoted 28 lines · Stefan Weil

This is a hack to support compilation with Mingw-w64 which provides a libusb-1.0 package, but no poll.h.

---

v2: Modified after feedback from Gerd.

static int usb_host_init(void)
{

hw/usb/host-libusb.c +5 -1
+#ifndef CONFIG_WIN32
     const struct libusb_pollfd **poll;
+#endif
     int i, rc;
 
     if (ctx) {
@@ -235,7 +243,9 @@ static int usb_host_init(void)
         return -1;
     }
     libusb_set_debug(ctx, loglevel);
-
+#ifdef CONFIG_WIN32
+    /* FIXME: add support for Windows. */
+#else
     libusb_set_pollfd_notifiers(ctx, usb_host_add_fd,
                                 usb_host_del_fd,
                                 ctx);

hw/usb/host-libusb.c static int usb_host_init(void) · line 260

Quoted 5 lines
hw/usb/host-libusb.c +1 -0
@@ -246,6 +256,7 @@ static int usb_host_init(void)
         }
     }
     free(poll);
+#endif
     return 0;

Would it make more sense to just disable this functionality entirely rather than leaving it compiling but not working?

thanks
-- PMM

#3 lore raw
Quoted 6 lines · Peter Maydell
Quoted 2 lines · Stefan Weil

This is a hack to support compilation with Mingw-w64 which provides a libusb-1.0 package, but no poll.h.

Would it make more sense to just disable this functionality entirely rather than leaving it compiling but not working?

It should be possible to get things working on windows, given that a libusb port exists now.

/me hopes that having things at least compile might encourage people to fill the missing bits.

I guess we'll have to either add some windows-specific bits for event handling (simliar to win_chr_init() in qemu-char.c) or do timer-based polling.

cheers,
Gerd