aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2013-02-27 22:58:49 +0000
committerPete Batard <pete@akeo.ie>2013-02-27 22:58:49 +0000
commit0ded9c126e9b48b5ed217e60d392cfb882cbc351 (patch)
tree96dcffe37667b4a47845a0e4d8d9af1b6c0022e1
parentc56f89068452f6ff144cd72ad234540049c06433 (diff)
downloadandroid_external_libusbx-0ded9c126e9b48b5ed217e60d392cfb882cbc351.tar.gz
android_external_libusbx-0ded9c126e9b48b5ed217e60d392cfb882cbc351.tar.bz2
android_external_libusbx-0ded9c126e9b48b5ed217e60d392cfb882cbc351.zip
Misc: Simplify includes and misc. cleanup
* fxload sample provenance * No need for <sys/types.h> in samples as already in libusb.h * Don't bother about sscanf_s in xusb * Use HAVE_### and rely on config.h where possible * Formal inclusion of <winsock.h> in libusb.h for WinCE and WDK * Cleanup of Windows' config.h * Avoid ENAMETOOLONG and ENOTEMPTY conflict between errno.h and winsock.h for WinCE * Additional newlines & braces cleanup
-rw-r--r--examples/fxload.c2
-rw-r--r--examples/listdevs.c3
-rw-r--r--examples/xusb.c7
-rw-r--r--libusb/core.c9
-rw-r--r--libusb/io.c3
-rw-r--r--libusb/libusb.h12
-rw-r--r--libusb/libusbi.h3
-rw-r--r--libusb/os/poll_windows.c2
-rw-r--r--libusb/os/windows_common.h1
-rw-r--r--libusb/os/windows_usb.c2
-rw-r--r--libusb/version_nano.h2
-rw-r--r--msvc/config.h25
-rw-r--r--msvc/errno.h2
-rw-r--r--tests/stress.c4
14 files changed, 25 insertions, 52 deletions
diff --git a/examples/fxload.c b/examples/fxload.c
index 93f9fb9..42e0ca4 100644
--- a/examples/fxload.c
+++ b/examples/fxload.c
@@ -49,7 +49,7 @@ static bool dosyslog = false;
#endif
#ifndef FXLOAD_VERSION
-#define FXLOAD_VERSION (__DATE__ " (development)")
+#define FXLOAD_VERSION (__DATE__ " (libusbx)")
#endif
#ifndef ARRAYSIZE
diff --git a/examples/listdevs.c b/examples/listdevs.c
index 8538bfa..e3d7ef0 100644
--- a/examples/listdevs.c
+++ b/examples/listdevs.c
@@ -18,9 +18,6 @@
*/
#include <stdio.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#endif
#include "libusb.h"
diff --git a/examples/xusb.c b/examples/xusb.c
index 707b58f..1aa3363 100644
--- a/examples/xusb.c
+++ b/examples/xusb.c
@@ -33,10 +33,6 @@
#define msleep(msecs) usleep(1000*msecs)
#endif
-#if !defined(_MSC_VER) || _MSC_VER<=1200 || defined(_WIN32_WCE)
-#define sscanf_s sscanf
-#endif
-
#if !defined(bool)
#define bool int
#endif
@@ -47,7 +43,6 @@
#define false (!true)
#endif
-
// Future versions of libusbx will use usb_interface instead of interface
// in libusb_config_descriptor => catter for that
#define usb_interface interface
@@ -992,7 +987,7 @@ int main(int argc, char** argv)
break;
}
if (i != arglen) {
- if (sscanf_s(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) {
+ if (sscanf(argv[j], "%x:%x" , &tmp_vid, &tmp_pid) != 2) {
printf(" Please specify VID & PID as \"vid:pid\" in hexadecimal format\n");
return 1;
}
diff --git a/libusb/core.c b/libusb/core.c
index 52908af..01b8082 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -25,20 +25,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-#if defined(OS_WINCE)
-#include "missing.h" // getenv()
-#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;
diff --git a/libusb/io.c b/libusb/io.c
index 58c077c..2539b26 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -24,15 +24,12 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
-
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
-
#ifdef USBI_TIMERFD_AVAILABLE
#include <sys/timerfd.h>
#endif
diff --git a/libusb/libusb.h b/libusb/libusb.h
index c3b2f67..d7e84c0 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -40,7 +40,7 @@
#endif /* _SSIZE_T_DEFINED */
#endif /* _MSC_VER */
-/* stdint.h is also not usually available on MS */
+/* stdint.h is not available on older MSVC */
#if defined(_MSC_VER) && (_MSC_VER < 1600) && (!defined(_STDINT)) && (!defined(_STDINT_H))
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
@@ -52,13 +52,14 @@ typedef unsigned __int32 uint32_t;
#if !defined(_WIN32_WCE)
#include <sys/types.h>
#endif
-#include <time.h>
-#include <limits.h>
#if defined(__linux) || defined(__APPLE__) || defined(__CYGWIN__)
#include <sys/time.h>
#endif
+#include <time.h>
+#include <limits.h>
+
/* 'interface' might be defined as a macro on Windows, so we need to
* undefine it so as not to break the current libusbx API, because
* libusb_config_descriptor has an 'interface' member
@@ -69,9 +70,8 @@ typedef unsigned __int32 uint32_t;
#if defined(interface)
#undef interface
#endif
-#if defined(_WIN32_WCE)
-// Needed for "struct timeval" definition
-#include <winsock2.h>
+#if !defined(__CYGWIN__)
+#include <winsock.h>
#endif
#endif
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index f81b5d1..e296a2c 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -30,9 +30,6 @@
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
-#ifdef DDKBUILD
-#include <winsock.h> // needed for struct timeval for WDK
-#endif
#include "libusb.h"
#include "version.h"
diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c
index 03e6f3c..559988a 100644
--- a/libusb/os/poll_windows.c
+++ b/libusb/os/poll_windows.c
@@ -43,7 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <libusbi.h>
+#include "libusbi.h"
// Uncomment to debug the polling layer
//#define DEBUG_POLL_WINDOWS
diff --git a/libusb/os/windows_common.h b/libusb/os/windows_common.h
index d12be6b..c063678 100644
--- a/libusb/os/windows_common.h
+++ b/libusb/os/windows_common.h
@@ -105,4 +105,3 @@
#define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, name, name, ret_on_failure)
#define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args) DLL_DECLARE_PREFIXNAME(api, ret, prefix##name, name, args)
#define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, prefix##name, name, ret_on_failure)
-
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index ffcfc01..1a0c846 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -34,7 +34,7 @@
#include <objbase.h>
#include <winioctl.h>
-#include <libusbi.h>
+#include "libusbi.h"
#include "poll_windows.h"
#include "windows_usb.h"
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 72343ba..c6654db 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10620
+#define LIBUSB_NANO 10621
diff --git a/msvc/config.h b/msvc/config.h
index eb05d3d..1814db5 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -17,28 +17,21 @@
/* Default visibility */
#define DEFAULT_VISIBILITY /**/
-/* Start with debug message logging enabled */
-//#define ENABLE_DEBUG_LOGGING 1
-
-/* Message logging */
+/* Enable global message logging */
#define ENABLE_LOGGING 1
+/* Uncomment to start with debug message logging enabled */
+// #define ENABLE_DEBUG_LOGGING 1
+
+/* type of second poll() argument */
+#define POLL_NFDS_TYPE unsigned int
+
/* Windows/WinCE backend */
#if defined(_WIN32_WCE)
#define OS_WINCE 1
+#define HAVE_MISSING_H
#else
#define OS_WINDOWS 1
-#endif
-
-/* type of second poll() argument */
-#define POLL_NFDS_TYPE unsigned int
-
-#if !defined(_WIN32_WCE)
-
-/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
-
-#endif \ No newline at end of file
+#endif
diff --git a/msvc/errno.h b/msvc/errno.h
index a1d4f64..07d15e3 100644
--- a/msvc/errno.h
+++ b/msvc/errno.h
@@ -59,12 +59,14 @@
/* 35 - Unknown Error */
#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
#define EDEADLK 36
+#if 0
/* 37 - Unknown Error */
#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
#define ENOLCK 39 /* No locks available (46 in Cyg?) */
#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
#define EILSEQ 42 /* Illegal byte sequence */
+#endif
/*
* NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the
diff --git a/tests/stress.c b/tests/stress.c
index 26860a0..e53f415 100644
--- a/tests/stress.c
+++ b/tests/stress.c
@@ -19,12 +19,8 @@
#include <stdio.h>
#include <memory.h>
-#if !defined(_WIN32_WCE)
-#include <sys/types.h>
-#endif
#include "libusb.h"
-
#include "libusbx_testlib.h"
/** Test that creates and destroys a single concurrent context