mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-09-29 13:30:38 +00:00
pool!: accept attributes
This commit is contained in:
parent
6938d75622
commit
087aa5feed
@ -14,7 +14,11 @@
|
||||
//! use heapless::{pool, pool::singleton::Box};
|
||||
//!
|
||||
//! // 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]
|
||||
//! fn main() -> ! {
|
||||
|
@ -18,16 +18,17 @@ use super::{Init, Uninit};
|
||||
#[cfg(any(armv7m, armv7r, test))]
|
||||
#[macro_export]
|
||||
macro_rules! pool {
|
||||
($ident:ident: $ty:ty) => {
|
||||
($(#[$($attr:tt)*])* $ident:ident: $ty:ty) => {
|
||||
pub struct $ident;
|
||||
|
||||
impl $crate::pool::singleton::Pool for $ident {
|
||||
type Data = $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