* [Qemu-devel] [PATCH] usb: Support compilation without poll.h
@ 2016-03-16 20:22 Stefan Weil
2016-03-18 12:20 ` Gerd Hoffmann
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2016-03-16 20:22 UTC (permalink / raw)
To: QEMU Developer; +Cc: Stefan Weil, Gerd Hoffmann
This is a hack to support compilation with Mingw-w64 which provides
a libusb-1.0 package, but no poll.h.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
I did not test whether this USB host code works on Windows,
but at least it compiles with this hack.
Suggestions for a better fix are welcome.
Regards,
Stefan
hw/usb/host-libusb.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 5e7ec45..139028e 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -34,7 +34,9 @@
*/
#include "qemu/osdep.h"
+#ifdef CONFIG_PPOLL
#include <poll.h>
+#endif
#include <libusb.h>
#include "qemu-common.h"
@@ -203,18 +205,24 @@ static const char *err_names[] = {
static libusb_context *ctx;
static uint32_t loglevel;
+#ifdef CONFIG_PPOLL
static void usb_host_handle_fd(void *opaque)
{
struct timeval tv = { 0, 0 };
libusb_handle_events_timeout(ctx, &tv);
}
+#endif
static void usb_host_add_fd(int fd, short events, void *user_data)
{
+#ifdef CONFIG_PPOLL
qemu_set_fd_handler(fd,
(events & POLLIN) ? usb_host_handle_fd : NULL,
(events & POLLOUT) ? usb_host_handle_fd : NULL,
ctx);
+#else
+ g_assert(events == 0);
+#endif
}
static void usb_host_del_fd(int fd, void *user_data)
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] usb: Support compilation without poll.h
2016-03-16 20:22 [Qemu-devel] [PATCH] usb: Support compilation without poll.h Stefan Weil
@ 2016-03-18 12:20 ` Gerd Hoffmann
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2016-03-18 12:20 UTC (permalink / raw)
To: Stefan Weil; +Cc: QEMU Developer
On Mi, 2016-03-16 at 21:22 +0100, Stefan Weil wrote:
> This is a hack to support compilation with Mingw-w64 which provides
> a libusb-1.0 package, but no poll.h.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> I did not test whether this USB host code works on Windows,
> but at least it compiles with this hack.
>
> Suggestions for a better fix are welcome.
>
> Regards,
> Stefan
>
> hw/usb/host-libusb.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
> index 5e7ec45..139028e 100644
> --- a/hw/usb/host-libusb.c
> +++ b/hw/usb/host-libusb.c
> @@ -34,7 +34,9 @@
> */
>
> #include "qemu/osdep.h"
> +#ifdef CONFIG_PPOLL
> #include <poll.h>
> +#endif
> #include <libusb.h>
>
> #include "qemu-common.h"
> @@ -203,18 +205,24 @@ static const char *err_names[] = {
> static libusb_context *ctx;
> static uint32_t loglevel;
>
> +#ifdef CONFIG_PPOLL
> static void usb_host_handle_fd(void *opaque)
> {
> struct timeval tv = { 0, 0 };
> libusb_handle_events_timeout(ctx, &tv);
> }
> +#endif
>
> static void usb_host_add_fd(int fd, short events, void *user_data)
> {
> +#ifdef CONFIG_PPOLL
> qemu_set_fd_handler(fd,
> (events & POLLIN) ? usb_host_handle_fd : NULL,
> (events & POLLOUT) ? usb_host_handle_fd : NULL,
> ctx);
> +#else
> + g_assert(events == 0);
> +#endif
> }
>
> static void usb_host_del_fd(int fd, void *user_data)
Hmm. I'm wondering how libusb @ windows is notified about pending data.
Probably not using file descriptors but something else ...
I'd suggest to use CONFIG_WIN32 instead of CONFIG_POLL, to make clear
what this is about. You can #ifdef out the whole block with all three
usb_host_*_fd functions, and the libusb call which registers these
callbacks somewhere further down in the code. The later place should
probably get a /* FIXME */ in the #else branch as I expect we need to do
something on windows too.
cheers,
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-18 12:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 20:22 [Qemu-devel] [PATCH] usb: Support compilation without poll.h Stefan Weil
2016-03-18 12:20 ` Gerd Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).