1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17:
18:
19: #ifndef _TIMER_
20: #define _TIMER_
21:
22: #include "longlong.h"
23:
24: 25: 26:
27: typedef D LSYSTIM;
28:
29: Inline LSYSTIM knl_toLSYSTIM( CONST SYSTIM *time )
30: {
31: LSYSTIM ltime;
32:
33: hilo_ll(ltime, time->hi, time->lo);
34:
35: return ltime;
36: }
37:
38: Inline SYSTIM knl_toSYSTIM( LSYSTIM ltime )
39: {
40: SYSTIM time;
41:
42: ll_hilo(time.hi, time.lo, ltime);
43:
44: return time;
45: }
46:
47: 48: 49:
50: typedef UW ABSTIM;
51:
52: #define ABSTIM_DIFF_MIN (0x7FFFFFFF)
53:
54: Inline BOOL knl_abstim_reached( ABSTIM curtim, ABSTIM evttim )
55: {
56: return (ABSTIM)(curtim - evttim) <= (ABSTIM)ABSTIM_DIFF_MIN;
57: }
58:
59: 60: 61:
62: typedef void (*CBACK)(void *);
63:
64: typedef struct timer_event_block {
65: QUEUE queue;
66: ABSTIM time;
67: CBACK callback;
68: void *arg;
69: } TMEB;
70:
71: 72: 73:
74: IMPORT LSYSTIM knl_current_time;
75: IMPORT LSYSTIM knl_real_time_ofs;
76:
77: 78: 79:
80: IMPORT QUEUE knl_timer_queue;
81:
82: 83: 84:
85: IMPORT void knl_timer_insert( TMEB *evt, TMO tmout, CBACK cback, void *arg );
86: IMPORT void knl_timer_insert_reltim( TMEB *event, RELTIM tmout, CBACK callback, void *arg );
87: IMPORT void knl_timer_insert_abs( TMEB *evt, ABSTIM time, CBACK cback, void *arg );
88:
89: 90: 91:
92: Inline void knl_timer_delete( TMEB *event )
93: {
94: QueRemove(&event->queue);
95: }
96:
97: #endif