WinCE: Post integration cleanup
authorPete Batard <pete@akeo.ie>
Sun, 3 Mar 2013 00:56:06 +0000 (00:56 +0000)
committerPete Batard <pete@akeo.ie>
Sun, 3 Mar 2013 00:56:06 +0000 (00:56 +0000)
* Update copyrights and switch to UTF-8 everywhere
* Add SleepEx() to missing.h, and move include to libusbi.h
* Remove ifdef for GetSystemTimeAsFileTime()

libusb/core.c
libusb/libusbi.h
libusb/os/poll_windows.c
libusb/os/poll_windows.h
libusb/os/threads_windows.c
libusb/os/wince_usb.c
libusb/os/wince_usb.h
libusb/os/windows_common.h
libusb/version_nano.h
msvc/missing.h

index 01b8082..b3df73a 100644 (file)
@@ -33,9 +33,6 @@
 #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;
index e296a2c..eed549e 100644 (file)
@@ -31,6 +31,9 @@
 #include <poll.h>
 #endif
 
+#ifdef HAVE_MISSING_H
+#include "missing.h"
+#endif
 #include "libusb.h"
 #include "version.h"
 
index 559988a..da97ca9 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * 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.
  *
@@ -52,7 +53,7 @@
 #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
@@ -157,7 +152,7 @@ void init_polling(void)
        int i;
 
        while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) {
-               usbi_sleep(0);
+               SleepEx(0, TRUE);
        }
        if (!is_polling_set) {
                setup_cancel_io();
@@ -225,7 +220,7 @@ void exit_polling(void)
        int i;
 
        while (InterlockedExchange((LONG *)&compat_spinlock, 1) == 1) {
-               usbi_sleep(0);
+               SleepEx(0, TRUE);
        }
        if (is_polling_set) {
                is_polling_set = FALSE;
index 32145fd..1e92dda 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * 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.
  *
index 9548252..cad27e9 100644 (file)
 
 #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,
@@ -77,7 +71,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) {
-               usbi_sleep(0);
+               SleepEx(0, TRUE);
        }
        return 0;
 }
@@ -87,8 +81,6 @@ int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex) {
        return 0;
 }
 
-
-
 int usbi_cond_init(usbi_cond_t *cond,
                                   const usbi_condattr_t *attr) {
        UNUSED(attr);
@@ -190,13 +182,10 @@ int usbi_cond_timedwait(usbi_cond_t *cond,
        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;
index b90950f..354c0e6 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * 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
index b125721..3db9693 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * 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
index c063678..3230b02 100644 (file)
@@ -3,6 +3,7 @@
  *
  * 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
index c6654db..5724385 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10621
+#define LIBUSB_NANO 10622
index 7846976..183b9d3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * 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
@@ -20,6 +20,9 @@
 #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.