summaryrefslogtreecommitdiff
path: root/libusb/os/threads_windows.h
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2018-01-06 21:43:12 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2018-01-06 21:43:12 -0800
commitd0779e93032affec1dcf04a5bba18f3968aa7922 (patch)
tree2609450edece322a4421764a2d804fa7607a1214 /libusb/os/threads_windows.h
parent0865774fe93b2d0d9729ab23f9dfb10af1433312 (diff)
downloadlibusb-d0779e93032affec1dcf04a5bba18f3968aa7922.tar.gz
Windows: Rework poll() emulation to a much simpler and effective design
The previous poll() implementation worked okay but had some issues. It was inefficient, had a large footprint, and there were simply some use cases that didn't work (e.g. a synchronous transfer that completes when no other event or transfer is pending would not be processed until the next poll() timeout). This commit introduces a new, simpler design that simply associates an OVERLAPPED structure to an integer that acts as a file descriptor. The poll() emulation now solely cares about the OVERLAPPED structure, not transfers or HANDLEs or cancelation functions. These details have been moved up into the higher OS-specific layers. For Windows NT environments, several deficiencies have been addressed: 1) It was previously possible to successfully submit a transfer but fail to add the "file descriptor" to the pollfd set. This was silently ignored and would result in the user never seeing the transfer being completed. 2) Synchronously completed transfers would previously not be processed unless another event (such as a timeout or other transfer completion) was processed. 3) Canceling any one transfer on an endpoint would previously result in *all* transfers on that endpoint being canceled, due to the use of the AbortPipe() function. This commit addresses all of these issues. In particular, run-time detection of the CancelIoEx() function will allow the user to cancel a single outstanding transfer without affecting any others still in process. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/os/threads_windows.h')
-rw-r--r--libusb/os/threads_windows.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/libusb/os/threads_windows.h b/libusb/os/threads_windows.h
index 630dcab..409de2d 100644
--- a/libusb/os/threads_windows.h
+++ b/libusb/os/threads_windows.h
@@ -22,7 +22,11 @@
#define LIBUSB_THREADS_WINDOWS_H
#define USBI_MUTEX_INITIALIZER 0L
+#ifdef _WIN32_WCE
+typedef LONG usbi_mutex_static_t;
+#else
typedef volatile LONG usbi_mutex_static_t;
+#endif
void usbi_mutex_static_lock(usbi_mutex_static_t *mutex);
static inline void usbi_mutex_static_unlock(usbi_mutex_static_t *mutex)
{