diff options
Diffstat (limited to 'embassy-time-driver/src/lib.rs')
| -rw-r--r-- | embassy-time-driver/src/lib.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/embassy-time-driver/src/lib.rs b/embassy-time-driver/src/lib.rs index 44d9a156a..f3e8e0153 100644 --- a/embassy-time-driver/src/lib.rs +++ b/embassy-time-driver/src/lib.rs | |||
| @@ -89,7 +89,7 @@ | |||
| 89 | //! Instead of the usual "trait + generic params" approach, calls from embassy to the driver are done via `extern` functions. | 89 | //! Instead of the usual "trait + generic params" approach, calls from embassy to the driver are done via `extern` functions. |
| 90 | //! | 90 | //! |
| 91 | //! `embassy` internally defines the driver function as `extern "Rust" { fn _embassy_time_now() -> u64; }` and calls it. | 91 | //! `embassy` internally defines the driver function as `extern "Rust" { fn _embassy_time_now() -> u64; }` and calls it. |
| 92 | //! The driver crate defines the function as `#[no_mangle] fn _embassy_time_now() -> u64`. The linker will resolve the | 92 | //! The driver crate defines the function as `#[unsafe(no_mangle)] fn _embassy_time_now() -> u64`. The linker will resolve the |
| 93 | //! calls from the `embassy` crate to call into the driver crate. | 93 | //! calls from the `embassy` crate to call into the driver crate. |
| 94 | //! | 94 | //! |
| 95 | //! If there is none or multiple drivers in the crate tree, linking will fail. | 95 | //! If there is none or multiple drivers in the crate tree, linking will fail. |
| @@ -133,7 +133,7 @@ pub trait Driver: Send + Sync + 'static { | |||
| 133 | fn schedule_wake(&self, at: u64, waker: &Waker); | 133 | fn schedule_wake(&self, at: u64, waker: &Waker); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | extern "Rust" { | 136 | unsafe extern "Rust" { |
| 137 | fn _embassy_time_now() -> u64; | 137 | fn _embassy_time_now() -> u64; |
| 138 | fn _embassy_time_schedule_wake(at: u64, waker: &Waker); | 138 | fn _embassy_time_schedule_wake(at: u64, waker: &Waker); |
| 139 | } | 139 | } |
| @@ -158,13 +158,13 @@ macro_rules! time_driver_impl { | |||
| 158 | (static $name:ident: $t: ty = $val:expr) => { | 158 | (static $name:ident: $t: ty = $val:expr) => { |
| 159 | static $name: $t = $val; | 159 | static $name: $t = $val; |
| 160 | 160 | ||
| 161 | #[no_mangle] | 161 | #[unsafe(no_mangle)] |
| 162 | #[inline] | 162 | #[inline] |
| 163 | fn _embassy_time_now() -> u64 { | 163 | fn _embassy_time_now() -> u64 { |
| 164 | <$t as $crate::Driver>::now(&$name) | 164 | <$t as $crate::Driver>::now(&$name) |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | #[no_mangle] | 167 | #[unsafe(no_mangle)] |
| 168 | #[inline] | 168 | #[inline] |
| 169 | fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker) { | 169 | fn _embassy_time_schedule_wake(at: u64, waker: &core::task::Waker) { |
| 170 | <$t as $crate::Driver>::schedule_wake(&$name, at, waker); | 170 | <$t as $crate::Driver>::schedule_wake(&$name, at, waker); |
