Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
spr0cketeer
Icecast-common
Commits
3937e807
Commit
3937e807
authored
Jan 09, 2009
by
Karl Heyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add handlers for spinlocks if available, map to mutexes when not.
svn path=/icecast/trunk/thread/; revision=15614
parent
a8048333
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
thread/thread.c
thread/thread.c
+29
-1
thread/thread.h
thread/thread.h
+18
-0
No files found.
thread/thread.c
View file @
3937e807
...
...
@@ -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
...
...
@@ -594,7 +596,7 @@ void thread_exit_c(long val, int line, char *file)
avl_delete
(
_threadtree
,
th
,
_free_thread
);
_mutex_unlock
(
&
_threadtree_mutex
);
}
pthread_exit
((
void
*
)
val
);
}
...
...
@@ -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
thread/thread.h
View file @
3937e807
...
...
@@ -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__)
...
...
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