Skip to content

Commit e977cdf

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 5b0fadc commit e977cdf

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
@@ -15,6 +15,7 @@ pub mod device;
1515
pub mod error;
1616
pub mod logging;
1717
pub mod object;
18+
#[cfg(CONFIG_RUST_ALLOC)]
1819
pub mod simpletls;
1920
pub mod sync;
2021
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},
@@ -74,6 +81,7 @@ impl Semaphore {
7481
/// Take a semaphore, async version.
7582
///
7683
/// Returns a future that either waits for the semaphore, or returns status.
84+
#[cfg(CONFIG_RUST_ALLOC)]
7785
pub fn take_async<'a>(&'a self, timeout: impl Into<Timeout>) -> impl Future<Output = Result<()>> + 'a {
7886
SemTake {
7987
sem: self,
@@ -109,6 +117,7 @@ impl Semaphore {
109117
}
110118

111119
/// The async 'take' Future
120+
#[cfg(CONFIG_RUST_ALLOC)]
112121
struct SemTake<'a> {
113122
/// The semaphore we're waiting on.
114123
sem: &'a Semaphore,
@@ -118,6 +127,7 @@ struct SemTake<'a> {
118127
ran: bool,
119128
}
120129

130+
#[cfg(CONFIG_RUST_ALLOC)]
121131
impl<'a> Future for SemTake<'a> {
122132
type Output = Result<()>;
123133

0 commit comments

Comments
 (0)