Skip to content

Commit 0228350

Browse files
committed
Fixed new TAIT requirement and release v2.0.1 of RTIC
1 parent 1967058 commit 0228350

File tree

8 files changed

+39
-17
lines changed

8 files changed

+39
-17
lines changed

Cargo.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616
"rtic-time",
1717
"xtask",
1818
]
19+
resolver = "2"
1920

2021
[profile.release]
2122
codegen-units = 1
@@ -36,6 +37,3 @@ debug = false
3637
debug-assertions = false
3738
opt-level = 0
3839
overflow-checks = false
39-
40-
[patch.crates-io]
41-
lm3s6965 = { git = "https://github.com/japaric/lm3s6965" }

rtic-macros/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
77

88
## [Unreleased]
99

10+
## [v2.0.1] - 2023-07-25
11+
1012
### Added
1113

12-
### Changed
14+
- `init` and `idle` can now be externed.
1315

1416
### Fixed
1517

18+
- Support new TAIT syntax requirement.
19+
1620
## [v2.0.0] - 2023-05-31
1721

1822
- Initial v2 release

rtic-macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ name = "rtic-macros"
2222
readme = "../README.md"
2323
repository = "https://github.com/rtic-rs/rtic"
2424

25-
version = "2.0.0"
25+
version = "2.0.1"
2626

2727
[lib]
2828
proc-macro = true

rtic-macros/src/codegen/module.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,26 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
150150
let (input_args, input_tupled, input_untupled, input_ty) =
151151
util::regroup_inputs(&spawnee.inputs);
152152

153+
let type_name = util::internal_task_ident(name, "F");
154+
153155
// Spawn caller
154156
items.push(quote!(
155157
#(#cfgs)*
156158
/// Spawns the task directly
157159
#[allow(non_snake_case)]
158160
#[doc(hidden)]
159161
pub fn #internal_spawn_ident(#(#input_args,)*) -> Result<(), #input_ty> {
160-
// SAFETY: If `try_allocate` suceeds one must call `spawn`, which we do.
162+
// New TAIT requirement hack; the opaque type must be in the argument or return
163+
// position of a function...
164+
#[inline(always)]
165+
fn tait_hack(#(#input_args,)*) -> #type_name {
166+
#name(unsafe { #name::Context::new() } #(,#input_untupled)*)
167+
}
168+
169+
// SAFETY: If `try_allocate` succeeds one must call `spawn`, which we do.
161170
unsafe {
162171
if #exec_name.try_allocate() {
163-
let f = #name(unsafe { #name::Context::new() } #(,#input_untupled)*);
172+
let f = tait_hack(#(#input_untupled,)*);
164173
#exec_name.spawn(f);
165174
#pend_interrupt
166175

@@ -169,7 +178,6 @@ pub fn codegen(ctxt: Context, app: &App, analysis: &Analysis) -> TokenStream2 {
169178
Err(#input_tupled)
170179
}
171180
}
172-
173181
}
174182
));
175183

rtic-monotonics/src/rp2040.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Timer {
3838
/// Start a `Monotonic` based on RP2040's Timer.
3939
pub fn start(
4040
timer: TIMER,
41-
resets: &mut RESETS,
41+
resets: &RESETS,
4242
_interrupt_token: impl crate::InterruptToken<Self>,
4343
) {
4444
resets.reset.modify(|_, w| w.timer().clear_bit());

rtic/CHANGELOG.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,23 @@ For each category, *Added*, *Changed*, *Fixed* add new entries at the top!
88
## [Unreleased]
99

1010
### Added
11-
- Allow #[init] and #[idle] to be defined externally
1211

1312
### Fixed
1413

1514
### Changed
1615

16+
## [v2.0.1] - 2023-07-25
17+
18+
### Added
19+
20+
- Allow `#[init]` and `#[idle]` to be defined externally
21+
22+
### Fixed
23+
24+
- Support new TAIT syntax requirement.
25+
26+
### Changed
27+
1728
- `cortex-m` set as an optional dependency
1829
- Moved `cortex-m`-related utilities from `rtic/lib.rs` to `rtic/export.rs`
1930
- Make async task priorities start at 0, instead of 1, to always start at the lowest priority
@@ -568,7 +579,8 @@ Yanked due to a soundness issue in `init`; the issue has been mostly fixed in v0
568579

569580
- Initial release
570581

571-
[Unreleased]: https://github.com/rtic-rs/rtic/compare/v2.0.0...HEAD
582+
[Unreleased]: https://github.com/rtic-rs/rtic/compare/v2.0.1...HEAD
583+
[v2.0.1]: https://github.com/rtic-rs/rtic/compare/v2.0.0...v2.0.1
572584
[v2.0.0]: https://github.com/rtic-rs/rtic/compare/v1.1.4...v2.0.0
573585
[v1.1.4]: https://github.com/rtic-rs/rtic/compare/v1.1.3...v1.1.4
574586
[v1.1.3]: https://github.com/rtic-rs/rtic/compare/v1.1.2...v1.1.3

rtic/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ name = "rtic"
2222
readme = "../README.md"
2323
repository = "https://github.com/rtic-rs/rtic"
2424

25-
version = "2.0.0"
25+
version = "2.0.1"
2626

2727
[package.metadata.docs.rs]
2828
features = ["rtic-macros/test-template"]
@@ -36,13 +36,13 @@ bare-metal = "1.0.0"
3636
#portable-atomic = { version = "0.3.19" }
3737
atomic-polyfill = "1"
3838
rtic-monotonics = { path = "../rtic-monotonics", version = "1.0.0", optional = true }
39-
rtic-macros = { path = "../rtic-macros", version = "2.0.0" }
39+
rtic-macros = { path = "../rtic-macros", version = "2.0.1" }
4040
rtic-core = "1"
4141
critical-section = "1"
4242

4343
[dev-dependencies]
4444
heapless = "0.7.7"
45-
lm3s6965 = "0.1.3"
45+
lm3s6965 = "0.2"
4646
cortex-m-semihosting = "0.5.0"
4747
rtic-time = { path = "../rtic-time" }
4848
rtic-sync = { path = "../rtic-sync" }

rtic/examples/async-task-multiple-prios.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ mod app {
3232
fn init(_: init::Context) -> (Shared, Local) {
3333
hprintln!("init");
3434

35-
async_task1::spawn().ok();
35+
async_task1::spawn(1).ok();
3636
async_task2::spawn().ok();
3737
async_task3::spawn().ok();
3838
async_task4::spawn().ok();
@@ -49,11 +49,11 @@ mod app {
4949
}
5050

5151
#[task(priority = 1, shared = [a, b])]
52-
async fn async_task1(mut cx: async_task1::Context) {
52+
async fn async_task1(mut cx: async_task1::Context, inc: u32) {
5353
hprintln!(
5454
"hello from async 1 a {}",
5555
cx.shared.a.lock(|a| {
56-
*a += 1;
56+
*a += inc;
5757
*a
5858
})
5959
);

0 commit comments

Comments
 (0)