33 pthread_mutexattr_settype(&
attr_recursive, PTHREAD_MUTEX_RECURSIVE);
45 const int err = pthread_mutex_init(&mutex->mutex, &
attr_recursive);
46 if (PREDICT_UNLIKELY(err)) {
48 raw_assert_unreached_msg(
"Error creating a mutex.");
61 err = pthread_mutex_init(&mutex->mutex, NULL);
62 if (PREDICT_UNLIKELY(err)) {
64 raw_assert_unreached_msg(
"Error creating a mutex.");
75 err = pthread_mutex_lock(&m->mutex);
76 if (PREDICT_UNLIKELY(err)) {
78 raw_assert_unreached_msg(
"Error locking a mutex.");
88 err = pthread_mutex_unlock(&m->mutex);
89 if (PREDICT_UNLIKELY(err)) {
91 raw_assert_unreached_msg(
"Error unlocking a mutex.");
117 err = pthread_mutex_destroy(&m->mutex);
118 if (PREDICT_UNLIKELY(err)) {
120 raw_assert_unreached_msg(
"Error destroying a mutex.");
Utility macros to handle different features and behavior in different compilers.
Header for compat_mutex.c.
void tor_mutex_release(tor_mutex_t *m)
void tor_mutex_acquire(tor_mutex_t *m)
void tor_mutex_init_nonrecursive(tor_mutex_t *mutex)
static int attr_initialized
void tor_mutex_init(tor_mutex_t *mutex)
void tor_locking_init(void)
static pthread_mutexattr_t attr_recursive
void tor_mutex_uninit(tor_mutex_t *m)