diff options
author | Pete Batard <pbatard@gmail.com> | 2010-03-17 15:25:50 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-03-17 15:25:50 +0000 |
commit | fc670d2ac06a84351fff89d6868e398e6cac8d18 (patch) | |
tree | 309abd77056bb67bc8b1b43585af5d33ca6a521f | |
parent | 58b722e94b768cf5ee1a9d8f97fedcca5ce0ec21 (diff) | |
download | libusb-fc670d2ac06a84351fff89d6868e398e6cac8d18.tar.gz |
merged -> r211c201
-rw-r--r-- | libusb/os/poll_windows.c | 11 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 7922fd4..1064457 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -143,6 +143,7 @@ static volatile LONG compat_spinlock = 0; // a single transfer (OVERLAPPED) when used. As it may not be part of any of the // platform headers, we hook into the Kernel32 system DLL directly to seek it. static BOOL (__stdcall *pCancelIoEx)(HANDLE, LPOVERLAPPED) = NULL; +#define CancelIoEx_Available (pCancelIoEx != NULL) __inline BOOL cancel_io(int index) { if ((index < 0) || (index >= MAX_FDS)) { @@ -153,7 +154,7 @@ __inline BOOL cancel_io(int index) || (poll_fd[index].handle == 0) || (poll_fd[index].overlapped == NULL) ) { return TRUE; } - if (pCancelIoEx != NULL) { + if (CancelIoEx_Available) { return (*pCancelIoEx)(poll_fd[index].handle, poll_fd[index].overlapped); } if (_poll_fd[index].thread_id == GetCurrentThreadId()) { @@ -175,7 +176,7 @@ void init_polling(void) pCancelIoEx = (BOOL (__stdcall *)(HANDLE,LPOVERLAPPED)) GetProcAddress(GetModuleHandle("KERNEL32"), "CancelIoEx"); usbi_dbg("Will use CancelIo%s for I/O cancellation", - (pCancelIoEx != NULL)?"Ex":""); + CancelIoEx_Available?"Ex":""); for (i=0; i<MAX_FDS; i++) { poll_fd[i] = INVALID_WINFD; _poll_fd[i].marker = 0; @@ -282,7 +283,7 @@ void exit_polling(void) _close(poll_fd[i].fd); } free_overlapped(poll_fd[i].overlapped); - if (pCancelIoEx == NULL) { + if (!CancelIoEx_Available) { // Close duplicate handle if (_poll_fd[i].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[i].handle); @@ -491,7 +492,7 @@ struct winfd usbi_create_fd(HANDLE handle, int access_mode) wfd.fd = fd; // Attempt to emulate some of the CancelIoEx behaviour on platforms // that don't have it - if (pCancelIoEx == NULL) { + if (!CancelIoEx_Available) { _poll_fd[i].thread_id = GetCurrentThreadId(); if (!DuplicateHandle(GetCurrentProcess(), handle, GetCurrentProcess(), &wfd.handle, 0, TRUE, DUPLICATE_SAME_ACCESS)) { @@ -534,7 +535,7 @@ void _free_index(int index) _close(poll_fd[index].fd); } // close the duplicate handle (if we have an actual duplicate) - if (pCancelIoEx == NULL) { + if (!CancelIoEx_Available) { if (_poll_fd[index].original_handle != INVALID_HANDLE_VALUE) { CloseHandle(poll_fd[index].handle); } diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index 40d36dc..4b58b87 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -1970,7 +1970,7 @@ static int windows_cancel_transfer(struct usbi_transfer *itransfer) struct windows_transfer_priv *transfer_priv = usbi_transfer_get_os_priv(itransfer); // Forces instant overlapped completion on timeouts - use at your own risks - if (itransfer->flags | USBI_TRANSFER_TIMED_OUT) { + if (itransfer->flags & USBI_TRANSFER_TIMED_OUT) { transfer_priv->pollable_fd.overlapped->Internal &= ~STATUS_PENDING; } #endif @@ -2008,7 +2008,7 @@ static void windows_transfer_callback(struct usbi_transfer *itransfer, uint32_t status = LIBUSB_TRANSFER_TIMED_OUT; break; case ERROR_OPERATION_ABORTED: - if (itransfer->flags | USBI_TRANSFER_TIMED_OUT) { + if (itransfer->flags & USBI_TRANSFER_TIMED_OUT) { usbi_dbg("detected timeout"); status = LIBUSB_TRANSFER_TIMED_OUT; } else { |