summaryrefslogtreecommitdiff
path: root/libusb/os/threads_posix.h
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2016-01-30 02:24:39 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2016-02-24 10:51:49 -0800
commit3a4fd0ac64cf9d4cf8f2a665f2f43f2bb1d25369 (patch)
tree6c6f51d19afe7dfe28a9549defbf54274c1ec003 /libusb/os/threads_posix.h
parenta05b282bee6998da3d1a8460b33dc24b69682fb7 (diff)
downloadlibusb-3a4fd0ac64cf9d4cf8f2a665f2f43f2bb1d25369.tar.gz
core: Remove POSIX threads influence from synchronization code
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>
Diffstat (limited to 'libusb/os/threads_posix.h')
-rw-r--r--libusb/os/threads_posix.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/libusb/os/threads_posix.h b/libusb/os/threads_posix.h
index ce78cc3..2abb820 100644
--- a/libusb/os/threads_posix.h
+++ b/libusb/os/threads_posix.h
@@ -22,6 +22,9 @@
#define LIBUSB_THREADS_POSIX_H
#include <pthread.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
#define usbi_mutex_static_t pthread_mutex_t
#define USBI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
@@ -29,26 +32,28 @@
#define usbi_mutex_static_unlock pthread_mutex_unlock
#define usbi_mutex_t pthread_mutex_t
-#define usbi_mutex_init pthread_mutex_init
+#define usbi_mutex_init(mutex) pthread_mutex_init((mutex), NULL)
#define usbi_mutex_lock pthread_mutex_lock
#define usbi_mutex_unlock pthread_mutex_unlock
#define usbi_mutex_trylock pthread_mutex_trylock
#define usbi_mutex_destroy pthread_mutex_destroy
#define usbi_cond_t pthread_cond_t
-#define usbi_cond_init pthread_cond_init
+#define usbi_cond_init(cond) pthread_cond_init((cond), NULL)
#define usbi_cond_wait pthread_cond_wait
-#define usbi_cond_timedwait pthread_cond_timedwait
#define usbi_cond_broadcast pthread_cond_broadcast
#define usbi_cond_destroy pthread_cond_destroy
#define usbi_tls_key_t pthread_key_t
-#define usbi_tls_key_create pthread_key_create
+#define usbi_tls_key_create(key) pthread_key_create((key), NULL)
#define usbi_tls_key_get pthread_getspecific
#define usbi_tls_key_set pthread_setspecific
#define usbi_tls_key_delete pthread_key_delete
-extern int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr);
+int usbi_mutex_init_recursive(pthread_mutex_t *mutex);
+
+int usbi_cond_timedwait(pthread_cond_t *cond,
+ pthread_mutex_t *mutex, const struct timeval *tv);
int usbi_get_tid(void);