diff --git a/core/reactor_common.c b/core/reactor_common.c index 8492ef48a..bd9cc1210 100644 --- a/core/reactor_common.c +++ b/core/reactor_common.c @@ -1325,3 +1325,8 @@ void termination(void) { } lf_tracing_global_shutdown(); } + +index_t lf_combine_deadline_and_level(interval_t deadline, int level) { + if (deadline > ULLONG_MAX >> 16) return ((ULLONG_MAX >> 16) << 16) | level; + else return (deadline << 16) | level; +} diff --git a/include/core/reactor_common.h b/include/core/reactor_common.h index 97ec976b8..92630be1e 100644 --- a/include/core/reactor_common.h +++ b/include/core/reactor_common.h @@ -65,6 +65,16 @@ extern struct allocation_record_t* _lf_reactors_to_free; ////////////////////// Functions ////////////////////// +/** + * @brief Combine a deadline and a level into a single index for sorting in the reaction queue. + * + * This shifts the deadline right by 16 bits and inserts the level in the low-order 16 bits. + * If the deadline is larger than `ULLONG_MAX >> 16`, then it is treated as the largest possible deadline. + * @oaran deadline THe deadline. + * @param level The level in the reaction graph. +*/ +index_t lf_combine_deadline_and_level(interval_t deadline, int level); + /** * @brief Create and initialize the required number of environments for the program. * @note This function will be code generated by the compiler.