1 /* $Header: /usr/home/yav/lupe/RCS/timer.h,v 1.2 1998/08/17 05:13:54 yav Exp $ 2 * Time control routine header 3 * written by yav <UHD98984@biglobe.ne.jp> 4 * 5 * HAVE_GETTIMEOFDAY - use gettimeofday system call 6 * HAVE_USLEEP - use usleep library 7 */ 8 9 10 #ifdef HAVE_GETTIMEOFDAY 11 #define TMV timeval 12 #else 13 struct TMV { 14 long tv_sec; /* seconds */ 15 long tv_usec; /* microseconds */ 16 }; 17 #endif 18 19 /* sleep_time(n) macro sleep n milliseconds */ 20 #ifdef HAVE_USLEEP 21 #define sleep_time(n) usleep((n)*1000L) /* to microseconds */ 22 #else 23 #define sleep_time(n) sleep(((n)+999)/1000) /* to seconds */ 24 #endif 25 26 #ifdef HAVE_GETTIMEOFDAY 27 #define current_time(p) gettimeofday((p),NULL) 28 #else 29 #define current_time(p) ((p)->tv_usec = 0, time(&(p)->tv_sec)) 30 #endif 31 32 /* timer.c function prototypes */ 33 long diff_time(); 34 void add_time(); 35 36 /* End of file */ 37