]> rtime.felk.cvut.cz Git - ulut.git/blob - ulut/ul_htimdefs.h
Fix non-typesafe/void * variant of GAVL to support non-unique keys.
[ulut.git] / ulut / 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 #ifdef UL_HTIMER_WITH_MSTIME
29 typedef unsigned long ul_mstime_t;
30 typedef signed long ul_msdiff_t;
31
32 typedef ul_mstime_t ul_htim_time_t;
33 typedef ul_msdiff_t ul_htim_diff_t;
34
35 #define UL_HTIM_RESOLUTION 1000
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 /*===========================================================*/
48 /*  Configuration of types for standard timer (ul_htimer) */
49
50 /* Additional, user defined fields for ul_htimer_t structure */
51 #define UL_HTIMER_USER_FIELDS 
52
53 #ifdef _WIN64
54 typedef uintptr_t ul_htimer_fnc_data_t;
55 #else
56 typedef unsigned long ul_htimer_fnc_data_t;
57 #endif
58 /*typedef void *ul_htimer_fnc_data_t;*/
59
60 typedef void (ul_htimer_fnc_t)(ul_htimer_fnc_data_t data) UL_ATTR_REENTRANT;
61
62 /* The wrapper for ul_htimer_run_expired */
63 #define UL_HTIMER_FNC_CALL(queue, timer, pact_time) \
64     do{ timer->function(timer->data); } while(0)
65
66
67 #ifdef __cplusplus
68 } /* extern "C"*/
69 #endif
70
71 #endif /* _UL_HTIMDEFS_H */