summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2010-03-19 18:13:37 +0000
committerPete Batard <pbatard@gmail.com>2010-03-19 18:13:37 +0000
commite63267c4bb6f8edeb7431932a85d97a27fe3597a (patch)
tree348c4183d806aaf371f861e9c2a63f077a0cc5d6
parent0758c0d9a9c6e26028dff3aff6fa3ed0b641f9c3 (diff)
downloadlibusb-r219.tar.gz
added MinGW-w64 supportr219
struct timespec was not properly detected as defined and ftime generated warnings also fixed a missing EOF CR in poll_windows.c (why do these keep disappearing?)
-rw-r--r--libusb/os/poll_windows.c2
-rw-r--r--libusb/os/threads_windows.c8
-rw-r--r--libusb/os/threads_windows.h5
-rw-r--r--libusb/os/windows_usb.c8
4 files changed, 12 insertions, 11 deletions
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index 645338a..2e0fd96 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -885,4 +885,4 @@ ssize_t usbi_read(int fd, void *buf, size_t count)
out:
LeaveCriticalSection(&_poll_fd[index].mutex);
return r;
-} \ No newline at end of file
+}
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index 6819059..6bc6d72 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -177,16 +177,16 @@ int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex) {
int usbi_cond_timedwait(usbi_cond_t *cond,
usbi_mutex_t *mutex,
const struct timespec *abstime) {
- FILETIME ftime;
+ FILETIME filetime;
ULARGE_INTEGER rtime;
struct timeval targ_time, cur_time, delta_time;
struct timespec cur_time_ns;
DWORD millis;
extern const uint64_t epoch_time;
- GetSystemTimeAsFileTime(&ftime);
- rtime.LowPart = ftime.dwLowDateTime;
- rtime.HighPart = ftime.dwHighDateTime;
+ GetSystemTimeAsFileTime(&filetime);
+ rtime.LowPart = filetime.dwLowDateTime;
+ rtime.HighPart = filetime.dwHighDateTime;
rtime.QuadPart -= epoch_time;
cur_time_ns.tv_sec = (long)(rtime.QuadPart / 10000000);
cur_time_ns.tv_nsec = (long)((rtime.QuadPart % 10000000)*100);
diff --git a/libusb/os/threads_windows.h b/libusb/os/threads_windows.h
index 52ae9c1..14fd662 100644
--- a/libusb/os/threads_windows.h
+++ b/libusb/os/threads_windows.h
@@ -41,13 +41,14 @@ struct usbi_cond_t_ {
typedef struct usbi_cond_t_ usbi_cond_t;
// We *were* getting timespec from pthread.h:
-#ifndef HAVE_STRUCT_TIMESPEC
+#if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED))
#define HAVE_STRUCT_TIMESPEC 1
+#define _TIMESPEC_DEFINED 1
struct timespec {
long tv_sec;
long tv_nsec;
};
-#endif /* HAVE_STRUCT_TIMESPEC */
+#endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */
// We *were* getting ETIMEDOUT from pthread.h:
#ifndef ETIMEDOUT
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 1e66f96..eb93635 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -2028,7 +2028,7 @@ unsigned __stdcall windows_clock_gettime_threaded(void* param)
static int windows_clock_gettime(int clk_id, struct timespec *tp)
{
- FILETIME ftime;
+ FILETIME filetime;
ULARGE_INTEGER rtime;
DWORD r;
switch(clk_id) {
@@ -2059,9 +2059,9 @@ static int windows_clock_gettime(int clk_id, struct timespec *tp)
// with a predef epoch_time to have an epoch that starts at 1970.01.01 00:00
// Note however that our resolution is bounded by the Windows system time
// functions and is at best of the order of 1 ms (or, usually, worse)
- GetSystemTimeAsFileTime(&ftime);
- rtime.LowPart = ftime.dwLowDateTime;
- rtime.HighPart = ftime.dwHighDateTime;
+ GetSystemTimeAsFileTime(&filetime);
+ rtime.LowPart = filetime.dwLowDateTime;
+ rtime.HighPart = filetime.dwHighDateTime;
rtime.QuadPart -= epoch_time;
tp->tv_sec = (long)(rtime.QuadPart / 10000000);
tp->tv_nsec = (long)((rtime.QuadPart % 10000000)*100);