]> rtime.felk.cvut.cz Git - ulut.git/blob - ulut/ul_htimdefs.h
DBUFF loging updated to match other projects.
[ulut.git] / ulut / ul_htimdefs.h
1 #ifndef _UL_HTIMDEFS_H
2 #define _UL_HTIMDEFS_H
3
4 #include "ul_utdefs.h"
5
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9
10 /* Select heap-tree as base structure to implement
11  * hierarchic timer - not recomended
12  */
13 //#define UL_HTIMER_WITH_HPTREE
14
15 /* If defined, standard timer type
16  * is built
17  */
18 #define UL_HTIMER_WITH_STD_TYPE
19
20 /* If defined, standard microsecond resolution 
21  * data types are selected for timer implementation
22  */
23 #define UL_HTIMER_WITH_MSTIME
24
25 #ifdef UL_HTIMER_WITH_MSTIME
26 typedef unsigned long ul_mstime_t;
27 typedef signed long ul_msdiff_t;
28
29 typedef ul_mstime_t ul_htim_time_t;
30 typedef ul_msdiff_t ul_htim_diff_t;
31
32 static inline int
33 ul_htimer_cmp_fnc(const ul_htim_time_t *a, const ul_htim_time_t *b)
34 {
35   ul_htim_diff_t d=(ul_htim_diff_t)(*a-*b);
36   if (d>0) return 1;
37   if (d<0) return -1;
38   return 0;
39 }
40 #endif /*UL_HTIMER_WITH_MSTIME*/
41
42 /*===========================================================*/
43 /*  Configuration of types for standard timer (ul_htimer) */
44
45 /* Additional, user defined fields for ul_htimer_t structure */
46 #define UL_HTIMER_USER_FIELDS 
47
48 typedef void (ul_htimer_fnc_t)(unsigned long data);
49
50 /* The wrapper for ul_htimer_run_expired */
51 #define UL_HTIMER_FNC_CALL(queue, timer, pact_time) \
52     do{ timer->function(timer->data); } while(0)
53
54
55 #ifdef __cplusplus
56 } /* extern "C"*/
57 #endif
58
59 #endif /* _UL_HTIMDEFS_H */