diff options
author | Pete Batard <pbatard@gmail.com> | 2010-01-15 01:19:47 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-01-15 01:19:47 +0000 |
commit | 3cb9ac7d88f2d7513b2b914510cd16def8eb8e1e (patch) | |
tree | 40c5d20c264e735de7c215f5ce9cb39231545997 /libusb/os/windows_compat.c | |
parent | 1626ee00424d3f9b90db1b9fc3834cfbbadda465 (diff) | |
download | libusb-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/os/windows_compat.c')
-rw-r--r-- | libusb/os/windows_compat.c | 24 |
1 files changed, 24 insertions, 0 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 |