aboutsummaryrefslogtreecommitdiff
path: root/src/std/thread.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-02-28 00:02:41 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commitcff67f93caeb3f98261860904dd232f6b551299e (patch)
tree94715ee98cc0ea62ea60da96b8b2d3a595b5276e /src/std/thread.c
parent0ed62b9337c64a91481afd91f9e5706a36eca7b5 (diff)
fix crashes
Diffstat (limited to 'src/std/thread.c')
-rw-r--r--src/std/thread.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/std/thread.c b/src/std/thread.c
index f717865..4f27c1d 100644
--- a/src/std/thread.c
+++ b/src/std/thread.c
@@ -101,33 +101,37 @@ int amal_mutex_lock(amal_mutex *self, const char *lock_identifier) {
int result;
result = pthread_mutex_lock(&self->mutex);
self->lock_identifier = lock_identifier;
+ #ifdef AMAL_MUTEX_DEBUG
if(result == 0 && self->lock_identifier) {
amal_log_debug("amal_mutex_lock: mutex locked by thread %lu (%s), identification: %s",
amal_thread_get_id(),
amal_thread_is_main() ? "main" : "not main",
self->lock_identifier ? self->lock_identifier : "none");
}
+ #endif
return result;
}
int amal_mutex_unlock(amal_mutex *self) {
int result;
+ #ifdef AMAL_MUTEX_DEBUG
const char *identifier;
identifier = self->lock_identifier;
+ #endif
result = pthread_mutex_unlock(&self->mutex);
+ #ifdef AMAL_MUTEX_DEBUG
if(result == 0 && identifier) {
amal_log_debug("amal_mutex_unlock: mutex unlocked by thread %lu (%s), identification: %s",
amal_thread_get_id(),
amal_thread_is_main() ? "main" : "not main",
identifier ? identifier : "none");
}
+ #endif
return result;
}
void amal_mutex_tryunlock(amal_mutex *self) {
- int _;
- (void)_;
- _ = amal_mutex_unlock(self);
+ ignore_result_int(amal_mutex_unlock(self));
}
bool amal_thread_is_main() {