\doxysection{src/core/timer\+\_\+gettimeofday.c File Reference}
\label{timer__gettimeofday_8c}\index{src/core/timer\_gettimeofday.c@{src/core/timer\_gettimeofday.c}}


Overriding Time\+: \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049}  


{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$sys/time.\+h$>$}\newline
{\ttfamily \#include \char`\"{}config.\+h\char`\"{}}\newline
{\ttfamily \#include $<$osmocom/core/timer\+\_\+compat.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\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 
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}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
bool \textbf{ osmo\+\_\+gettimeofday\+\_\+override} = false
\item 
struct timeval \textbf{ osmo\+\_\+gettimeofday\+\_\+override\+\_\+time} = \{ 23, 424242 \}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Overriding Time\+: \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049} 


\begin{DoxyItemize}
\item Useful to write and reproduce tests that depend on specific time factors. This API allows to fake the timeval provided by {\ttfamily gettimeofday()} by using a small shim \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049}.
\item If the clock override is disabled (default) for a given clock, \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049} will do the same as regular {\ttfamily gettimeofday()}.
\item If you want \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049} to provide a specific time, you must enable time override by setting the global variable osmo\+\_\+gettimeofday\+\_\+override ({\ttfamily osmo\+\_\+gettimeofday\+\_\+override = true}), then set the global struct timeval osmo\+\_\+gettimeofday\+\_\+override\+\_\+time wih the desired value. Next time \doxyref{osmo\+\_\+gettimeofday()}{p.}{group__timer_ga8c559c124f4720d0a54af5f206681049} is called, it will return the values previously set.
\item A helper \doxyref{osmo\+\_\+gettimeofday\+\_\+override\+\_\+add()}{p.}{group__timer_gafcbae57ab2c2635d0dd248ec3011bd1c} is provided to easily increment osmo\+\_\+gettimeofday\+\_\+override\+\_\+time with a specific amount of time. 
\end{DoxyItemize}