projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added preliminary Symbian support.
[silc.git]
/
lib
/
silcutil
/
unix
/
silcunixthread.c
diff --git
a/lib/silcutil/unix/silcunixthread.c
b/lib/silcutil/unix/silcunixthread.c
index b32f61d62d6d663f4042b7d6b513ae65ea6f0dcc..7f52de901daca7baafd9d1c1bca4aaf949e52ad3 100644
(file)
--- a/
lib/silcutil/unix/silcunixthread.c
+++ b/
lib/silcutil/unix/silcunixthread.c
@@
-104,9
+104,8
@@
SilcBool silc_thread_wait(SilcThread thread, void **exit_value)
struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
-#else
- void *tmp;
#endif /* SILC_THREADS */
#endif /* SILC_THREADS */
+ unsigned int locked : 1;
};
SilcBool silc_mutex_alloc(SilcMutex *mutex)
};
SilcBool silc_mutex_alloc(SilcMutex *mutex)
@@
-116,6
+115,7
@@
SilcBool silc_mutex_alloc(SilcMutex *mutex)
if (*mutex == NULL)
return FALSE;
pthread_mutex_init(&(*mutex)->mutex, NULL);
if (*mutex == NULL)
return FALSE;
pthread_mutex_init(&(*mutex)->mutex, NULL);
+ (*mutex)->locked = FALSE;
return TRUE;
#else
return FALSE;
return TRUE;
#else
return FALSE;
@@
-137,7
+137,8
@@
void silc_mutex_lock(SilcMutex mutex)
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_lock(&mutex->mutex))
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_lock(&mutex->mutex))
- assert(FALSE);
+ SILC_ASSERT(FALSE);
+ mutex->locked = TRUE;
}
#endif /* SILC_THREADS */
}
}
#endif /* SILC_THREADS */
}
@@
-147,16
+148,25
@@
void silc_mutex_unlock(SilcMutex mutex)
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_unlock(&mutex->mutex))
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_unlock(&mutex->mutex))
- assert(FALSE);
+ SILC_ASSERT(FALSE);
+ mutex->locked = FALSE;
}
#endif /* SILC_THREADS */
}
}
#endif /* SILC_THREADS */
}
+void silc_mutex_assert_locked(SilcMutex mutex)
+{
+#ifdef SILC_THREADS
+ if (mutex)
+ SILC_ASSERT(mutex->locked);
+#endif /* SILC_THREADS */
+}
+
-/****************************
SILC CondVar API
******************************/
+/****************************
** SILC Cond API *
******************************/
/* SILC Conditional Variable context */
/* SILC Conditional Variable context */
-struct SilcCond
Var
Struct {
+struct SilcCondStruct {
#ifdef SILC_THREADS
pthread_cond_t cond;
#else
#ifdef SILC_THREADS
pthread_cond_t cond;
#else
@@
-164,7
+174,7
@@
struct SilcCondVarStruct {
#endif /* SILC_THREADS*/
};
#endif /* SILC_THREADS*/
};
-SilcBool silc_cond
var_alloc(SilcCondVar
*cond)
+SilcBool silc_cond
_alloc(SilcCond
*cond)
{
#ifdef SILC_THREADS
*cond = silc_calloc(1, sizeof(**cond));
{
#ifdef SILC_THREADS
*cond = silc_calloc(1, sizeof(**cond));
@@
-177,7
+187,7
@@
SilcBool silc_condvar_alloc(SilcCondVar *cond)
#endif /* SILC_THREADS*/
}
#endif /* SILC_THREADS*/
}
-void silc_cond
var_free(SilcCondVar
cond)
+void silc_cond
_free(SilcCond
cond)
{
#ifdef SILC_THREADS
pthread_cond_destroy(&cond->cond);
{
#ifdef SILC_THREADS
pthread_cond_destroy(&cond->cond);
@@
-185,29
+195,29
@@
void silc_condvar_free(SilcCondVar cond)
#endif /* SILC_THREADS*/
}
#endif /* SILC_THREADS*/
}
-void silc_cond
var_signal(SilcCondVar
cond)
+void silc_cond
_signal(SilcCond
cond)
{
#ifdef SILC_THREADS
pthread_cond_signal(&cond->cond);
#endif /* SILC_THREADS*/
}
{
#ifdef SILC_THREADS
pthread_cond_signal(&cond->cond);
#endif /* SILC_THREADS*/
}
-void silc_cond
var_broadcast(SilcCondVar
cond)
+void silc_cond
_broadcast(SilcCond
cond)
{
#ifdef SILC_THREADS
pthread_cond_broadcast(&cond->cond);
#endif /* SILC_THREADS*/
}
{
#ifdef SILC_THREADS
pthread_cond_broadcast(&cond->cond);
#endif /* SILC_THREADS*/
}
-void silc_cond
var_wait(SilcCondVar
cond, SilcMutex mutex)
+void silc_cond
_wait(SilcCond
cond, SilcMutex mutex)
{
#ifdef SILC_THREADS
pthread_cond_wait(&cond->cond, &mutex->mutex);
#endif /* SILC_THREADS*/
}
{
#ifdef SILC_THREADS
pthread_cond_wait(&cond->cond, &mutex->mutex);
#endif /* SILC_THREADS*/
}
-SilcBool silc_cond
var_timedwait(SilcCondVar
cond, SilcMutex mutex,
-
int timeout)
+SilcBool silc_cond
_timedwait(SilcCond
cond, SilcMutex mutex,
+ int timeout)
{
#ifdef SILC_THREADS
struct timespec t;
{
#ifdef SILC_THREADS
struct timespec t;
@@
-218,5
+228,7
@@
SilcBool silc_condvar_timedwait(SilcCondVar cond, SilcMutex mutex,
}
return pthread_cond_wait(&cond->cond, &mutex->mutex) == 0;
}
return pthread_cond_wait(&cond->cond, &mutex->mutex) == 0;
+#else
+ return FALSE;
#endif /* SILC_THREADS*/
}
#endif /* SILC_THREADS*/
}