#endif
#include "libusbi.h"
-#ifdef HAVE_MISSING_H
-#include "missing.h"
-#endif
#if defined(OS_LINUX)
const struct usbi_os_backend * const usbi_backend = &linux_usbfs_backend;
#include <poll.h>
#endif
+#ifdef HAVE_MISSING_H
+#include "missing.h"
+#endif
#include "libusb.h"
#include "version.h"
/*
* poll_windows: poll compatibility wrapper for Windows
- * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
+ * Copyright © 2012-2013 RealVNC Ltd.
+ * Copyright © 2009-2010 Pete Batard <pete@akeo.ie>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of poll implementation from libusb-win32, by Stephan Meyer et al.
*
#else
// MSVC++ < 2005 cannot use a variadic argument and non MSVC
// compilers produce warnings if parenthesis are ommitted.
-#if defined(_MSC_VER) && _MSC_VER < 1400
+#if defined(_MSC_VER) && (_MSC_VER < 1400)
#define poll_dbg
#else
#define poll_dbg(...)
#pragma warning(disable:28719)
#endif
-#if defined(_WIN32_WCE)
-#define usbi_sleep(ms) Sleep(ms)
-#else
-#define usbi_sleep(ms) SleepEx(ms, TRUE)
-#endif
-
#define CHECK_INIT_POLLING do {if(!is_polling_set) init_polling();} while(0)
// public fd data
int i;
while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) {
- usbi_sleep(0);
+ SleepEx(0, TRUE);
}
if (!is_polling_set) {
setup_cancel_io();
int i;
while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) {
- usbi_sleep(0);
+ SleepEx(0, TRUE);
}
if (is_polling_set) {
is_polling_set = FALSE;
/*
* Windows compat: POSIX compatibility wrapper
- * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
+ * Copyright © 2012-2013 RealVNC Ltd.
+ * Copyright © 2009-2010 Pete Batard <pete@akeo.ie>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of poll implementation from libusb-win32, by Stephan Meyer et al.
*
#include "libusbi.h"
-#if defined(_WIN32_WCE)
-#define usbi_sleep(ms) Sleep(ms)
-#else
-#define usbi_sleep(ms) SleepEx(ms, TRUE)
-#endif
-
extern const uint64_t epoch_time;
int usbi_mutex_init(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) {
- usbi_sleep(0);
+ SleepEx(0, TRUE);
}
return 0;
}
return 0;
}
-
-
int usbi_cond_init(usbi_cond_t *cond,
const usbi_condattr_t *attr) {
UNUSED(attr);
struct timespec cur_time_ns;
DWORD millis;
-#ifdef _WIN32_WCE
+ // GetSystemTimeAsFileTime() is not available on CE
SYSTEMTIME st;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &filetime);
-#else
- GetSystemTimeAsFileTime(&filetime);
-#endif
rtime.LowPart = filetime.dwLowDateTime;
rtime.HighPart = filetime.dwHighDateTime;
rtime.QuadPart -= epoch_time;
/*
- * Windows CE backend for libusb 1.0
- * Copyright (C) 2011-2012 RealVNC Ltd.
+ * Windows CE backend for libusbx 1.0
+ * Copyright © 2011-2013 RealVNC Ltd.
* Large portions taken from Windows backend, which is
- * Copyright (C) 2009-2010 Pete Batard <pbatard@gmail.com>
+ * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
* Major code testing contribution by Xiaofan Chen
/*
- * Windows CE backend for libusb 1.0
- * Copyright (C) 2011-2012 RealVNC Ltd.
+ * Windows CE backend for libusbx 1.0
+ * Copyright © 2011-2013 RealVNC Ltd.
* Portions taken from Windows backend, which is
- * Copyright (C) 2009-2010 Pete Batard <pbatard@gmail.com>
+ * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
* Major code testing contribution by Xiaofan Chen
*
* This file brings together header code common between
* the desktop Windows and Windows CE backends.
+ * Copyright © 2012-2013 RealVNC Ltd.
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
* With contributions from Michael Plante, Orin Eman et al.
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
-#define LIBUSB_NANO 10621
+#define LIBUSB_NANO 10622
/*
* Header file for missing WinCE functionality
- * Copyright © 2012 RealVNC Ltd.
+ * Copyright © 2012-2013 RealVNC Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#ifndef MISSING_H
#define MISSING_H
+/* Windows CE doesn't have SleepEx() - Fallback to Sleep() */
+#define SleepEx(m, a) Sleep(m)
+
/* Windows CE doesn't have any APIs to query environment variables.
*
* This contains a registry based implementation of getenv.