Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8a5551

Browse files
macOS: work around compiler warning
1 parent 7466ec6 commit d8a5551

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/darwin_compat.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include <errno.h>
1111
#include <sys/types.h>
1212

13+
static void _unlock_mutex(void *mutex)
14+
{
15+
pthread_mutex_unlock((pthread_mutex_t *)mutex);
16+
}
17+
1318
/*
1419
* Semaphore implementation based on:
1520
*
@@ -152,7 +157,7 @@ darwin_sem_timedwait(darwin_sem_t *sem, const struct timespec *abs_timeout)
152157
return -1;
153158
}
154159

155-
pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock,
160+
pthread_cleanup_push(&_unlock_mutex,
156161
&sem->__data.local.count_lock);
157162

158163
pthread_mutex_lock(&sem->__data.local.count_lock);
@@ -213,7 +218,7 @@ darwin_sem_wait(darwin_sem_t *sem)
213218
/* Must be volatile or will be clobbered by longjmp */
214219
volatile int res = 0;
215220

216-
pthread_cleanup_push((void(*)(void*))&pthread_mutex_unlock,
221+
pthread_cleanup_push(&_unlock_mutex,
217222
&sem->__data.local.count_lock);
218223

219224
pthread_mutex_lock(&sem->__data.local.count_lock);

0 commit comments

Comments
 (0)