Commit 78cbf2a0 authored by Kirill Smelkov's avatar Kirill Smelkov

lib/utils: X- versions for pthread_mutex_{lock,unlock}

Mutex lock/unlock should not fail if mutex was correctly initialized/used.
parent 786d418d
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <ccan/build_assert/build_assert.h> #include <ccan/build_assert/build_assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h>
/* compile-time exact ilog2(x); x must be 2^k */ /* compile-time exact ilog2(x); x must be 2^k */
...@@ -79,4 +80,7 @@ void xsigaddset(sigset_t *set, int sig); ...@@ -79,4 +80,7 @@ void xsigaddset(sigset_t *set, int sig);
int xsigismember(const sigset_t *set, int sig); int xsigismember(const sigset_t *set, int sig);
void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset); void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset);
void xpthread_mutex_lock(pthread_mutex_t *);
void xpthread_mutex_unlock(pthread_mutex_t *);
#endif #endif
...@@ -141,3 +141,21 @@ void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset) ...@@ -141,3 +141,21 @@ void xpthread_sigmask(int how, const sigset_t *set, sigset_t *oldset)
if (err) if (err)
BUGerr(err); BUGerr(err);
} }
/* mutex lock/unlock should not fail if mutex was correctly initialized/used */
void xpthread_mutex_lock(pthread_mutex_t *lock)
{
int err;
err = pthread_mutex_lock(lock);
if (err)
BUGerr(err);
}
void xpthread_mutex_unlock(pthread_mutex_t *lock)
{
int err;
err = pthread_mutex_unlock(lock);
if (err)
BUGerr(err);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment