mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-01 06:20:34 +00:00
pool!: accept attributes
This commit is contained in:
parent
6938d75622
commit
087aa5feed
@ -14,7 +14,11 @@
|
|||||||
//! use heapless::{pool, pool::singleton::Box};
|
//! use heapless::{pool, pool::singleton::Box};
|
||||||
//!
|
//!
|
||||||
//! // instantiate a memory pool of `[u8; 128]` blocks as a global singleton
|
//! // instantiate a memory pool of `[u8; 128]` blocks as a global singleton
|
||||||
//! pool!(A: [u8; 128]);
|
//! pool!(
|
||||||
|
//! // attributes can be used here
|
||||||
|
//! // #[link_section = ".ccram.A"]
|
||||||
|
//! A: [u8; 128]
|
||||||
|
//! );
|
||||||
//!
|
//!
|
||||||
//! #[entry]
|
//! #[entry]
|
||||||
//! fn main() -> ! {
|
//! fn main() -> ! {
|
||||||
|
@ -18,16 +18,17 @@ use super::{Init, Uninit};
|
|||||||
#[cfg(any(armv7m, armv7r, test))]
|
#[cfg(any(armv7m, armv7r, test))]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! pool {
|
macro_rules! pool {
|
||||||
($ident:ident: $ty:ty) => {
|
($(#[$($attr:tt)*])* $ident:ident: $ty:ty) => {
|
||||||
pub struct $ident;
|
pub struct $ident;
|
||||||
|
|
||||||
impl $crate::pool::singleton::Pool for $ident {
|
impl $crate::pool::singleton::Pool for $ident {
|
||||||
type Data = $ty;
|
type Data = $ty;
|
||||||
|
|
||||||
fn ptr() -> &'static $crate::pool::Pool<$ty> {
|
fn ptr() -> &'static $crate::pool::Pool<$ty> {
|
||||||
static POOL: $crate::pool::Pool<$ty> = $crate::pool::Pool::new();
|
$(#[$($attr)*])*
|
||||||
|
static $ident: $crate::pool::Pool<$ty> = $crate::pool::Pool::new();
|
||||||
|
|
||||||
&POOL
|
&$ident
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user