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

Tracking issue for atomic_mut_ptr #66893

Closed
5 of 6 tasks
KodrAus opened this issue Nov 30, 2019 · 11 comments · Fixed by #108419
Closed
5 of 6 tasks

Tracking issue for atomic_mut_ptr #66893

KodrAus opened this issue Nov 30, 2019 · 11 comments · Fixed by #108419
Labels
A-concurrency Area: Concurrency A-raw-pointers Area: raw pointers, MaybeUninit, NonNull B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@KodrAus
Copy link
Contributor

KodrAus commented Nov 30, 2019

This is a tracking issue foratomic_mut_ptr.

Public API

impl AtomicBool {
    pub const fn as_ptr(&self) -> *mut bool;
}

impl AtomicI32 {
    pub const fn as_ptr(&self) -> *mut i32;
}

// … etc.

impl<T> AtomicPtr<T> {
    pub const fn as_ptr(&self) -> *mut *mut T;
}

Steps / History

@KodrAus KodrAus added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Nov 30, 2019
@JohnTitor JohnTitor added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Feb 28, 2020
@nox
Copy link
Contributor

nox commented Apr 17, 2020

Any use of the returned raw pointer requires an unsafe block and still has to uphold the same restriction: operations on it must be atomic.

I'm not sure this is phrased as best as it could in the documentation, in the sense that callers are definitely allowed to do non-atomic accesses to the underlying value, but they must do so only if they can guarantee that absolutely no other thread will observe a non-atomic access. Does that make sense?

@KodrAus KodrAus added A-concurrency Area: Concurrency Libs-Tracked Libs issues that are tracked on the team's project board. A-raw-pointers Area: raw pointers, MaybeUninit, NonNull labels Jul 29, 2020
@m-ou-se
Copy link
Member

m-ou-se commented Nov 1, 2020

This should probably also be added to AtomicPtr, for consistency between the Atomic* types.

JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Jan 14, 2023
@tgross35
Copy link
Contributor

tgross35 commented Feb 5, 2023

@KodrAus are there any concerns about stabilizing this feature? If not, could we go ahead with the stabilization PR?

@tgross35
Copy link
Contributor

tgross35 commented Feb 5, 2023

Actually I have one addition - this could be const with no problem, which would make it easier to use with FFI statics. (opened #107706 for this)

@m-ou-se
Copy link
Member

m-ou-se commented Feb 6, 2023

I'm wondering if it should just be as_ptr instead of as_mut_ptr. Cell<T> also has a as_ptr() that returns a *mut T.

@tgross35
Copy link
Contributor

tgross35 commented Feb 6, 2023

Yeah, that's a good point. I don't think there are many cases where a separate as_ptr and as_mut_ptr make sense, since you'd always prefer to just .load(...) the data if you don't need to change it.

Would this naming change require a FCP?

Edit: created #107736 to discuss

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 6, 2023
Mark 'atomic_mut_ptr' methods const

There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts

Related tracking issue: rust-lang#66893
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 7, 2023
Mark 'atomic_mut_ptr' methods const

There's nothing that would block these methods from being const (just an UnsafeCell get), and it would be helpful for FFI interfaces in static contexts

Related tracking issue: rust-lang#66893
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 10, 2023
 Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref rust-lang#66893)

Originally discussed in rust-lang#66893 (comment)

~~This uses rust-lang#107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased

`@rustbot` label +T-libs-api
r? m-ou-se
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 22, 2023
 Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref rust-lang#66893)

Originally discussed in rust-lang#66893 (comment)

~~This uses rust-lang#107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased

`@rustbot` label +T-libs-api
r? m-ou-se
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 22, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#107736 ( Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref rust-lang#66893) )
 - rust-lang#108176 (Don't delay `ReError` bug during lexical region resolve)
 - rust-lang#108315 (Lint dead code in closures and generators)
 - rust-lang#108342 (apply query response: actually define opaque types)
 - rust-lang#108344 (Fix test filename for rust-lang#105700)
 - rust-lang#108353 (resolve: Remove `ImportResolver`)

Failed merges:

 - rust-lang#107911 (Add check for invalid #[macro_export] arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
@tgross35
Copy link
Contributor

I don't think there's too much debate about anything here, so I opened #108419 to stabilize it

@m-ou-se
Copy link
Member

m-ou-se commented Feb 28, 2023

@rfcbot merge

@rfcbot
Copy link

rfcbot commented Feb 28, 2023

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Feb 28, 2023
@rfcbot
Copy link

rfcbot commented Feb 28, 2023

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Mar 10, 2023
@rfcbot
Copy link

rfcbot commented Mar 10, 2023

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 13, 2023
Stabilize `atomic_as_ptr`

Fixes rust-lang#66893

This stabilizes the `as_ptr` methods for atomics. The stabilization feature gate used here is `atomic_as_ptr` which supersedes `atomic_mut_ptr` to match the change in rust-lang#107736.

This needs FCP.

New stable API:

```rust
impl AtomicBool {
    pub const fn as_ptr(&self) -> *mut bool;
}

impl AtomicI32 {
    pub const fn as_ptr(&self) -> *mut i32;
}

// Includes all other atomic types

impl<T> AtomicPtr<T> {
    pub const fn as_ptr(&self) -> *mut *mut T;
}
```

r? libs-api
`@rustbot` label +needs-fcp
@bors bors closed this as completed in e670379 Mar 14, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Mar 23, 2023
thomcc pushed a commit to tcdi/postgrestd that referenced this issue May 31, 2023
thomcc pushed a commit to tcdi/postgrestd that referenced this issue May 31, 2023
 Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893)

Originally discussed in rust-lang/rust#66893 (comment)

~~This uses #107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased

`@rustbot` label +T-libs-api
r? m-ou-se
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency A-raw-pointers Area: raw pointers, MaybeUninit, NonNull B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants