\doxysection{timer\+\_\+compat.\+h}
\label{timer__compat_8h_source}\index{include/osmocom/core/timer\_compat.h@{include/osmocom/core/timer\_compat.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{4 \textcolor{comment}{/*}}
\DoxyCodeLine{5 \textcolor{comment}{ * (C) 2011 Sylvain Munaut <tnt@246tNt.com>}}
\DoxyCodeLine{6 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{7 \textcolor{comment}{ *}}
\DoxyCodeLine{8 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{9 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{10 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{11 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{14 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{15 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{16 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{17 \textcolor{comment}{ *}}
\DoxyCodeLine{18 \textcolor{comment}{ */}}
\DoxyCodeLine{19 }
\DoxyCodeLine{24 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{comment}{/* MacOS < 10.12 Sierra does not define clockid\_t */}}
\DoxyCodeLine{27 \textcolor{preprocessor}{\#if defined(\_\_APPLE\_\_) \&\& (!defined(\_\_DARWIN\_C\_LEVEL) || \_\_DARWIN\_C\_LEVEL < 199309L)}}
\DoxyCodeLine{28 \textcolor{keyword}{typedef} \textcolor{keywordtype}{int} clockid\_t;}
\DoxyCodeLine{29 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{30 }
\DoxyCodeLine{31 \textcolor{comment}{/* Convenience macros for operations on timevals.}}
\DoxyCodeLine{32 \textcolor{comment}{   NOTE: `timercmp' does not work for >= or <=.  */}}
\DoxyCodeLine{33 }
\DoxyCodeLine{34 \textcolor{preprocessor}{\#ifndef timerisset}}
\DoxyCodeLine{35 \textcolor{preprocessor}{\# define timerisset(tvp)        ((tvp)-\/>tv\_sec || (tvp)-\/>tv\_usec)}}
\DoxyCodeLine{36 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{37 }
\DoxyCodeLine{38 \textcolor{preprocessor}{\#ifndef timerclear}}
\DoxyCodeLine{39 \textcolor{preprocessor}{\# define timerclear(tvp)        ((tvp)-\/>tv\_sec = (tvp)-\/>tv\_usec = 0)}}
\DoxyCodeLine{40 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{41 }
\DoxyCodeLine{42 \textcolor{preprocessor}{\#ifndef timercmp}}
\DoxyCodeLine{43 \textcolor{preprocessor}{\# define timercmp(a, b, CMP)                                                  \(\backslash\)}}
\DoxyCodeLine{44 \textcolor{preprocessor}{  (((a)-\/>tv\_sec == (b)-\/>tv\_sec) ?                                             \(\backslash\)}}
\DoxyCodeLine{45 \textcolor{preprocessor}{   ((a)-\/>tv\_usec CMP (b)-\/>tv\_usec) :                                          \(\backslash\)}}
\DoxyCodeLine{46 \textcolor{preprocessor}{   ((a)-\/>tv\_sec CMP (b)-\/>tv\_sec))}}
\DoxyCodeLine{47 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{48 }
\DoxyCodeLine{49 \textcolor{preprocessor}{\#ifndef timeradd}}
\DoxyCodeLine{50 \textcolor{preprocessor}{\# define timeradd(a, b, result)                                               \(\backslash\)}}
\DoxyCodeLine{51 \textcolor{preprocessor}{  do \{                                                                        \(\backslash\)}}
\DoxyCodeLine{52 \textcolor{preprocessor}{    (result)-\/>tv\_sec = (a)-\/>tv\_sec + (b)-\/>tv\_sec;                             \(\backslash\)}}
\DoxyCodeLine{53 \textcolor{preprocessor}{    (result)-\/>tv\_usec = (a)-\/>tv\_usec + (b)-\/>tv\_usec;                          \(\backslash\)}}
\DoxyCodeLine{54 \textcolor{preprocessor}{    if ((result)-\/>tv\_usec >= 1000000)                                         \(\backslash\)}}
\DoxyCodeLine{55 \textcolor{preprocessor}{      \{                                                                       \(\backslash\)}}
\DoxyCodeLine{56 \textcolor{preprocessor}{        ++(result)-\/>tv\_sec;                                                   \(\backslash\)}}
\DoxyCodeLine{57 \textcolor{preprocessor}{        (result)-\/>tv\_usec -\/= 1000000;                                         \(\backslash\)}}
\DoxyCodeLine{58 \textcolor{preprocessor}{      \}                                                                       \(\backslash\)}}
\DoxyCodeLine{59 \textcolor{preprocessor}{  \} while (0)}}
\DoxyCodeLine{60 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{61 }
\DoxyCodeLine{62 \textcolor{preprocessor}{\#ifndef timersub}}
\DoxyCodeLine{63 \textcolor{preprocessor}{\# define timersub(a, b, result)                                               \(\backslash\)}}
\DoxyCodeLine{64 \textcolor{preprocessor}{  do \{                                                                        \(\backslash\)}}
\DoxyCodeLine{65 \textcolor{preprocessor}{    (result)-\/>tv\_sec = (a)-\/>tv\_sec -\/ (b)-\/>tv\_sec;                             \(\backslash\)}}
\DoxyCodeLine{66 \textcolor{preprocessor}{    (result)-\/>tv\_usec = (a)-\/>tv\_usec -\/ (b)-\/>tv\_usec;                          \(\backslash\)}}
\DoxyCodeLine{67 \textcolor{preprocessor}{    if ((result)-\/>tv\_usec < 0) \{                                              \(\backslash\)}}
\DoxyCodeLine{68 \textcolor{preprocessor}{      -\/-\/(result)-\/>tv\_sec;                                                     \(\backslash\)}}
\DoxyCodeLine{69 \textcolor{preprocessor}{      (result)-\/>tv\_usec += 1000000;                                           \(\backslash\)}}
\DoxyCodeLine{70 \textcolor{preprocessor}{    \}                                                                         \(\backslash\)}}
\DoxyCodeLine{71 \textcolor{preprocessor}{  \} while (0)}}
\DoxyCodeLine{72 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{73 }
\DoxyCodeLine{74 \textcolor{comment}{/* Convenience macros for operations on timespecs.}}
\DoxyCodeLine{75 \textcolor{comment}{   NOTE: `timercmp' does not work for >= or <=.  */}}
\DoxyCodeLine{76 }
\DoxyCodeLine{77 \textcolor{preprocessor}{\#ifndef timespecisset}}
\DoxyCodeLine{78 \textcolor{preprocessor}{\# define timespecisset(tvp)     ((tvp)-\/>tv\_sec || (tvp)-\/>tv\_nsec)}}
\DoxyCodeLine{79 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{80 }
\DoxyCodeLine{81 \textcolor{preprocessor}{\#ifndef timespecclear}}
\DoxyCodeLine{82 \textcolor{preprocessor}{\# define timespecclear(tvp)     ((tvp)-\/>tv\_sec = (tvp)-\/>tv\_nsec = 0)}}
\DoxyCodeLine{83 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{84 }
\DoxyCodeLine{85 \textcolor{preprocessor}{\#ifndef timespeccmp}}
\DoxyCodeLine{86 \textcolor{preprocessor}{\# define timespeccmp(a, b, CMP)                                               \(\backslash\)}}
\DoxyCodeLine{87 \textcolor{preprocessor}{  (((a)-\/>tv\_sec == (b)-\/>tv\_sec) ?                                             \(\backslash\)}}
\DoxyCodeLine{88 \textcolor{preprocessor}{   ((a)-\/>tv\_nsec CMP (b)-\/>tv\_nsec) :                                          \(\backslash\)}}
\DoxyCodeLine{89 \textcolor{preprocessor}{   ((a)-\/>tv\_sec CMP (b)-\/>tv\_sec))}}
\DoxyCodeLine{90 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{91 }
\DoxyCodeLine{92 \textcolor{preprocessor}{\#ifndef timespecadd}}
\DoxyCodeLine{93 \textcolor{preprocessor}{\# define timespecadd(a, b, result)                                            \(\backslash\)}}
\DoxyCodeLine{94 \textcolor{preprocessor}{  do \{                                                                        \(\backslash\)}}
\DoxyCodeLine{95 \textcolor{preprocessor}{    (result)-\/>tv\_sec = (a)-\/>tv\_sec + (b)-\/>tv\_sec;                             \(\backslash\)}}
\DoxyCodeLine{96 \textcolor{preprocessor}{    (result)-\/>tv\_nsec = (a)-\/>tv\_nsec + (b)-\/>tv\_nsec;                          \(\backslash\)}}
\DoxyCodeLine{97 \textcolor{preprocessor}{    if ((result)-\/>tv\_nsec >= 1000000000)                                      \(\backslash\)}}
\DoxyCodeLine{98 \textcolor{preprocessor}{      \{                                                                       \(\backslash\)}}
\DoxyCodeLine{99 \textcolor{preprocessor}{        ++(result)-\/>tv\_sec;                                                   \(\backslash\)}}
\DoxyCodeLine{100 \textcolor{preprocessor}{        (result)-\/>tv\_nsec -\/= 1000000000;                                      \(\backslash\)}}
\DoxyCodeLine{101 \textcolor{preprocessor}{      \}                                                                       \(\backslash\)}}
\DoxyCodeLine{102 \textcolor{preprocessor}{  \} while (0)}}
\DoxyCodeLine{103 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{preprocessor}{\#ifndef timespecsub}}
\DoxyCodeLine{106 \textcolor{preprocessor}{\# define timespecsub(a, b, result)                                            \(\backslash\)}}
\DoxyCodeLine{107 \textcolor{preprocessor}{  do \{                                                                        \(\backslash\)}}
\DoxyCodeLine{108 \textcolor{preprocessor}{    (result)-\/>tv\_sec = (a)-\/>tv\_sec -\/ (b)-\/>tv\_sec;                             \(\backslash\)}}
\DoxyCodeLine{109 \textcolor{preprocessor}{    (result)-\/>tv\_nsec = (a)-\/>tv\_nsec -\/ (b)-\/>tv\_nsec;                          \(\backslash\)}}
\DoxyCodeLine{110 \textcolor{preprocessor}{    if ((result)-\/>tv\_nsec < 0) \{                                              \(\backslash\)}}
\DoxyCodeLine{111 \textcolor{preprocessor}{      -\/-\/(result)-\/>tv\_sec;                                                     \(\backslash\)}}
\DoxyCodeLine{112 \textcolor{preprocessor}{      (result)-\/>tv\_nsec += 1000000000;                                        \(\backslash\)}}
\DoxyCodeLine{113 \textcolor{preprocessor}{    \}                                                                         \(\backslash\)}}
\DoxyCodeLine{114 \textcolor{preprocessor}{  \} while (0)}}
\DoxyCodeLine{115 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{116 }
\DoxyCodeLine{117 }
\DoxyCodeLine{118 }

\end{DoxyCode}
