Skip to content

Commit 3a4e44f

Browse files
authored
Merge pull request #381 from lf-lang/combine-deadline-and-level
Added lf_combine_deadline_and_level function for use by code generator
2 parents bb3b158 + ed9d354 commit 3a4e44f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

core/reactor_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,3 +1325,8 @@ void termination(void) {
13251325
}
13261326
lf_tracing_global_shutdown();
13271327
}
1328+
1329+
index_t lf_combine_deadline_and_level(interval_t deadline, int level) {
1330+
if (deadline > ULLONG_MAX >> 16) return ((ULLONG_MAX >> 16) << 16) | level;
1331+
else return (deadline << 16) | level;
1332+
}

include/core/reactor_common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ extern struct allocation_record_t* _lf_reactors_to_free;
6565

6666
////////////////////// Functions //////////////////////
6767

68+
/**
69+
* @brief Combine a deadline and a level into a single index for sorting in the reaction queue.
70+
*
71+
* This shifts the deadline right by 16 bits and inserts the level in the low-order 16 bits.
72+
* If the deadline is larger than `ULLONG_MAX >> 16`, then it is treated as the largest possible deadline.
73+
* @oaran deadline THe deadline.
74+
* @param level The level in the reaction graph.
75+
*/
76+
index_t lf_combine_deadline_and_level(interval_t deadline, int level);
77+
6878
/**
6979
* @brief Create and initialize the required number of environments for the program.
7080
* @note This function will be code generated by the compiler.

0 commit comments

Comments
 (0)