Skip to content

Commit

Permalink
Merge pull request #381 from lf-lang/combine-deadline-and-level
Browse files Browse the repository at this point in the history
Added lf_combine_deadline_and_level function for use by code generator
  • Loading branch information
lhstrh authored Mar 3, 2024
2 parents bb3b158 + ed9d354 commit 3a4e44f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 10 additions & 0 deletions include/core/reactor_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3a4e44f

Please sign in to comment.