-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add AtomicI32
and AtomicU32
.
#1000
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
Conversation
Would be nice if |
Implemented at rust-lang/rust#23572 +1 @eddyb Any sort of trait bound we need to place on X for that? I like this idea. |
@Manishearth well, yes, you'd use a trait that you implement only for a few types. |
So would this trait be implementable on external types? Eg one might want to slap the trait onto our wrapping types -- would that (could it?) be possible? What methods would one need to provide, if any? |
@Manishearth well, if that's allowed then it has to be |
|
||
# Drawbacks | ||
|
||
More wrappers for what should simply be freestanding functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an alternative in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Such freestanding functions would have to be intrinsics (not wrappers) and would have to be unsafe.
Two worries I've had about Specifically on the topic of @mahkoh could you investigate the story here a bit more? I'm curious if committing to these 32-bits would hurt our portability in any way, and if so it should be mentioned in the RFC. |
You're not allowing people to
in 1.0 stable. You're the one who is forcing this commitment on the standard library by making it the only place where atomics can be implemented.
This isn't javascript. If you want Rust to be called a systems language (and with the lack of inline assembly that's already a stretch) then you have to allow people to write non-portable code. It's pretty amazing that the only way to do this right now is to link to non-Rust code. |
I think by this you mean that we are being conservative with respect to what we include in 1.0. I don't really see a problem with that. No 1.0 release is meant to be all things to all people (or, at least, no 1.0 release that ever actually gets shipped). We'll expand capabilities over time, but I don't see why we should commit too early to assembly or intrinsics. That said, it seems obvious that we will want 32-bit atomics in the stdlib at some point. And while I would like to support 16-bit CPUs to the extent we can, I don't want to let the perfect be the enemy of the good either. 16-bit CPUs seem like a distinctly more specialized market that 32-bit or 64-bit, so it feels a bit silly to limit libstd to just those things that a 16-bit CPU can support natively. |
@alexcrichton is there some known reasoning for backing Actually, |
The only reason I know of is that it's basically just the way it's always been. I do not know of the implications of supporting atomic intrinsics that operate on bytes, but it would probably just require some |
@alexcrichton If we really care about portability to those platforms, we probably have to distinguish between |
I expect an RFC to thoroughly explore the design space and constraints of what it is proposing to understand the tradeoffs associated with it. I'm only requesting that this topic be investigated and mentioned for completeness, I do not want to block additions to the standard library on the basis of 16-bit support. |
Just throwing out that AtomicU32 could still be present on 16bit systems by using a lock of some sort on those systems. |
@carllerche I'm inclined to disagree. That assumes that such a lock is possible to implement. A hardware DMA will ignore a CPU lock, and may get an inconsistent view of a U32 if it takes multiple transactions to store the U32 in memory. This seems contrary to expectation when working with "atomic" types. On the other hand, a 16-bit write would be atomic even to a DMA when all 16 bits can be written in a single memory transaction. |
Most/all 16-bit usize platforms are single processor, which means they can implement any sort of atomics (by disabling interrupts if in kernel space or by completing the operation in the kernel before switching tasks if in user space). This doesn't work if you are in user space and the kernel can't be modified and doesn't support atomic emulation, but that seems unlikely considering that a system with <64K RAM can't really run any complex off the shelf kernel. It's not atomic WRT MMIO devices, but that doesn't matter for portable code. |
Chill the hell out; this attitude is not welcome. You've been warned about it many times in the past. And don't think I forgot about your pointless name squatting on crates.io. You seem to go out of your way to antagonize the Rust developers and community whenever you find a minor, fixable bug that annoys you personally. Unfortunately the precedent is that the code of conduct can't really be enforced against a regular contributor. I hope the core team has learned from these past mistakes and will handle the present situation differently. Until I see evidence of that, about all I can do is speak up in public. Please spare me any lectures on the impropriety of addressing this in the open. Edit: Wow, I didn't even see #1007 when I wrote this comment. |
This kind of language might work on your children, but it doesn't work on people
Too bad. If you wanted a code of conduct that can actually be enforced, you Such a CoC cannot be enforced in anything but the most extreme cases without
That's right, by sliding this topic into an off-topic discussion, you're
Then there is this paragraph:
Which is nothing but the golden mean fallacy.
If you think that I am against people speaking their minds publicly then you The team is currently applying a policy never to offend anyone, never to call Of course, you think that you're without fault here and that, as long as If this happens often enough, then the goodwill gets used up and people will
"You're treating your volunteers like shit" is not an overstatement. And when @alexcrichton posts bullshit like telling me to "investigate" the Now go ahead and "enforce the CoC." I've said everything I had to say. |
Lay off. This is like the fallacious "Giving you freedom to do X violates my freedom to not be surrounded by people who do X" argument that's seen often these days. kmc is pointing out behavior they find unwanted, which is totally okay. There's no ad hominem or anything there.
I've said this multiple times before, and I'll say it again: In my experience, having civility rules is less harmful in the long run than not. More details here if you want something to back that assertion up. If the CoC is changed so that civility is no longer expected on Rust projects, I will be leaving. So will others, afaict. I also feel that it and its execution can be improved, but that's tangential.
Which is why one should be pretty clear on the Internet. You have a tendency of not doing so, though this has improved lately :)
Your example shows that huon asked for a test, which you didn't provide, and later closed the issue yourself. FWIW it's hard to keep track of issues and PRs, and stuff does get missed often. Now with the assignee system hopefully that's less of an issue, but it may still happen. Just ping someone in IRC for review, or on the issue.
This actually happens all the time. Your PR is not an example of this.
Your title is vague and addresses the wrong issue. It is unclear what you want done about it; and you should open a different issue if the underlying issue has changed. Nothing passive aggressive about that. It's harder to find duplicates and triage when issues have misleading/vague names.
That sounds like a mistake in the acceptance; that the RfC was accepted prematurely. This can happen -- just because an RfC is accepted doesn't mean that we should turn a deaf ear to new doubts on the design. It's hard to gauge when an RfC has reached its saturation in doubts raised; just seems like more people noticed the PR than noticed the RfC. Meh.
What discussion? I see pages of discussion on that page, along with more pages on the original RfC. The core team tries to gauge consensus on the RfC (from what I've seen this is in IRC or in the weekly meetings, both of which are publicly logged), and I don't think they vote. Aaron's comment gives a pretty good idea of how they gauged consensus.
No, he's right. It is a portability issue. It's not one which might block the RfC, but it's one which should be considered. Your arguments about this being a systems language are a straw man -- Rust does support these atomics via intrinsics, but not stable Rust. Stable 1.0 Rust was never meant to be all the things. But once you mark something as
I read that as "Don't assume malice on my part -- I may be assuming malice on your part" It doesn't really matter who was originally at fault, causing the other party to get antagonized. What matters is that everyone should just calm down, stop assuming malice on any side, and try to be more precise in their communications. Can we get back to writing code and being awesome, please? |
OK, woah, things seem to have gotten rather out of control here. I think we should all take a step back for a second. @mahkoh, I'm sorry that you decided to close this RFC. I wanted to see it land, since it seems clear that there will be a need for With respect to prioritization and PRs that sit for some time, I know it's frustrating, but delays do happen. I certainly acknowledge that I have been guilty of letting RFCs and things sit in the past (and in the present). We all have a lot of demands on our time and we're trying to pull a release together; this can lead to things being overlooked or deprioritized. It's unfortunate but true. To some extent, this is just a fact of life, but we've also been thinking it would be good to tweak our decision-making process to help it scale better. We have actually been working for some time now on a revised "governance proposal" that we plan to bring forward soon, though certainly not till after the beta period is over (we've got other things to focus on right now). I'd like to also respond briefly regarding transparency. The reason that the core team does not write out votes when writing about a final decision is fairly simple: there aren't any. The core team discussion is not about "new" analysis; rather, we try to focus on the pros/cons that were raised in the discussion, and be sure that every objection was satisfactorily addressed (we also don't vote; we operate on a consensus-based model). If we do uncover new objections, then we write those in the thread and postpone making a decision until there has been a chance to respond. In other words, the discussion takes place in public -- even private IRC discussions should be transposed into the RFC so that they can be commented on. This hasn't always been the case, but we've been working pretty hard on it, and I think it's been working pretty well: I know that the quality of the RFCs has risen due to the increased community feedback. Finally, regarding the code of conduct. I am a firm believer in the principle that, in most technical debates, there is no single right answer, and that every decision involves tradeoffs. I think that the Rust language itself is really based in this principle, which is why we frequently surface implementation decisions (like what memory management strategy to use) up to the programmer, rather than offering a single "one size fits all" abstraction. The goal of design discussions therefore is to uncover and understand these tradeoffs, and find the way that we can cover as many of them as we can without undue complexity. This goal is best aided by having a welcoming, diverse community, and the Code of Conduct is an important part of making that happen. That said, I tend to agree that the Code of Conduct as written is somewhat incomplete. It lays out the principles that we want but is relatively silent on the topic of how it is to be enforced. To address this, the "governance proposal" I discussed is intended to include an enforcement plan that will hopefully clarify such matters. Perhaps we can save further dissection of the CoC's language until then. PS. I nominate "write code and and be awesome" as official Rust slogan. |
No description provided.