• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

timer_ticks.h

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  *
00005  * timer frequency and ticks conversions
00006  *
00007  * Copyright (C) 2005 iptelorg GmbH
00008  *
00009  * This file is part of SIP-router, a free SIP server.
00010  *
00011  * SIP-router is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version
00015  *
00016  * SIP-router is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License 
00022  * along with this program; if not, write to the Free Software 
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  */
00025 /* History:
00026  * --------
00027  *  2005-07-27  complete re-design/re-implemnetation (andrei)
00028  *  2007-07-02  added ticks comparison macros (andrei)
00029  */
00030 
00038 #ifndef _timer_ticks_h
00039 #define _timer_ticks_h
00040 
00043 #define TIMER_TICKS_HZ  16U
00044 
00046 #define MS_TO_TICKS(m)  (((m)*TIMER_TICKS_HZ+999U)/1000U)
00047 
00048 
00050 #define S_TO_TICKS(s)   ((s)*TIMER_TICKS_HZ)
00051 
00052 
00054 #define TICKS_TO_S(t)   ((t)/TIMER_TICKS_HZ)
00055 
00057 #define TICKS_TO_MS(t) (((t)*1000U)/TIMER_TICKS_HZ)
00058 
00059 
00061 #define TICKS_CMP_OP(t1, t2, OP) \
00062         (((s_ticks_t)((ticks_t)(t1)-(ticks_t)(t2))) OP (s_ticks_t)0)
00063 
00064 #define TICKS_LT(t1, t2)  TICKS_CMP_OP(t1, t2, <)
00065 
00066 #define TICKS_LE(t1, t2)  TICKS_CMP_OP(t1, t2, <=)
00067 
00068 #define TICKS_GT(t1, t2)  TICKS_CMP_OP(t1, t2, >)
00069 
00070 #define TICKS_GE(t1, t2)  TICKS_CMP_OP(t1, t2, >=)
00071 
00072 
00073 typedef unsigned int ticks_t;/* type used to keep the ticks (must be 32 bits)*/
00074 typedef signed   int s_ticks_t; /* signed ticks type */
00075 
00076 #endif

Generated on Tue May 22 2012 13:10:17 for SIP Router by  doxygen 1.7.1