/* these are used to wake up the CDR thread when there's work to do */
AST_MUTEX_DEFINE_STATIC(cdr_pending_lock);
-static pthread_cond_t cdr_pending_cond;
+static ast_cond_t cdr_pending_cond;
/*
* We do a lot of checking here in the CDR code to try to be sure we don't ever let a CDR slip
cdr_sched = ast_sched_add(sched, 1, submit_scheduled_batch, NULL);
/* signal the do_cdr thread to wakeup early and do some work (that lazy thread ;) */
ast_mutex_lock(&cdr_pending_lock);
- pthread_cond_signal(&cdr_pending_cond);
+ ast_cond_signal(&cdr_pending_cond);
ast_mutex_unlock(&cdr_pending_lock);
}
timeout.tv_nsec = (now.tv_usec * 1000) + ((schedms % 1000) * 1000);
/* prevent stuff from clobbering cdr_pending_cond, then wait on signals sent to it until the timeout expires */
ast_mutex_lock(&cdr_pending_lock);
- ast_pthread_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
+ ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
numevents = ast_sched_runq(sched);
ast_mutex_unlock(&cdr_pending_lock);
if (option_debug > 1)
/* if this reload enabled the CDR batch mode, create the background thread
if it does not exist */
if (enabled && batchmode && (!was_enabled || !was_batchmode) && (cdr_thread == AST_PTHREADT_NULL)) {
- pthread_cond_init(&cdr_pending_cond, NULL);
+ ast_cond_init(&cdr_pending_cond, NULL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ast_pthread_create(&cdr_thread, &attr, do_cdr, NULL) < 0) {
pthread_kill(cdr_thread, SIGURG);
pthread_join(cdr_thread, NULL);
cdr_thread = AST_PTHREADT_NULL;
- pthread_cond_destroy(&cdr_pending_cond);
+ ast_cond_destroy(&cdr_pending_cond);
ast_cli_unregister(&cli_submit);
ast_unregister_atexit(ast_cdr_engine_term);
res = 0;
static AST_LIST_HEAD_STATIC(state_changes, state_change);
static pthread_t change_thread = AST_PTHREADT_NULL;
-static pthread_cond_t change_pending;
+static ast_cond_t change_pending;
/*--- devstate2str: Find devicestate as text message for output */
const char *devstate2str(int devstate)
AST_LIST_INSERT_TAIL(&state_changes, change, list);
if (AST_LIST_FIRST(&state_changes) == change)
/* the list was empty, signal the thread */
- pthread_cond_signal(&change_pending);
+ ast_cond_signal(&change_pending);
AST_LIST_UNLOCK(&state_changes);
}
} else {
/* there was no entry, so atomically unlock the list and wait for
the condition to be signalled (returns with the lock held) */
- ast_pthread_cond_wait(&change_pending, &state_changes.lock);
+ ast_cond_wait(&change_pending, &state_changes.lock);
}
}
{
pthread_attr_t attr;
- pthread_cond_init(&change_pending, NULL);
+ ast_cond_init(&change_pending, NULL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
if (ast_pthread_create(&change_thread, &attr, do_devstate_changes, NULL) < 0) {
typedef struct ast_mutex_info ast_mutex_t;
+typedef pthread_cond_t ast_cond_t;
+
static inline int __ast_pthread_mutex_init_attr(const char *filename, int lineno, const char *func,
const char *mutex_name, ast_mutex_t *t,
pthread_mutexattr_t *attr)
return res;
}
+static inline int __ast_pthread_cond_init(const char *filename, int lineno, const char *func,
+ const char *cond_name, ast_cond_t *cond, pthread_condattr_t *cond_attr)
+{
+ return pthread_cond_init(cond, cond_attr);
+}
+
+static inline int __ast_pthread_cond_signal(const char *filename, int lineno, const char *func,
+ const char *cond_name, ast_cond_t *cond)
+{
+ return pthread_cond_signal(cond);
+}
+
+static inline int __ast_pthread_cond_broadcast(const char *filename, int lineno, const char *func,
+ const char *cond_name, ast_cond_t *cond)
+{
+ return pthread_cond_broadcast(cond);
+}
+
+static inline int __ast_pthread_cond_destroy(const char *filename, int lineno, const char *func,
+ const char *cond_name, ast_cond_t *cond)
+{
+ return pthread_cond_destroy(cond);
+}
+
static inline int __ast_pthread_cond_wait(const char *filename, int lineno, const char *func,
- pthread_cond_t *cond, const char *mutex_name, ast_mutex_t *t)
+ const char *cond_name, const char *mutex_name,
+ ast_cond_t *cond, ast_mutex_t *t)
{
int res;
int canlog = strcmp(filename, "logger.c");
}
static inline int __ast_pthread_cond_timedwait(const char *filename, int lineno, const char *func,
- pthread_cond_t *cond, const struct timespec *abstime,
- const char *mutex_name, ast_mutex_t *t)
+ const char *cond_name, const char *mutex_name, ast_cond_t *cond,
+ ast_mutex_t *t, const struct timespec *abstime)
{
int res;
int canlog = strcmp(filename, "logger.c");
}
#define ast_mutex_init(pmutex) __ast_pthread_mutex_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
-#define ast_pthread_mutex_init(pmutex,attr) __ast_pthread_mutex_init_attr(__FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex, attr)
#define ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
#define ast_mutex_trylock(a) __ast_pthread_mutex_trylock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
-#define ast_pthread_cond_wait(cond, a) __ast_pthread_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, #a, a)
-#define ast_pthread_cond_timedwait(cond, a, t) __ast_pthread_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, cond, t, #a, a)
-
-#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
-#define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock
-#define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock
-#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock
-#define pthread_mutex_init use_ast_pthread_mutex_init_instead_of_pthread_mutex_init
-#define pthread_mutex_destroy use_ast_pthread_mutex_destroy_instead_of_pthread_mutex_destroy
-#define pthread_cond_wait use_ast_pthread_cond_wait_instead_of_pthread_cond_wait
-#define pthread_cond_timedwait use_ast_pthread_cond_wait_instead_of_pthread_cond_timedwait
+#define ast_cond_init(cond, attr) __ast_pthread_cond_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond, attr)
+#define ast_cond_destroy(cond) __ast_pthread_cond_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)
+#define ast_cond_signal(cond) __ast_pthread_cond_signal(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)
+#define ast_cond_broadcast(cond) __ast_pthread_cond_broadcast(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, cond)
+#define ast_cond_wait(cond, mutex) __ast_pthread_cond_wait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex)
+#define ast_cond_timedwait(cond, mutex, time) __ast_pthread_cond_timedwait(__FILE__, __LINE__, __PRETTY_FUNCTION__, #cond, #mutex, cond, mutex, time)
#else /* !DEBUG_THREADS */
#define ast_mutex_trylock(pmutex) pthread_mutex_trylock(pmutex)
#endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
-#define ast_pthread_cond_wait pthread_cond_wait
-#define ast_pthread_cond_timedwait pthread_cond_timedwait
+typedef pthread_cond_t ast_cond_t
+
+#define ast_cond_init pthread_cond_init
+#define ast_cond_destroy pthread_cond_destroy
+#define ast_cond_signal pthread_cond_signal
+#define ast_cond_broadcast pthread_cond_broadcast
+#define ast_cond_wait pthread_cond_wait
+#define ast_cond_timedwait pthread_cond_timedwait
#endif /* !DEBUG_THREADS */
+#define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
+#define pthread_mutex_lock use_ast_mutex_lock_instead_of_pthread_mutex_lock
+#define pthread_mutex_unlock use_ast_mutex_unlock_instead_of_pthread_mutex_unlock
+#define pthread_mutex_trylock use_ast_mutex_trylock_instead_of_pthread_mutex_trylock
+#define pthread_mutex_init use_ast_mutex_init_instead_of_pthread_mutex_init
+#define pthread_mutex_destroy use_ast_mutex_destroy_instead_of_pthread_mutex_destroy
+#define pthread_cond_t use_ast_cond_t_instead_of_pthread_cond_t
+#define pthread_cond_init use_ast_cond_init_instead_of_pthread_cond_init
+#define pthread_cond_destroy use_ast_cond_destroy_instead_of_pthread_cond_destroy
+#define pthread_cond_signal use_ast_cond_signal_instead_of_pthread_cond_signal
+#define pthread_cond_broadcast use_ast_cond_broadcast_instead_of_pthread_cond_broadcast
+#define pthread_cond_wait use_ast_cond_wait_instead_of_pthread_cond_wait
+#define pthread_cond_timedwait use_ast_cond_wait_instead_of_pthread_cond_timedwait
+
#define AST_MUTEX_DEFINE_STATIC(mutex) __AST_MUTEX_DEFINE(static,mutex)
#define AST_MUTEX_DEFINE_EXPORTED(mutex) __AST_MUTEX_DEFINE(/**/,mutex)