File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / mpd / src / timer.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:39:23 2021 UTC (4 years ago) by misho
Branches: mpd, MAIN
CVS tags: v5_9p16, v5_9, HEAD
mpd 5.9

    1: 
    2: /*
    3:  * timer.h
    4:  *
    5:  * Written by Archie Cobbs <archie@freebsd.org>
    6:  * Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved.
    7:  * See ``COPYRIGHT.whistle''
    8:  */
    9: 
   10: #ifndef _TIMER_H_
   11: #define	_TIMER_H_
   12: 
   13: #include "defs.h"
   14: #include "event.h"
   15: 
   16: /*
   17:  * DEFINITIONS
   18:  */
   19: 
   20: #define TICKSPERSEC	1000		/* Microsecond granularity */
   21: #define SECONDS	TICKSPERSEC		/* Timers count in usec */
   22: 
   23: struct pppTimer;
   24: typedef struct pppTimer *PppTimer;
   25: 
   26: struct pppTimer {
   27: 	EventRef event;			/* Event registration */
   28: 	u_int	load;			/* Initial load value */
   29: 	void (*func) (void *arg);	/* Called when timer expires */
   30: 	void *arg;			/* Arg passed to timeout function */
   31: 	const char *desc;
   32: 	const char *dbg;
   33: };
   34: 
   35: /*
   36:  * FUNCTIONS
   37:  */
   38: 
   39: #define	TimerInit(timer, desc, load, handler, arg)	\
   40: 	    TimerInit2(timer, desc, load, handler, arg, #handler)
   41: extern void 
   42: TimerInit2(PppTimer timer, const char *desc,
   43:     int load, void (*handler) (void *), void *arg, const char *dbg);
   44: 
   45: #define	TimerStart(t)	\
   46: 	    TimerStart2(t, __FILE__, __LINE__)
   47: 	extern void TimerStart2(PppTimer t, const char *file, int line);
   48: 
   49: #define	TimerStartRecurring(t)	\
   50: 	    TimerStartRecurring2(t, __FILE__, __LINE__)
   51: 	extern void TimerStartRecurring2(PppTimer t, const char *file, int line);
   52: 
   53: #define	TimerStop(t)	\
   54: 	    TimerStop2(t, __FILE__, __LINE__)
   55: 	extern void TimerStop2(PppTimer t, const char *file, int line);
   56: 	extern int TimerRemain(PppTimer t);
   57: 	extern int TimerStarted(PppTimer t);
   58: 
   59: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>