From 277d3f295167b9f9f3b45356937af8cf57bef3b8 Mon Sep 17 00:00:00 2001 From: "Edward A. Lee" Date: Sun, 3 Mar 2024 11:22:25 -0800 Subject: [PATCH 1/2] Added lf_combine_deadline_and_level function for use by code generator --- core/reactor_common.c | 5 +++++ include/core/reactor_common.h | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/core/reactor_common.c b/core/reactor_common.c index 8492ef48a..a7cd1bb18 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; +} \ No newline at end of file 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. From ed9d3546eb898091461913d4e526d8b3bb9a6bee Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Sun, 3 Mar 2024 13:50:29 -0800 Subject: [PATCH 2/2] Update core/reactor_common.c --- core/reactor_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/reactor_common.c b/core/reactor_common.c index a7cd1bb18..bd9cc1210 100644 --- a/core/reactor_common.c +++ b/core/reactor_common.c @@ -1329,4 +1329,4 @@ void termination(void) { 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; -} \ No newline at end of file +}