41 #ifndef __TIMETABLE_H__
42 #define __TIMETABLE_H__
48 struct timetable_timestamp {
51 #if TIMETABLE_WITH_TYPE
56 struct timetable_timestamp *timestamps;
58 unsigned int *
const ptr;
61 #define TIMETABLE_NONSTATIC(name) \
62 struct timetable_timestamp CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_size)]; \
63 unsigned int CC_CONCAT(name,_ptr); \
64 struct timetable name = { \
65 CC_CONCAT(name,_timestamps), \
66 CC_CONCAT(name,_size), \
67 &CC_CONCAT(name,_ptr)}
69 #define TIMETABLE_STATIC(name) \
70 static struct timetable_timestamp CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_size)]; \
71 static unsigned int CC_CONCAT(name,_ptr); \
72 static struct timetable name = { \
73 CC_CONCAT(name,_timestamps), \
74 CC_CONCAT(name,_size), \
75 &CC_CONCAT(name,_ptr)}
77 #define TIMETABLE_DECLARE(name) \
78 extern unsigned int CC_CONCAT(name,_ptr); \
79 extern struct timetable_timestamp CC_CONCAT(name, _timestamps)[CC_CONCAT(name,_size)]; \
80 extern struct timetable name
82 #define TIMETABLE(name) TIMETABLE_STATIC(name)
84 #define TIMETABLE_TIMESTAMP(name, str) \
86 CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_ptr)].id = str; \
87 CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_ptr)].time = RTIMER_NOW(); \
88 CC_CONCAT(name,_ptr) = (CC_CONCAT(name,_ptr) + 1) % \
89 CC_CONCAT(name,_size); \
92 #if TIMETABLE_WITH_TYPE
93 #define TIMETABLE_TIMESTAMP_TYPE(name, str, t) \
95 CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_ptr)].id = str; \
96 CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_ptr)].type = t; \
97 CC_CONCAT(name,_timestamps)[CC_CONCAT(name,_ptr)].time = RTIMER_NOW(); \
98 CC_CONCAT(name,_ptr) = (CC_CONCAT(name,_ptr) + 1) % \
99 CC_CONCAT(name,_size); \
102 #define TIMETABLE_TIMESTAMP_TYPE(name, str, t) TIMETABLE_TIMESTAMP(name, str)
106 #define TIMETABLE_RESUME(name,num) \
107 TIMETABLE_TIMESTAMP(CC_CONCAT(name,_timestamps[num].id))
109 #define TIMETABLE_COND_TIMESTAMP(cond,name,id) \
111 TIMETABLE_TIMESTAMP(id); \
114 #define TIMETABLE_COND_RESUME(cond,name,num) \
115 TIMETABLE_COND_TIMESTAMP(cond,name, \
116 CC_CONCAT(name,_timestamps[num].id))
118 #define TIMETABLE_ENTRY(name, num) CC_CONCAT(name,_timestamps)[num]
119 #define TIMETABLE_PTR(name) CC_CONCAT(name,_ptr)
127 struct timetable_timestamp *timetable_entry(
struct timetable *t,
129 int timetable_ptr(
struct timetable *t);
131 void timetable_clear(
struct timetable *t);
132 rtimer_clock_t timetable_timediff(
struct timetable *t,
133 const char *id1,
const char *id2);
134 void timetable_init(
void);
136 void timetable_print(
struct timetable *t);