86#define CONTINUOUS_EVFILT_TYPE EVFILT_USER
96 EV_SET(&kev[0], (uintptr_t)
timer, EVFILT_USER, EV_ADD | EV_ENABLE,
98 EV_SET(&kev[1], (uintptr_t)
timer, EVFILT_USER, 0, NOTE_TRIGGER,
107 EV_SET(&kev, (uintptr_t)
timer, EVFILT_USER, EV_DELETE, 0, 0,
NULL);
117#define CONTINUOUS_EVFILT_TYPE EVFILT_READ
125 timer->continuous_fd = pipefds[0];
126 timer->continuous_fd_valid = 1;
134 if (
timer->continuous_fd_valid) {
135 close(
timer->continuous_fd);
143 EV_SET(&kev,
timer->continuous_fd, EVFILT_READ, EV_ADD | EV_ENABLE,
152 EV_SET(&kev,
timer->continuous_fd, EVFILT_READ, EV_DELETE, 0, 0,
NULL);
162 if (
timer->handle > -1) {
163 close(
timer->handle);
176 if ((
timer->handle = kqueue()) < 0) {
207 uint64_t
period = period_ns;
210 if (
period < INTPTR_MAX) {
211 *units = NOTE_NSECONDS;
215 if (
period < INTPTR_MAX) {
216 *units = NOTE_USECONDS;
220 *units = NOTE_MSECONDS;
226 *units = NOTE_MSECONDS;
233 if (
period > INTPTR_MAX) {
251 if (
timer->period == 0) {
259 flags = EV_ADD | EV_ENABLE;
260 period_ns = (uint64_t)1000000000 / rate;
264 timer->handle, units, (uintmax_t)
timer->period);
265 EV_SET(&kev,
timer->handle, EVFILT_TIMER, flags, units,
281 static struct timespec ts_nowait = { 0, 0 };
283 struct kevent kev[2];
296 for (i = 0; i <
retval; i++) {
299 if (kev[i].data > quantity) {
302 (uintmax_t)kev[i].
data - quantity);
306 if (!
timer->is_continuous) {
308 "[%d]: Spurious user event\n",
314 timer->handle, kev[i].filter);
330 if (!
timer->is_continuous) {
335 "[%d]: Error signaling continuous event: %s\n",
338 timer->is_continuous = 1;
353 if (
timer->is_continuous) {
358 "[%d]: Error clearing continuous event: %s\n",
361 timer->is_continuous = 0;
374 if (
timer->is_continuous) {
385 return INTPTR_MAX > UINT_MAX ? UINT_MAX : INTPTR_MAX;
392 return timer->handle;
400 struct pollfd pfd = { 0, POLLIN, 0 };
402 struct timeval start;
406 info->name =
"test_kqueue_timing";
407 info->category =
"/res/res_timing_kqueue/";
408 info->summary =
"Test KQueue timing interface";
409 info->description =
"Verify that the KQueue timing interface correctly generates timing events";
432 if (pfd.revents != POLLIN) {
450 for (i = 0; i < 100; i++) {
Asterisk main include file. File version handling, generic pbx functions.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
static struct ast_timer * timer
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Support for logging to various files, console and syslog Configuration in file logger....
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_EXTENDED
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
#define ast_poll(a, b, c)
static void kqueue_timer_close(void *data)
#define CONTINUOUS_EVFILT_TYPE
static int kqueue_timer_enable_continuous_event(struct kqueue_timer *timer)
static int kqueue_timer_init_continuous_event(struct kqueue_timer *timer)
static void kqueue_timer_fini_continuous_event(struct kqueue_timer *timer)
static void timer_destroy(void *obj)
static int kqueue_timer_disable_continuous(void *data)
static int kqueue_timer_set_rate(void *data, unsigned int rate)
static enum ast_timer_event kqueue_timer_get_event(void *data)
static void * kqueue_timer_open(void)
static intptr_t kqueue_scale_period(unsigned int period_ns, int *units)
static int kqueue_timer_fd(void *data)
static int load_module(void)
Load the module.
static void * timing_funcs_handle
static int kqueue_timer_ack(void *data, unsigned int quantity)
static int unload_module(void)
static struct ast_timing_interface kqueue_timing
static int kqueue_timer_disable_continuous_event(struct kqueue_timer *timer)
static unsigned int kqueue_timer_get_max_rate(void *data)
static int kqueue_timer_enable_continuous(void *data)
unsigned int continuous_fd_valid
unsigned int is_continuous
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
Time-related functions and macros.
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Timing source management.
#define ast_register_timing_interface(i)
Register a set of timing functions.
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
@ AST_TIMING_EVENT_CONTINUOUS
@ AST_TIMING_EVENT_EXPIRED