Building libusb from another build directory doesn't properly work right
now, as calling autogen.sh from there won't work.
An example is when using jhbuild to build it.
So always use absolute paths to call configure and bootstrap scripts
Signed-off-by: Ludovic Rousseau <[email protected]>
warning: Tag 'TCL_SUBST' at line 255 of file 'doxygen.cfg.in' has become obsolete.
This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1056 of file 'doxygen.cfg.in' has become obsolete.
This tag has been removed.
Signed-off-by: Ludovic Rousseau <[email protected]>
A timed out transfer might have been partially filled. Propagate
tpriv->size to avoid dropping this data.
Closes#876
Signed-off-by: Nathan Hjelm <[email protected]>
The commit f74c7f5 "core: new API libusb_set_log_cb() to redirect
global and per context log messages to the provided log handling
function" in 2018-12-05 is present from 1.0.23 onwards.
This commit just adds this to the docs.
Closes#872
Signed-off-by: Victor Toso <[email protected]>
Signed-off-by: Chris Dickens <[email protected]>
The USB spec states that a configuration value of 0 is reserved and is
used to indicate the device in not configured (e.g. is in the address
state). Unfortunately some devices do exist that violate this and use 0
as the bConfigurationValue of the configuration descriptor.
Improve how the Linux backend handles such non-conformant devices by
adding special handling around the configuration value 0. Most devices
will not require this special handling, but for those that do there is
no way to distinguish between the device being unconfigured and using
configuration 0.
Closes#850
Signed-off-by: Chris Dickens <[email protected]>
Benjamin Berg reports that some CI systems that simulate sysfs devices
are causing libusb to report errors because such systems are not
conforming to the sysfs pattern of terminating attribute values with a
newline character. Reduce the severity of encountering such
non-conforming attibute values from an error that prevents enumeration
to a warning message.
Closes#857
Signed-off-by: Chris Dickens <[email protected]>
Commit b51c743e42 ("Windows: Filter out non-libusb I/O completions")
causes problems with the HID backend functions and synchronous transfer
completions. Address these by fetching the correct pointer in the HID
functions and posting an I/O completion for synchronous transfers.
Closes#863
Signed-off-by: Chris Dickens <[email protected]>
The I/O completion port thread gets notified of every I/O operation that
completes for a given HANDLE, but not all I/O operations originate from
within libusb. For example, libusbK performs a number of I/O control
calls during initialization and specific device operations, such as
setting an interface alternate setting. These non-libusb operations need
to be ignored as the OVERLAPPED associated with such operations is not
tied to a libusb_transfer structure.
Resolve this situation by using the libusb device handle as the I/O
completion port's unique key and keeping a list of active transfers for
each device handle. When the I/O competion port thread is notified of an
I/O completion, it will first match the OVERLAPPED to an outstanding
transfer before acting on it.
Closes#844
Signed-off-by: Chris Dickens <[email protected]>
The AC_CHECK_FUNCS() macro checks whether a program compiled on the host
will link against the function, but it does not help when targeting
older systems where that function is not available. Additionally, the
way that autoconf compiles the program ignores any attributes or
preprocessor guards that installed headers might have applied to that
function.
Resolve this by verifying that the OS X target version is 10.12 or newer
before checking for clock_gettime().
Closes#836
Signed-off-by: Chris Dickens <[email protected]>
In commit "89b810ec Android: Add option LIBUSB_OPTION_WEAK_AUTHORITY
to support used in apk", we should also check weak_authority when
exiting the backend.
[dickens] Fixed whitespace
Closes#842
Signed-off-by: Mark Kuo <[email protected]>
Signed-off-by: Chris Dickens <[email protected]>
On OpenBSD USB controllers are shown as normal devices, making the
initial limit too small. On a recent machine this value is almost
always exceeded, so bump it.
Change committed to OpenBSD ports tree by Matthias Kilian <[email protected]>
on Tue Jun 19 21:10:59 2012 UTC
Closes#835
Signed-off-by: Chris Dickens <[email protected]>
It makes it clear from debug logs, that values are in hex,
without a need to check the source code.
Closes#832
Signed-off-by: Chris Dickens <[email protected]>
darwin_set_interface_altsetting() no longer returns the status of the underlying SetAlternateInterface(), but instead the result of a subsequent GetNumEndpoints() call. This reverts to the behaviour prior to commit 065e586.
Since darwin_set_interface_altsetting() resets the interface after SetAlternateInterface(), one of the consequences is that if SetAlternateInterface() returns a kIOUSBPipeStalled error, and the interface is successfully reset, darwin_set_interface_altsetting() now returns LIBUSB_SUCCESS instead of LIBUSB_ERROR_PIPE.
Closes: #838
Signed-off-by: Freek Dijkstra
Signed-off-by: Nathan Hjelm <[email protected]>
The OLE32 library provides the IIDFromString() function to parse a
string to a GUID, but we can implement a simple GUID parsing function
and remove this dependence. Doing so also avoids fetching the Unicode
form of the "DeviceInterfaceGUIDs" property.
Signed-off-by: Chris Dickens <[email protected]>
Now that a sufficiently recent toolchain is required to build, we can
drop a bunch of redundant definitions and get the definitions from the
Windows headers instead. We can also remove a number of '#ifndef'
guards because no header included by the source would have defined the
symbols being protected.
Signed-off-by: Chris Dickens <[email protected]>
The builds no longer succeed on the xcode9.4 image because updating
Homebrew takes too much time. The packages we need from Homebrew are not
frequently updated, so using the latest formulae that the image provides
should be sufficient.
Signed-off-by: Chris Dickens <[email protected]>
The __atomic operations are internal to gcc and not necessarily supported
by all c11 compilers. Use the atomics in stdatomic instead.
Signed-off-by: Nathan Hjelm <[email protected]>
An atomic variable is useful for reference counting and is much less
overhead than accessing such a variable while holding a lock. To that
end, replace the libusb_device 'refcnt' variable with an atomic and use
the atomic operations to manipulate it. This removes the need for the
mutex in the libusb_device.
Also convert the 'attached' variable to an atomic as well. This variable
was previously accessed both while holding the libusb_device mutex and
not.
Signed-off-by: Chris Dickens <[email protected]>
Commit e2be556bd2 ("linux_usbfs: Parse config descriptors during device
initialization") introduced a regression for devices with multiple
configurations. The logic that verifies the reported length of the
configuration descriptors failed to count the length of the
configuration descriptor itself and would truncate the actual length by
9 bytes, leading to a parsing error for subsequent descriptors.
Closes#825
Signed-off-by: Chris Dickens <[email protected]>
When building libusb out-of-tree, ie when running configure from another
directory, building the documentation fails with:
$ make -C doc
make: Entering directory '/tmp/build/doc'
make: *** No rule to make target 'libusb.png', needed by 'api-1.0'. Stop.
make: Leaving directory '/tmp/build/doc'
This has likely been broken by commit 4a5540a925 ("autotools: Fix a number of
issues"). This patch fixes that by prefixing libusb.png with @top_srcdir@/doc.
Signed-off-by: Aurelien Jarno <[email protected]>
There are certain games played in the examples and tests source to
account for differences in build environments and target platforms. This
can be simplified by including config.h and using the definitions there.
To that end, move the printf function attribute definition from
libusbi.h to config.h and leverage it where it is used in the examples
and tests.
Signed-off-by: Chris Dickens <[email protected]>
Commit f69548c3b3 ("examples: Enable all examples to build on all
platforms") modified dpfp and sam3u_benchmark to be buildable on any
platform, however there were some oversights and regressions introduced
for Android and Xcode.
Update the Android and Xcode build files to account for the removal of
dpfp_threaded.c as well as the inclusion of config.h from examples
and/or tests source.
Additionally switch the threaded version of dpfp to use sem_open()
instead of sem_init() as the latter is in fact deprecated on MacOS.
Closes#808
Signed-off-by: Chris Dickens <[email protected]>
Prior to this change, the dpfp and sam3u_benchmark examples were only
built on POSIX platforms due to a dependency on sigaction(). Furthermore
the dpfp_threaded example only worked with POSIX threads.
Lift this limitation by breaking the dependence on sigaction(). Also
provide a minimal threading abstraction so that dpfp_threaded can be
built on Windows as well.
Also merge the sources for dpfp and dpfp_threaded. The only difference
between the two is how libusb's event handling functions are called and
this can be easily handled within a single source file.
Signed-off-by: Chris Dickens <[email protected]>
* [-Wpointer-arith] arithmetic on a pointer to void is a GNU extension
* [-Wswitch-enum] enumeration values 'E1, ...' not explicitly handled in switch
* [-Wunused-parameter] unused parameter 'p'
For '-Wswitch-enum', the switch statements in the individual backends'
set_option() function has been removed. It is not expected that backends
will need to handle or be aware of all the options.
Signed-off-by: Chris Dickens <[email protected]>
Add Ubuntu's Focal distribution to get the latest Linux toolchain.
Add Xcode 12.2 to get the latest MacOS toolchain.
Remove Xcode 7.3 as it is now obsolete and will not successfully build.
Signed-off-by: Chris Dickens <[email protected]>
The LoadLibraryA() function performs a search through various paths when
provided a library name that does not include a path element. All of the
libraries that libusb needs to dynamically load are installed in the
Windows system directory, thus it is not necessary to search any paths.
To harden the security of libusb and prevent loading libraries from
outside of the system directory should an attacker be able to alter the
environment or place an identically named library somewhere in the
search paths that occur before the Windows system directory, introduce a
function that calls LoadLibraryA() with a full path to the requested
library witin the Windows system directory. Note that we cannot call
SetDllDirectoryA() because as a library we should not alter the DLL
search path of the application. We also cannot use LoadLibraryExA() with
the LOAD_LIBRARY_SEARCH_* flags because those flags require a specific
security update to be installed on Vista and 7.
Signed-off-by: Chris Dickens <[email protected]>
Commit 006ca0fbaa ("Guard against getting stuck while handling events")
caused a regression using the wrong list node when iterating a list. Fix
this by introducing and using an alternate for_each iterator.
Closes#796
Signed-off-by: Chris Dickens <[email protected]>
The recently introduced PTHREAD_CHECK and WINAPI_CHECK macros cause a
large number of compiler warnings for unused variables on release
builds. Fix this by implementing those macros in terms of some new
macros that are defined based on the definition of NDEBUG.
Closes#788
Signed-off-by: Chris Dickens <[email protected]>
This commit adds an extra parameter check to darwin_handle_transfer_completion
and cleans the code up a bit.
Signed-off-by: Nathan Hjelm <[email protected]>
In macOS 11.x the USEC_PER_SEC and NSEC_PER_SEC are defined by a system
header. The values are the same so use the system defines if they are
available.
Signed-off-by: Nathan Hjelm <[email protected]>
Sometimes it is useful to be able to test libusb_wrap_sys_device(),
add support for this to the testlibusb example
Signed-off-by: Hans de Goede <[email protected]>
We don't have a sysfs_dir for wrapped devices, so we cannot read the speed
from sysfs.
The Linux kernel has supported a new ioctl to get the speed directly from
the fd for a while now, use that when we don't have sysfs access.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1871818
Reported-by: Gerd Hoffmann <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
Commit fa3f91e7c4 ("descriptor: Miscellaneous improvements to the
overall source") introduced some union types, however since descriptor.c
is parsed by Doxygen it will complain with the following warnings:
libusb/descriptor.c:49: warning: Compound string_desc_buf is not documented.
libusb/descriptor.c:55: warning: Compound bos_desc_buf is not documented.
libusb/descriptor.c:43: warning: Compound config_desc_buf is not documented.
Fix this by moving the union definitions into libusbi.h.
Signed-off-by: Chris Dickens <[email protected]>