Skip to content

Commit 1d19fb7

Browse files
committed
zephyr: Add numerous missing conditionals around alloc
These are starting to get messy, but for now, add to at least allow code to compile with alloc off. Signed-off-by: David Brown <[email protected]>
1 parent 6a82af0 commit 1d19fb7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

zephyr/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod align;
1414
pub mod error;
1515
pub mod logging;
1616
pub mod object;
17+
#[cfg(CONFIG_RUST_ALLOC)]
1718
pub mod simpletls;
1819
pub mod sync;
1920
pub mod sys;

zephyr/src/sys/sync/semaphore.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@
1111
//! operation, which in situation where counting is actually desired, will result in the count being
1212
//! incorrect.
1313
14+
#[cfg(CONFIG_RUST_ALLOC)]
1415
use core::pin::Pin;
16+
#[cfg(CONFIG_RUST_ALLOC)]
1517
use core::task::{Context, Poll};
16-
use core::{ffi::c_uint, future::Future};
18+
#[cfg(CONFIG_RUST_ALLOC)]
19+
use core::future::Future;
20+
use core::ffi::c_uint;
1721
use core::fmt;
1822
#[cfg(CONFIG_RUST_ALLOC)]
1923
use core::mem;
2024

25+
#[cfg(CONFIG_RUST_ALLOC)]
2126
use zephyr_sys::ETIMEDOUT;
2227

28+
#[cfg(CONFIG_RUST_ALLOC)]
2329
use crate::time::NoWait;
30+
#[cfg(CONFIG_RUST_ALLOC)]
2431
use crate::work::futures::WakeInfo;
2532
use crate::{
2633
error::{to_result_void, Result},
@@ -77,6 +84,7 @@ impl Semaphore {
7784
/// Take a semaphore, async version.
7885
///
7986
/// Returns a future that either waits for the semaphore, or returns status.
87+
#[cfg(CONFIG_RUST_ALLOC)]
8088
pub fn take_async<'a>(&'a self, timeout: impl Into<Timeout>) -> impl Future<Output = Result<()>> + 'a {
8189
SemTake {
8290
sem: self,
@@ -118,6 +126,7 @@ impl Semaphore {
118126
}
119127

120128
/// The async 'take' Future
129+
#[cfg(CONFIG_RUST_ALLOC)]
121130
struct SemTake<'a> {
122131
/// The semaphore we're waiting on.
123132
sem: &'a Semaphore,
@@ -127,6 +136,7 @@ struct SemTake<'a> {
127136
ran: bool,
128137
}
129138

139+
#[cfg(CONFIG_RUST_ALLOC)]
130140
impl<'a> Future for SemTake<'a> {
131141
type Output = Result<()>;
132142

0 commit comments

Comments
 (0)