mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
Various fixes for OS X
This patch addresses compilation errors on OS X. It's been a while, so there's quite a few things. * Fixed __attribute__ decls in route.h to be portable. * Fixed htonll and ntohll to work when they are defined as macros. * Replaced sem_t usage with our ast_sem wrapper. * Added ast_sem_timedwait to our ast_sem wrapper. * Fixed some GCC 4.9 warnings using sig*set() functions. * Fixed some format strings for portability. * Fixed compilation issues with res_timing_kqueue (although tests still fail on OS X). * Fixed menuconfig /sbin/launchd detection, which disables res_timing_kqueue on OS X). ASTERISK-24539 #close Reported by: George Joseph ASTERISK-24544 #close Reported by: George Joseph Review: https://reviewboard.asterisk.org/r/4327/ ........ Merged revisions 431092 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@431093 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
33
main/sem.c
33
main/sem.c
@@ -85,6 +85,7 @@ int ast_sem_post(struct ast_sem *sem)
|
||||
|
||||
int ast_sem_wait(struct ast_sem *sem)
|
||||
{
|
||||
int res;
|
||||
SCOPED_MUTEX(lock, &sem->mutex);
|
||||
|
||||
ast_assert(sem->count >= 0);
|
||||
@@ -92,7 +93,37 @@ int ast_sem_wait(struct ast_sem *sem)
|
||||
/* Wait for a non-zero count */
|
||||
++sem->waiters;
|
||||
while (sem->count == 0) {
|
||||
ast_cond_wait(&sem->cond, &sem->mutex);
|
||||
res = ast_cond_wait(&sem->cond, &sem->mutex);
|
||||
/* Give up on error */
|
||||
if (res != 0) {
|
||||
--sem->waiters;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
--sem->waiters;
|
||||
|
||||
/* Take it! */
|
||||
--sem->count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)
|
||||
{
|
||||
int res;
|
||||
SCOPED_MUTEX(lock, &sem->mutex);
|
||||
|
||||
ast_assert(sem->count >= 0);
|
||||
|
||||
/* Wait for a non-zero count */
|
||||
++sem->waiters;
|
||||
while (sem->count == 0) {
|
||||
res = ast_cond_timedwait(&sem->cond, &sem->mutex, abs_timeout);
|
||||
/* Give up on error */
|
||||
if (res != 0) {
|
||||
--sem->waiters;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
--sem->waiters;
|
||||
|
||||
|
Reference in New Issue
Block a user