diff options
author | Pete Batard <pbatard@gmail.com> | 2010-03-17 14:59:20 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-03-17 14:59:20 +0000 |
commit | 307f3f4289f1d4883aab3d2c4c09322f328c857a (patch) | |
tree | b7eb349ecac7deb5ebec9667f8c4582376bf2679 /libusb | |
parent | 070d871037eebc8de42b8bb855ae232f1c997f83 (diff) | |
download | libusb-307f3f4289f1d4883aab3d2c4c09322f328c857a.tar.gz |
readability improvements in poll_windows.cr211
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/os/poll_windows.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index dee5cac..234edcd 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); @@ -490,7 +491,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)) { @@ -532,7 +533,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); } |