1 /* $Header: /home/yav/catty/fkiss/RCS/timer.h,v 1.4 2000/08/24 02:25:50 yav Exp $
2  * Time control routine header
3  * written by yav <yav@bigfoot.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifdef HAVE_GETTIMEOFDAY
21 #define USE_GETTIMEOFDAY	/* use gettimeofday system call */
22 #endif
23 
24 #ifdef HAVE_USLEEP
25 #define USE_USLEEP		/* use usleep library */
26 #endif
27 
28 #ifdef USE_GETTIMEOFDAY
29 #define TMV timeval
30 #else
31 struct TMV {
32   long tv_sec;			/* seconds */
33   long tv_usec;			/* microseconds */
34 };
35 #endif
36 
37 /* sleep_time(n) macro sleep n milliseconds */
38 #ifdef USE_USLEEP
39 #define sleep_time(n) usleep((n)*1000L)	/* to microseconds */
40 #else
41 #define sleep_time(n) sleep(((n)+999)/1000) /* to seconds */
42 #endif
43 
44 #ifdef USE_GETTIMEOFDAY
45 #define current_time(p) gettimeofday((p),NULL)
46 #else
47 #define current_time(p) ((p)->tv_usec = 0, time(&(p)->tv_sec))
48 #endif
49 
50 /* timer.c function prototypes */
51 long diff_time();
52 void add_time();
53 
54 /* End of file */
55