diff options
-rw-r--r-- | libusb/os/poll_windows.c | 5 | ||||
-rw-r--r-- | libusb/os/threads_windows.c | 5 | ||||
-rw-r--r-- | libusb/os/windows_usb.c | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 6941164..7567ca4 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -96,12 +96,17 @@ 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) +#define INIT_INTERLOCKEDEXCHANGE +#define pInterlockedExchange InterlockedExchange +#else 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; \ } +#endif // public fd data const struct winfd INVALID_WINFD = {-1, INVALID_HANDLE_VALUE, NULL, RW_NONE}; diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c index 9d64fb0..5eb0478 100644 --- a/libusb/os/threads_windows.c +++ b/libusb/os/threads_windows.c @@ -26,12 +26,17 @@ #include "libusbi.h" // Workaround for MinGW-w64 multilib bug +#if defined(_WIN64) +#define INIT_INTERLOCKEDEXCHANGE +#define pInterlockedExchange InterlockedExchange +#else 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 ((errno=ENOENT)); \ } +#endif int usbi_mutex_init(usbi_mutex_t *mutex, const usbi_mutexattr_t *attr) { diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index bb37572..6d1dbca 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -112,6 +112,12 @@ 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) +#define INIT_INTERLOCKEDEXCHANGE +#define INIT_INTERLOCKEDINCREMENT +#define pInterlockedExchange InterlockedExchange +#define pInterlockedIncrement InterlockedIncrement +#else static LONG (WINAPI *pInterlockedExchange)(LONG volatile *, LONG) = NULL; #define INIT_INTERLOCKEDEXCHANGE if (pInterlockedExchange == NULL) { \ pInterlockedExchange = (LONG (WINAPI *)(LONG volatile *, LONG)) \ @@ -124,6 +130,7 @@ static LONG (WINAPI *pInterlockedIncrement)(LONG volatile *) = NULL; GetProcAddress(GetModuleHandle("KERNEL32"), "InterlockedIncrement");\ if (pInterlockedIncrement == NULL) return LIBUSB_ERROR_NOT_FOUND; \ } +#endif // Global variables struct windows_hcd_priv* hcd_root = NULL; |