mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2024-09-29 04:25:57 -04:00
Add handlers for spinlocks if available, map to mutexes when not.
svn path=/icecast/trunk/thread/; revision=15614
This commit is contained in:
parent
a80483333d
commit
3937e807fe
@ -195,6 +195,7 @@ void thread_shutdown(void)
|
||||
avl_tree_free(_mutextree, _free_mutex);
|
||||
#endif
|
||||
avl_tree_free(_threadtree, _free_thread);
|
||||
_threadtree = NULL;
|
||||
}
|
||||
|
||||
#ifdef THREAD_DEBUG
|
||||
@ -222,6 +223,7 @@ static void _block_signals(void)
|
||||
sigdelset(&ss, SIGKILL);
|
||||
sigdelset(&ss, SIGSTOP);
|
||||
sigdelset(&ss, SIGSEGV);
|
||||
sigdelset(&ss, SIGCHLD);
|
||||
sigdelset(&ss, SIGBUS);
|
||||
if (pthread_sigmask(SIG_BLOCK, &ss, NULL) != 0) {
|
||||
#ifdef THREAD_DEBUG
|
||||
@ -811,3 +813,29 @@ static int _free_thread(void *key)
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_PTHREAD_SPIN_LOCK
|
||||
void thread_spin_create (spin_t *spin)
|
||||
{
|
||||
int x = pthread_spin_init (&spin->lock, PTHREAD_PROCESS_PRIVATE);
|
||||
if (x)
|
||||
abort();
|
||||
}
|
||||
|
||||
void thread_spin_destroy (spin_t *spin)
|
||||
{
|
||||
pthread_spin_destroy (&spin->lock);
|
||||
}
|
||||
|
||||
void thread_spin_lock (spin_t *spin)
|
||||
{
|
||||
int x = pthread_spin_lock (&spin->lock);
|
||||
if (x != 0)
|
||||
abort();
|
||||
}
|
||||
|
||||
void thread_spin_unlock (spin_t *spin)
|
||||
{
|
||||
pthread_spin_unlock (&spin->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -89,6 +89,24 @@ typedef struct {
|
||||
pthread_rwlock_t sys_rwlock;
|
||||
} rwlock_t;
|
||||
|
||||
#ifdef HAVE_PTHREAD_SPIN_LOCK
|
||||
typedef struct
|
||||
{
|
||||
pthread_spinlock_t lock;
|
||||
} spin_t;
|
||||
|
||||
void thread_spin_create (spin_t *spin);
|
||||
void thread_spin_destroy (spin_t *spin);
|
||||
void thread_spin_lock (spin_t *spin);
|
||||
void thread_spin_unlock (spin_t *spin);
|
||||
#else
|
||||
typedef mutex_t spin_t;
|
||||
#define thread_spin_create(x) thread_mutex_create(x)
|
||||
#define thread_spin_destroy(x) thread_mutex_destroy(x)
|
||||
#define thread_spin_lock(x) thread_mutex_lock(x)
|
||||
#define thread_spin_unlock(x) thread_mutex_unlock(x)
|
||||
#endif
|
||||
|
||||
#define thread_create(n,x,y,z) thread_create_c(n,x,y,z,__LINE__,__FILE__)
|
||||
#define thread_mutex_create(x) thread_mutex_create_c(x,__LINE__,__FILE__)
|
||||
#define thread_mutex_lock(x) thread_mutex_lock_c(x,__LINE__,__FILE__)
|
||||
|
Loading…
Reference in New Issue
Block a user