summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libusb/os/sources34
-rw-r--r--libusb/os/windows_compat.c8
-rw-r--r--libusb/os/windows_compat.h25
-rw-r--r--libusb/os/windows_usb.c6
4 files changed, 68 insertions, 5 deletions
diff --git a/libusb/os/sources b/libusb/os/sources
new file mode 100644
index 0000000..bc1bde2
--- /dev/null
+++ b/libusb/os/sources
@@ -0,0 +1,34 @@
+TARGETNAME=libusb
+TARGETTYPE=DYNLINK
+
+DLLDEF=..\libusb-1.0.def
+
+!IFNDEF MSC_WARNING_LEVEL
+MSC_WARNING_LEVEL=/W3
+!ENDIF
+
+!IFDEF WIN64
+PTHREAD_LIB=pthreadVC2_x64.lib
+!ELSE
+PTHREAD_LIB=pthreadVC2.lib
+!ENDIF
+
+USE_MSVCRT=1
+
+INCLUDES=..;..\..;..\..\msvc;$(DDK_INC_PATH)
+C_DEFINES = $(C_DEFINES) /DDDKBUILD
+
+TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
+ $(SDK_LIB_PATH)\advapi32.lib \
+ $(SDK_LIB_PATH)\user32.lib \
+ $(SDK_LIB_PATH)\setupapi.lib \
+ $(SDK_LIB_PATH)\ole32.lib \
+ ..\..\msvc\$(PTHREAD_LIB)
+
+SOURCES=..\core.c \
+ ..\descriptor.c \
+ ..\io.c \
+ ..\sync.c \
+ windows_compat.c \
+ windows_usb.c
+
diff --git a/libusb/os/windows_compat.c b/libusb/os/windows_compat.c
index 98ff0e5..dfab210 100644
--- a/libusb/os/windows_compat.c
+++ b/libusb/os/windows_compat.c
@@ -68,6 +68,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdlib.h>
#include <windows.h>
#include <pthread.h>
#include <io.h>
@@ -520,7 +521,7 @@ struct winfd overlapped_to_winfd(OVERLAPPED* overlapped)
int poll(struct pollfd *fds, unsigned int nfds, int timeout)
{
unsigned i, triggered = 0;
- int index;
+ int index, object_index;
HANDLE *handles_to_wait_on = malloc(nfds*sizeof(HANDLE));
int *handle_to_index = malloc(nfds*sizeof(int));
DWORD nb_handles_to_wait_on = 0;
@@ -599,9 +600,10 @@ int poll(struct pollfd *fds, unsigned int nfds, int timeout)
ret = WaitForMultipleObjects(nb_handles_to_wait_on, handles_to_wait_on,
FALSE, (timeout==-1)?INFINITE:(DWORD)timeout);
- if (((ret-WAIT_OBJECT_0) >= 0) && ((ret-WAIT_OBJECT_0) < nb_handles_to_wait_on)) {
+ object_index = ret-WAIT_OBJECT_0;
+ if ((object_index >= 0) && ((DWORD)object_index < nb_handles_to_wait_on)) {
printb(" completed after wait\n");
- i = handle_to_index[ret-WAIT_OBJECT_0];
+ i = handle_to_index[object_index];
index = _fd_to_index_and_lock(fds[i].fd);
fds[i].revents = fds[i].events;
triggered++;
diff --git a/libusb/os/windows_compat.h b/libusb/os/windows_compat.h
index 689b82a..8cae332 100644
--- a/libusb/os/windows_compat.h
+++ b/libusb/os/windows_compat.h
@@ -78,6 +78,31 @@ struct winfd handle_to_winfd(HANDLE handle);
struct winfd overlapped_to_winfd(OVERLAPPED* overlapped);
// On Windows, timeval (defined in WinSock.h) uses long for its members
+
+/*
+ * Structure used in select() call, taken from the BSD file sys/time.h.
+ */
+#if defined(DDKBUILD)
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+#endif
+
+#if !defined(timerisset)
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#endif
+
+#if !defined(timercmp)
+#define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+#endif
+
+#if !defined(timerclr)
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+#endif
+
#if !defined(TIMESPEC_TO_TIMEVAL)
#define TIMESPEC_TO_TIMEVAL(tv, ts) { \
(tv)->tv_sec = (long)(ts)->tv_sec; \
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 7ad958d..b5ce63f 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -2709,7 +2709,7 @@ static int _hid_get_config_descriptor(struct hid_device_priv* dev, void *data, i
cd->bLength = LIBUSB_DT_CONFIG_SIZE;
cd->bDescriptorType = LIBUSB_DT_CONFIG;
- cd->wTotalLength = config_total_len;
+ cd->wTotalLength = (uint16_t) config_total_len;
cd->bNumInterfaces = 1;
cd->bConfigurationValue = 1;
cd->iConfiguration = 0;
@@ -2817,7 +2817,7 @@ static int _hid_get_hid_descriptor(struct hid_device_priv* dev, void *data, int
d.bCountryCode = 0;
d.bNumDescriptors = 1;
d.bClassDescriptorType = LIBUSB_DT_REPORT;
- d.wClassDescriptorLength = report_len;
+ d.wClassDescriptorLength = (uint16_t)report_len;
if(size > LIBUSB_DT_HID_SIZE)
size = LIBUSB_DT_HID_SIZE;
@@ -2923,6 +2923,7 @@ static int _hid_get_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
return size + 1;
// TODO:
// return winio_write_sync(hid_handle, buf, size + 1, USBI_DEFAULT_TIMEOUT);
+ return -1;
}
static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int id, void *data, int size)
@@ -2939,6 +2940,7 @@ static int _hid_set_report(struct hid_device_priv* dev, HANDLE hid_handle, int i
return size + 1;
// TODO:
// return winio_write_sync(hid_handle, buf, size + 1, USBI_DEFAULT_TIMEOUT);
+ return -1;
}
static int _hid_get_feature(struct hid_device_priv* dev, HANDLE hid_handle, int id, void *data, int size)