From 087aa5feedbe8093b3f352ed7161b1512daccd8e Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 3 May 2019 21:03:04 +0200 Subject: [PATCH] pool!: accept attributes --- src/pool/mod.rs | 6 +++++- src/pool/singleton.rs | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pool/mod.rs b/src/pool/mod.rs index 7ba3314e..c9f8a94b 100644 --- a/src/pool/mod.rs +++ b/src/pool/mod.rs @@ -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() -> ! { diff --git a/src/pool/singleton.rs b/src/pool/singleton.rs index cb2ffc02..43ef6827 100644 --- a/src/pool/singleton.rs +++ b/src/pool/singleton.rs @@ -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 } } };