platform/upstream/libusb.git
13 years agoio.c: Fix clang analyzer warning about unused variable
Sean McBride [Fri, 5 Feb 2010 16:50:34 +0000 (11:50 -0500)]
io.c: Fix clang analyzer warning about unused variable

References #28.

13 years ago.gitignore: Add m4 subdirectory created by libtool
Peter Stuge [Tue, 10 May 2011 08:44:18 +0000 (10:44 +0200)]
.gitignore: Add m4 subdirectory created by libtool

13 years agoLinux: Do not include useless pthread.h
Ludovic Rousseau [Mon, 15 Nov 2010 13:45:50 +0000 (14:45 +0100)]
Linux: Do not include useless pthread.h

The code does not use threads so no need to #include <pthread.h>
Fixes #74.

13 years agoWindows: minor code improvements
Pete Batard [Tue, 8 Mar 2011 17:41:05 +0000 (17:41 +0000)]
Windows: minor code improvements

* mostly warnings from VS2010's Intellisense

13 years agoWindows: prevent set_configuration request from being sent using WinUSB
Pete Batard [Tue, 8 Mar 2011 17:40:39 +0000 (17:40 +0000)]
Windows: prevent set_configuration request from being sent using WinUSB

* multiple WinUSB set configuration requests can stall a device and
  WinUSB does not support setting of alt configuration in the first place
* issue reported and investigated by Xiaofan Chen

13 years agoWindows: fixed default WinUSB timeout and ineffective policy settings
Graeme Gill [Tue, 8 Mar 2011 17:39:16 +0000 (17:39 +0000)]
Windows: fixed default WinUSB timeout and ineffective policy settings

* default WinUSB timeout was 5 seconds, which may be to small.
  PIPE_TRANSFER_TIMEOUT policy is now set to infinite for all EPs.
* other WinUSB policy settings were called before the endpoints
  had been set. This is now fixed.

13 years agoWindows: Don't leak pipe fds
Pete Batard [Tue, 8 Mar 2011 17:37:40 +0000 (17:37 +0000)]
Windows: Don't leak pipe fds

use _open() and _close() rather than _open_osfhandle() and CloseHandle()

* use of CloseHandle() prevented the pipe fds from being
  relinquished on libusb_exit()
* leaked fds could lead to the OS running out of new fds
  and LIBUSB_ERROR_NO_MEM being returned as a result
* using _open() avoids _open_osfhandle() redef for cygwin
* issue reported by Stephano Antonelli

13 years agoWindows: enumeration overhaul
Peter Stuge [Tue, 10 May 2011 08:05:29 +0000 (10:05 +0200)]
Windows: enumeration overhaul

* uses multiple passes in a single call
* uses a hash table, in anticipation for hotplug
* adds a (dummy) HUB interface for harmonization
* adds calloc on device struct creation in core
  (to detect and avoid unnecessary double initialization)

13 years agoWindows: MS project files part 4 - MSVC6 project files
Pete Batard [Mon, 9 May 2011 23:56:18 +0000 (00:56 +0100)]
Windows: MS project files part 4 - MSVC6 project files

Fixes #57 and #1.

13 years agoWindows: MS project files part 3 - VS2005 project files
Pete Batard [Mon, 9 May 2011 23:53:09 +0000 (00:53 +0100)]
Windows: MS project files part 3 - VS2005 project files

References #57.

13 years agoWindows: MS project files part 2 - WDK project files
Pete Batard [Mon, 9 May 2011 23:38:49 +0000 (00:38 +0100)]
Windows: MS project files part 2 - WDK project files

References #57.

13 years agoWindows: MS project files part 1 - support files & preliminaries
Pete Batard [Mon, 9 May 2011 23:38:12 +0000 (00:38 +0100)]
Windows: MS project files part 1 - support files & preliminaries

* adds the MSVC support files used by MSVC6, VS2005 and WDK
* also adds missing defines required by MS compilers in libusb.h
* also anticipatory sets .gitattributes for CRLF handling
* also adds manually maintained .def file for import lib generation

References #57.

13 years agoMove library version number from configure.ac to libusb/version.h
Peter Stuge [Mon, 9 May 2011 06:12:24 +0000 (08:12 +0200)]
Move library version number from configure.ac to libusb/version.h

This is neccessary to support native MS builds. The Windows resource
file libusb/libusb-1.0.rc must include the release version, which was
previously only available after configure had run and had substituted
the numbers into a generated libusb/libusb-1.0.rc file.

The version atoms are now stored as CPP style #defines in libusb/version.h
so that the .rc no longer needs to be generated but can simply include the
header file and access the version information directly.

The m4 macro LU_DEFINE_VERSION_ATOM() was added to configure.ac to get
version atoms from libusb/version.h for use in AC_INIT(). The macro
handles C and C++ style comments in version.h, but can easily be made
to fail by obscuring the file. Please don't do that.

Tested with MinGW using autoconf, and manual compile of libusb-1.0.rc
using RC.EXE Version 5.2.3690.0 from Visual C++ 2005 Express Edition.

13 years agoWindows: Debug builds create the same .dll file name as non-debug
Peter Stuge [Tue, 10 May 2011 06:36:32 +0000 (08:36 +0200)]
Windows: Debug builds create the same .dll file name as non-debug

Thanks to Pete for pointing this out!

13 years agoWindows: explicit use of ANSI or WideChar calls
Pete Batard [Tue, 8 Mar 2011 17:18:48 +0000 (17:18 +0000)]
Windows: explicit use of ANSI or WideChar calls

* This is in anticipation of adding MSVC project files
  that use Unicode rather than MBCS

13 years agoWindows: Remove SetupAPI, AdvAPI32 and OLE32 link-time dependencies
Pete Batard [Tue, 8 Mar 2011 17:16:23 +0000 (17:16 +0000)]
Windows: Remove SetupAPI, AdvAPI32 and OLE32 link-time dependencies

* this ensures that libusb dependent applications only need
  to explicitly link against libusb on Windows

The run-time dependency on Cfgmgr32.dll, OLE32.dll and SetupAPI.dll remains.

13 years agoAdd .gitattributes to avoid Windows line ending issues with autocrlf
Pete Batard [Tue, 8 Mar 2011 17:12:33 +0000 (17:12 +0000)]
Add .gitattributes to avoid Windows line ending issues with autocrlf

13 years agoWindows: Touch up FileDescription and ProductName resource strings
Peter Stuge [Sun, 27 Feb 2011 08:37:54 +0000 (09:37 +0100)]
Windows: Touch up FileDescription and ProductName resource strings

13 years agoWindows: Remove emulated direct device access via HID API
Peter Stuge [Sun, 27 Feb 2011 06:20:40 +0000 (07:20 +0100)]
Windows: Remove emulated direct device access via HID API

Either use a library such as HIDAPI to communicate with HID class
devices, or replace the kernel driver for the device with one that
offers support for the complete libusb API.

13 years agoRevert libusb_strerror() until we have i18n and l10n
Peter Stuge [Sun, 27 Feb 2011 05:59:15 +0000 (06:59 +0100)]
Revert libusb_strerror() until we have i18n and l10n

13 years agodpfp_threaded: return instead of pthread_exit() to avoid Cygwin warning
Pete Batard [Wed, 19 Jan 2011 14:00:12 +0000 (14:00 +0000)]
dpfp_threaded: return instead of pthread_exit() to avoid Cygwin warning

13 years agoWindows: Rename various variables named "index" to avoid shadow warnings
Pete Batard [Wed, 19 Jan 2011 13:52:08 +0000 (13:52 +0000)]
Windows: Rename various variables named "index" to avoid shadow warnings

13 years agoWindows: Fix logic in enumeration of driver name and port number
Pete Batard [Tue, 5 Oct 2010 11:50:53 +0000 (12:50 +0100)]
Windows: Fix logic in enumeration of driver name and port number

13 years agoWindows: Allow claiming any interface in composite device using WinUSB
Pete Batard [Tue, 5 Oct 2010 11:50:13 +0000 (12:50 +0100)]
Windows: Allow claiming any interface in composite device using WinUSB

Issue reported by Benjamin Dobell, see #48. The call to
WinUsb_QueryInterfaceSettings() is removed since it doesn't work
on any other interface but the first (a WinUSB limitation).

This allows the use of WinUSB.sys in lieu of the usbccgp.sys
"USB Generic Parent" default driver for composite devices.

13 years agoWindows: Allow arbitrary bConfigurationValue in config descriptors
Pete Batard [Tue, 5 Oct 2010 11:47:15 +0000 (12:47 +0100)]
Windows: Allow arbitrary bConfigurationValue in config descriptors

Unlike bInterfaceNumber, bConfigurationValue does not have to be
either sequential or contiguous. The bConfigurationValue is now
included in debug output. Fixes #48 reported by Benjamin Dobell.

13 years agoDarwin: Schedule isochronous transfers further in the future
Thomas Röfer [Fri, 19 Nov 2010 21:03:11 +0000 (22:03 +0100)]
Darwin: Schedule isochronous transfers further in the future

This is required to make OpenKinect transfer data at 30 fps. This
change was originally made by Theo Watson, and Thomas improved on it.
The commit came via OpenKinect into libusb thanks to Kyle Machulis and
Hector Martin. Fixes #66.

13 years agoDarwin: Fix #65 memory leak in submit_iso_transfer()
Thomas Röfer [Fri, 19 Nov 2010 21:03:11 +0000 (22:03 +0100)]
Darwin: Fix #65 memory leak in submit_iso_transfer()

This was also independently fixed by Hoi-Ho Chan, but Thomas caught
an additional problem with his fix.

This commit came via OpenKinect into libusb thanks to Kyle Machulis
and Hector Martin.

13 years agoconfigure.ac: Refactor Windows backend settings into one occurence
Peter Stuge [Sat, 26 Feb 2011 03:21:05 +0000 (04:21 +0100)]
configure.ac: Refactor Windows backend settings into one occurence

The Windows backend is used both with MinGW and Cygwin, and since most
settings are identical they can be set in one place.

13 years agoconfigure.ac: Rename AM_LDFLAGS to LTLDFLAGS and actually use them
Peter Stuge [Mon, 15 Nov 2010 18:58:51 +0000 (19:58 +0100)]
configure.ac: Rename AM_LDFLAGS to LTLDFLAGS and actually use them

The new variable name tries to clarify that libtool is being used.
Linker flags must thus always be specified with -Wl.

Factor out the libtool flag -no-undefined from host specific cases.
The flag is required to build a Windows DLL, but is correct also for
the other supported systems.

Also, start actually using LTLDFLAGS in libusb/Makefile.am, so that
libtool will see the options set by configure.

13 years agoconfigure.ac: Clean up PC_LIBS_PRIVATE and AM_LDFLAGS
Peter Stuge [Sun, 21 Nov 2010 22:38:46 +0000 (23:38 +0100)]
configure.ac: Clean up PC_LIBS_PRIVATE and AM_LDFLAGS

Move linker options for when linking the library itself from
PC_LIBS_PRIVATE into AM_LDFLAGS. PC_LIBS_PRIVATE should only
contain flags needed to link applications statically against libusb.
Fixes #72.

13 years agoconfigure.ac: Call AC_CONFIG_FILES() for each output file
Peter Stuge [Fri, 25 Feb 2011 01:33:29 +0000 (02:33 +0100)]
configure.ac: Call AC_CONFIG_FILES() for each output file

This avoids a problem with Windows line endings.

13 years agoconfigure.ac: Whitespace changes and trivial reordering
Peter Stuge [Sun, 21 Nov 2010 22:37:27 +0000 (23:37 +0100)]
configure.ac: Whitespace changes and trivial reordering

13 years agoconfigure.ac: Quote AC_COMPILE_IFELSE() input
Peter Stuge [Sun, 21 Nov 2010 22:10:35 +0000 (23:10 +0100)]
configure.ac: Quote AC_COMPILE_IFELSE() input

13 years agoconfigure.ac: Define booleans to 1 when set, instead of an empty string
Peter Stuge [Sun, 21 Nov 2010 22:09:02 +0000 (23:09 +0100)]
configure.ac: Define booleans to 1 when set, instead of an empty string

This makes the generated config.h look a lot nicer.

13 years agoconfigure.ac: Clean up redundancy and fix LIBS on Linux
Peter Stuge [Sat, 30 Oct 2010 20:28:59 +0000 (22:28 +0200)]
configure.ac: Clean up redundancy and fix LIBS on Linux

LIBS, AM_LDFLAGS, OS_ conditionals and THREADS_POSIX had a bit of
redundancy throughout the file, and on Linux LIBS ended up missing
the -pthread flag.

13 years agoconfigure.ac: Touch up Darwin and Cygwin OS messages
Peter Stuge [Sat, 26 Feb 2011 03:08:38 +0000 (04:08 +0100)]
configure.ac: Touch up Darwin and Cygwin OS messages

13 years agoconfigure.ac: Do not use -pthread on Darwin
Peter Stuge [Sat, 30 Oct 2010 20:13:05 +0000 (22:13 +0200)]
configure.ac: Do not use -pthread on Darwin

It's not needed because Darwin has POSIX Threads in libc. Fixes #96.

13 years agoconfigure.ac: Check for poll.h, and for nfds_t on Darwin
Peter Stuge [Sat, 30 Oct 2010 20:07:37 +0000 (22:07 +0200)]
configure.ac: Check for poll.h, and for nfds_t on Darwin

On Linux, assume nfds_t is always available.

On Darwin, fall back to unsigned int when poll() exists but there
is no nfds_t, such as on Mac OS X before 10.4.

On Windows (both MinGW and Cygwin), always use unsigned int instead
of nfds_t, and don't check for poll.h because we use our own poll()
implementation.

13 years agoDarwin: Add support for control requests on endpoints other than 0
Nathan Hjelm [Wed, 6 Oct 2010 02:08:08 +0000 (20:08 -0600)]
Darwin: Add support for control requests on endpoints other than 0

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
13 years agoDarwin: Add more error checking for libusb_open()
Nathan Hjelm [Wed, 6 Oct 2010 05:11:50 +0000 (23:11 -0600)]
Darwin: Add more error checking for libusb_open()

Now also check the CreateDeviceAsyncEventSource() return code for errors.

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
13 years agoCore: libusb_get_next_timeout() must consider all flying transfers
Peter Stuge [Wed, 3 Nov 2010 20:46:53 +0000 (21:46 +0100)]
Core: libusb_get_next_timeout() must consider all flying transfers

If transfer->flags indicated that a transfer had a timeout, but no
timeout was actually set, then libusb_get_next_timeout() would look
no further for a timeout, ignoring any transfers later in the list
which had a timeout set.

Since libusb has an internal 60 second timeout this bug could not
cause complete lockup, but it could cause a 60 second timeout even
when a transfer was submitted with a shorter timeout.

13 years agoLinux: Correctly catch read() errors for sysfs config descriptors
Ludovic Rousseau [Mon, 15 Nov 2010 13:55:51 +0000 (14:55 +0100)]
Linux: Correctly catch read() errors for sysfs config descriptors

read(2) returns ssize_t (signed) and not size_t (unsigned) or int.

Silence "warning: comparison of unsigned expression < 0 is always false"
and fix #75.

13 years agoLinux: Refactor cancellation into one function for all transfer types
Peter Stuge [Sun, 23 Jan 2011 03:01:25 +0000 (04:01 +0100)]
Linux: Refactor cancellation into one function for all transfer types

13 years agoLinux: Refactor discarding of URBs into a function and return all errors
Peter Stuge [Sun, 17 Oct 2010 06:19:56 +0000 (08:19 +0200)]
Linux: Refactor discarding of URBs into a function and return all errors

The Linux backend did not always return errors according to the
libusb_cancel_transfer() documentation.

13 years agoLinux: Set private number of URBs also for control transfers
Peter Stuge [Sun, 23 Jan 2011 03:01:01 +0000 (04:01 +0100)]
Linux: Set private number of URBs also for control transfers

13 years agoLinux: cancel URBs in reverse order
Alan Stern [Sun, 17 Oct 2010 04:57:06 +0000 (06:57 +0200)]
Linux: cancel URBs in reverse order

In a multi-URB transfer, URBs should be cancelled in reverse order of
submission. This prevents races that might otherwise occur (after URB N
is cancelled, data may be transferred for URB N+1 before it too can be
cancelled). Fixes #8.

13 years agoLinux: report correct value for urb->actual_length
Alan Stern [Sun, 17 Oct 2010 02:17:32 +0000 (04:17 +0200)]
Linux: report correct value for urb->actual_length

Transferred bytes are returned correctly by the kernel for every URB,
even when an error occurs.  Hence they should always be included in
the transfer statistics.  The same is true for isochronous packet
length and status.

[stuge: set itransfer->transferred so data is stored at correct offset]

13 years agoLinux: improve reporting of URB error status codes
Alan Stern [Fri, 22 Oct 2010 09:13:34 +0000 (11:13 +0200)]
Linux: improve reporting of URB error status codes

Fix the way overflow errors are handled (they can occur in any
transaction, not just the last one in a transfer) and add tests
for other commonly-occuring error statuses.

13 years agoLinux: improve detection of BULK_CONTINUATION kernel support
Alan Stern [Tue, 5 Oct 2010 15:08:40 +0000 (11:08 -0400)]
Linux: improve detection of BULK_CONTINUATION kernel support

Clarify the comments describing the BULK_CONTINATION flag, and improve
the subroutine that checks whether the flag is supported by making it
"future-proof", i.e., by working properly with kernel version numbers
higher than 2.6.

13 years agoREADME: Update webpage URL and add Peter's email address
Peter Stuge [Mon, 22 Nov 2010 04:14:00 +0000 (05:14 +0100)]
README: Update webpage URL and add Peter's email address

13 years agolibusb is not just for Linux!
Peter Stuge [Wed, 4 Aug 2010 05:30:22 +0000 (07:30 +0200)]
libusb is not just for Linux!

13 years agoRemove USBI_OS_HANDLES_TIMEOUT and fix int/isoc timeouts on Darwin
Nathan Hjelm [Wed, 6 Oct 2010 01:48:39 +0000 (19:48 -0600)]
Remove USBI_OS_HANDLES_TIMEOUT and fix int/isoc timeouts on Darwin

Backends set USBI_TRANSFER_OS_HANDLES_TIMEOUT for transfers instead.
Darwin only handles timeouts for bulk and control transfers, so the
backend now sets that flag accordingly, making libusb core handle
timeouts for interrupt and isochronous transfers. Fixes #31.

Signed-off-by: Nathan Hjelm <hjelmn@me.com>
[stuge: rework libusb_get_next_timeout() and enum usbi_transfer_flags]
[stuge: fix typo; set USBI_TRANSFER_TIMED_OUT flag correctly]

13 years agoSilence "warning: suggest braces around empty body in an 'if' statement"
Peter Stuge [Sun, 14 Nov 2010 02:14:00 +0000 (03:14 +0100)]
Silence "warning: suggest braces around empty body in an 'if' statement"

13 years agoDisallow libusb_get_string_descriptor_ascii() with index 0
Konrad Rzepecki [Sat, 13 Nov 2010 13:09:22 +0000 (14:09 +0100)]
Disallow libusb_get_string_descriptor_ascii() with index 0

String descriptor 0 is the list of supported language IDs in the device,
which can't have an ASCII representation. Calling the function with
index 0 is thus not really useful. Fixes #43.

13 years agoUse const for the usbi_parse_descriptor() format string
Ludovic Rousseau [Fri, 19 Mar 2010 14:35:14 +0000 (15:35 +0100)]
Use const for the usbi_parse_descriptor() format string

Constant strings should be "const char *" instead of "char *". Silence
"discards qualifiers from pointer target type" warnings. Fixes #61.

13 years agoLinux: Fix usbfs/sysfs config descriptor handling on big-endian
Hector Martin [Wed, 25 Aug 2010 01:21:57 +0000 (03:21 +0200)]
Linux: Fix usbfs/sysfs config descriptor handling on big-endian

usbfs endian-swaps, sysfs doesn't, not the other way around. Fixes #51;
descriptor endian parsing is backwards using sysfs on big-endian hosts.
usbfs is untested.

Signed-off-by: Hector Martin <hector@marcansoft.com>
[stuge: checked against Documentation/usb/proc_usb_info.txt]

13 years agoexamples: #include <libusb.h> without directory name
Ludovic Rousseau [Tue, 17 Aug 2010 18:53:04 +0000 (20:53 +0200)]
examples: #include <libusb.h> without directory name

The libusb-1.0 directory name belongs in the compile command, e.g.
via pkg-config --cflags. Fixes #58.

13 years agoAdd missing argument to libusb_wait_for_event() documentation, fix #55
Ludovic Rousseau [Thu, 24 Jun 2010 08:14:24 +0000 (10:14 +0200)]
Add missing argument to libusb_wait_for_event() documentation, fix #55

In the libusb_wait_for_event() sample code in the section "Letting other
threads do the work for you" the call to libusb_wait_for_event() was not
updated by commit 1df713d622ab4f0b03aad72d903ac7beb8fb3b90, which added
the libusb_context *ctx parameter to the function, so the sample code
was broken until now.

13 years agoexamples: Silence warnings about return value of fwrite()
Peter Stuge [Sat, 16 Oct 2010 12:22:30 +0000 (14:22 +0200)]
examples: Silence warnings about return value of fwrite()

13 years agoLinux: Don't free() URBs prematurely on hardware error; fix #54
Peter Stuge [Sat, 16 Oct 2010 09:47:14 +0000 (11:47 +0200)]
Linux: Don't free() URBs prematurely on hardware error; fix #54

When an URB in a multi-URB transfer had an error, handle_bulk_completion()
would free all URBs and segfault once the next one completed, instead of
cancelling the remaining URBs and cleaning up as usual.

This is basically the patch from the ticket, plus some restructuring
for increased readability of the function.

Many thanks to Brian Shirley and National Instruments for finding and
fixing this!

13 years agoWindows: add support for filter drivers
Pete Batard [Tue, 5 Oct 2010 11:43:41 +0000 (12:43 +0100)]
Windows: add support for filter drivers

* precedence is driver > upper filter > lower filter, and defined
  in struct driver_lookup lookup from set_device_paths()

13 years agoWindows: fix errcode shadow warning, and string and DLL_DECLARE fixes
Pete Batard [Tue, 5 Oct 2010 11:36:49 +0000 (12:36 +0100)]
Windows: fix errcode shadow warning, and string and DLL_DECLARE fixes

* use FormatMessageA, and overall improvement of windows_error_str()
* use safe_strlen() always
* better typing/init default
* more explicit debug message for devices with no driver

13 years agoWindows: use IOCTLs for HID input, output and feature reports
Pete Batard [Tue, 5 Oct 2010 11:29:32 +0000 (12:29 +0100)]
Windows: use IOCTLs for HID input, output and feature reports

* fixes feature reports not providing actual read size
  (reported by Axel Rohde http://marc.info/?m=127033070021994)
* removes the USE_HIDD_FOR_REPORTS macro
* IOCTL usage inspired from HIDAPI by Alan Ott

13 years agoFix libtool version setting
Daniel Drake [Mon, 4 Oct 2010 19:03:58 +0000 (20:03 +0100)]
Fix libtool version setting

This was being set too early to take effect.

13 years agoPopulate the pkg-config Libs.private field
Mike Frysinger [Mon, 4 Oct 2010 19:01:07 +0000 (20:01 +0100)]
Populate the pkg-config Libs.private field

13 years agoLinux: fix build failure when CLOCK_MONOTONIC does not exist
Mike Frysinger [Fri, 20 Aug 2010 04:09:46 +0000 (00:09 -0400)]
Linux: fix build failure when CLOCK_MONOTONIC does not exist

This is not available on all platforms.

13 years agoUpdate libtool version info
Daniel Drake [Mon, 4 Oct 2010 17:45:18 +0000 (18:45 +0100)]
Update libtool version info

With input from various people on the mailing list, update the libtool
versioning info and start to update this on every release.

The next libusb release will not need a change here. All following ones
will.

13 years agoUpdated documentation for unsupported Darwin/Windows calls
Pete Batard [Thu, 5 Aug 2010 15:40:09 +0000 (16:40 +0100)]
Updated documentation for unsupported Darwin/Windows calls

13 years agoWindows: Make libusb_pollfd() return error
Pete Batard [Sun, 19 Sep 2010 13:24:25 +0000 (14:24 +0100)]
Windows: Make libusb_pollfd() return error

Windows does not have numerical file descriptors but does have the
concept of event sources. Exposing these event sources will require
some careful thought and design, to be completed later.

13 years agoMinGW: Use --add-stdcall-alias linker option
Daniel Drake [Sun, 19 Sep 2010 13:21:01 +0000 (14:21 +0100)]
MinGW: Use --add-stdcall-alias linker option

Naming of symbols inside the library is inconsistent on Windows:
http://wyw.dcweb.cn/stdcall.htm

Use this linker option to add aliases which add compatibility with
the "MSVC DLL" platform when a DEF file is used. It also better matches
the appearance of the Windows API itself.

13 years agoIntroduced calling convention (for Windows)
Pete Batard [Fri, 13 Aug 2010 10:59:49 +0000 (11:59 +0100)]
Introduced calling convention (for Windows)

Under Windows, a variety of compilers and configurations are available,
meaning that the manner of parameter passing (e.g. registers vs stack)
can vary.

Match the Windows API calling convention and document this appropriately.
This calling convention will be used regardless of the configuration of
the user's development platform.

The only user-level complication is that all functions used as libusb
callbacks must use the same calling convention as libusb. The
LIBUSB_CALL macro is provided to make this easy.

Signed-off-by: Michael Plante <michael.plante@gmail.com>
Signed-off-by: Pete Batard <pbatard@gmail.com>
[dsd: slight change of strategy, add documentation]

13 years agoWindows: fix string copy in sanitize_path
Pete Batard [Sat, 7 Aug 2010 03:56:04 +0000 (21:56 -0600)]
Windows: fix string copy in sanitize_path

The NULL byte was not being copied.

13 years agoWindows: DuplicateHandle failure is not a warning
Pete Batard [Thu, 29 Jul 2010 23:30:31 +0000 (00:30 +0100)]
Windows: DuplicateHandle failure is not a warning

This is because WinUSB handles are not duplicable, and generate a
lot of these warnings.

13 years agoremoved trailing whitespaces
Pete Batard [Thu, 29 Jul 2010 23:23:05 +0000 (00:23 +0100)]
removed trailing whitespaces

13 years agoWindows: Mark interfaces as unused when releasing
Pete Batard [Thu, 5 Aug 2010 00:18:32 +0000 (18:18 -0600)]
Windows: Mark interfaces as unused when releasing

Without this important cleanup, the autoclaim code could attempt to
reuse an unclaimed interface as if it were already claimed.

13 years agoWindows: fix device path string duplication
Pete Batard [Thu, 5 Aug 2010 00:15:59 +0000 (18:15 -0600)]
Windows: fix device path string duplication

13 years agoDarwin: Cache device configuration value
Nathan Hjelm [Tue, 3 Aug 2010 03:27:38 +0000 (21:27 -0600)]
Darwin: Cache device configuration value

Cache device configuration value to bring the Darwin backend more in
line with the libusb spec. To handle buggy devices GetConfiguration is
not called unless the device has more than one configuration.

13 years agoFix inconsistencies between prototypes and definitions
Xiaofan Chen [Fri, 30 Jul 2010 14:56:43 +0000 (15:56 +0100)]
Fix inconsistencies between prototypes and definitions

This removes some warnings on cygwin regarding a name clash against
the standard library "index" function.

13 years agoDarwin: handle kIOReturnUnderrun
Hoi-Ho Chan [Wed, 28 Jul 2010 03:04:17 +0000 (21:04 -0600)]
Darwin: handle kIOReturnUnderrun

This return code indicates that the device returned a data packet
less than the max packet size. In libusb backend terms, this is
a successful transfer.

13 years agoAdd Windows support
Pete Batard [Sat, 10 Jul 2010 23:51:13 +0000 (17:51 -0600)]
Add Windows support

Via Cygwin/MinGW, libusb now has windows support.
Thanks to contributors: Michael Plante, Orin Eman, Peter Stuge,
Stephan Meyer, Xiaofan Chen.

13 years agoDarwin: write iso transfer details into correct packets
Hoi-Ho Chan [Sat, 24 Jul 2010 19:48:00 +0000 (13:48 -0600)]
Darwin: write iso transfer details into correct packets

13 years agoDarwin: fix interface object leak
Nathan Hjelm [Sat, 24 Jul 2010 19:42:57 +0000 (13:42 -0600)]
Darwin: fix interface object leak

13 years agoDarwin: clean up some debug messages
Nathan Hjelm [Sat, 24 Jul 2010 19:41:03 +0000 (13:41 -0600)]
Darwin: clean up some debug messages

13 years agoDarwin: Don't open devices during scan unless we have to unsuspend
Nathan Hjelm [Sat, 24 Jul 2010 19:39:16 +0000 (13:39 -0600)]
Darwin: Don't open devices during scan unless we have to unsuspend

13 years agoLinux: Handle early complete of multi-URB transfer
Peter Stuge [Fri, 25 Jun 2010 06:08:13 +0000 (08:08 +0200)]
Linux: Handle early complete of multi-URB transfer

13 years agoOnly compile dpfp examples when sigaction is available
Daniel Drake [Wed, 21 Jul 2010 23:49:21 +0000 (17:49 -0600)]
Only compile dpfp examples when sigaction is available

It's not available on MinGW.

14 years agoconfigure.ac: fix bashisms
Aurelien Jarno [Tue, 25 May 2010 07:32:19 +0000 (09:32 +0200)]
configure.ac: fix bashisms

14 years agoOnly include sys/time.h on appropriate platforms
Daniel Drake [Fri, 25 Jun 2010 17:01:58 +0000 (12:01 -0500)]
Only include sys/time.h on appropriate platforms

This header doesn't exist on windows.
For libusb, determine at configure-time if the header is available.
For libusb.h, use gcc predefined macros to only include the header
on platforms that need it.

14 years agoLinux: Fix log message commit
Daniel Drake [Tue, 22 Jun 2010 23:45:38 +0000 (18:45 -0500)]
Linux: Fix log message commit

Forgot to test this.

14 years agoOnly initialize the default context when it is requested
Ludovic Rousseau [Mon, 21 Jun 2010 08:19:29 +0000 (10:19 +0200)]
Only initialize the default context when it is requested

14 years agoLinux: fix log message that was being unconditionally sent to stderr (#44)
Daniel Drake [Tue, 22 Jun 2010 23:20:23 +0000 (18:20 -0500)]
Linux: fix log message that was being unconditionally sent to stderr (#44)

This message was put in place to aid libusb-compat-0.1 users, who
may run into the change that libusb-0.1 allowed you to usb_open() a
device that you don't have write access to, but libusb-1.0 does not.

As explained on the ticket this change is dangerous so it should go through
the usual logging mechanism. I also added a similar regular log message
to libusb-compat-0.1.

14 years agoFix 2 documentation typos
Ludovic Rousseau [Thu, 10 Jun 2010 16:41:27 +0000 (18:41 +0200)]
Fix 2 documentation typos

14 years agoadd AM_MAINTAINER_MODE
Ludovic Rousseau [Wed, 21 Apr 2010 14:49:33 +0000 (16:49 +0200)]
add AM_MAINTAINER_MODE

14 years agoFactorize event handler interruption code
Pete Batard [Thu, 10 Jun 2010 22:00:25 +0000 (17:00 -0500)]
Factorize event handler interruption code

This will be additionally used by the windows backend which modifies
the fd set frequently.

14 years agoAbstract low-level event handler operations
Pete Batard [Sat, 5 Jun 2010 17:14:19 +0000 (12:14 -0500)]
Abstract low-level event handler operations

The Windows backend uses something other than UNIX file descriptors
for event handling. Abstract out the operations to allow for this.

14 years agofixes the possibility of using a broken timercmp on Windows
Pete Batard [Tue, 1 Jun 2010 10:38:14 +0000 (11:38 +0100)]
fixes the possibility of using a broken timercmp on Windows

Microsoft's implementation of timercmp does not work for >= or <=.

14 years agoSwitched to standard int pointer type for windows 64-bit compat
Pete Batard [Mon, 1 Feb 2010 19:26:13 +0000 (19:26 +0000)]
Switched to standard int pointer type for windows 64-bit compat

On 64-bit Windows a pointer is 64 bit, but long is still 32 bit for
backwards compatibility.
uintptr_t nicely hides this difference and also works on Linux.

[dsd: add appropriate include]

14 years agoadded doxygen, dpfp, msvc, and xusb stuff to gitignore
Michael Plante [Tue, 9 Mar 2010 22:39:46 +0000 (16:39 -0600)]
added doxygen, dpfp, msvc, and xusb stuff to gitignore

14 years agoAdd reference counting to default context
Daniel Drake [Tue, 1 Jun 2010 00:56:34 +0000 (19:56 -0500)]
Add reference counting to default context

Michael Plante pointed out that if 2 users call libusb_init(NULL) within
a process, we end up creating 2 default contexts, one of which is lost.

Add reference counting so that the default context is reused and
destroyed only after the last user.

14 years agoFix libusb_init() error handling
Daniel Drake [Thu, 27 May 2010 23:24:49 +0000 (19:24 -0400)]
Fix libusb_init() error handling

9996ccaed7 introduced a problem in that mutexes could be destroyed
in the error handling codepath before they had been created.
Pointed out by Michael Plante.