Skip to content

Commit 1231bbd

Browse files
authored
reactor-c header (#155)
* Add legacy compatability header for reactor-c
1 parent 828008b commit 1231bbd

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

include/reactor-uc/reactor-c.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef REACTOR_C_H
2+
#define REACTOR_C_H
3+
4+
#define lf_print(str, ...) printf(str, __VA_ARGS__)
5+
#define PRINTF_TIME "%" PRId64
6+
#define PRINTF_MICROSTEP "%" PRIu32
7+
#define PRINTF_TAG "(" PRINTF_TIME ", " PRINTF_MICROSTEP ")"
8+
9+
#define lf_time_logical_elapsed() env->get_elapsed_logical_time(env)
10+
#define lf_time_logical() env->get_logical_time(env)
11+
#define lf_tag() env->get_logical_time(env)
12+
#define lf_time_physical() env->get_physical_time(env)
13+
14+
#define lf_request_stop() env->request_shutdown(env)
15+
16+
#define lf_schedule_token(action, offset, val) \
17+
do { \
18+
__typeof__(val) __val = (val); \
19+
lf_ret_t ret = (action)->super.schedule(&(action)->super, (offset), (const void *)&__val); \
20+
if (ret == LF_FATAL) { \
21+
LF_ERR(TRIG, "Scheduling an value, that doesn't have value!"); \
22+
Scheduler *sched = (action)->super.super.parent->env->scheduler; \
23+
sched->do_shutdown(sched, sched->current_tag(sched)); \
24+
throw("Tried to schedule a value onto an action without a type!"); \
25+
} \
26+
} while (0)
27+
28+
#define lf_set_token(action, val) \
29+
do { \
30+
__typeof__(val) __val = (val); \
31+
Port *_port = (Port *)(port); \
32+
_port->set(_port, &__val); \
33+
} while (0)
34+
35+
#warning "You are using the deprecated reactor-c interface"
36+
37+
#endif // REACTOR_C_H

0 commit comments

Comments
 (0)