From 9393bf48673a9faa76fdcf75872392fd51d224c1 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Fri, 12 Mar 2010 02:17:05 +0000 Subject: merged r202 to r204 --- ddk_build.cmd | 2 +- libusb/os/poll_windows.c | 15 +-------------- libusb/os/poll_windows.h | 7 ++++++- libusb/os/threads_windows.c | 4 +++- libusb/os/windows_usb.c | 19 +++++++++++++++---- libusb/os/windows_usb.h | 5 ----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ddk_build.cmd b/ddk_build.cmd index 236c589..f64b78d 100644 --- a/ddk_build.cmd +++ b/ddk_build.cmd @@ -20,7 +20,7 @@ set destType=x64 set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir% set dstPath=%destType%\Debug -if %_BuildType%==chk goto isDebug +if %DDKBUILDENV%==chk goto isDebug set dstPath=%destType%\Release :isDebug diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index b6fed7c..3bbe615 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -70,12 +70,6 @@ // Uncomment to debug the polling layer //#define DEBUG_POLL_WINDOWS - -// Uncomment to have poll return with EINTR as soon as a new transfer (fd) is added -// This should result in a LIBUSB_ERROR_INTERRUPTED being returned by libusb calls, -// which should give the app an opportunity to resubmit a new fd set. -//#define DYNAMIC_FDS - #if defined(DEBUG_POLL_WINDOWS) #define poll_dbg usbi_dbg #else @@ -122,8 +116,6 @@ static inline int _open_osfhandle(intptr_t osfhandle, int flags) #define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0) -extern void usbi_fd_notification(struct libusb_context *ctx); - // public fd data const struct winfd INVALID_WINFD = {-1, NULL, NULL, RW_NONE, FALSE}; struct winfd poll_fd[MAX_FDS]; @@ -434,7 +426,7 @@ out1: * read and one for write. Using a single R/W fd is unsupported and will * produce unexpected results */ -struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_context *ctx) +struct winfd usbi_create_fd(HANDLE handle, int access_mode) { int i, fd; struct winfd wfd = INVALID_WINFD; @@ -489,11 +481,6 @@ struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_contex usbi_mutex_unlock(&new_fd_mutex); // Notify poll that fds have been updated SetEvent(fd_update); -#else - // NOTE: For now, usbi_fd_notification is only called on fd creation, as - // fd deletion results in a CancelIo() event, which poll should detect. - // Will see if there's an actual justification to call this on delete... - usbi_fd_notification(ctx); #endif return wfd; } diff --git a/libusb/os/poll_windows.h b/libusb/os/poll_windows.h index 996ff48..0da805b 100644 --- a/libusb/os/poll_windows.h +++ b/libusb/os/poll_windows.h @@ -26,6 +26,11 @@ #pragma warning(disable:4127) // conditional expression is constant #endif +// Uncomment to have poll return with EINTR as soon as a new transfer (fd) is added +// This should result in a LIBUSB_ERROR_INTERRUPTED being returned by libusb calls, +// which should give the app an opportunity to resubmit a new fd set. +//#define DYNAMIC_FDS + #if !defined(ssize_t) #if defined (_WIN64) #define ssize_t __int64 @@ -84,7 +89,7 @@ int usbi_close(int fd); void init_polling(void); void exit_polling(void); -struct winfd usbi_create_fd(HANDLE handle, int access_mode, struct libusb_context *ctx); +struct winfd usbi_create_fd(HANDLE handle, int access_mode); void usbi_free_fd(int fd); struct winfd fd_to_winfd(int fd); struct winfd handle_to_winfd(HANDLE handle); diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c index 7762190..6819059 100644 --- a/libusb/os/threads_windows.c +++ b/libusb/os/threads_windows.c @@ -194,11 +194,13 @@ int usbi_cond_timedwait(usbi_cond_t *cond, TIMESPEC_TO_TIMEVAL(&targ_time, abstime); timersub(&targ_time, &cur_time, &delta_time); - if(delta_time.tv_sec <= 0) // abstime already passed? + if(delta_time.tv_sec < 0) // abstime already passed? millis = 0; else { millis = delta_time.tv_usec/1000; millis += delta_time.tv_sec *1000; + if (delta_time.tv_usec % 1000) // round up to next millisecond + millis++; } return usbi_cond_intwait(cond, mutex, millis); diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 62fb871..fe7961e 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -58,6 +58,8 @@ #define LOOP_CHECK(fcall) { r=fcall; if (r != LIBUSB_SUCCESS) continue; } #define LOOP_BREAK(err) { r=err; continue; } +extern void usbi_fd_notification(struct libusb_context *ctx); + // Helper prototypes static int windows_get_active_config_descriptor(struct libusb_device *dev, unsigned char *buffer, size_t len, int *host_endian); static int windows_clock_gettime(int clk_id, struct timespec *tp); @@ -1737,6 +1739,9 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, (short)((transfer->endpoint & LIBUSB_ENDPOINT_IN)?POLLIN:POLLOUT)); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; } @@ -1756,6 +1761,9 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, (short)((transfer->endpoint & LIBUSB_ENDPOINT_IN)?POLLIN:POLLOUT)); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; } @@ -1774,6 +1782,9 @@ static int submit_control_transfer(struct usbi_transfer *itransfer) } usbi_add_pollfd(ctx, transfer_priv->pollable_fd.fd, POLLIN); +#if !defined(DYNAMIC_FDS) + usbi_fd_notification(ctx); +#endif return LIBUSB_SUCCESS; @@ -2543,7 +2554,7 @@ static int winusb_submit_control_transfer(struct usbi_transfer *itransfer) usbi_dbg("will use interface %d", current_interface); winusb_handle = handle_priv->interface_handle[current_interface].api_handle; - wfd = usbi_create_fd(winusb_handle, _O_RDONLY, ctx); + wfd = usbi_create_fd(winusb_handle, _O_RDONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -2619,7 +2630,7 @@ static int winusb_submit_bulk_transfer(struct usbi_transfer *itransfer) winusb_handle = handle_priv->interface_handle[current_interface].api_handle; direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN; - wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx); + wfd = usbi_create_fd(winusb_handle, direction_in?_O_RDONLY:_O_WRONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -3583,7 +3594,7 @@ static int hid_submit_control_transfer(struct usbi_transfer *itransfer) usbi_dbg("will use interface %d", current_interface); hid_handle = handle_priv->interface_handle[current_interface].api_handle; - wfd = usbi_create_fd(hid_handle, _O_RDONLY, ctx); + wfd = usbi_create_fd(hid_handle, _O_RDONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } @@ -3685,7 +3696,7 @@ static int hid_submit_bulk_transfer(struct usbi_transfer *itransfer) { hid_handle = handle_priv->interface_handle[current_interface].api_handle; direction_in = transfer->endpoint & LIBUSB_ENDPOINT_IN; - wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY, ctx); + wfd = usbi_create_fd(hid_handle, direction_in?_O_RDONLY:_O_WRONLY); if (wfd.fd < 0) { return LIBUSB_ERROR_NO_MEM; } diff --git a/libusb/os/windows_usb.h b/libusb/os/windows_usb.h index a7aaf7e..7a181b9 100644 --- a/libusb/os/windows_usb.h +++ b/libusb/os/windows_usb.h @@ -330,11 +330,6 @@ typedef RETURN_TYPE CONFIGRET; #define CR_SUCCESS 0x00000000 #define CR_NO_SUCH_DEVNODE 0x0000000D -//#if defined(_CFGMGR32_) -//#define CMAPI DECLSPEC_EXPORT -//#else -//#define CMAPI DECLSPEC_IMPORT -//#endif #define USB_DEVICE_DESCRIPTOR_TYPE LIBUSB_DT_DEVICE #define USB_CONFIGURATION_DESCRIPTOR_TYPE LIBUSB_DT_CONFIG -- cgit v1.2.1