Rahix / shared-bus

Crate for sharing buses between multiple devices
Apache License 2.0
129 stars 34 forks source link

Use atomic-polyfill for AtomicCheckMutex #30

Closed Rahix closed 2 years ago

Rahix commented 2 years ago

This will allow using shared-bus on thumbv6 platforms which do not have real atomics.

@pdgilbert, can you please give this a try on your systems to verify that it actually works now?

Fixes #29.

pdgilbert commented 2 years ago

Maybe you left in some debugging statements? I'm getting

   Compiling shared-bus v0.2.2 (https://github.com/Rahix/shared-bus?branch=atomic-polyfill#1474747c)
error[E0308]: mismatched types
   --> /home/paul/.cargo/git/checkouts/shared-bus-afeeec54cdff0f33/1474747/src/mutex.rs:202:53
    |
202 |             busy: atomic_polyfill::AtomicBool::from(false),
    |                                                     ^^^^^ expected struct `atomic_polyfill::AtomicBool`, found `bool`

error[E0277]: `atomic_polyfill::AtomicBool` doesn't implement `Debug`
   --> /home/paul/.cargo/git/checkouts/shared-bus-afeeec54cdff0f33/1474747/src/mutex.rs:187:5
    |
184 | #[derive(Debug)]
    |          ----- in this derive macro expansion
...
187 |     busy: atomic_polyfill::AtomicBool,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `atomic_polyfill::AtomicBool` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = help: the trait `Debug` is not implemented for `atomic_polyfill::AtomicBool`
    = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
Rahix commented 2 years ago
error[E0308]: mismatched types
   --> /home/paul/.cargo/git/checkouts/shared-bus-afeeec54cdff0f33/1474747/src/mutex.rs:202:53
    |
202 |             busy: atomic_polyfill::AtomicBool::from(false),
    |                                                     ^^^^^ expected struct `atomic_polyfill::AtomicBool`, found `bool`

Okay, it looks like there is a

impl From<bool> for atomic_polyfill::AtomicBool { }

missing in atomic-polyfill.

error[E0277]: `atomic_polyfill::AtomicBool` doesn't implement `Debug`
   --> /home/paul/.cargo/git/checkouts/shared-bus-afeeec54cdff0f33/1474747/src/mutex.rs:187:5
    |
184 | #[derive(Debug)]
    |          ----- in this derive macro expansion
...
187 |     busy: atomic_polyfill::AtomicBool,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `atomic_polyfill::AtomicBool` cannot be formatted using `{:?}` because it doesn't implement `Debug`

And this seems to be a known issue: https://github.com/embassy-rs/atomic-polyfill/issues/11

I think the most reasonable solution here is to send a PR upstream to fix these two. I'll try to do that in the coming days and I will ping you once this PR here is ready for re-testing.

pdgilbert commented 2 years ago

Sounds good.

Rahix commented 2 years ago

@pdgilbert, here you go, atomic-polyfill already released a new version with the fixes. Please try again :)

pdgilbert commented 2 years ago

Looks good. Thanks @Rahix .