27 Commits

Author SHA1 Message Date
Harry Mallon
5b17c383f8 Add API support for LIBUSB_SPEED_SUPER_PLUS_X2 20Gbps USB 3.2 gen 2x2
Implement detection on darwin and linux_usbfs, and report it in xusb.

Closes #1477
2024-05-07 19:44:28 +02:00
Yegor Yefremov
0d9731ef67 android: Fix typo and syntax in comments
Fix a typo and add missing commas.

Also, delete a blank line at the end of the file and
use /* */ for comments consistently.

Closes #1071

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2022-03-18 19:16:27 +01:00
Peter-St
f33c9562a1 examples: Add example for unrooted Android
Closes #830
2021-11-02 00:20:26 +01:00
luz paz
14d3bde10f Fix various typos in docs/comments
Found via `codespell -q 3`

Closes #1015
2021-10-31 17:44:55 +01:00
Peter-St
35b3a52188 Update Android Readme
Add another approach for connecting USB devices on Android.

References #830
Closes #996
2021-09-23 10:52:11 +02:00
xloem
42407102fd Android build name correction
Fixes #31

See #143 and #596 for solutions to the whole build system.

Closes #971
2021-09-23 10:51:48 +02:00
Chris Dickens
f2e551a5ff build: Prepare config.h for inclusion in examples/tests
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>
2020-11-27 15:22:29 -08:00
Chris Dickens
9d23ed25b4 build: Fix Android and Xcode compilation errors/warnings
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 <christopher.a.dickens@gmail.com>
2020-11-16 13:03:52 -08:00
Chris Dickens
da5df37c4d build: Merge events and threads into single platform abstraction
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>
2020-09-12 22:44:28 -07:00
Chris Dickens
d67eb5beaa core: Introduce platform events abstraction
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>
2020-08-12 16:06:38 -07:00
Aaron Luft
71a3fb3faa Android: fixes unknown warning option from ndk build
A command line option is not correct.
Fix by spelling the option correctly.

BEFORE

[x86] Compile        : xusb <= xusb.c
warning: unknown warning option '-Werror=unintialized'; did you mean '-Werror=uninitialized'? [-Wunknown-warning-option]

AFTER

[x86] Compile        : xusb <= xusb.c
[x86] Executable     : xusb
[x86] Install        : xusb => libs/x86/xusb
2020-04-17 18:41:55 +02:00
Chris Dickens
500c64aef2 android: Update makefiles to include recent autobuild changes
Add C11, thread and visibility compiler flags. Enable additional
warnings and errors. Unify spacing amongst the makefiles.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-03-30 13:21:04 -07:00
Chris Dickens
9a1bc8cafb build: Require C11 to build and clean up autoconfig/automake files
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>
2020-03-30 12:28:11 -07:00
Chris Dickens
8b09dd490d core: Kill the OS_* definitions and use in the source code
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>
2020-03-27 18:23:16 -07:00
Chris Dickens
30b56baec5 threads_posix: Improve usbi_get_tid() for various platforms
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>
2020-03-27 00:03:41 -07:00
Chris Dickens
d5bb64b3dc configure.ac: Cleanup and refactoring
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>
2020-01-24 11:22:49 -08:00
Chris Dickens
aaff15d48d Misc: Trim and consolidate header file usage
Refactor libusbi.h to include the set of common header files needed by
every main source file in the library and change these source files to
include libusbi.h first, followed by any non-common headers. Including
libusbi.h first ensures that the config definitions are pulled in and
will eliminate redundant includes in the individual sources files.

Also clean up some whitespace errors and remove unnecessary definitions
in the manually generated config.h files.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2020-01-24 11:21:27 -08:00
Chris Dickens
068b594306 core: Remove use of gettimeofday()
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>
2017-01-12 15:03:16 -08:00
Chris Dickens
80f1657f06 core: Remove check for and inclusion of signal.h
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
2017-01-12 15:02:59 -08:00
William Skellenger
ba9eef2f61 android: update README
Added other $ARCH

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
2016-03-06 21:45:02 +01:00
William Skellenger
8b42622b07 android: Fix typo in README
Remove the /sdcard copy and not the /system/lib copy

Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
2016-03-06 21:44:51 +01:00
hjelmn@cs.unm.edu
1eff220474 Misc: Revert all references to libusb/libusb.info 2014-01-08 23:51:01 +00:00
Kuangye Guo
7e3de5de09 Android: Add support for Linux/Android platforms
* Closes #154
2013-12-28 23:03:32 +00:00
Andrew Fernandes
650e22508f Android: Build for all Android architectures
* Don't limit support to ARM only (adds MIPS support)
* Also add a workaround for a MIPS NDK linker bug
* Also add a gitignore entry required to run bootstrap.sh on OS X
* Closes #134
2013-12-28 22:58:06 +00:00
Toby Gray
0837c479dc Android: Add further documentation to Android README file
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-08-21 16:27:03 +02:00
Toby Gray
c632101790 Android: Add examples and stress tests 2013-08-11 22:14:13 +01:00
Toby Gray
7bfbb8b331 Android: Add formal Android support
* Also fix an issue with LIBUSB_LOG_LEVEL_NONE
2013-08-11 22:12:03 +01:00