\doxysection{include/osmocom/core/timer.h File Reference}
\label{timer_8h}\index{include/osmocom/core/timer.h@{include/osmocom/core/timer.h}}


Osmocom timer handling routines.  


{\ttfamily \#include $<$sys/time.\+h$>$}\newline
{\ttfamily \#include $<$time.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxlist.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/linuxrbtree.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/timer\+\_\+compat.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+timer\+\_\+list}
\begin{DoxyCompactList}\small\item\em A structure representing a single instance of a timer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ OSMO\+\_\+\+SEC2\+MIN}(\textbf{ sec})~((\textbf{ sec} \% (60 $\ast$ 60)) / 60)
\item 
\#define \textbf{ OSMO\+\_\+\+SEC2\+HRS}(\textbf{ sec})~((\textbf{ sec} \% (60 $\ast$ 60 $\ast$ 24)) / (60 $\ast$ 60))
\item 
\#define \textbf{ OSMO\+\_\+\+SEC2\+DAY}(\textbf{ sec})~((\textbf{ sec} \% (60 $\ast$ 60 $\ast$ 24 $\ast$ 365)) / (60 $\ast$ 60 $\ast$ 24)) /$\ast$ we ignore leap year \textbf{ for} simplicity $\ast$/
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ osmo\+\_\+timer\+\_\+setup} (struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer, void($\ast$cb)(void $\ast$\textbf{ data}), void $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em set up timer callback and data \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+timer\+\_\+add} (struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer)
\begin{DoxyCompactList}\small\item\em add a new timer to the timer management \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+timer\+\_\+schedule} (struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer, int seconds, int microseconds)
\begin{DoxyCompactList}\small\item\em schedule a timer at a given future relative time \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+timer\+\_\+del} (struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer)
\begin{DoxyCompactList}\small\item\em delete a timer from timer management \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+timer\+\_\+pending} (const struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer)
\begin{DoxyCompactList}\small\item\em check if given timer is still pending \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+timer\+\_\+remaining} (const struct \textbf{ osmo\+\_\+timer\+\_\+list} $\ast$timer, const struct timeval $\ast$now, struct timeval $\ast$remaining)
\begin{DoxyCompactList}\small\item\em compute the remaining time of a timer \end{DoxyCompactList}\item 
struct timeval $\ast$ \textbf{ osmo\+\_\+timers\+\_\+nearest} (void)
\begin{DoxyCompactList}\small\item\em Determine time between now and the nearest timer. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+timers\+\_\+nearest\+\_\+ms} (void)
\begin{DoxyCompactList}\small\item\em Determine time between now and the nearest timer in milliseconds. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+timers\+\_\+prepare} (void)
\begin{DoxyCompactList}\small\item\em Find the nearest time and update nearest\+\_\+p. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+timers\+\_\+update} (void)
\begin{DoxyCompactList}\small\item\em fire all timers... and remove them \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+timers\+\_\+check} (void)
\begin{DoxyCompactList}\small\item\em Check how many timers we have in the system. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+gettimeofday} (struct timeval $\ast$tv, struct timezone $\ast$tz)
\begin{DoxyCompactList}\small\item\em shim around gettimeofday to be able to set the time manually. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+clock\+\_\+gettime} (clockid\+\_\+t clk\+\_\+id, struct timespec $\ast$tp)
\item 
void \textbf{ osmo\+\_\+gettimeofday\+\_\+override\+\_\+add} (time\+\_\+t secs, suseconds\+\_\+t usecs)
\begin{DoxyCompactList}\small\item\em convenience function to advance the fake time. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+clock\+\_\+override\+\_\+enable} (clockid\+\_\+t clk\+\_\+id, bool enable)
\item 
void \textbf{ osmo\+\_\+clock\+\_\+override\+\_\+add} (clockid\+\_\+t clk\+\_\+id, time\+\_\+t secs, long nsecs)
\item 
struct timespec $\ast$ \textbf{ osmo\+\_\+clock\+\_\+override\+\_\+gettimespec} (clockid\+\_\+t clk\+\_\+id)
\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
bool \textbf{ osmo\+\_\+gettimeofday\+\_\+override}
\item 
struct timeval \textbf{ osmo\+\_\+gettimeofday\+\_\+override\+\_\+time}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Osmocom timer handling routines. 

