Blame view

3rdparty/libosip2-5.3.0/include/osip2/osip_time.h 2.58 KB
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  /*
    The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
    Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
  
    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
  
  #ifndef _OSIP_TIME_H_
  #define _OSIP_TIME_H_
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /* Common time-related functions and data types */
  
  #if defined(_WIN32_WCE)
  struct _timeb {
    time_t time;
    unsigned short millitm;
    short timezone;
    short dstflag;
  };
  
  #endif
  
  /* struct timeval, as defined in <sys/time.h>, <winsock.h> or <winsock2.h> */
  struct timeval;
  
  /* Time manipulation functions */
  void add_gettimeofday(struct timeval *atv, int ms);
  void min_timercmp(struct timeval *tv1, struct timeval *tv2);
  
  /* Operations on struct timeval */
  #if !defined(timerisset)
  #define osip_timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
  #else
  #define osip_timerisset(tvp) timerisset(tvp)
  #endif
  
  #if !defined(timercmp)
  #define osip_timercmp(a, b, CMP) (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_usec CMP(b)->tv_usec) : ((a)->tv_sec CMP(b)->tv_sec))
  #else
  #define osip_timercmp(tvp, uvp, cmp) timercmp(tvp, uvp, cmp)
  #endif
  
  #if !defined(timerclear)
  #define osip_timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
  #else
  #define osip_timerclear(tvp) timerclear(tvp)
  #endif
  
  #if !defined(timersub)
  #define osip_timersub(a, b, result)                  \
    do {                                               \
      (result)->tv_sec = (a)->tv_sec - (b)->tv_sec;    \
      (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
      if ((result)->tv_usec < 0) {                     \
        --(result)->tv_sec;                            \
        (result)->tv_usec += 1000000;                  \
      }                                                \
    } while (0)
  #else
  #define osip_timersub(a, b, result) timersub(a, b, result)
  #endif
  
  int osip_gettimeofday(struct timeval *tp, void *tz);
  time_t osip_getsystemtime(time_t *t);
  void osip_compensatetime(void);
  
  #ifdef __cplusplus
  }
  #endif
  #endif