summaryrefslogtreecommitdiff
path: root/src/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/atomic.h')
-rw-r--r--src/atomic.h28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/atomic.h b/src/atomic.h
index cdbd21e..87ba20d 100644
--- a/src/atomic.h
+++ b/src/atomic.h
@@ -2,8 +2,10 @@
#define _ATOMIC_H_
#include <stdlib.h>
+#include <assert.h>
#include <pthread.h>
-#include <util.h>
+
+#include <message.h>
typedef int refcnt;
@@ -28,31 +30,13 @@ static inline void lock_init(lock *l)
static inline void lock_acquire(lock *l)
{
int ret = pthread_mutex_lock(l);
- if (ret < 0) {
- switch (ret) {
- case EINVAL:
- pr_err("invalid mutex\n");
- exit(1);
- case EDEADLK:
- pr_err("a deadlock would occur\n");
- exit(1);
- }
- }
+ assert(ret == 0);
}
static inline void lock_release(lock *l)
{
int ret = pthread_mutex_unlock(l);
- if (ret < 0) {
- switch (ret) {
- case EINVAL:
- pr_err("invalid mutex\n");
- exit(1);
- case EPERM:
- pr_err("this thread does not hold this mutex\n");
- exit(1);
- }
- }
+ assert(ret == 0);
}
static inline void lock_release_via_cleanup(void *l)
@@ -65,7 +49,7 @@ static inline void lock_release_via_cleanup(void *l)
pthread_cleanup_push(lock_release_via_cleanup, l)
-#define LOCK_RELEASE_THREAD(l) \
+#define LOCK_RELEASE_THREAD() \
pthread_cleanup_pop(1)
#endif /* _ATOMIC_H_ */