summaryrefslogtreecommitdiff
path: root/Xcode
Commit message (Collapse)AuthorAgeFilesLines
* Simplify clock_gettime() conditionalization and fallback on macOSSean McBride2022-06-261-6/+0
| | | | | | | | | | | | | | 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
* core: Refactor initialization and how the default context is handledChris Dickens2021-06-021-4/+0
| | | | | | | | | | | | | | | | | | | Highlights for this change: - usbi_default_context is only set if libusb_init() is called with NULL. - All hotplug related functionality (e.g. initialization, processing) has been moved to hotplug.c - Backends are simplified by removing initialization mutexes. Mutual exclusion between init()/exit() is provided by default_context_lock. - Make hotplug types and functions part of libusbi.h with the common usbi_ prefixes (removes hotplug.h). Addresses issue highlighted in #855 Closes #856 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com> Signed-off-by: Nathan Hjelm <hjelmn@google.com>
* darwin: add authorization for device captureosy2021-05-161-25/+54
| | | | | | | | | | | | | | | | | | | 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>
* build: Prepare config.h for inclusion in examples/testsChris Dickens2020-11-271-0/+4
| | | | | | | | | | | | 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>
* build: Fix Android and Xcode compilation errors/warningsChris Dickens2020-11-161-116/+108
| | | | | | | | | | | | | | | | | | 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>
* build: Merge events and threads into single platform abstractionChris Dickens2020-09-121-5/+2
| | | | | | | | | | | | | | 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>
* core: Introduce platform events abstractionChris Dickens2020-08-122-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Xcode: Update project fileChris Dickens2020-03-303-107/+295
| | | | | | | | | | | | | | | | | Add '-fvisibility=hidden' to the additional compiler flags of the libusb target so that internal library symbols are hidden. Add '-pthread' to the additional compiler flags of the targets that directly use pthread functionality Add the 'sam3u_benchmark' and 'testlibusb' targets so that all examples are now built and fix build warnings that occur when building 'sam3u_benchmark'. Fix target dependencies so that all targets are able to build without issues. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* build: Require C11 to build and clean up autoconfig/automake filesChris Dickens2020-03-302-11/+8
| | | | | | | | | | | | | | | | | | | | | | | 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>
* core: Kill the OS_* definitions and use in the source codeChris Dickens2020-03-271-3/+0
| | | | | | | 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>
* threads_posix: Improve usbi_get_tid() for various platformsChris Dickens2020-03-271-5/+15
| | | | | | | | | | | | | 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>
* core: Kill usbi_backend.clock_gettime() functionChris Dickens2020-03-151-0/+7
| | | | | | | | | | | | | | | | | | 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>
* configure.ac: Cleanup and refactoringChris Dickens2020-01-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Misc: Trim and consolidate header file usageChris Dickens2020-01-241-3/+0
| | | | | | | | | | | | | 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>
* Xcode: add tests/stress targetLudovic Rousseau2019-11-011-0/+149
| | | | Also build tests/stress
* Xcode: apply suggested changes from Xcode 11.2Ludovic Rousseau2019-11-011-1/+13
| | | | Enable code signing.
* Xcode: apply suggested changes from Xcode 10.3Ludovic Rousseau2019-09-151-2/+42
|
* Fixed Xcode 10.1 warning by setting project setting ↵Sean McBride2019-04-042-0/+7
| | | | | | | | | | | | 'ALWAYS_SEARCH_USER_PATHS = NO' The warning was: "Traditional headermap style is no longer supported; please migrate to using separate headermaps and set 'ALWAYS_SEARCH_USER_PATHS' to NO." Also made sure all targets are referencing the xcconfig files. Closes #532 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* Fixed many compiler warnings about sign and size mismatchSean McBride2019-01-301-0/+9
| | | | | | | | | | - added various casts - added some asserts where the casts made assumptions - enabled additional warnings in Xcode project (especially -Wshorten-64-to-32) Closes #509 Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* darwin: Configure Xcode project to specify tab/space, indent amountSean McBride2018-01-081-32/+32
| | | | | | | | All source files are now tagged as using tabs of 4 spaces, except darwin_usb.c and darwin_usb.h which use spaces of 2 spaces. This allows editing files in Xcode without it messing up any particular files. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Remove use of gettimeofday()Chris Dickens2017-01-121-3/+0
| | | | | | | | | | | | | | | | | 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>
* darwin: build hotplugtest sample in XcodeLudovic Rousseau2016-03-061-3/+93
| | | | | The Xcode project now also builds the hotplugtest (from examples/hotplugtest.c) target.
* darwin: change Xcode project end-of-lineLudovic Rousseau2015-01-251-1/+865
| | | | | | | The end of line character was CR (0x0D) instead of NL (0x0A). It looks like the mistake is from 1eff220474f63d7ea7f8f99bef2a3da9da5324eb
* Use @rpath in Xcode projectSean McBride2014-05-061-0/+1
| | | | | | | | | In the Xcode project, set: LD_DYLIB_INSTALL_NAME = @rpath Such that the built dylib's install name uses rpath, which is generally what one wants.
* Removed obsolete comment related to libusbx forkSean McBride2014-03-211-1/+0
|
* Enabled LTO optimization in release in Xcode projectSean McBride2014-03-211-0/+1
|
* Enabled additional warnings in Xcode projectSean McBride2014-03-211-1/+10
|
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-088-879/+16
|
* fixed link errors by adding missing files to Xcode projectSean McBride2013-07-301-0/+16
|
* make targets for examples depend on library target. Generate library named ↵Sean McBride2013-07-307-51/+287
| | | | | | | libusb-1.0.0.dylib not libusbx.dylib. Added several xcconfig files to make source control and documentation easier. Reorganised a few files' positions within the project. Disable strict aliasing since libusbx breaks strict aliasing rules anyway. Set project format as 3.1-compatible. Conflicts: Xcode/libusbx.xcodeproj/project.pbxproj
* Xcode: build for 32 and 64 bitsLudovic Rousseau2013-07-301-0/+2
|
* Xcode: remove implicit/default configurationLudovic Rousseau2013-07-301-19/+0
|
* Add minimal config.h for XcodeLudovic Rousseau2013-07-301-0/+28
| | | | | | Xcode do not use ./configure so the config.h file needs to be generated by hand. This config.h is the minimal file for libusbx built using Xcode.
* Adapt Xcode project to the new pathsLudovic Rousseau2013-07-301-2/+4
|
* Move Xcode project in Xcode/ directoryLudovic Rousseau2013-07-301-0/+788
This is to use Xcode special config.h file in a independent directory. The same is already done for MS Visual C with msvc/ directory.