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 cfg_has_atomic_x public #133

Closed
Finomnis opened this issue Dec 1, 2023 · 5 comments
Closed

Make cfg_has_atomic_x public #133

Finomnis opened this issue Dec 1, 2023 · 5 comments
Labels
C-enhancement Category: A new feature or an improvement for an existing one

Comments

@Finomnis
Copy link

Finomnis commented Dec 1, 2023

Quote from the library:

// Not public API. (please submit an issue if you want this to be public API)

Rationale

I have a library crate that wants to

impl MyTrait for AtomicU8 { /* ... */ }
impl MyTrait for AtomicU16 { /* ... */ }
impl MyTrait for AtomicU32 { /* ... */ }
impl MyTrait for AtomicU64 { /* ... */ }

The problem is that one of the target architectures does not support AtomicU64 by default, and as a lib I shouldn't enable any features of portable-atomic. So I get the compiler error that AtomicU64 does not exist.

I need a cfg detection of whether or not a specific atomic exists, so I can disable impls for unavailable atomic types.

@Finomnis Finomnis changed the title Make cfg_has_atomic_64 public Make cfg_has_atomic_x public Dec 1, 2023
@taiki-e
Copy link
Owner

taiki-e commented Dec 2, 2023

Thanks for the request. I'm open to making them public, but I have one question.

one of the target architectures does not support AtomicU64 by default

At first glance, your use case seems to always require AtomicU64, why have you disabled the enabled by default fallback feature? If it is enabled, AtomicU64 should be provided except for one exception (mipsel-psx).

@Finomnis
Copy link
Author

Finomnis commented Dec 2, 2023

It's more in the line of : my function can receive any atomic integer. And I'm trying to model this by introducing a trait for it. So I don't "require all atomics", instead I would like to "support all existing atomics".
I did try the "fallback" feature, but AtomicU64 still wasn't available at thumbv6m-none-eabi. But again, I don't require it, I just want to support it if it's available without forcing flags on the user.

@taiki-e
Copy link
Owner

taiki-e commented Dec 3, 2023

I did try the "fallback" feature, but AtomicU64 still wasn't available at thumbv6m-none-eabi.

Your code used fetch_add (which is not available in thumbv6m by default), so I was wondering if you enabled critical-section or single-core related features, otherwise AtomicU64 is indeed not provided even with fallback feature enabled.

@taiki-e taiki-e closed this as completed in 0074816 Dec 3, 2023
taiki-e added a commit that referenced this issue Dec 3, 2023
@taiki-e taiki-e added the C-enhancement Category: A new feature or an improvement for an existing one label Dec 3, 2023
taiki-e added a commit that referenced this issue Dec 3, 2023
@Finomnis
Copy link
Author

Finomnis commented Dec 3, 2023

Thanks <3

@taiki-e
Copy link
Owner

taiki-e commented Dec 6, 2023

Published in 1.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A new feature or an improvement for an existing one
Projects
None yet
Development

No branches or pull requests

2 participants