libosip 3.6.0

osip_time.h

00001 /*
00002   The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
00003   Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Aymeric MOIZARD jack@atosc.org
00004   
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009   
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _OSIP_TIME_H_
00021 #define _OSIP_TIME_H_
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Common time-related functions and data types */
00028 
00029 #if defined(_WIN32_WCE)
00030         struct _timeb {
00031                 time_t time;
00032                 unsigned short millitm;
00033                 short timezone;
00034                 short dstflag;
00035         };
00036 
00037 #endif
00038 
00039 /* struct timeval, as defined in <sys/time.h>, <winsock.h> or <winsock2.h> */
00040         struct timeval;
00041 
00042 /* Time manipulation functions */
00043         void add_gettimeofday(struct timeval *atv, int ms);
00044         void min_timercmp(struct timeval *tv1, struct timeval *tv2);
00045 
00046 /* OS-dependent */
00047 #if defined(WIN32) || defined(_WIN32_WCE) || defined (__VXWORKS_OS__) || defined(__arc__)
00048 /* Operations on struct timeval */
00049 #define osip_timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
00050 # define osip_timercmp(a, b, CMP)                          \
00051   (((a)->tv_sec == (b)->tv_sec) ?                          \
00052    ((a)->tv_usec CMP (b)->tv_usec) :                       \
00053    ((a)->tv_sec CMP (b)->tv_sec))
00054 #define osip_timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
00055 
00056 /* osip_gettimeofday() for Windows */
00057 #if defined(__arc__)
00058 #define osip_gettimeofday gettimeofday
00059 #else
00060         int osip_gettimeofday(struct timeval *tp, void *tz);
00061 #endif
00062 
00063 #else
00064 /* Operations on struct timeval */
00065 #define osip_timerisset(tvp)            timerisset(tvp)
00066 #define osip_timercmp(tvp, uvp, cmp)    timercmp(tvp,uvp,cmp)
00067 #define osip_timerclear(tvp)            timerclear(tvp)
00068 
00069 /* osip_gettimeofday() == gettimeofday() */
00070 #define osip_gettimeofday gettimeofday
00071 
00072 #endif
00073 
00074 #ifdef __cplusplus
00075 }
00076 #endif
00077 #endif