]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/ul_htimdefs.h
d3dae41f7c0cb148260683058ae4388d0d69d2fd
[orte.git] / orte / include / 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 /* If defined, NTPTimer type
26  * is built
27  */
28 #define UL_HTIMER_WITH_NTPTIME 
29
30 #ifdef UL_HTIMER_WITH_MSTIME
31 typedef unsigned long ul_mstime_t;
32 typedef signed long ul_msdiff_t;
33
34 typedef ul_mstime_t ul_htim_time_t;
35 typedef ul_msdiff_t ul_htim_diff_t;
36
37 static inline int
38 ul_htimer_cmp_fnc(const ul_htim_time_t *a, const ul_htim_time_t *b)
39 {
40   ul_htim_diff_t d=(ul_htim_diff_t)(*a-*b);
41   if (d>0) return 1;
42   if (d<0) return -1;
43   return 0;
44 }
45 #endif /*UL_HTIMER_WITH_MSTIME*/
46
47 #ifdef UL_HTIMER_WITH_NTPTIME
48 #include "orte/typedefs_defines_rtps.h"
49 #include "orte/defines_api.h"
50 typedef NtpTime ul_htim_time_t;
51
52 static inline int
53 ul_htimer_cmp_fnc(const ul_htim_time_t *a, const ul_htim_time_t *b){
54    return NtpTimeCmp(*a,*b);
55 }
56 #endif /*UL_HTIMER_WITH_NTPTIME*/ 
57
58 /*===========================================================*/
59 /*  Configuration of types for standard timer (ul_htimer) */
60
61 /* Additional, user defined fields for ul_htimer_t structure */
62 #define UL_HTIMER_USER_FIELDS 
63
64 typedef void (ul_htimer_fnc_t)(unsigned long data);
65
66 /* The wrapper for ul_htimer_run_expired */
67 #define UL_HTIMER_FNC_CALL(queue, timer, pact_time) \
68     do{ timer->function(timer->data); } while(0)
69
70
71 #ifdef __cplusplus
72 } /* extern "C"*/
73 #endif
74
75 #endif /* _UL_HTIMDEFS_H */