Commit Graph
205 Commits
Author SHA1 Message Date
Peter Stuge 091f0631d6 Add internal abstraction for POSIX Threads
This prepares for a Windows backend without dependency on pthreads-w32.

pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*.

A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are
introduced for statically initialized mutexes, since they may be
implemented using other types when pthreads mutexes aren't used.

Move -pthread from libusb/Makefile.am to host-specific AM_CFLAGS in
configure.ac. AM_CFLAGS is already used in Makefile.am.
usbi_sync
2010-02-16 06:58:32 +01:00
Nathan Hjelm cfce4d1271 Darwin: fix memory leak in process_device
Credit to Mike Colagrosso for finding this bug.
2010-02-15 14:10:08 -06:00
Nathan Hjelm 161893cfbe Darwin: use logging functions
Use usbi_warn, usbi_err, and usbi_info instead of _usbi_log.
2010-02-15 14:09:19 -06:00
Nathan Hjelm 2a72f38548 Darwin: support multiple calls to libusb_init
Credit to Orin Eman for finding this bug.
2010-02-15 14:07:44 -06:00
Daniel Drake a4186794d8 v1.0.6 release v1.0.6 2009-11-22 17:20:53 +00:00
Ludovic Rousseau 8392ff2213 lsusb example: make print_devs() static
lsusb.c:26: warning: no previous prototype for ‘print_devs’
2009-11-21 17:12:17 +00:00
Ludovic Rousseau 9cc6bfaa15 Darwin: fix warning in darwin_error_str()
os/darwin_usb.c:63: warning: return discards qualifiers from pointer
target type
2009-11-21 17:11:40 +00:00
Nathan Hjelm 4c706d2fb6 Darwin: allow devices to be opened multiple times
Allows libusb applications to access multiple interfaces of the same
device in the same application.

Also fixes a set alt interface bug.
2009-11-21 17:06:43 +00:00
Daniel Drake 0232fc559c Increase libusb_handle_events() timeout to 60 seconds
The internal timing seems to be working, this will be a better test of
it before we make this timeout unlimited.
2009-11-21 17:02:53 +00:00
Daniel Drake 0bd7ef5d86 Refine timerfd header check (#18)
Require glibc-2.9 for the working timerfd support.
2009-11-21 16:58:31 +00:00
Daniel Drake 90d8fcab90 v1.0.5 release v1.0.5 2009-11-15 12:17:13 +00:00
Daniel Drake 11d591058e Update documentation about early completion caveats 2009-11-07 10:46:12 +00:00
Ludovic Rousseau f796c9528a Add libusb_get_max_iso_packet_size() to libusb.h
core.c:777: warning: no previous prototype for 'libusb_get_max_iso_packet_size'
2009-11-07 10:46:12 +00:00
Daniel Drake 4783008b7e Use timerfd for timeout handling
Use a new file descriptor from the timerfd system calls to handle
timeouts. On supported systems, this means that there is less hassle
figuring out when the poll() timeout should be, since
libusb_get_next_timeout() will always return 0 and the timeout events will
be triggered as regular activity on the file descriptor set.

Add API function libusb_pollfds_handle_timeouts() to detect whether
you're on a platform with the timing headache, and flesh out the
surrounding documentation.
2009-11-07 10:46:09 +00:00
Daniel Drake 9b120c2b37 Use AM_SILENT_RULES for building 2009-11-07 10:03:20 +00:00
Daniel Drake ef6ea6c3ae v1.0.4 release v1.0.4 2009-11-06 21:54:08 +00:00
David Moore 217f57617e Linux: Add support for the new URB_BULK_CONTINUATION flag
Add support for the new USBDEVFS_URB_BULK_CONTINUATION flag to libusb.

This flag, which is expected to be available in usbfs starting with
kernel 2.6.32, allows the kernel to cancel multiple URBs upon receipt
of a short packet.  This capability allows libusb to preserve data
integrity of large bulk transfers that are split into multiple URBs.
Without this support, these URBs must be canceled in userspace upon
receipt of a short packet, a race condition against future transfers
which might partially fill these canceled URBs.

This patch automatically detects whether a supported kernel is present
and enables the use of the flag when possible.

[dsd: tweaks to supported kernel detection, and some inline
 documentation of this mechanism]
2009-11-06 21:50:41 +00:00
Daniel Drake 6983005754 Transfer locking
At least on Linux, there were some possible races that could occur if
a transfer is cancelled from one thread while another thread is handling
an event for that transfer, or for if a transfer completes while it is
still being submitted from another thread, etc.

On the global level, transfers could be submitted and cancelled at the
same time.

Fix those issues with transfer-level locks.
2009-11-06 21:45:37 +00:00
Daniel Drake 98f1b30d24 Clarify that timeout 0 means unlimited timeout 2009-09-14 08:01:24 +01:00
Daniel Drake 858684f0dd Linux: more flexibility with monotonic clock
Some users have reported that CLOCK_MONOTONIC does not work on their
systems - I suspect it is available on x86 but perhaps not some
of the more uncommon architectures. We should fall back on
CLOCK_REALTIME in these cases.

Also, CLOCK_MONOTONIC_RAW seems even more monotonic, so we should use
that if it is available.

We now test different clock IDs during initialization to find the
best one that works.
2009-09-11 22:12:27 +01:00
Nathan Hjelm fe0d8dce1e Darwin: handle overflows 2009-09-11 18:00:29 +01:00
Daniel Drake f46716f420 v1.0.3 release v1.0.3 2009-08-27 21:40:57 +05:45
Toby Peterson 5b489b8b2a Darwin: 64-bit type fixes 2009-08-23 10:04:59 +05:45
Nathan Hjelm ad8ae04d0b Darwin: fix crash when reading descriptors after close
Fix a crash which occurs if the user does the following sequence on a
device: open, close, get_configuration_descriptor.
2009-08-23 10:02:55 +05:45
Daniel Drake 45ae2aecf5 move bug info to bug tracker
Protection needed: http://www.libusb.org/ticket/4
Losing data: fixed in previous commit
2009-08-01 13:56:11 +05:45
Daniel Drake 126129e174 Linux: try harder not to lose any data
We would previously lose any data that was present on a cancelled URB.
Work harder to make sure this doesn't happen.
2009-07-09 22:09:04 +01:00
Daniel Drake 0334ee642b Add libusb_get_max_iso_packet_size()
As pointed out by Dennis Muhlestein, libusb_get_max_packet_size()
doesn't really do what the documentation might suggest because it
does not consider the number of transaction opportunities per
microframe.

Add a new function to do what is useful for isochronous I/O.
2009-06-28 19:49:10 +01:00
Daniel Drake 615f18e64e Linux: fix sending of zero length bulk packets
Note that there are is a kernel bug preventing this from working
properly at the moment, even after this fix.
2009-06-20 22:33:21 +01:00
Nathan Hjelm 86f79fbf61 Darwin: Don't cancel transfers on timeout
...because the OS does this for us.
2009-06-19 22:18:44 +01:00
Daniel Drake d4bd9ed4de Don't terminate enums with commas
g++ -pedantic doesn't like this
Reported by Eberhard Mattes
2009-06-14 19:23:21 +01:00
Daniel Drake 8be256082e v1.0.2 release v1.0.2 2009-06-13 17:19:07 +01:00
Daniel Drake 060e006e66 Linux: fix config descriptor parsing on big-endian systems
Multi-byte fields in the configuration descriptors that come back from
usbfs are always in bus endian format.

Thanks to Joe Jezak for help investigating and fixing this.
2009-06-10 21:42:05 +01:00
Nathan Hjelm c4a905022f Darwin: improve handling of disconnected devices 2009-06-07 22:31:49 +01:00
Nathan Hjelm 6b69f54451 Darwin: fix parsing of config descriptors
This was a confusion between configuration numbers and zero-based
configuration indexes.
2009-06-07 22:26:37 +01:00
Daniel Drake 2b3a9ffa77 Eliminate -Wsign-compare compiler warnings
This was due to an API inconsistency which can be safely worked around.
Hopefully we'll remember to fix the API next time we come to break
things.
2009-06-07 22:19:53 +01:00
David Moore cad5cb55c3 Make synchronous transfer APIs robust against signal interruption
libusb_control_transfer and libusb_bulk_transfer are designed to be
synchronous such that control is not returned until the transfer
definitively succeeds or fails.  That assumption is violated if a signal
interrupts these functions because there is no way for the application
to continue waiting for the transfer without resubmitting it.  This
patch changes these synchronous APIs so they do not abort in the case of
a signal interruption.

Signed-off-by: David Moore <[email protected]>
2009-05-29 11:21:11 -04:00
Alex Vatchenko b501795985 pre-gcc-3.4 compatibility
The -fvisibility and -Wno-pointer-sign options are not available on
old GCC versions.
2009-05-28 16:06:24 -04:00
Daniel Drake 00bb2805e9 Fix memory leak in config descriptor parsing
Pointed out by Martin Koegler.
2009-05-26 15:53:26 -04:00
Daniel Drake 068ff5b8a8 Update AUTHORS 2009-05-12 19:20:51 -04:00
Daniel Drake aa24c04e40 v1.0.1 release v1.0.1 2009-05-12 19:03:37 -04:00
Daniel Drake 4476767744 Add BUGS file
Probably missed a couple of outstanding issues
2009-05-12 19:02:11 -04:00
Nathan Hjelm e0365a6f22 Darwin: get_config_descriptor bugfixes 2009-03-22 21:13:29 -04:00
Daniel Drake 5fd0e84782 Fix compilation of Darwin backend
My fault. Reported by [email protected]
2009-02-25 12:33:33 -03:00
Nathan Hjelm b49f6bf5c9 Darwin backend 2009-02-16 21:40:45 -03:00
Nathan Hjelm d859158581 Make endianness macros endian-independent
Implementation suggested by David Moore. Needed for proper universal
code support on Darwin.
2009-02-16 21:30:49 -03:00
Nathan Hjelm 9196f58bdc Abstract clock reading into OS layer
This will differ on Linux and Darwin, at least.

[dsd: minor style tweaks]
2009-02-16 21:25:51 -03:00
Daniel Drake e91207860c Fix endianness in device descriptors
Pointed out by Nathan Hjelm.
2009-02-16 21:20:28 -03:00
Nathan Hjelm ccf6d3d2f6 Only link with librt on Linux
[dsd: tweak configure.ac change]
2009-02-16 21:19:56 -03:00
Hans Ulrich Niedermann 894539931e API docs: describe libusb_transfer_cb_fn type
Add some text describing the libusb_transfer_cb_fn function type
with the semantics I have gathered from reading other parts of
the API docs, referring to the proper section for more details.

[dsd: tweaked the description slightly]
2009-02-01 19:40:18 -03:00
Hans Ulrich Niedermann abe34a2656 Make empty array in struct compatible with C99
If the compiler is known to be running in C99 mode,
use "flexible array members" ("foo[]").

If the compiler is running in any other mode, continue
using the non-standard but widely common "foo[0]" syntax.
2009-02-01 19:30:21 -03:00