Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-IceS
Commits
858c9a97
Commit
858c9a97
authored
Jan 09, 2009
by
Karl Heyes
Browse files
Add handlers for spinlocks if available, map to mutexes when not.
svn path=/icecast/trunk/thread/; revision=15614
parent
cfa169ab
Changes
2
Show whitespace changes
Inline
Side-by-side
src/thread/thread.c
View file @
858c9a97
...
@@ -195,6 +195,7 @@ void thread_shutdown(void)
...
@@ -195,6 +195,7 @@ void thread_shutdown(void)
avl_tree_free
(
_mutextree
,
_free_mutex
);
avl_tree_free
(
_mutextree
,
_free_mutex
);
#endif
#endif
avl_tree_free
(
_threadtree
,
_free_thread
);
avl_tree_free
(
_threadtree
,
_free_thread
);
_threadtree
=
NULL
;
}
}
#ifdef THREAD_DEBUG
#ifdef THREAD_DEBUG
...
@@ -222,6 +223,7 @@ static void _block_signals(void)
...
@@ -222,6 +223,7 @@ static void _block_signals(void)
sigdelset
(
&
ss
,
SIGKILL
);
sigdelset
(
&
ss
,
SIGKILL
);
sigdelset
(
&
ss
,
SIGSTOP
);
sigdelset
(
&
ss
,
SIGSTOP
);
sigdelset
(
&
ss
,
SIGSEGV
);
sigdelset
(
&
ss
,
SIGSEGV
);
sigdelset
(
&
ss
,
SIGCHLD
);
sigdelset
(
&
ss
,
SIGBUS
);
sigdelset
(
&
ss
,
SIGBUS
);
if
(
pthread_sigmask
(
SIG_BLOCK
,
&
ss
,
NULL
)
!=
0
)
{
if
(
pthread_sigmask
(
SIG_BLOCK
,
&
ss
,
NULL
)
!=
0
)
{
#ifdef THREAD_DEBUG
#ifdef THREAD_DEBUG
...
@@ -811,3 +813,29 @@ static int _free_thread(void *key)
...
@@ -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
src/thread/thread.h
View file @
858c9a97
...
@@ -89,6 +89,24 @@ typedef struct {
...
@@ -89,6 +89,24 @@ typedef struct {
pthread_rwlock_t
sys_rwlock
;
pthread_rwlock_t
sys_rwlock
;
}
rwlock_t
;
}
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_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_create(x) thread_mutex_create_c(x,__LINE__,__FILE__)
#define thread_mutex_lock(x) thread_mutex_lock_c(x,__LINE__,__FILE__)
#define thread_mutex_lock(x) thread_mutex_lock_c(x,__LINE__,__FILE__)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment