Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / lwp / timer.h
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 /*******************************************************************\
11 * *
12 * Information Technology Center *
13 * Carnegie-Mellon University *
14 * *
15 * *
16 \*******************************************************************/
17
18 struct TM_Elem {
19 struct TM_Elem *Next; /* filled by package */
20 struct TM_Elem *Prev; /* filled by package */
21 struct timeval TotalTime; /* filled in by caller -- modified by package */
22 struct timeval TimeLeft; /* filled by package */
23 char *BackPointer; /* filled by caller, not interpreted by package */
24 };
25
26 void openafs_insque(struct TM_Elem *elementp, struct TM_Elem *quep);
27 void openafs_remque(struct TM_Elem *elementp);
28 extern int TM_eql(struct timeval *t1, struct timeval *t2);
29
30 #ifndef _TIMER_IMPL_
31 #define Tm_Insert(list, elem) openafs_insque(list, elem)
32 #define TM_Remove(list, elem) openafs_remque(elem)
33 extern int TM_Rescan(struct TM_Elem *tlist);
34 void TM_Insert(struct TM_Elem *tlistPtr, struct TM_Elem *elem);
35 extern struct TM_Elem *TM_GetExpired(struct TM_Elem *tlist);
36 extern struct TM_Elem *TM_GetEarliest(struct TM_Elem *tlist);
37 #endif
38
39 extern int TM_Init(struct TM_Elem **list);
40 extern int TM_Final(struct TM_Elem **list);
41
42 #define FOR_ALL_ELTS(var, list, body)\
43 {\
44 struct TM_Elem *_LIST_, *var, *_NEXT_;\
45 _LIST_ = (list);\
46 for (var = _LIST_ -> Next; var != _LIST_; var = _NEXT_) {\
47 _NEXT_ = var -> Next;\
48 body\
49 }\
50 }