summaryrefslogtreecommitdiff
path: root/libusb/os/threads_posix.c
Commit message (Collapse)AuthorAgeFilesLines
* Misc: Trim and consolidate header file usageChris Dickens2020-01-241-11/+4
| | | | | | | | | | | | | 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>
* darwin: Replaced low-level mach API with pthread APISean McBride2018-01-081-3/+2
| | | | | | | | | | | | | | | | | | Found this because clang was warning that the return value was being converted from unsigned to signed. The need for a mach API surprised me, and I found this alternative formulation in a Chromium bug: https://groups.google.com/forum/#!topic/native-client-reviews/z---hlHbQNc which describes: "mach_thread_self() needs to be balanced by mach_port_deallocate(), which is two system calls. pthread_mach_thread_np(pthread_self()) is two libc function calls and no system calls, because pthread caches the Mach port." Fixed the conversion warning too, with a cast. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Fixed various trivial cppcheck 1.80 warningsSean McBride2017-12-281-1/+3
| | | | | | | | | | | | | | | | | Specifically: redundantAssignment,examples/dpfp.c:422,style,Variable 'r' is reassigned a value before the old one has been used. redundantAssignment,libusb/os/threads_posix.c:64,style,Variable 'ret' is reassigned a value before the old one has been used. unreadVariable,libusb/os/netbsd_usb.c:217,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/netbsd_usb.c:235,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/openbsd_usb.c:251,style,Variable 'hpriv' is assigned a value that is never used. unreadVariable,libusb/os/openbsd_usb.c:275,style,Variable 'hpriv' is assigned a value that is never used. unsignedLessThanZero,libusb/os/windows_winusb.c:259,style,Checking if unsigned variable '_index' is less than zero. unsignedLessThanZero,libusb/os/windows_winusb.c:298,style,Checking if unsigned variable '_index' is less than zero. unsignedLessThanZero,libusb/os/windows_winusb.c:367,style,Checking if unsigned variable '_index' is less than zero. invalidPrintfArgType_sint,examples/xusb.c:534,warning,%d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Kill usbi_os_backend structure definition madnessChris Dickens2017-07-061-1/+1
| | | | | | | | | | | Prior to this commit, each backend provided its own uniquely named usbi_os_backend structure and a massive pile of #ifdefs assigned the global usbi_backend pointer to the correct one. This commit kills off all this code and instead has each backend provide the usbi_backend symbol directly. The linker can inform of any issues that might arise with symbols. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Change event handling lock to traditional (non-recursive) typeChris Dickens2016-08-171-22/+0
| | | | | | | | | | | | | | | | | | | The event handling lock was previously required to be of the recursive type because the libusb_close() path requires the lock and may be called by a thread that is handling events (e.g. from within a transfer or hotplug callback). With commit 960a6e75, it is possible to determine whether the current function is being called from an event handling context, thus the recursive lock type is no longer necessary. References: * http://libusb.org/ticket/82 * 74282582cc879f091ad1d847411337bc3fa78a2b * c775c2f43037cd235b65410583179195e25f9c4a Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> [hdegoede@redhat.com: rebase on top of current master] Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* threads_posix: use backend clock_gettime()Nathan Hjelm2016-02-251-1/+2
| | | | | | | Some platforms do not implement the optional clock_gettime(). Need to use the backend implementation instead. Signed-off-by: Nathan Hjelm <hjelmn@me.com>
* core: Remove POSIX threads influence from synchronization codeChris Dickens2016-02-241-12/+30
| | | | | | | | | | | | | | This commit changes the signatures of the synchronization functions to reflect the needs of the library rather than the signature of the pthreads API. The mutex and condition variable attributes parameters have been removed as no part of the core library makes use of them. In addition, the condition variable timed-wait function has been modified to accept the relative time passed in via libusb_wait_for_event(). This allows the implementation-specific code to handle conversion to absolute time as necessary, rather than forcing this to occur. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* threads_posix: Fix compiler warning due to redefinition of _GNU_SOURCEChris Dickens2014-09-061-3/+1
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* core: Make use of headers consistent across all filesChris Dickens2014-09-061-0/+2
| | | | | | | | * Include config.h before anything else in all files * Remove unnecessary inclusion of libusb.h * Use angle brackets for system headers and quotes for local headers Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Misc: Revert all references to libusb/libusb.infohjelmn@cs.unm.edu2014-01-081-1/+1
|
* Android: Add formal Android supportToby Gray2013-08-111-1/+3
| | | | * Also fix an issue with LIBUSB_LOG_LEVEL_NONE
* Linux: Fix a major regression in threads_posix.cPete Batard2012-06-061-9/+6
| | | | | | | | | | | * On some Linux platforms, libusbx compilation breaks with: error: implicit declaration of function ‘pthread_mutexattr_settype’ * This regression, introduced in 463dda06db5da5de0eab32820c7af60605625afe, is due to pthread.h needing __USE_UNIX98, which is tied to _XOPEN_SOURCE or _GNU_SOURCE being correctly defined, and which the inclusion of <unistd.h> before the _XOPEN_SOURCE override modified * As _GNU_LINUX ensures the definition of __USE_UNIX98 and we require it for syscalls, we now only define _GNU_SOURCE for Linux.
* Misc: Ensure all sources are UTF-8Pete Batard2012-05-231-2/+2
| | | | * Also remove extra lines at the end of samples
* Windows: Fix missing cygwin thread IDPete Batard2012-05-101-0/+4
| | | | * Cygwin uses POSIX threads, not Windows threads
* BSD: Add thread ID support for OpenBSD > 5.1Pete Batard2012-05-081-2/+6
| | | | | | * Uses syscall(SYS_getthrid) which requires real thread support, currently only available in 5.1-current (but not 5.1-release). For OpenBSD <= 5.1, -1 will be returned for the thread ID.
* Core: Add a timestamping and thread ID to loggingPeter Stuge2012-05-061-0/+20
|
* Misc: Rebrand to libusbxPete Batard2012-04-031-3/+3
| | | | | * Mentions of 'libusb' in doxygen are changed to 'libusbx' * Also update copyright notices and remove unneeded EOF LFs
* threads_posix.c: Fix prototype warning by including threads_posix.hSean McBride2012-02-081-1/+1
|
* Add recursive mutexes to threading abstractionVitali Lovich2011-07-241-0/+55
This is necessary for the device close path which needs to attain the events lock, but which might itself be called while handling an event. The events lock is necessary to properly clean up transfers which might still be pointing to the device. References #82. [stuge: Move usbi_mutex_init_recursive() into threads_posix.c] [stuge: Must also #define _XOPEN_SOURCE 500 to be able to build] [pbatard: Un-inline usbi_mutex_init_recursive() to make Cygwin happy]