]> rtime.felk.cvut.cz Git - orte.git/blob - orte/include/ul_htimdefs.h
ANDROID: fix for NDK r9
[orte.git] / orte / include / ul_htimdefs.h
1 #ifndef _UL_HTIMDEFS_H
2 #define _UL_HTIMDEFS_H
3
4 #include "ul_utdefs.h"
5 #ifdef _WIN64
6 #include <stdint.h>
7 #endif
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 /* Select heap-tree as base structure to implement
14  * hierarchic timer - not recomended
15  */
16 //#define UL_HTIMER_WITH_HPTREE
17
18 /* If defined, standard timer type
19  * is built
20  */
21 //#define UL_HTIMER_WITH_STD_TYPE
22
23 /* If defined, standard microsecond resolution 
24  * data types are selected for timer implementation
25  */
26 //#define UL_HTIMER_WITH_MSTIME
27
28 /* If defined, NTPTimer type
29  * is built
30  */
31 #define UL_HTIMER_WITH_NTPTIME 
32
33 #ifdef UL_HTIMER_WITH_MSTIME
34 typedef unsigned long ul_mstime_t;
35 typedef signed long ul_msdiff_t;
36
37 typedef ul_mstime_t ul_htim_time_t;
38 typedef ul_msdiff_t ul_htim_diff_t;
39
40 #define UL_HTIM_RESOLUTION 1000
41
42 static inline int
43 ul_htimer_cmp_fnc(const ul_htim_time_t *a, const ul_htim_time_t *b)
44 {
45   ul_htim_diff_t d=(ul_htim_diff_t)(*a-*b);
46   if (d>0) return 1;
47   if (d<0) return -1;
48   return 0;
49 }
50 #endif /*UL_HTIMER_WITH_MSTIME*/
51
52 #ifdef UL_HTIMER_WITH_NTPTIME
53 #include "orte/typedefs_defines_rtps.h"
54 #include "orte/defines_api.h"
55 typedef NtpTime ul_htim_time_t;
56 typedef NtpTime ul_htim_diff_t;
57
58 #define UL_HTIM_RESOLUTION 0x100000000
59
60 static inline int
61 ul_htimer_cmp_fnc(const ul_htim_time_t *a, const ul_htim_time_t *b){
62    return NtpTimeCmp(*a,*b);
63 }
64 #endif /*UL_HTIMER_WITH_NTPTIME*/ 
65
66 /*===========================================================*/
67 /*  Configuration of types for standard timer (ul_htimer) */
68
69 /* Additional, user defined fields for ul_htimer_t structure */
70 #define UL_HTIMER_USER_FIELDS 
71
72 #ifdef _WIN64
73 typedef uintptr_t ul_htimer_fnc_data_t;
74 #else
75 typedef unsigned long ul_htimer_fnc_data_t;
76 #endif
77 /*typedef void *ul_htimer_fnc_data_t;*/
78
79 typedef void (ul_htimer_fnc_t)(ul_htimer_fnc_data_t data) UL_ATTR_REENTRANT;
80
81 /* The wrapper for ul_htimer_run_expired */
82 #define UL_HTIMER_FNC_CALL(queue, timer, pact_time) \
83     do{ timer->function(timer->data); } while(0)
84
85
86 #ifdef __cplusplus
87 } /* extern "C"*/
88 #endif
89
90 #endif /* _UL_HTIMDEFS_H */