33#include <sys/timerfd.h> 
   68#define TIMERFD_MAX_RATE 1000 
   89        ast_log(
LOG_ERROR, 
"Could not allocate memory for timerfd_timer structure\n");
 
   92    if ((
timer->fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
 
 
  113    timer->saved_timer.it_value.tv_sec = 0;
 
  114    timer->saved_timer.it_value.tv_nsec = rate ? (long) (1000000000 / rate) : 0L;
 
  115    timer->saved_timer.it_interval.tv_sec = 
timer->saved_timer.it_value.tv_sec;
 
  116    timer->saved_timer.it_interval.tv_nsec = 
timer->saved_timer.it_value.tv_nsec;
 
  118    if (!
timer->is_continuous) {
 
 
  130    uint64_t expirations;
 
  137        struct itimerspec timer_status;
 
  139        if (timerfd_gettime(
timer->fd, &timer_status)) {
 
  146        if (timer_status.it_value.tv_sec == 0 && timer_status.it_value.tv_nsec == 0) {
 
  147            ast_debug(1, 
"Avoiding read on disarmed timerfd %d\n", 
timer->fd);
 
  152        read_result = read(
timer->fd, &expirations, 
sizeof(expirations));
 
  153        if (read_result == -1) {
 
  162    } 
while (read_result != 
sizeof(expirations));
 
  166    if (expirations != quantity) {
 
  167        ast_debug(2, 
"Expected to acknowledge %u ticks but got %llu instead\n", quantity, (
unsigned long long) expirations);
 
 
  177    static const struct itimerspec continuous_timer = {
 
  178        .it_value.tv_nsec = 1L,
 
  183    if (
timer->is_continuous) {
 
  191    res = timerfd_settime(
timer->fd, 0, &continuous_timer, &
timer->saved_timer);
 
  192    timer->is_continuous = 1;
 
 
  205    if (!
timer->is_continuous) {
 
  214    timer->is_continuous = 0;
 
  215    memset(&
timer->saved_timer, 0, 
sizeof(
timer->saved_timer));
 
 
  228    if (
timer->is_continuous) {
 
 
  256    if ((
fd = timerfd_create(CLOCK_MONOTONIC, 0)) < 0) {
 
  257        ast_log(
LOG_ERROR, 
"timerfd_create() not supported by the kernel.  Not loading.\n");
 
 
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
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_MODULE_SUPPORT_CORE
#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.
static int timerfd_timer_enable_continuous(void *data)
static struct ast_timing_interface timerfd_timing
static int timerfd_timer_disable_continuous(void *data)
static unsigned int timerfd_timer_get_max_rate(void *data)
static enum ast_timer_event timerfd_timer_get_event(void *data)
static void timer_destroy(void *obj)
static int timerfd_timer_ack(void *data, unsigned int quantity)
static void timerfd_timer_close(void *data)
static int timerfd_timer_fd(void *data)
static void * timerfd_timer_open(void)
static int load_module(void)
static void * timing_funcs_handle
static int unload_module(void)
static int timerfd_timer_set_rate(void *data, unsigned int rate)
unsigned int is_continuous
struct itimerspec saved_timer
Time-related functions and macros.
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