libosmocore 1.9.0.192-1c24
Osmocom core library
timer.h File Reference

Osmocom timer handling routines. More...

#include <sys/time.h>
#include <time.h>
#include <stdbool.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/linuxrbtree.h>
#include <osmocom/core/timer_compat.h>

Go to the source code of this file.

Data Structures

struct  osmo_timer_list
 A structure representing a single instance of a timer. More...
 

Macros

#define OSMO_SEC2MIN(sec)   ((sec % (60 * 60)) / 60)
 
#define OSMO_SEC2HRS(sec)   ((sec % (60 * 60 * 24)) / (60 * 60))
 
#define OSMO_SEC2DAY(sec)   ((sec % (60 * 60 * 24 * 365)) / (60 * 60 * 24)) /* we ignore leap year for simplicity */
 

Functions

void osmo_timer_setup (struct osmo_timer_list *timer, void(*cb)(void *data), void *data)
 set up timer callback and data More...
 
void osmo_timer_add (struct osmo_timer_list *timer)
 add a new timer to the timer management More...
 
void osmo_timer_schedule (struct osmo_timer_list *timer, int seconds, int microseconds)
 schedule a timer at a given future relative time More...
 
void osmo_timer_del (struct osmo_timer_list *timer)
 delete a timer from timer management More...
 
int osmo_timer_pending (const struct osmo_timer_list *timer)
 check if given timer is still pending More...
 
int osmo_timer_remaining (const struct osmo_timer_list *timer, const struct timeval *now, struct timeval *remaining)
 compute the remaining time of a timer More...
 
struct timeval * osmo_timers_nearest (void)
 Determine time between now and the nearest timer. More...
 
int osmo_timers_nearest_ms (void)
 Determine time between now and the nearest timer in milliseconds. More...
 
void osmo_timers_prepare (void)
 Find the nearest time and update nearest_p. More...
 
int osmo_timers_update (void)
 fire all timers... and remove them More...
 
int osmo_timers_check (void)
 Check how many timers we have in the system. More...
 
int osmo_gettimeofday (struct timeval *tv, struct timezone *tz)
 shim around gettimeofday to be able to set the time manually. More...
 
int osmo_clock_gettime (clockid_t clk_id, struct timespec *tp)
 
void osmo_gettimeofday_override_add (time_t secs, suseconds_t usecs)
 convenience function to advance the fake time. More...
 
void osmo_clock_override_enable (clockid_t clk_id, bool enable)
 
void osmo_clock_override_add (clockid_t clk_id, time_t secs, long nsecs)
 
struct timespec * osmo_clock_override_gettimespec (clockid_t clk_id)
 

Variables

bool osmo_gettimeofday_override
 
struct timeval osmo_gettimeofday_override_time
 

Detailed Description

Osmocom timer handling routines.