Skip to content

Rollup of 19 pull requests #44649

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

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1ed962b
Fix #43493 (new trace_macros doesn't work if there's an error during …
bjorn3 Aug 25, 2017
878013c
Fix error
bjorn3 Aug 27, 2017
8bb7dba
Dont abort on first macro error
bjorn3 Sep 2, 2017
8b71e0b
Better trace-macro and less span_err_fatal
bjorn3 Sep 2, 2017
30603ee
Fix tidy error
bjorn3 Sep 2, 2017
0a2c95b
Fix test
bjorn3 Sep 3, 2017
cbc9031
ci: introduce haiku x86_64 builder
jessicah Sep 6, 2017
a095ee4
Add class for codeblocks
GuillaumeGomez Sep 6, 2017
9c12e5d
add test
GuillaumeGomez Sep 7, 2017
79f888d
Add arrow and improve display
GuillaumeGomez Sep 9, 2017
c4508e1
Add rustfmt as a submodule
nrc Sep 1, 2017
d0070e8
Build and test Rustfmt
nrc Sep 1, 2017
368cab3
Reviewer changes
nrc Sep 13, 2017
916ccc5
remove overzealous Box<ZeroSizeType> optimization
qmx Sep 13, 2017
313b8f8
Use double quotes to appease some TOML parsers
tamird Sep 12, 2017
49492cb
Update compiler-builtins
tamird Sep 10, 2017
d3c2386
extend E0623 for earlybound and latebound for structs
gaurikholkar Sep 13, 2017
f8df89a
adding ui tests
gaurikholkar Sep 13, 2017
696a268
fix depth for structs
gaurikholkar Sep 14, 2017
9240454
add ui tests for EBR
gaurikholkar Sep 14, 2017
06478d1
rustdoc: pretty-print Unevaluated expressions in types.
eddyb Sep 14, 2017
5229443
Delete fn.rs
gaurikholkar Sep 14, 2017
4253a41
Trim and document compiler-builtins shim
tamird Sep 12, 2017
509982c
Trim and document libc shim
tamird Sep 12, 2017
ed7a7cf
Avoid unnecessary allocas for indirect function arguments
dotdash Sep 14, 2017
2819122
Update cargo submodule
alexcrichton Sep 15, 2017
4fb402c
ci: move dist-x86_64-haiku into disabled.
jessicah Sep 16, 2017
5ff7064
Fix incorrect `into_inner` link in docs.
frewsxcv Sep 16, 2017
06d8118
ci: haiku: rename llvm-config to address tidy issues.
jessicah Sep 16, 2017
3443dd8
ci: haiku: wrap lines as necessary for tidy.
jessicah Sep 16, 2017
474c717
compiletest: print the correct basename of the src dir
RalfJung Sep 16, 2017
83589f2
fix test name being printed twice for ui tests
RalfJung Sep 16, 2017
5cfee9b
ci: Upload/download from a new S3 bucket
alexcrichton Sep 15, 2017
8a11172
stabilized compiler_fences (fixes #41091)
budziq Sep 15, 2017
9a60bb0
Added example to `compiler_fence` docs taken from unstable-book
budziq Sep 15, 2017
5f62c0c
Added more text from unstable-book to `compiler_fence` docs
budziq Sep 16, 2017
b715290
stabilized iterator_for_each (closes #42986)
budziq Sep 15, 2017
0485595
stabilized needs_drop (fixes #41890)
budziq Sep 16, 2017
1cbb2b3
Implement `Arc`/`Rc` raw pointer conversions for `?Sized`
murarth Aug 24, 2017
fcdd46e
Ensure tcp test case passes when disconnected from network
tmerr Sep 17, 2017
badd0bc
Rollup merge of #44073 - murarth:rc-into-raw-unsized, r=alexcrichton
TimNN Sep 17, 2017
cafcdbb
Rollup merge of #44088 - bjorn3:better_trace_macros, r=jseyfried
TimNN Sep 17, 2017
45e4306
Rollup merge of #44381 - jessicah:haiku-ci, r=alexcrichton
TimNN Sep 17, 2017
6ecec1b
Rollup merge of #44397 - GuillaumeGomez:codeblock-color, r=QuietMisdr…
TimNN Sep 17, 2017
334da4a
Rollup merge of #44509 - tamird:remove-rustbuild-feature, r=nikomatsakis
TimNN Sep 17, 2017
16d9204
Rollup merge of #44515 - tamird:clean-shims, r=alexcrichton
TimNN Sep 17, 2017
dbd8763
Rollup merge of #44533 - nrc:rustfmt-submod, r=alexcrichton
TimNN Sep 17, 2017
736010e
Rollup merge of #44549 - gaurikholkar:master, r=arielb1
TimNN Sep 17, 2017
0273ce3
Rollup merge of #44553 - qmx:refactor-remove-overzealous-box-szero-op…
TimNN Sep 17, 2017
a5bc385
Rollup merge of #44562 - eddyb:ugh-rustdoc, r=nikomatsakis
TimNN Sep 17, 2017
a0920b8
Rollup merge of #44567 - budziq:stabilize_iterator_for_each, r=alexcr…
TimNN Sep 17, 2017
353d501
Rollup merge of #44573 - dotdash:dbg_bloat, r=michaelwoerister
TimNN Sep 17, 2017
f01d609
Rollup merge of #44595 - budziq:stabilize_compiler_fences, r=alexcric…
TimNN Sep 17, 2017
0ef6aed
Rollup merge of #44604 - alexcrichton:update-cargo, r=Mark-Simulacrum
TimNN Sep 17, 2017
e781cba
Rollup merge of #44617 - alexcrichton:download-from-us-west-1, r=aidanhs
TimNN Sep 17, 2017
f151622
Rollup merge of #44622 - frewsxcv:frewsxcv-invalid-link, r=QuietMisdr…
TimNN Sep 17, 2017
269dc0f
Rollup merge of #44630 - RalfJung:compiletest, r=Mark-Simulacrum
TimNN Sep 17, 2017
dfbf8e3
Rollup merge of #44639 - budziq:stabilize_needs_drop, r=dtolnay
TimNN Sep 17, 2017
7e08a23
Rollup merge of #44647 - tmerr:fix-44645, r=dtolnay
TimNN Sep 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 0 additions & 106 deletions src/doc/unstable-book/src/library-features/compiler-fences.md

This file was deleted.

59 changes: 54 additions & 5 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1679,10 +1679,14 @@ pub fn fence(order: Ordering) {

/// A compiler memory fence.
///
/// `compiler_fence` does not emit any machine code, but prevents the compiler from re-ordering
/// memory operations across this point. Which reorderings are disallowed is dictated by the given
/// [`Ordering`]. Note that `compiler_fence` does *not* introduce inter-thread memory
/// synchronization; for that, a [`fence`] is needed.
/// `compiler_fence` does not emit any machine code, but restricts the kinds
/// of memory re-ordering the compiler is allowed to do. Specifically, depending on
/// the given [`Ordering`] semantics, the compiler may be disallowed from moving reads
/// or writes from before or after the call to the other side of the call to
/// `compiler_fence`. Note that it does **not** prevent the *hardware*
/// from doing such re-ordering. This is not a problem in a single-threaded,
/// execution context, but when other threads may modify memory at the same
/// time, stronger synchronization primitives such as [`fence`] are required.
///
/// The re-ordering prevented by the different ordering semantics are:
///
Expand All @@ -1691,19 +1695,64 @@ pub fn fence(order: Ordering) {
/// - with [`Acquire`], subsequent reads and writes cannot be moved ahead of preceding reads.
/// - with [`AcqRel`], both of the above rules are enforced.
///
/// `compiler_fence` is generally only useful for preventing a thread from
/// racing *with itself*. That is, if a given thread is executing one piece
/// of code, and is then interrupted, and starts executing code elsewhere
/// (while still in the same thread, and conceptually still on the same
/// core). In traditional programs, this can only occur when a signal
/// handler is registered. In more low-level code, such situations can also
/// arise when handling interrupts, when implementing green threads with
/// pre-emption, etc. Curious readers are encouraged to read the Linux kernel's
/// discussion of [memory barriers].
///
/// # Panics
///
/// Panics if `order` is [`Relaxed`].
///
/// # Examples
///
/// Without `compiler_fence`, the `assert_eq!` in following code
/// is *not* guaranteed to succeed, despite everything happening in a single thread.
/// To see why, remember that the compiler is free to swap the stores to
/// `IMPORTANT_VARIABLE` and `IS_READ` since they are both
/// `Ordering::Relaxed`. If it does, and the signal handler is invoked right
/// after `IS_READY` is updated, then the signal handler will see
/// `IS_READY=1`, but `IMPORTANT_VARIABLE=0`.
/// Using a `compiler_fence` remedies this situation.
///
/// ```
/// use std::sync::atomic::{AtomicBool, AtomicUsize};
/// use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT};
/// use std::sync::atomic::Ordering;
/// use std::sync::atomic::compiler_fence;
///
/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT;
/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT;
///
/// fn main() {
/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed);
/// // prevent earlier writes from being moved beyond this point
/// compiler_fence(Ordering::Release);
/// IS_READY.store(true, Ordering::Relaxed);
/// }
///
/// fn signal_handler() {
/// if IS_READY.load(Ordering::Relaxed) {
/// assert_eq!(IMPORTANT_VARIABLE.load(Ordering::Relaxed), 42);
/// }
/// }
/// ```
///
/// [`fence`]: fn.fence.html
/// [`Ordering`]: enum.Ordering.html
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
/// [`SeqCst`]: enum.Ordering.html#variant.SeqCst
/// [`Release`]: enum.Ordering.html#variant.Release
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
/// [memory barriers]: https://www.kernel.org/doc/Documentation/memory-barriers.txt
#[inline]
#[unstable(feature = "compiler_fences", issue = "41091")]
#[stable(feature = "compiler_fences", since = "1.22.0")]
pub fn compiler_fence(order: Ordering) {
unsafe {
match order {
Expand Down