reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
tag.h
Go to the documentation of this file.
1
11#ifndef TAG_H
12#define TAG_H
13
14#define NSEC(t) ((interval_t)(t * 1LL))
15#define NSECS(t) ((interval_t)(t * 1LL))
16#define USEC(t) ((interval_t)(t * 1000LL))
17#define USECS(t) ((interval_t)(t * 1000LL))
18#define MSEC(t) ((interval_t)(t * 1000000LL))
19#define MSECS(t) ((interval_t)(t * 1000000LL))
20#define SEC(t) ((interval_t)(t * 1000000000LL))
21#define SECS(t) ((interval_t)(t * 1000000000LL))
22#define SECOND(t) ((interval_t)(t * 1000000000LL))
23#define SECONDS(t) ((interval_t)(t * 1000000000LL))
24#define MINUTE(t) ((interval_t)(t * 60000000000LL))
25#define MINUTES(t) ((interval_t)(t * 60000000000LL))
26#define HOUR(t) ((interval_t)(t * 3600000000000LL))
27#define HOURS(t) ((interval_t)(t * 3600000000000LL))
28#define DAY(t) ((interval_t)(t * 86400000000000LL))
29#define DAYS(t) ((interval_t)(t * 86400000000000LL))
30#define WEEK(t) ((interval_t)(t * 604800000000000LL))
31#define WEEKS(t) ((interval_t)(t * 604800000000000LL))
32
33#define NEVER ((interval_t)LLONG_MIN)
34#define NEVER_MICROSTEP 0u
35#define FOREVER ((interval_t)LLONG_MAX)
36#define FOREVER_MICROSTEP UINT_MAX
37#define NEVER_TAG \
38 (tag_t) { .time = NEVER, .microstep = NEVER_MICROSTEP }
39// Need a separate initializer expression to comply with some C compilers
40#define NEVER_TAG_INITIALIZER \
41 { NEVER, NEVER_MICROSTEP }
42#define FOREVER_TAG \
43 (tag_t) { .time = FOREVER, .microstep = FOREVER_MICROSTEP }
44// Need a separate initializer expression to comply with some C compilers
45#define FOREVER_TAG_INITIALIZER \
46 { FOREVER, FOREVER_MICROSTEP }
47#define ZERO_TAG \
48 (tag_t) { .time = 0LL, .microstep = 0u }
49
50// Returns true if timeout has elapsed.
51#define CHECK_TIMEOUT(start, duration) (lf_time_physical() > ((start) + (duration)))
52
53// Convenience for converting times
54#define BILLION ((instant_t)1000000000LL)
55
56#include <stdint.h>
57#include <stddef.h>
58#include <limits.h>
59
61
66typedef int64_t instant_t;
67
71typedef int64_t interval_t;
72
76typedef uint32_t microstep_t;
77
85
87
92tag_t lf_tag(void* env);
93
106
115
126int lf_tag_compare(tag_t tag1, tag_t tag2);
127
146tag_t lf_delay_tag(tag_t tag, interval_t interval);
147
164
173instant_t lf_time_logical(void* env);
174
182
190
198
206
222#define LF_TIME_BUFFER_LENGTH 64
223
238size_t lf_readable_time(char* buffer, instant_t time);
239
249size_t lf_comma_separated_time(char* buffer, instant_t time);
250
251#endif // TAG_H
#define lf_tag()
Definition reaction_macros.h:189
#define lf_time_logical()
Definition reaction_macros.h:194
#define lf_time_logical_elapsed()
Definition reaction_macros.h:200
Definition tag.h:81
microstep_t microstep
Definition tag.h:83
instant_t time
Definition tag.h:82
instant_t lf_time_add(instant_t a, interval_t b)
Return the sum of an interval and an instant, saturating on overflow and underflow.
Definition tag.c:42
size_t lf_readable_time(char *buffer, instant_t time)
Definition tag.c:145
int lf_tag_compare(tag_t tag1, tag_t tag2)
Definition tag.c:85
instant_t lf_time_physical(void)
Definition tag.c:134
int64_t instant_t
Definition tag.h:66
instant_t lf_time_start(void)
Definition tag.c:143
instant_t lf_time_physical_elapsed(void)
Definition tag.c:141
tag_t lf_tag_add(tag_t a, tag_t b)
Definition tag.c:61
uint32_t microstep_t
Definition tag.h:76
size_t lf_comma_separated_time(char *buffer, instant_t time)
Definition tag.c:229
int64_t interval_t
Definition tag.h:71
tag_t lf_delay_strict(tag_t tag, interval_t interval)
Definition tag.c:118
tag_t lf_delay_tag(tag_t tag, interval_t interval)
Definition tag.c:99
char buffer[BUFFER_SIZE]
Definition trace_util.c:42