struct SilcMutexStruct {
#ifdef SILC_THREADS
pthread_mutex_t mutex;
-#else
- void *tmp;
#endif /* SILC_THREADS */
+ unsigned int locked : 1;
};
SilcBool silc_mutex_alloc(SilcMutex *mutex)
if (*mutex == NULL)
return FALSE;
pthread_mutex_init(&(*mutex)->mutex, NULL);
+ (*mutex)->locked = FALSE;
return TRUE;
#else
return FALSE;
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_lock(&mutex->mutex))
- assert(FALSE);
+ SILC_ASSERT(FALSE);
+ mutex->locked = TRUE;
}
#endif /* SILC_THREADS */
}
#ifdef SILC_THREADS
if (mutex) {
if (pthread_mutex_unlock(&mutex->mutex))
- assert(FALSE);
+ SILC_ASSERT(FALSE);
+ mutex->locked = FALSE;
}
#endif /* SILC_THREADS */
}
+void silc_mutex_assert_locked(SilcMutex mutex)
+{
+#ifdef SILC_THREADS
+ if (mutex)
+ SILC_ASSERT(mutex->locked);
+#endif /* SILC_THREADS */
+}
+
-/**************************** SILC Cond API ******************************/
+/****************************** SILC Cond API *******************************/
/* SILC Conditional Variable context */
struct SilcCondStruct {
}
return pthread_cond_wait(&cond->cond, &mutex->mutex) == 0;
+#else
+ return FALSE;
#endif /* SILC_THREADS*/
}