summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-08-17 13:33:01 +0100
committerPete Batard <pbatard@gmail.com>2010-08-17 13:33:01 +0100
commitda2cf62775b4492a73f2bdcb922927fd2d6c6477 (patch)
tree45cd9e435091e874ef1981ae6ddfe44bb88dd238
parent2ffa5342c4237cec17e391e5bb809f382240d9a9 (diff)
downloadlibusb-da2cf62775b4492a73f2bdcb922927fd2d6c6477.tar.gz
restrict scope of previous workaround and return error when possible
-rw-r--r--libusb/os/poll_windows.c9
-rw-r--r--libusb/os/threads_windows.c2
-rw-r--r--libusb/os/windows_usb.c16
3 files changed, 18 insertions, 9 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index 7567ca4..8656ea0 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -96,7 +96,7 @@ static inline int _open_osfhandle(intptr_t osfhandle, int flags)
#define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0)
// Workaround for MinGW-w64 multilib bug
-#if defined(_WIN64)
+#if defined(_MSC_VER) || defined(_WIN64)
#define INIT_INTERLOCKEDEXCHANGE
#define pInterlockedExchange InterlockedExchange
#else
@@ -104,8 +104,11 @@ static LONG (WINAPI *pInterlockedExchange)(LONG volatile *, LONG) = NULL;
#define INIT_INTERLOCKEDEXCHANGE if (pInterlockedExchange == NULL) { \
pInterlockedExchange = (LONG (WINAPI *)(LONG volatile *, LONG)) \
GetProcAddress(GetModuleHandle("KERNEL32"), "InterlockedExchange"); \
- if (pInterlockedExchange == NULL) return; \
- }
+ if (pInterlockedExchange == NULL) { \
+ usbi_err(NULL, "InterlockedExchange is unavailable"); \
+ return; \
+ } \
+}
#endif
// public fd data
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index 5eb0478..fe84ec0 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -26,7 +26,7 @@
#include "libusbi.h"
// Workaround for MinGW-w64 multilib bug
-#if defined(_WIN64)
+#if defined(_MSC_VER) || defined(_WIN64)
#define INIT_INTERLOCKEDEXCHANGE
#define pInterlockedExchange InterlockedExchange
#else
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 6d1dbca..a3c33f9 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -112,7 +112,7 @@ static int composite_reset_device(struct libusb_device_handle *dev_handle);
static int composite_copy_transfer_data(struct usbi_transfer *itransfer, uint32_t io_size);
// Workaround for MinGW-w64 multilib bug
-#if defined(_WIN64)
+#if defined(_MSC_VER) || defined(_WIN64)
#define INIT_INTERLOCKEDEXCHANGE
#define INIT_INTERLOCKEDINCREMENT
#define pInterlockedExchange InterlockedExchange
@@ -122,14 +122,20 @@ static LONG (WINAPI *pInterlockedExchange)(LONG volatile *, LONG) = NULL;
#define INIT_INTERLOCKEDEXCHANGE if (pInterlockedExchange == NULL) { \
pInterlockedExchange = (LONG (WINAPI *)(LONG volatile *, LONG)) \
GetProcAddress(GetModuleHandle("KERNEL32"), "InterlockedExchange"); \
- if (pInterlockedExchange == NULL) return 1; \
- }
+ if (pInterlockedExchange == NULL) { \
+ usbi_err(NULL, "InterlockedExchange is unavailable"); \
+ return 1; \
+ } \
+}
static LONG (WINAPI *pInterlockedIncrement)(LONG volatile *) = NULL;
#define INIT_INTERLOCKEDINCREMENT if (pInterlockedIncrement == NULL) { \
pInterlockedIncrement = (LONG (WINAPI *)(LONG volatile *)) \
GetProcAddress(GetModuleHandle("KERNEL32"), "InterlockedIncrement");\
- if (pInterlockedIncrement == NULL) return LIBUSB_ERROR_NOT_FOUND; \
- }
+ if (pInterlockedIncrement == NULL) { \
+ usbi_err(NULL, "IInterlockedIncrement is unavailable"); \
+ return LIBUSB_ERROR_NOT_FOUND; \
+ } \
+}
#endif
// Global variables