205 struct timeval start, end;
206 unsigned int test_rate = 50;
211 e->
usage =
"Usage: timing test <rate>\n" 212 " Test a timer with a specified rate, 50/sec by default.\n" 225 if (sscanf(a->
argv[2],
"%30u", &rate) == 1) {
228 ast_cli(a->
fd,
"Invalid rate '%s', using default of %u\n", a->
argv[2], test_rate);
232 ast_cli(a->
fd,
"Attempting to test a timer with %u ticks per second.\n", test_rate);
235 ast_cli(a->
fd,
"Failed to open timing fd\n");
247 struct pollfd pfd = {
249 .events = POLLIN | POLLPRI,
257 ast_cli(a->
fd,
"Timer failed to acknowledge.\n");
262 ast_cli(a->
fd,
"poll() timed out! This is bad.\n");
263 }
else if (
errno != EAGAIN &&
errno != EINTR) {
271 ast_cli(a->
fd,
"It has been %" PRIi64
" milliseconds, and we got %d timer ticks\n",
286 timing_interfaces =
NULL;
void ast_timer_close(struct ast_timer *handle)
Close an opened timing handle.
unsigned int ast_timer_get_max_rate(const struct ast_timer *handle)
Get maximum rate supported for a timer.
#define AST_CLI_DEFINE(fn, txt,...)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static void timing_shutdown(void)
struct ast_timing_interface * iface
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static int timing_holder_cmp(void *_h1, void *_h2)
Time-related functions and macros.
#define ast_heap_unlock(h)
descriptor for a cli entry.
void(* timer_close)(void *data)
int ast_unregister_timing_interface(void *handle)
Unregister a previously registered timing interface.
struct ast_timer * ast_timer_open(void)
Open a timer.
enum ast_timer_event(* timer_get_event)(void *data)
void *(* timer_open)(void)
struct ast_heap * ast_heap_destroy(struct ast_heap *h)
Destroy a max heap.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
static char * timing_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void ast_cli(int fd, const char *fmt,...)
const char * ast_timer_get_name(const struct ast_timer *handle)
Get name of timer in use.
int(* timer_disable_continuous)(void *data)
#define ast_module_unref(mod)
Release a reference to the module.
#define ast_heap_push(h, elm)
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
int(* timer_fd)(void *data)
int ast_timing_init(void)
#define ast_poll(a, b, c)
enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle)
Retrieve timing event.
int ast_timer_enable_continuous(const struct ast_timer *handle)
Enable continuous mode.
struct timing_holder * holder
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
int(* timer_set_rate)(void *data, unsigned int rate)
#define ast_heap_rdlock(h)
#define ast_calloc(num, len)
A wrapper for calloc()
unsigned int(* timer_get_max_rate)(void *data)
int ast_timer_disable_continuous(const struct ast_timer *handle)
Disable continuous mode.
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
Prototypes for public functions only of internal interest,.
static struct ast_heap * timing_interfaces
#define ast_heap_create(init_height, cmp_fn, index_offset)
#define ast_module_running_ref(mod)
Hold a reference to the module if it is running.
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
void * ast_heap_remove(struct ast_heap *h, void *elm)
Remove a specific element from a heap.
Standard Command Line Interface.
void * _ast_register_timing_interface(struct ast_timing_interface *funcs, struct ast_module *mod)
int(* timer_enable_continuous)(void *data)
void * ast_heap_peek(struct ast_heap *h, unsigned int index)
Peek at an element on a heap.
static struct ast_cli_entry cli_timing[]
int(* timer_ack)(void *data, unsigned int quantity)
static struct ast_timer * timer
Asterisk module definitions.
Timing source management.
#define ast_heap_wrlock(h)