Statistics
| Branch: | Revision:

streamers / compatibility / timer.h @ 63ebb93d

History | View | Annotate | Download (1.44 KB)

1
#ifndef COMP_TIMER_H
2
#define COMP_TIMER_H
3

    
4
#ifdef WIN32
5
# define timeradd(a, b, result)                                               \
6
  do {                                                                        \
7
    (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                             \
8
    (result)->tv_usec = (a)->tv_usec + (b)->tv_usec;                          \
9
    if ((result)->tv_usec >= 1000000)                                         \
10
      {                                                                       \
11
        ++(result)->tv_sec;                                                   \
12
        (result)->tv_usec -= 1000000;                                         \
13
      }                                                                       \
14
  } while (0)
15
# define timersub(a, b, result)                                               \
16
  do {                                                                        \
17
    (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;                             \
18
    (result)->tv_usec = (a)->tv_usec - (b)->tv_usec;                          \
19
    if ((result)->tv_usec < 0) {                                              \
20
      --(result)->tv_sec;                                                     \
21
      (result)->tv_usec += 1000000;                                           \
22
    }                                                                         \
23
  } while (0)
24

    
25
#endif
26

    
27
#endif //COMP_TIMER_H