*/
#include <pthread.h>
-#include <assert.h>
#include <poll.h>
#include <stdbool.h>
+#include <urcu/assert.h>
#include <urcu/compiler.h>
#include <urcu/uatomic.h>
_cds_wfcq_node_init(&head->node);
tail->p = &head->node;
ret = pthread_mutex_init(&head->lock, NULL);
- assert(!ret);
+ urcu_posix_assert(!ret);
}
/*
* cds_wfcq_init().
*/
static inline void _cds_wfcq_destroy(struct cds_wfcq_head *head,
- struct cds_wfcq_tail *tail)
+ struct cds_wfcq_tail *tail __attribute__((unused)))
{
int ret = pthread_mutex_destroy(&head->lock);
- assert(!ret);
+ urcu_posix_assert(!ret);
}
/*
}
static inline void _cds_wfcq_dequeue_lock(struct cds_wfcq_head *head,
- struct cds_wfcq_tail *tail)
+ struct cds_wfcq_tail *tail __attribute__((unused)))
{
int ret;
ret = pthread_mutex_lock(&head->lock);
- assert(!ret);
+ urcu_posix_assert(!ret);
}
static inline void _cds_wfcq_dequeue_unlock(struct cds_wfcq_head *head,
- struct cds_wfcq_tail *tail)
+ struct cds_wfcq_tail *tail __attribute__((unused)))
{
int ret;
ret = pthread_mutex_unlock(&head->lock);
- assert(!ret);
+ urcu_posix_assert(!ret);
}
static inline bool ___cds_wfcq_append(cds_wfcq_head_ptr_t u_head,
return ___cds_wfcq_append(head, tail, new_tail, new_tail);
}
+/*
+ * CDS_WFCQ_WAIT_SLEEP:
+ *
+ * By default, this sleeps for the given @msec milliseconds.
+ * This is a macro which LGPL users may #define themselves before
+ * including wfcqueue.h to override the default behavior (e.g.
+ * to log a warning or perform other background work).
+ */
+#ifndef CDS_WFCQ_WAIT_SLEEP
+#define CDS_WFCQ_WAIT_SLEEP(msec) ___cds_wfcq_wait_sleep(msec)
+#endif
+
+static inline void ___cds_wfcq_wait_sleep(int msec)
+{
+ (void) poll(NULL, 0, msec);
+}
+
/*
* ___cds_wfcq_busy_wait: adaptative busy-wait.
*
if (!blocking)
return 1;
if (++(*attempt) >= WFCQ_ADAPT_ATTEMPTS) {
- (void) poll(NULL, 0, WFCQ_WAIT); /* Wait for 10ms */
+ CDS_WFCQ_WAIT_SLEEP(WFCQ_WAIT); /* Wait for 10ms */
*attempt = 0;
} else {
caa_cpu_relax();
}
static inline struct cds_wfcq_node *
-___cds_wfcq_next(cds_wfcq_head_ptr_t head,
+___cds_wfcq_next(cds_wfcq_head_ptr_t head __attribute__((unused)),
struct cds_wfcq_tail *tail,
struct cds_wfcq_node *node,
int blocking)