From c8bab4e19413d70c515a2eaf747a75b7f66fdc0b Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 19 Sep 2010 14:24:25 +0100 Subject: [PATCH] Windows: Make libusb_pollfd() return error Windows does not have numerical file descriptors but does have the concept of event sources. Exposing these event sources will require some careful thought and design, to be completed later. --- libusb/io.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libusb/io.c b/libusb/io.c index 2ea38a5..90590ef 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -582,6 +582,10 @@ while (user_has_not_requested_exit) * * \section pollmain The more advanced option * + * \note This functionality is currently only available on Unix-like platforms. + * On Windows, libusb_get_pollfds() simply returns NULL. Exposing event sources + * on Windows will require some further thought and design. + * * In more advanced applications, you will already have a main loop which * is monitoring other event sources: network sockets, X11 events, mouse * movements, etc. Through exposing a set of file descriptors, libusb is @@ -2258,14 +2262,19 @@ void usbi_remove_pollfd(struct libusb_context *ctx, int fd) * The returned list is NULL-terminated and should be freed with free() when * done. The actual list contents must not be touched. * + * As file descriptors are a Unix-specific concept, this function is not + * available on Windows and will always return NULL. + * * \param ctx the context to operate on, or NULL for the default context - * \returns a NULL-terminated list of libusb_pollfd structures, or NULL on - * error + * \returns a NULL-terminated list of libusb_pollfd structures + * \returns NULL on error + * \returns NULL on platforms where the functionality is not available */ DEFAULT_VISIBILITY const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds( libusb_context *ctx) { +#ifndef OS_WINDOWS struct libusb_pollfd **ret = NULL; struct usbi_pollfd *ipollfd; size_t i = 0; @@ -2287,6 +2296,9 @@ const struct libusb_pollfd ** LIBUSB_CALL libusb_get_pollfds( out: usbi_mutex_unlock(&ctx->pollfds_lock); return (const struct libusb_pollfd **) ret; +#else + return NULL; +#endif } /* Backends call this from handle_events to report disconnection of a device. @@ -2331,4 +2343,3 @@ void usbi_handle_disconnect(struct libusb_device_handle *handle) } } - -- 2.7.4