tor  0.4.2.1-alpha-dev
Macros
timeval.h File Reference
#include "orconfig.h"
#include "lib/cc/torint.h"

Go to the source code of this file.

Macros

#define timeradd(tv1, tv2, tvout)
 
#define timersub(tv1, tv2, tvout)
 
#define timercmp(tv1, tv2, op)
 

Detailed Description

Declarations for timeval-related macros that some platforms are missing.

Definition in file timeval.h.

Macro Definition Documentation

◆ timeradd

#define timeradd (   tv1,
  tv2,
  tvout 
)
Value:
do { \
(tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec; \
(tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \
if ((tvout)->tv_usec >= 1000000) { \
(tvout)->tv_usec -= 1000000; \
(tvout)->tv_sec++; \
} \
} while (0)

Replacement for timeradd on platforms that do not have it: sets tvout to the sum of tv1 and tv2.

Definition at line 47 of file timeval.h.

◆ timercmp

#define timercmp (   tv1,
  tv2,
  op 
)
Value:
(((tv1)->tv_sec == (tv2)->tv_sec) ? \
((tv1)->tv_usec op (tv2)->tv_usec) : \
((tv1)->tv_sec op (tv2)->tv_sec))

Replacement for timercmp on platforms that do not have it: returns true iff the relational operator "op" makes the expression tv1 op tv2 true.

Note that while this definition should work for all boolean operators, some platforms' native timercmp definitions do not support >=, <=, or ==. So don't use those.

Definition at line 80 of file timeval.h.

◆ timersub

#define timersub (   tv1,
  tv2,
  tvout 
)
Value:
do { \
(tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec; \
(tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec; \
if ((tvout)->tv_usec < 0) { \
(tvout)->tv_usec += 1000000; \
(tvout)->tv_sec--; \
} \
} while (0)

Replacement for timersub on platforms that do not have it: sets tvout to tv1 minus tv2.

Definition at line 61 of file timeval.h.