summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
Diffstat (limited to 'libusb')
-rw-r--r--libusb/os/windows_compat.c24
-rw-r--r--libusb/os/windows_usb.c1
2 files changed, 24 insertions, 1 deletions
diff --git a/libusb/os/windows_compat.c b/libusb/os/windows_compat.c
index 641ef15..711d553 100644
--- a/libusb/os/windows_compat.c
+++ b/libusb/os/windows_compat.c
@@ -88,6 +88,30 @@
#endif
#endif
+#if defined(__CYGWIN__ )
+// _open_osfhandle() is not available on cygwin, but we can emulate
+// it for our needs with cygwin_attach_handle_to_fd()
+static inline int _open_osfhandle(intptr_t osfhandle, int flags)
+{
+ int access;
+ switch (flags) {
+ case _O_RDONLY:
+ access = GENERIC_READ;
+ break;
+ case _O_WRONLY:
+ access = GENERIC_WRITE;
+ break;
+ case _O_RDWR:
+ access = GENERIC_READ|GENERIC_WRITE;
+ break;
+ default:
+ printb("_open_osfhandle (emulated): unuspported access mode\n");
+ return -1;
+ }
+ return cygwin_attach_handle_to_fd("/dev/null", -1, osfhandle, -1, access);
+}
+#endif
+
#define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0)
// public fd data
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index fb14cd0..d628e1f 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -37,7 +37,6 @@
#include <pthread.h>
#include <stdio.h>
#include <windows.h>
-#include <tchar.h>
#include <setupapi.h>
#if defined(_MSC_VER)
// Fixes DDK errors