| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
| |
E.g. the LLVM LLD doesn't support this option.
Closes #1192
References #944
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Only keep it for Cygwin.
Clang doesn't support this option, and it seems only needed for
Cygwin since MinGW predefines e.g. the _WIN32 macro anyway.
From GCC documentation: -mwin32 This option is available for Cygwin
and MinGW targets. It specifies that the typical Microsoft Windows
predefined macros are to be set in the pre-processor, but does not
influence the choice of runtime library/startup code.
References #1192
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
| |
Fixes #501
Closes #1057
|
|
|
|
|
|
|
|
|
|
|
|
| |
Follow-up to 561dbda, a check of GCC atomic builtins needs to be done
first.
I'm no autoconf guru, but using this:
https://github.com/mesa3d/mesa/blob/0df485c285b73c34ba9062f0c27e55c3c702930d/configure.ac#L469
as inspiration, I created a pre-check before calling AC_SEARCH_LIBS(...)
Fixes #1135
Closes #1139
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Removed the logic in configure.ac (for Darwin only) that detected if the
clock_gettime() function exists. Instead, just use the preprocessor to
introspect the macOS SDK version and deployment target and call
clock_gettime() if they are new enough.
Also replaced the fallback code for older macOS with
mach_absolute_time() and gettimeofday(), which are simplier because they
do not need setup and teardown carefully balanced and their usage is in
one place instead of spread in multiple places in the file.
Closes #1080
|
|
|
|
|
|
|
|
|
| |
libusb only uses pkg-config macros in configure to check for umockdev. Since
this is only required for testing it makes sense to protect the usage of these
macros to only be used when pkg-config is installed. This will be the case for
maintainers and testers.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
Add some basic umockdev tests. The setup in this case is all in one
process, but umockdev in principle could also work between processes.
This is just a start, more tests would make sense.
|
|
|
|
|
|
| |
References #1056
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
| |
Fixes #1049
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libusb unconditionally uses atomic_fetch_add since version 1.0.25 and
commit 1a08aa8 and commit eed8a37 but some architectures (e.g. sparc)
needs to link with -latomic to be able to use it. So check if -latomic
is needed and update libusb-1.0.pc accordingly to avoid the following
build failure with openocd:
/home/buildroot/autobuild/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/10.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/instance-0/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libusb-1.0.so: undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status
Full build log:
http://autobuild.buildroot.org/results/4a27a769bb3cdf78643c3049b87d792178d6512c
Closes #1064
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
|
|
|
|
|
|
|
| |
This macro was replaced by AS_HELP_STRING. This commit updates the lingering deprecated call
with the new macro as used elsewhere in configure.ac.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
interface
The implementation of libusb_kernel_driver_active was attempting to open the interface to
check if a driver is attached. This may have side effects (like configuring the device)
that may be unexpected to the user. This commit updates the code to find the interface's
IO registry entry (either IOUSBHostInterface or the legacy IOUSBInterface) and check if
the entry has a child entry. A child entry indicates that a driver is currently attached.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To use USBDeviceReEnumerate with kUSBReEnumerateCaptureDeviceMask your app
either needs to be running as root OR have the 'com.apple.vm.device-access'
entitlement AND have the user authorization requested via
IOServiceAuthorize().
We can use the capture re-enumerate APIs if either 1) the process is running
as root or 2) the 'com.apple.vm.device-access' entitlement is used AND
IOServiceAuthorize() is called. We assume that if the entitlement is not
there then we are running as root--if this is not true, then
darwin_detach_kernel_driver will fail anyways.
The authorization status is cached in the device's start() so we have to
stop() and start() the device by destroying the plugin and recreating it
again.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
The pthread_condattr_setclock() function allows one to specify that the
condition variable use CLOCK_MONOTONIC as the base for timed waits. This
is desirable to avoid premature timeouts if the system time is adjusted
while a timed wait is occurring. Add a check for the availability of
this function and use it where possible.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Most of the library only uses the monotonic clock. In fact, the only use
of the realtime clock is to implement the POSIX version of
usbi_cond_timedwait(). Now that Windows can no longer use the POSIX
thread abstraction, there is no need for Windows to implement a means of
reading the realtime clock.
This change replaces usbi_clock_gettime() with usbi_get_monotonic_time()
and usbi_get_real_time(). When clock_gettime() is available, both
functions are implemented as simple inline calls, otherwise the backend
must provide a definition for usbi_get_monotonic_time() *AND*
usbi_get_real_time() iff the platform is POSIX.
Reading the clocks is also never expected to fail. In practice, if it
ever did there would be much more than libusb that would not function
correctly. The new functions therefore have no return value, thus
allowing the callers to assume success and remove a bunch of error
handling code. The clock_gettime() wrappers have a simple error check
that is only enforced in debug builds.
This change also makes it unnecessary to check for and use
clock_gettime() on Windows, so remove it and always provide
usbi_get_monotonic_time().
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The split between events and threads abstractions is unnecessary.
Simplify the library by merging the two into a "platform" abstraction.
The only meaningful change is that Cygwin builds will no longer use the
POSIX threads abstraction but will instead use the native Windows one.
The downside to doing this is that the dpfp_threaded example program
will no longer be available on Cygwin builds. This should be fine, and
future work will make dpfp_threaded available for all forms of Windows
build systems.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
| |
On systems that support it, using an eventfd for simple signalling is
much more efficient than using a pipe. Add detection of eventfd to the
configure script and wire it up in the POSIX event abstraction.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The way in which system handles or resources are represented differs
greatly between Unix-like operating systems and Windows. Ever since
Windows support was added to libusb, Windows been emulating principles
of Unix-like operating systems such as file descriptors and poll().
This commit introduces an abstraction layer that completely removes the
need to perform any emulation. Fundamentally there are three things that
each platform provides to libusb:
1) A signallable event
2) A timer (not required, but useful)
3) A means to wait for event sources such as the above to be triggered
The POSIX abstraction for Unix-like operating systems uses file
descriptors as the "handles" to the underlying system resources. The
signallable event is implemented using a pipe, the timer as a timerfd
(where supported) and the poll() system call is used to wait for events.
The Windows abstraction uses native HANDLEs as the "handles" to the
underlying system resources. The signallable event is implemented using
a manual-reset event, the timer as a manual-reset waitable timer, and
the WaitForMultipleObjects() system call is used to wait for events.
Closes #252
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There apparently exist some compiler ports (e.g Haiku's GCC) that do not
support the ubiquitous '-pthread' compiler option. Add a check for this
and only use the option if supported.
Also tweak the check for the pthread library to check for the
pthread_create() function. Even though libusb does not use this function,
it seems to be sufficiently distinct such that the standard C library
would not provide this directly if the pthread implementation resided in
a separate library. Also explicitly check whether no additional library
linkage is required.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are a few parts within the library where code is conditionally
compiled based on whether or not the target OS is Windows. Prior to
commit 8b09dd490d ("core: Kill the OS_* definitions and use in the
source code"), the OS_WINDOWS definition was used. With that definition
gone, the checks were replaced with _WIN32. Unfortunately the different
cross-platform toolchains do not universally define this, so add this to
AM_CPPFLAGS when building for Windows.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 9a1bc8cafb ("build: Require C11 to build and clean up
autoconfig/automake files") added the language standard compiler option
to the AM_CFLAGS and AM_CXXFLAGS. Placing it in the latter is incorrect
as compiling C++ source with the C11 language standard does not make
sense.
Fix this by determining which C11 dialect (GNU or C) the compiler
supports and then constructing the compiler option from that.
Also restrict LT_LDFLAGS to the final libusb library (as was done
previously) since libtool complains about versioning options for
convenience libraries.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Help catch more errors by enabling additional build errors and warnings.
Address some of the warnings seen with these new flags, including moving
the libusb_transfer structure back out of the usbi_transfer structure to
address 'warning: invalid use of structure with flexible array member'.
Apparently a structure ending with a flexible array member is not okay
with the compiler as the last member within another structure.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
C11 compiler support has been available for many years now. It is not
unreasonable to require this now, and doing so allows some cleanup to
the configure script. It is no longer necessary to check for compiler
support of the '-fvibility' flag because any compiler that supports C11
will support this flag as well.
Fix up the way that compiler and linker flags are passed down to the
various makefiles. The compiler flags should be shared by all, but the
linker flags and libraries should be separated between the library and
the examples/tests. The visibility flag is only relevant for the
library and the thread flags are only relevant for sources using thread
constructs, so provide them as needed.
Rearrange configure.ac to group similar functionality and consolidate
where possible.
Based on these changes, update the Travis configuration file to include
newer versions of test platforms to ensure proper C11 compiler support.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
| |
These symbols are no longer necessary for the source code since commit
cad7d0edd9 ("core: Kill usbi_os_backend structure definition madness").
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add support for real thread IDs on macOS 10.6 and later using the new
pthread_threadid_np() function.
Add support for thread IDs on Haiku, NetBSD and Solaris.
Provide a fallback value other than -1 when direct support is not
available. This should suffice as a unique identifier since pthread_t,
while opaque, is still distinct amongst active threads.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the name of the project to be what it actually is called
everywhere: libusb-1.0. This allows the public libusb.h header file to
be tracked by automake through pkginclude_HEADERS.
Decouple the doc directory from automake. There aren't any targets that
automake understands, so the build uselessly recurses into the directory.
Update the makefile targets with the correct dependencies so that the
docs aren't regenerated unnecessarily. Update the doxygen config file to
include the version, exclude irrelevant source files and create the
output into 'api-1.0' instead of 'html'. Also fix a deprecation tag for
the libusb_get_port_path() function and add Solaris to the list of
supported platforms.
Fix the 'dist' target. Clean up the README file to remote the GitHub
Markdown and remove the .gitattributes file from the msvc directory.
Add doc/libusb.png to EXTRA_DIST.
Enhance the {dist,doc}-upload targets to look at the SF_USER environment
variable to get the SourceForge username. This allows maintainers (like
me!) to have a local username that is different from their SourceForge
username. Switch the docs-upload recipe to use rsync with --delete to
clean up obsolete files.
Fix the Windows shared library (DLL) targets. The dependencies for the
RC file were incorrect, leading to cases of missed recompilation. The
'all' rule should not be overridden, so define an 'all-local' rule when
necessary. Fix the rule for running dlltool on the just generated DLL so
that it only fires when the correct dependencies change and do not
bother to run the rule when not building a DLL.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Out of all the backends supported by libusb, only two need to provide an
implementation of the clock_gettime() function. Windows completely lacks
such a function and versions of Mac OS prior to 10.12 do not provide it.
In all other cases the backend simply ends up calling the C library's
clock_gettime() function.
Let's optimize for the common case and check for the availability of
clock_gettime() during configure. If available, we will just call it
directly from any part of the library that needs it. If not available,
the backend is required to provide an implementation of
usbi_clock_gettime() that matches the current requirements.
Closes #685
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Instead of having just the application name as thread name, provide a more
descriptive one, which can e.g. read by htop.
If setting the name fails, the thread will still work as intended, just
raise a warning in this case.
Closes #689
Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Trying to capture debug logs that reproduce a problem can be tricky.
Turning up the debug level will automatically make the program a bit
slower. This alone cane make timing-sensitive bugs "disappear" when
capturing logs. One of the hot paths for debug messages is fetching the
thread ID, which is immeasurably helpful in understanding thread
interactions within the library. Unfortunately most implementations
require a system call to fetch the executing thread's ID, which isn't
exactly going to help in the way of execution time.
Add a check for thread-local storage support when configuring the
library to build. If the toolchain provides this support, only one
system call will be required per thread. This check is only done for
non-Windows systems because thread-local storage is inefficiently
implemented on MinGW.
Closes #682
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The test for defining the automake conditional for the poll
implementation was keying off of the threads variable, producing
incorrect results for Cygwin.
A simple typo in the Makefile causes a build failure when
cross-compiling for Windows.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Make the formatting consistent across the entire file. In particular:
- Always quote strings whose values are derived
- Use tabs consistently
- Wrap all arguments with square brackets
Replace the use of '-a' with '&&' to be more portable.
Rearrange some of the feature checks to be conditional upon the platform
or backend. For example, there is no need to check for nfds_t on Windows
because poll() doesn't exist there. Similarly we now only check for
timerfd on Linux and Solaris. This translates into slightly faster
configure times.
Explicitly define tokens for both the poll and thread implementations.
This makes the preprocessor conditionals much nicer since it is not
necessary to enumerate all possible OS_* tokens. Also replace
POLL_NFDS_TYPE with a proper typedef that is based on the availability
of the nfds_t type.
Migrate to config definition names that are more consistent with
autoconf. The check for timerfd actually verifies the presence of the
library function instead of just the header definitions, and the token
USBI_TIMERFD_AVAILABLE is now HAVE_TIMERFD. Similarly the check for
syslog results in a definition of HAVE_SYSLOG.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
| |
XP is nearly 20 years old and there are hoops we jump through to keep
supporting it. Time to say goodbye and simplify some things.
Closes #267
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
| |
Add a simple null backend for POSIX platforms that reports no available
devices, and provides no capabilities. Make use of this new backend on
all the OSes without an existing backend, so libusb can be built even on
OSes without USB support.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
says:
4. If any interfaces have been added, removed, or changed since the last
update, increment current, and set revision to 0.
5. If any interfaces have been added since the last public release, then
increment age.
So both current and age must be incremented. The patch in
fde20bb9b7cba0ea6e96db920d0a0169c361ca92 was not complete.
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
| |
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
glibc before 2.17 requires link with librt for clock_gettime(). The
AC_SEARCH_LIBS check in configure.ac should detect this dependency.
Unfortunately commit cb77a25e51 (configure.ac: Remove obsolete AC_ERROR
and make formatting consistent) inadvertently renamed to clock_gettime2,
thus breaking librt detection.
Restore the correct clock_gettime() name.
Closes #439
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
|
|
|
|
|
|
|
| |
Previous patch introduced run-time UsbDk backend activation,
therefore separate build configuration is not needed anymore.
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
As a library, libusb should take care to be as friendly as possible
with various use cases. One such way is to ensure that internal file
descriptors have the CLOEXEC flag set, thus allowing processes to do
a fork() + exec() without leaking libusb's file descriptors to the
child process.
References #268
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
| |
Remove unnecessary quotes around simple string values.
Replace AC_ERROR with AC_MSG_ERROR.
Use [] around arguments to macros.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
| |
For consistency, only use quotes for strings where variables are
interpolated.
Also make the check for syslog capability dependent upon whether system
logging has been enabled.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Prior to this commit, gettimeofday() was being used for timestamps
in debug messages. This function has been marked as deprecated in
the latest POSIX specification and furthermore is not supported on
Windows, thus requiring our own implementation as usbi_gettimeofday().
This commit changes the logging code to obtain timestamps using the
clock_gettime() function provided by the backend. The implementation of
usbi_gettimeofday() for Windows was actually equivalent to that of the
USBI_CLOCK_REALTIME implementation for clock_gettime(), so this
eliminates code duplication. In addition, the USBI_CLOCK_REALTIME
implementation has been updated for Windows to leverage the
timespec_get() function available in VS 2015 and later.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
| |
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Closes #177
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit bumps the minimum autoconf version to 2.69. This only
affects maintainers and will ensure libusb tarballs have up-to-date
configure scripts. At the same time we are removing the
AM_MAINTAINER_MODE macro as even its creator recommends against
using it.
Closes #122
Signed-off-by: Nathan Hjelm <hjelmn@me.com>
|
|
|
|
|
|
| |
Closes #140
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|