36 #include <sys/types.h> 37 #include <sys/event.h> 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,
100 return kevent(timer->handle, kev, 2,
NULL, 0,
NULL);
107 EV_SET(&kev, (uintptr_t)timer, EVFILT_USER, EV_DELETE, 0, 0,
NULL);
108 return kevent(timer->handle, &kev, 1,
NULL, 0,
NULL);
117 #define CONTINUOUS_EVFILT_TYPE EVFILT_READ 123 retval = pipe(pipefds);
143 EV_SET(&kev, timer->
continuous_fd, EVFILT_READ, EV_ADD | EV_ENABLE,
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) {
259 flags = EV_ADD | EV_ENABLE;
260 period_ns = (uint64_t)1000000000 / rate;
265 EV_SET(&kev, timer->
handle, EVFILT_TIMER, flags, units,
281 static struct timespec ts_nowait = { 0, 0 };
283 struct kevent kev[2];
288 retval = kevent(timer->
handle,
NULL, 0, kev, 2, &ts_nowait);
296 for (i = 0; i <
retval; i++) {
299 if (kev[i].data > quantity) {
302 (uintmax_t)kev[i].data - quantity);
308 "[%d]: Spurious user event\n",
314 timer->
handle, kev[i].filter);
335 "[%d]: Error signaling continuous event: %s\n",
358 "[%d]: Error clearing continuous event: %s\n",
385 return INTPTR_MAX > UINT_MAX ? UINT_MAX : INTPTR_MAX;
395 #ifdef TEST_FRAMEWORK 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++) {
static int kqueue_timer_disable_continuous_event(struct kqueue_timer *timer)
static int kqueue_timer_set_rate(void *data, unsigned int rate)
static int kqueue_timer_enable_continuous(void *data)
static void kqueue_timer_fini_continuous_event(struct kqueue_timer *timer)
Asterisk main include file. File version handling, generic pbx functions.
static unsigned int kqueue_timer_get_max_rate(void *data)
static void timer_destroy(void *obj)
static enum ast_timer_event kqueue_timer_get_event(void *data)
static int kqueue_timer_enable_continuous_event(struct kqueue_timer *timer)
static int kqueue_timer_disable_continuous(void *data)
static struct ast_timing_interface kqueue_timing
Time-related functions and macros.
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
unsigned int continuous_fd_valid
#define AST_TEST_REGISTER(cb)
static int kqueue_timer_ack(void *data, unsigned int quantity)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
AST_TEST_DEFINE(test_kqueue_timing)
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_test_status_update(a, b, c...)
#define ast_poll(a, b, c)
#define ao2_ref(o, delta)
static void kqueue_timer_close(void *data)
static int load_module(void)
Load the module.
#define AST_TEST_UNREGISTER(cb)
static void * timing_funcs_handle
static void * kqueue_timer_open(void)
#define ao2_alloc(data_size, destructor_fn)
static intptr_t kqueue_scale_period(unsigned int period_ns, int *units)
Module has failed to load, may be in an inconsistent state.
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
static int kqueue_timer_fd(void *data)
#define CONTINUOUS_EVFILT_TYPE
#define ast_register_timing_interface(i)
Register a set of timing functions.
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int kqueue_timer_init_continuous_event(struct kqueue_timer *timer)
static int unload_module(void)
#define ASTERISK_GPL_KEY
The text the key() function should return.
static struct ast_timer * timer
Asterisk module definitions.
Timing source management.
unsigned int is_continuous