Repository navigation
task_slot: Bind at compile time instead of post-link patchup - #2764
Merged
Merged
Conversation
jamesmunns
commented
Nov 5, 2026
Contributor
Author
|
Tested on an [tasks.spartan7_loader]
name = "drv-spartan7-loader"
features = ["h753"]
priority = 4
max-sizes = {flash = 131072, ram = 16384 }
stacksize = 2600
start = true
task-slots = ["sys", {spi = "spi2_driver"}, "auxflash"]And seems happy in practice: Will fix merge conflicts and make a docs pass. |
Contributor
Author
|
I've also looked through |
mkeeter
reviewed
Nov 6, 2026
| panic!("task slot index is not a decimal number"); | ||
| } | ||
| value = match value.checked_mul(10) { | ||
| Some(v) => match v.checked_add((digit - b'0') as u16) { |
Collaborator
There was a problem hiding this comment.
I tried rewriting this with and_then + into, but alas neither of those are stable in a const context 🥲
mkeeter
approved these changes
Nov 6, 2026
labbott
approved these changes
Nov 6, 2026
Comment on lines
+11
to
+17
| /// Parse a slot index from the given string, e.g. "11". | ||
| /// | ||
| /// The mapping is provided via an `env!` var inserted by `xtask`. | ||
| /// See the `task_slot!` macro for more details. | ||
| /// | ||
| /// Calling get_task_id() on an unbound TaskSlot will cause a fault from the | ||
| /// kernel. | ||
| pub const UNBOUND: Self = Self(VolatileConst::new(TaskId::UNBOUND.0)); | ||
| /// This is intended to (only) be used at compile time, and panics if | ||
| /// `index` cannot be parsed as a `u16`. |
Collaborator
There was a problem hiding this comment.
Behold the power of const. I think this works really well!
jamesmunns
added a commit
that referenced
this pull request
Nov 6, 2026
This has been replaced by the changes introduced by #2764
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an extract of the task-slot binding mechanism I was building in #2736.
I think with today's
const(andxtask), we can actually skip the post-linking patchup entirely, instead directly patching in via environment variables, asxtaskis aware of all renames/remappings prior to building any tasks.I won't be able to test this on hardware until tomorrow (but will do so!), and I wanted to see what CI thought of it as well.