diff options
author | Toby Gray <toby.gray@realvnc.com> | 2013-01-15 22:46:49 +0000 |
---|---|---|
committer | Toby Gray <toby.gray@realvnc.com> | 2013-01-23 00:39:51 +0000 |
commit | 790ffc78b008a03c95d10899f53997b504f55c72 (patch) | |
tree | 77e4913b91518fce4efa1c4aa825c31dd60310c5 /libusb/os/threads_windows.c | |
parent | 788e433d0a628fc8aa2aca3b23c1f64b16d5f4be (diff) | |
download | libusb-790ffc78b008a03c95d10899f53997b504f55c72.tar.gz |
Windows: Simplify poll_windows and add provisions for WinCE
* Because poll_windows now requires struct usbi_transfer to be
defined, it's inclusion in libusbi.h had to be moved down.
Diffstat (limited to 'libusb/os/threads_windows.c')
-rw-r--r-- | libusb/os/threads_windows.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c index 7c09e7d..393d498 100644 --- a/libusb/os/threads_windows.c +++ b/libusb/os/threads_windows.c @@ -25,6 +25,11 @@ #include "libusbi.h" +#if defined(_WIN32_WCE) +#define usbi_sleep(ms) Sleep(ms) +#else +#define usbi_sleep(ms) SleepEx(ms, TRUE) +#endif int usbi_mutex_init(usbi_mutex_t *mutex, const usbi_mutexattr_t *attr) { @@ -70,7 +75,7 @@ int usbi_mutex_unlock(usbi_mutex_t *mutex) { int usbi_mutex_static_lock(usbi_mutex_static_t *mutex) { if(!mutex) return ((errno=EINVAL)); while (InterlockedExchange((LONG *)mutex, 1) == 1) { - SleepEx(0, TRUE); + usbi_sleep(0); } return 0; } @@ -184,7 +189,13 @@ int usbi_cond_timedwait(usbi_cond_t *cond, DWORD millis; extern const uint64_t epoch_time; +#ifdef _WIN32_WCE + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, &filetime); +#else GetSystemTimeAsFileTime(&filetime); +#endif rtime.LowPart = filetime.dwLowDateTime; rtime.HighPart = filetime.dwHighDateTime; rtime.QuadPart -= epoch_time; |