diff options
author | Pete Batard <pbatard@gmail.com> | 2010-02-24 11:29:43 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-02-24 11:29:43 +0000 |
commit | c83b94c78f1cc5c823b677c9963d133a2d408776 (patch) | |
tree | 1fbc38157c924eafb8134d863fbe449b52114655 /libusb/os/linux_usbfs.c | |
parent | 1d8a2cc6ae71cc445bc6d1c3f43a803e24a8fbb9 (diff) | |
download | libusb-c83b94c78f1cc5c823b677c9963d133a2d408776.tar.gz |
merge abstraction for POSIX Threads and integration changes (Michael Plante, Peter Stuge)r169
v1.0.6 release
Darwin: support multiple calls to libusb_init
Credit to Orin Eman for finding this bug.
Darwin: use logging functions
Use usbi_warn, usbi_err, and usbi_info instead of _usbi_log.
Darwin: fix memory leak in process_device
Credit to Mike Colagrosso for finding this bug.
Add internal abstraction for POSIX Threads
This prepares for a Windows backend without dependency on pthreads-w32.
pthread_* is renamed to usbi_* and PTHREAD_* to USBI_*.
A usbi_mutex_static_t and usbi_mutex_static_lock() and _unlock() are
introduced for statically initialized mutexes, since they may be
implemented using other types when pthreads mutexes aren't used.
Move -pthread from libusb/Makefile.am to host-specific AM_CFLAGS in
configure.ac. AM_CFLAGS is already used in Makefile.am.
(Numerous merge conflicts resolved by Michael Plante)
misc fixes to pthreads abstraction
* windows_compat.h should not be directly included (use libusbi.h)
* windows_usb.c still had some references to pthread_mutex_[un]lock
Add libusb_strerror() to get short error message in English from enum
(Merge conflicts resolved by Michael Plante)
Better cleanup on errors, stricter types and some good casts
Avoid various memory leaks in error code paths and remove warnings. Also
add usbi_cond_destroy in os/threads_posix.h because it's used for cleanup
now.
(Merge conflicts resolved by Michael Plante)
Rename all interface parameters to usb_interface or interface_number
(Merge conflicts resolved by Michael Plante)
Add type parameter to the list_for_each_entry() and _safe() macros
(Merge conflicts resolved by Michael Plante)
VA_ARGS workaround for logging with MSVC6
(Merge conflicts resolved by Michael Plante)
Fix context memory leak in libusb_init()
* Now holds default_context_lock for duration of libusb_init
* Doesn't allocate it if not needed
Fix the last MSVC /W3 warning
removal of pthreads from MSVC and mingw
* removed pthread*.lib from linking in msvc6 (2005/8 not yet edited)
* added threads_windows.[ch] to all project files in msvc6
* added usbi_cond_signal to both threading versions, unused
* added native windows threading code, now used
removed redundant time.h includes
removed pthread-win32 informational solution files
updated MSVC 2005/2008 for thread abstraction
fixed DDK build
fixed cygwin's use of POSIX threads
fixed dpfp/dpfp_threaded for MinGW compatibility
config_msvc.h -> msvc/config.h
pthread abstraction for DLL project files
fixed bad reference to thread_windows in 2005 DLL vcproj
cygwin ifdef is not required in threads_windows.h - removed
fixed residuals from previous patches
moved thread source detection into autotool scripts
Diffstat (limited to 'libusb/os/linux_usbfs.c')
-rw-r--r-- | libusb/os/linux_usbfs.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 3888aa9..dd38e65 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -1775,7 +1775,7 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer, enum libusb_transfer_status status = LIBUSB_TRANSFER_COMPLETED; int r = 0; - pthread_mutex_lock(&itransfer->lock); + usbi_mutex_lock(&itransfer->lock); usbi_dbg("handling completion status %d of bulk urb %d/%d", urb->status, urb_idx + 1, num_urbs); @@ -1819,7 +1819,7 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer, if (tpriv->reap_action == CANCELLED) { free(tpriv->urbs); tpriv->urbs = NULL; - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); r = usbi_handle_transfer_cancellation(itransfer); goto out_unlock; } @@ -1897,10 +1897,10 @@ static int handle_bulk_completion(struct usbi_transfer *itransfer, completed: free(tpriv->urbs); tpriv->urbs = NULL; - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_completion(itransfer, status); out_unlock: - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return r; } @@ -1914,7 +1914,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer, int urb_idx = 0; int i; - pthread_mutex_lock(&itransfer->lock); + usbi_mutex_lock(&itransfer->lock); for (i = 0; i < num_urbs; i++) { if (urb == tpriv->iso_urbs[i]) { urb_idx = i + 1; @@ -1923,7 +1923,7 @@ static int handle_iso_completion(struct usbi_transfer *itransfer, } if (urb_idx == 0) { usbi_err(TRANSFER_CTX(transfer), "could not locate urb!"); - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return LIBUSB_ERROR_NOT_FOUND; } @@ -1951,10 +1951,10 @@ static int handle_iso_completion(struct usbi_transfer *itransfer, usbi_dbg("CANCEL: last URB handled, reporting"); free_iso_urbs(tpriv); if (tpriv->reap_action == CANCELLED) { - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_cancellation(itransfer); } else { - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_ERROR); } @@ -1981,12 +1981,12 @@ static int handle_iso_completion(struct usbi_transfer *itransfer, if (urb_idx == num_urbs) { usbi_dbg("last URB in transfer --> complete!"); free_iso_urbs(tpriv); - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_completion(itransfer, LIBUSB_TRANSFER_COMPLETED); } out: - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return 0; } @@ -1996,7 +1996,7 @@ static int handle_control_completion(struct usbi_transfer *itransfer, struct linux_transfer_priv *tpriv = usbi_transfer_get_os_priv(itransfer); int status; - pthread_mutex_lock(&itransfer->lock); + usbi_mutex_lock(&itransfer->lock); usbi_dbg("handling completion status %d", urb->status); if (urb->status == 0) @@ -2008,7 +2008,7 @@ static int handle_control_completion(struct usbi_transfer *itransfer, "cancel: unrecognised urb status %d", urb->status); free(tpriv->urbs); tpriv->urbs = NULL; - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_cancellation(itransfer); } @@ -2036,7 +2036,7 @@ static int handle_control_completion(struct usbi_transfer *itransfer, free(tpriv->urbs); tpriv->urbs = NULL; - pthread_mutex_unlock(&itransfer->lock); + usbi_mutex_unlock(&itransfer->lock); return usbi_handle_transfer_completion(itransfer, status); } @@ -2087,7 +2087,7 @@ static int op_handle_events(struct libusb_context *ctx, int r; int i = 0; - pthread_mutex_lock(&ctx->open_devs_lock); + usbi_mutex_lock(&ctx->open_devs_lock); for (i = 0; i < nfds && num_ready > 0; i++) { struct pollfd *pollfd = &fds[i]; struct libusb_device_handle *handle; @@ -2118,7 +2118,7 @@ static int op_handle_events(struct libusb_context *ctx, r = 0; out: - pthread_mutex_unlock(&ctx->open_devs_lock); + usbi_mutex_unlock(&ctx->open_devs_lock); return r; } |