Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make armv6m-atomic-hack less annoying #1635

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Conversation

hawkw
Copy link
Member

@hawkw hawkw commented Feb 28, 2024

Currently, the armv6m-atomic-hack crate is, to use a technical term,
annoying. Its extension traits only exist when #[cfg(armv6m)] is
set. This means that, in downstream crates that wish to use
armv6m-atomic-hack to support v6m targets, the extension traits may
only be imported when #[cfg(armv6m)] is set. Because RUSTFLAGS cfgs
don't propagate across dependency boundaries, this means that each
dependent of armv6m-atomic-hack must add a build script with a call to
build_utils::expose_m_profile() so that the cfg is set properly when
building for a v6m board. This is, as previously stated, annoying ---
especially when using crates like counters, whose #[derive(Count)]
attribute expands to a use of AtomicU32Ext, and thus requires any
crate that derives Count to add a build script.

This branch changes armv6m-atomic-hack so that the extension traits
AtomicU32Ext and AtomicBoolExt are always defined, regardless of
whether #[cfg(armv6m)] is set. Now, only the implementation of those
traits differs based on the presence of the armv6m cfg --- if it is
not set, an implementation is provided that simply forwards to the
corresponding methods on the AtomicU32 and AtomicBool types in
libcore. This way, dependents of armv6m-atomic-hack can just import
the extension traits without needing to add a build script with
expose_m_profile(); now, only armv6m-atomic-hack itself needs the
build script. Now, the armv6m-atomic-hack crate can no longer be
considered annoying.

Currently, the `armv6m-atomic-hack` crate is, to use a technical term,
*annoying*. Its extension traits only exist when `#[cfg(armv6m)]` is
set. This means that, in downstream crates that wish to _use_
`armv6m-atomic-hack` to support v6m targets, the extension traits may
only be imported when `#[cfg(armv6m)]` is set. Because `RUSTFLAGS` cfgs
don't propagate across dependency boundaries, this means that _each_
dependent of `armv6m-atomic-hack` must add a build script with a call to
`build_utils::expose_m_profile()` so that the cfg is set properly when
building for a v6m board. This is, as previously stated, annoying ---
especially when using crates like `counters`, whose `#[derive(Count)]`
attribute expands to a use of `AtomicU32Ext`, and thus requires any
crate that derives `Count` to add a build script.

This branch changes `armv6m-atomic-hack` so that the extension traits
`AtomicU32Ext` and `AtomicBoolExt` are always defined, regardless of
whether `#[cfg(armv6m)]` is set. Now, only the *implementation* of those
traits differs based on the presence of the `armv6m` cfg --- if it is
not set, an implementation is provided that simply forwards to the
corresponding methods on the `AtomicU32` and `AtomicBool` types in
libcore. This way, dependents of `armv6m-atomic-hack` can just import
the extension traits without needing to add a build script with
`expose_m_profile()`; now, only `armv6m-atomic-hack` itself needs the
build script. Now, the `armv6m-atomic-hack` crate can no longer be
considered annoying.
@hawkw hawkw self-assigned this Feb 28, 2024
hawkw added a commit that referenced this pull request Feb 28, 2024
This branch adds event counters to `host-sp-comms`'s existing 20-element
ringbuffer, so that the total number of events can be tracked. In
particular, we count the total number of each message variant messages
sent and received between the host and SP, and each variant of the
`KeyLookupResult`, `KeySetResult`, and `InventoryResult` messages.

Depends on #1635.
Copy link
Collaborator

@cbiffle cbiffle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@hawkw hawkw merged commit 2f23c58 into master Feb 29, 2024
83 checks passed
@hawkw hawkw deleted the eliza/less-annoying-atomic-hack branch February 29, 2024 00:15
hawkw added a commit that referenced this pull request Mar 13, 2024
This branch adds event counters to `host-sp-comms`'s existing 20-element
ringbuffer, so that the total number of events can be tracked. In
particular, we count the total number of each message variant messages
sent and received between the host and SP, and each variant of the
`KeyLookupResult`, `KeySetResult`, and `InventoryResult` messages.

Depends on #1635.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants