552 Commits

Author SHA1 Message Date
Nicholas Corgan
1421e31ec5 Windows: Add support for 2nd gen Renesas USB 3.0 controllers
* Driver version 3.0.20.0 for uPD720201 & uPD720202 uses RUSB3HUB
* Closes #40
2012-08-22 00:05:59 +01:00
Pete Batard
f2b19e4a32 Windows: Add libusbk.sys & libusb0.sys driver support
* Both libusbk and libusb0.sys rely on libusbk.dll being
  installed to provides a WinUSB-like API for driver access.
* In case libusbk.dll is not present, fall back to WinUSB.
* Closes #11
* Closes #12
2012-08-20 01:17:13 +01:00
Anthony Clay, ZarthCode LLC
c86fb21a3b Windows: Fix C4005 warning under VS2012 for inline.
* Changed inline macro to not fire when using Visual Studio/C++,
  which attempts to redefine the macro - resulting in a C4005 warning.
2012-08-20 01:14:44 +01:00
Pete Batard
d53c599d0b Samples: Make target mandatory with -b option in xusb 2012-08-12 22:57:10 +01:00
Pete Batard
de56675c99 Core: Improve instrumentation of timerfd_settime failures
* Report errno as well as itimerspec data
* Also reuse the timeout variable set to &transfer->timeout
2012-08-12 22:37:02 +01:00
Pete Batard
2d7d3beccc Core: Fix a Clang warning in io.c
* Using sizeof() in the UNUSED() macro didn't silence all
  unused variable warnings.
* Also fix an "unused ctx" warning when ENABLE_DEBUG_LOGGING is on
* Also improve debug output on libusb_open() failure
2012-08-12 22:13:04 +01:00
Matthias Bolte
636ed66d26 Windows: Add workaround for Intel USB 3.0 root hubs
* Intel USB 3.0 root hubs are similar to the Nec/Renesas USB 3.0 root
  hubs as they aren't listed under "USB" either but under "IUSB3".
* Extend the existing workaround for Nec/Renesas USB 3.0 root hubs to
  handle the Intel ones as well.
* Closes #39
2012-08-06 00:00:32 +01:00
Pete Batard
3fadb8b4fa Core: Fix unconditional disarming of timerfd
* Existing code appears disarms the timerfd always, which cancels
  pending timeouts as soon as one packet completes.
* This fix moves the disarming of the timerfd to
  arm_timerfd_for_next_timeout(), where it is now done conditionally.
  It also avoids calling disarm outside of the above call.
* This patch also ensures that all handling of the timerfd is done
  under the flying transfers lock.
* Issue reported by Hans de Goede. For more info, see:
  https://sourceforge.net/mailarchive/message.php?msg_id=29442693
2012-08-04 17:18:18 +01:00
Orin Eman
d2e8b37a68 Core: NULL list pointers on deletion
* This aims at highlighting unwanted behaviours on list operations,
  and facilitate early detection of potential bugs.
* This also requires a fix in threads_windows.c
* See http://sourceforge.net/mailarchive/message.php?msg_id=29626351
2012-08-03 14:31:13 +01:00
Pete Batard
873c65b24f Misc: Add a readme for git user
* Suggested by Yves Arrouye:
  http://sourceforge.net/mailarchive/message.php?msg_id=29577839
2012-08-01 17:43:33 +01:00
Pete Batard
8cd30bb706 Windows: Set device number for root hubs to 1
* Other platforms (Linux, OS-X) appear to use 1 => follow suit.
* For non root hub devices, we simply increment the USB device address.
* Collisions with device address 0 are not expected, but we add
  an assertion for just in case.
2012-07-18 18:25:11 +01:00
Pete Batard
e82c677b5f Windows: Fix overflow when handling HID or composite devices
* When libusb_get_device_list() is called mutliple times, the HID device
  path was unconditionally duplicated in the list of device's interfaces.
* Because array boundaries were not checked, this caused overflow and crash.
* This patch adds an out of bound check and also ensures that duplication
  of data, for HID and composite, does not occur
* It also renames the private composite_api_flags to api_flags, as well as
  reorganizes the private attributes
* Bug report and part of the fix provided by Toby Gray
2012-07-17 20:00:13 +01:00
Simon Haggett
ab1b3843bf Windows: usbi_cond_destroy() should free handles created by usbi_cond_intwait().
* Without this change every call to usbi_cond_destroy() leaks an event handle.
2012-07-17 18:05:20 +01:00
Davidlohr Bueso
1572419e94 All: Replace malloc+memset with calloc 2012-07-13 15:59:57 +01:00
Pete Batard
7ec94a45ed Core: Prefix LOG_LEVEL_ with LIBUSB_ to avoid conflicts
* The LOG_LEVEL_ enums, that were moved to the public API
  in 933a319469bcccc962031c989e39d9d1f44f2885 may conflict
  with applications/headers that also define their own
  LOG_LEVEL_ values internally.
* As a matter of fact, as per Trac #31, this produces a
  conflict with libusb-compat, as it defines its own levels.
2012-07-03 11:01:41 +01:00
Pete Batard
63f569be66 Misc: Fix more Clang warnings in core and darwin
* http://sourceforge.net/mailarchive/message.php?msg_id=29418038
* core.c:700:4: warning: Function call argument is an uninitialized value
* darwin_usb.c:1713:11: warning: Access to field 'cfSource' results in a
  dereference of a null pointer (loaded from variable 'hpriv')
* sync.c/dpfp.c/dpfp_threaded.c: warning: Result of 'malloc' is converted
  to a pointer of type 'unsigned char', which is incompatible with sizeof
  operand type
2012-07-02 18:29:27 +01:00
Pete Batard
0e0cbb6c27 Windows: Address MSVC Level 4 & WDK's OACR/Prefast warnings
* The library is now compiled with warning level 4 for VS2010
* Move silencing of 4200, 28125 and 28719 to msvc/config.h
* Add fixes in core to silence unused variables warnings
* Ensure that spinlock is always set interlocked in poll_windows
* Add missing check for calloc return value
* Fix data assignation in conditionals warnings
* Fix an OACR/Prefast error related to the use of strncpy in xusb.c
* Also fixes whitespace inconsistencies in core
* Issues reported by Orin Eman and Xiaofan Chen. See:
  https://sourceforge.net/mailarchive/message.php?msg_id=29412656
2012-07-02 18:28:37 +01:00
Xiaofan Chen
89b43a6929 Windows: Some versions of dlltool require a library name
* Even though the library name is optional as specified by Microsoft,
  some recent versions of libtool require one in libusb-1.0.def.
* Reference thread in MinGW-w64 mailing list.
  http://comments.gmane.org/gmane.comp.gnu.mingw.w64.general/5141
2012-06-25 18:52:59 +01:00
Pete Batard
f557e096fd Windows: Fix warnings reported by the Intel Compiler
* windows_usb.c(161): warning #181: argument is incompatible
  with corresponding format string conversion
* windows_usb.c(2124): warning #111: statement is unreachable
  usbi_dbg("ERROR: broken timer thread");
* multiple: warning #188: enumerated type mixed with another
* Issues reported by Orin Eman
2012-06-25 18:52:04 +01:00
Pete Batard
8b49ddf248 libusbx-1.0.12 v1.0.12 2012-06-15 15:14:48 +01:00
Xiaofan Chen
5330c3d8ae Samples: Remove USB version for speed designations in xusb 2012-06-14 12:43:26 +01:00
Pete Batard
67df11b691 Windows: Fix erroneous pointer array allocation reported by Clang
* Result of 'calloc' is converted to a pointer of type 'unsigned char *',
  which is incompatible with sizeof operand type 'PUSB_CONFIGURATION_DESCRIPTOR'
* priv->config_descriptor is indeed an array of pointers, with each descriptor
  allocated, rather than a sequential list of fixed descriptor.
2012-06-13 20:52:39 +01:00
Pete Batard
21ce673102 Core: Fix Clang warnings
core.c:
* Result of 'malloc' is converted to a pointer of type 'struct libusb_device *',
  which is incompatible with sizeof operand type 'void *'
* Memory is never released; potential leak of memory pointed to by 'devs'
* Assigned value is garbage or undefined (due to potentially empty and
  uninitialized device list)
descriptor.c:
* Function call argument is an uninitialized value
io.c:
* Call to 'malloc' has an allocation size of 0 bytes
* Branch condition evaluates to a garbage value (due to get_next_timeout
  returning a negative error code instead of zero on error)
2012-06-13 20:52:24 +01:00
Pete Batard
c38f551e16 libusbx 1.0.12-rc1 v1.0.12-rc1 2012-06-11 14:27:17 +01:00
Pete Batard
beeb662e7c Autotools: add libusb-1.0.def and libusb_nano.h as dependencies
* Also add version_nano.h to EXTRA_DIST as it is not added to the
  dist archive by default
2012-06-11 14:26:51 +01:00
Pete Batard
6b33cd4589 Windows: Enable MinGW and MSVC DLL interchangeability
* Because we use the WINAPI calling convention, the def file MUST have the @n
  aliases. There is no way around this as MinGW's .o use decoration always
  for __stdcall, which can't be turned off.
* dlltool must therefore be invoked to create a proper import lib from the .def,
  using the --kill-at option.
* To do that, a CREATE_IMPORT_LIB autotools variable is introduced.
* Note: the .def file is currently maintained manually.
2012-06-08 23:31:56 +01:00
Pete Batard
a983fad006 All: Prevent memory leaks on realloc failures
* p = realloc(p, new_size) does not free the original buffer in case of
  a realloc failure.
* reallocf() can be used to do so, but is not available on all platforms.
* This patch introduces usbi_reallocf() in libusbi.h and use that instead of realloc
* Issue and original patch submitted by Moritz Lipp (trac #27)
2012-06-08 23:30:54 +01:00
Pete Batard
ff3259b440 Windows: Fix possible crash when using longjmp and gcc 4.6
* With gcc-4.6 the option -fomit-frame-pointer is turned on per default
  even for the win32 target. This results in segfaults for any application
  using setjmp/longjmp and MSVCRT.dll on WinXP.
  See http://gcc.gnu.org/ml/gcc/2011-10/msg00351.html
* Issue reported by Lars Kanis
2012-06-07 11:55:30 +01:00
Pete Batard
9497ad5711 Core: Display libusbx version in libusb_init's debug output 2012-06-07 11:50:42 +01:00
Lars Wirzenius
802a994e6c Autotools: Fix autogen.sh behavior when libtool is not found
* Fix naked "exit", which no exit code, to prevent a build failure
  from being noticed automatically if a build dependency is lacking.
* Also printed error message to stderr rather than stdout.
2012-06-06 17:34:59 +01:00
Pete Batard
dd06d6004c Linux: Fix a major regression in threads_posix.c
* On some Linux platforms, libusbx compilation breaks with:
  error: implicit declaration of function ‘pthread_mutexattr_settype’
* This regression, introduced in 463dda06db5da5de0eab32820c7af60605625afe,
  is due to pthread.h needing __USE_UNIX98, which is tied to _XOPEN_SOURCE
  or _GNU_SOURCE being correctly defined, and which the inclusion of
  <unistd.h> before the _XOPEN_SOURCE override modified
* As _GNU_LINUX ensures the definition of __USE_UNIX98 and we require it
  for syscalls, we now only define _GNU_SOURCE for Linux.
2012-06-06 10:53:43 +01:00
Pete Batard
0c089c7a14 Autotools: Fix versioning regression in configure.ac
* Because of missing [], "LIBUSB_MICROLIBUSB_RC" was being displayed
  in lieu of version number
* Regression introduced with c9d41fe5f0324d969f758f42843e1fd05859f438
2012-06-05 17:29:46 +01:00
Pete Batard
cf6e68acb1 Core: Add toggleable debug logging
* Also fix a missing space in debug log messages introduced
  with the previous timestamp logging update
2012-06-04 01:31:06 +01:00
Ludovic Rousseau
a7ab6bafa9 Core: Fix "LOG_LEVEL_NONE not handled in switch" warning 2012-06-04 01:27:11 +01:00
Ludovic Rousseau
56853b54d0 Samples: Fix no previous prototype warnings in xusb 2012-06-04 01:20:45 +01:00
Ludovic Rousseau
c9d41fe5f0 Autotools: Apply autoupdate 2.68 recommendations
* Not applied: AC_PREREQ([2.68]) as this doesn't seem
  necessary and 2.68 was released less than 2 years ago.
2012-06-04 01:19:25 +01:00
Pete Batard
e654642938 Core: Send all logging output to stderr
* This effectively removes the use of stdout for info messages
2012-05-31 18:35:50 +01:00
Pete Batard
4633b7b0cf Darwin: More OS-X logging improvements
* Further alignment of log messages according to severity
* Fix "'darwin_error_str' defined but not used" warning when
  option --disable-log is used (reported by Xiaofan Chen)
2012-05-31 18:35:47 +01:00
Pete Batard
b88ce7d245 Windows: Add new API calls to DLL .def file
* Generated from a MinGW32 generated DLL using the command:
  echo -e "LIBRARY\nEXPORTS" > libusb-1.0.def; strings libusb-1.0.dll | grep libusb | grep @ | sort | sed -e "s/\(.*\)@\([0-9]*\)/  \1\n  \1@\2 = \1/" >> libusb-1.0.def
2012-05-29 16:06:57 +01:00
Pete Batard
3fae93a941 Windows: Restore HID support 2012-05-28 10:57:51 +01:00
Pete Batard
500b037e7d Core: Only display timestamps in debug mode and use init() as origin 2012-05-28 10:54:41 +01:00
Pete Batard
933a319469 Core: Define log levels in libusb.h
* Also update xusb sample to use these levels
2012-05-28 10:35:23 +01:00
Pete Batard
9ec54b6919 Darwin: Align severity of OS-X logging messages
* Some informational messages were actually debug or warning
* Fixes #1
2012-05-28 10:33:55 +01:00
Pete Batard
cfb8610242 All: Add parent and port topology calls
* Adds libusb_get_port_number, libusb_get_parent and libusb_get_port_path
* Linux implementation provided by Alan Stern, OS X by Nathan Hjelm
* Unsupported for *BSD platforms
2012-05-28 10:26:44 +01:00
Pete Batard
a544e5972b Misc: Ensure all sources are UTF-8
* Also remove extra lines at the end of samples
2012-05-23 18:25:01 +01:00
Pete Batard
cd87b6b1f1 Windows: Reduce severity of initial conf desc readout failures
* Failure to read the config descriptor through regular API calls can
  occur for some hubs (eg. 05E3:0608) and is of no major consequence.
* Later failures still reported with error severity as they may hide
  something more dramatic
* Issue reported by Jerry from NovaDSP
2012-05-23 00:10:19 +01:00
Pete Batard
1cc9c6087d Windows: Fix missing cygwin thread ID
* Cygwin uses POSIX threads, not Windows threads
2012-05-10 17:42:16 +01:00
Pete Batard
75b1cf81db Windows: Add INSTALL_WIN.txt 2012-05-10 16:44:30 +01:00
Pete Batard
a221271c67 Misc: Separate nano from version.h
* As version.h processed by autotools, the automatic updating of the
  nano there can result in unneeded reconfs (eg. after issuing a git
  pull, regardless of whether the conf is still valid)
* Avoid this by placing the nano in its own file, as it won't be
  processed by autoconf. This also simplifies the versioning git hooks
  and removes the sed dependency.
2012-05-10 15:56:51 +01:00
Ludovic Rousseau
7e52e1e753 Samples: Use the implicit _SOURCES rule
* By default automake looks for a source file foo.c for a foo binary.
2012-05-10 15:39:11 +01:00