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 {NEVER, NEVER_MICROSTEP}
41#define FOREVER_TAG \
42 (tag_t) { .time = FOREVER, .microstep = FOREVER_MICROSTEP }
43// Need a separate initializer expression to comply with some C compilers
44#define FOREVER_TAG_INITIALIZER {FOREVER, FOREVER_MICROSTEP}
45#define ZERO_TAG (tag_t){.time = 0LL, .microstep = 0u}
46
47// Returns true if timeout has elapsed.
48#define CHECK_TIMEOUT(start, duration) (lf_time_physical() > ((start) + (duration)))
49
50// Convenience for converting times
51#define BILLION ((instant_t)1000000000LL)
52
53#include <stdint.h>
54#include <stddef.h>
55#include <limits.h>
56
58
63typedef int64_t instant_t;
64
68typedef int64_t interval_t;
69
73typedef uint32_t microstep_t;
74
82
84
89tag_t lf_tag(void* env);
90
103
112
121
132int lf_tag_compare(tag_t tag1, tag_t tag2);
133
152tag_t lf_delay_tag(tag_t tag, interval_t interval);
153
170
179instant_t lf_time_logical(void* env);
180
188
196
204
212
228#define LF_TIME_BUFFER_LENGTH 64
229
244size_t lf_readable_time(char* buffer, instant_t time);
245
255size_t lf_comma_separated_time(char* buffer, instant_t time);
256
257#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:78
microstep_t microstep
Definition tag.h:80
instant_t time
Definition tag.h:79
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:164
int lf_tag_compare(tag_t tag1, tag_t tag2)
Definition tag.c:104
instant_t lf_time_physical(void)
Definition tag.c:153
int64_t instant_t
Definition tag.h:63
instant_t lf_time_start(void)
Definition tag.c:162
instant_t lf_time_subtract(instant_t a, interval_t b)
Return an instant minus an interval, saturating on overflow and underflow.
Definition tag.c:61
instant_t lf_time_physical_elapsed(void)
Definition tag.c:160
tag_t lf_tag_add(tag_t a, tag_t b)
Definition tag.c:80
uint32_t microstep_t
Definition tag.h:73
size_t lf_comma_separated_time(char *buffer, instant_t time)
Definition tag.c:248
int64_t interval_t
Definition tag.h:68
tag_t lf_delay_strict(tag_t tag, interval_t interval)
Definition tag.c:137
tag_t lf_delay_tag(tag_t tag, interval_t interval)
Definition tag.c:118
char buffer[BUFFER_SIZE]
Definition trace_util.c:42