summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-01-15 01:19:47 +0000
committerPete Batard <pbatard@gmail.com>2010-01-15 01:19:47 +0000
commit3cb9ac7d88f2d7513b2b914510cd16def8eb8e1e (patch)
tree40c5d20c264e735de7c215f5ce9cb39231545997 /libusb
parent1626ee00424d3f9b90db1b9fc3834cfbbadda465 (diff)
downloadlibusb-3cb9ac7d88f2d7513b2b914510cd16def8eb8e1e.tar.gz
r76: added cygwin support
- use AM_CFLAGS instead of CFLAGS (configure.ac) - added -Werror in visibility attribute test to properly detect on cygwin (configure.ac) - moved -Wshadow to AM_CFLAGS and disabled it on cygwin (configure.ac) - emulated _open_osfhandle in windows_compat.c - removed unneeded <tchar> include in windows_usb.c
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