Skip to content

Commit de1941a

Browse files
authored
Rollup merge of #72998 - poliorcetics:atomic-availability-doc, r=Amanieu
Mention that some atomic operations may not be available on some platforms fixes #54250 This simply adds a line saying the type/function/method may not be available on some platforms, depending on said platform capabilities. I *think* I got them all.
2 parents 1ff0ba0 + 5398456 commit de1941a

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

src/libcore/sync/atomic.rs

+87
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ pub fn spin_loop_hint() {
153153
///
154154
/// This type has the same in-memory representation as a [`bool`].
155155
///
156+
/// **Note**: This type is only available on platforms that support atomic
157+
/// loads and stores of `u8`.
158+
///
156159
/// [`bool`]: ../../../std/primitive.bool.html
157160
#[cfg(target_has_atomic_load_store = "8")]
158161
#[stable(feature = "rust1", since = "1.0.0")]
@@ -178,6 +181,9 @@ unsafe impl Sync for AtomicBool {}
178181
/// A raw pointer type which can be safely shared between threads.
179182
///
180183
/// This type has the same in-memory representation as a `*mut T`.
184+
///
185+
/// **Note**: This type is only available on platforms that support atomic
186+
/// loads and stores of pointers. Its size depends on the target pointer's size.
181187
#[cfg(target_has_atomic_load_store = "ptr")]
182188
#[stable(feature = "rust1", since = "1.0.0")]
183189
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
@@ -447,6 +453,9 @@ impl AtomicBool {
447453
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
448454
/// using [`Release`] makes the load part [`Relaxed`].
449455
///
456+
/// **Note:** This method is only available on platforms that support atomic
457+
/// operations on `u8`.
458+
///
450459
/// [`Ordering`]: enum.Ordering.html
451460
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
452461
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -481,6 +490,9 @@ impl AtomicBool {
481490
/// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
482491
/// happens, and using [`Release`] makes the load part [`Relaxed`].
483492
///
493+
/// **Note:** This method is only available on platforms that support atomic
494+
/// operations on `u8`.
495+
///
484496
/// [`Ordering`]: enum.Ordering.html
485497
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
486498
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -524,6 +536,8 @@ impl AtomicBool {
524536
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
525537
/// and must be equivalent to or weaker than the success ordering.
526538
///
539+
/// **Note:** This method is only available on platforms that support atomic
540+
/// operations on `u8`.
527541
///
528542
/// [`bool`]: ../../../std/primitive.bool.html
529543
/// [`Ordering`]: enum.Ordering.html
@@ -586,6 +600,9 @@ impl AtomicBool {
586600
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
587601
/// and must be equivalent to or weaker than the success ordering.
588602
///
603+
/// **Note:** This method is only available on platforms that support atomic
604+
/// operations on `u8`.
605+
///
589606
/// [`bool`]: ../../../std/primitive.bool.html
590607
/// [`compare_exchange`]: #method.compare_exchange
591608
/// [`Ordering`]: enum.Ordering.html
@@ -646,6 +663,9 @@ impl AtomicBool {
646663
/// [`Release`]: enum.Ordering.html#variant.Release
647664
/// [`Acquire`]: enum.Ordering.html#variant.Acquire
648665
///
666+
/// **Note:** This method is only available on platforms that support atomic
667+
/// operations on `u8`.
668+
///
649669
/// # Examples
650670
///
651671
/// ```
@@ -683,6 +703,9 @@ impl AtomicBool {
683703
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
684704
/// using [`Release`] makes the load part [`Relaxed`].
685705
///
706+
/// **Note:** This method is only available on platforms that support atomic
707+
/// operations on `u8`.
708+
///
686709
/// [`Ordering`]: enum.Ordering.html
687710
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
688711
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -737,6 +760,9 @@ impl AtomicBool {
737760
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
738761
/// using [`Release`] makes the load part [`Relaxed`].
739762
///
763+
/// **Note:** This method is only available on platforms that support atomic
764+
/// operations on `u8`.
765+
///
740766
/// [`Ordering`]: enum.Ordering.html
741767
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
742768
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -779,6 +805,9 @@ impl AtomicBool {
779805
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
780806
/// using [`Release`] makes the load part [`Relaxed`].
781807
///
808+
/// **Note:** This method is only available on platforms that support atomic
809+
/// operations on `u8`.
810+
///
782811
/// [`Ordering`]: enum.Ordering.html
783812
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
784813
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -981,6 +1010,9 @@ impl<T> AtomicPtr<T> {
9811010
/// [`Acquire`] makes the store part of this operation [`Relaxed`], and
9821011
/// using [`Release`] makes the load part [`Relaxed`].
9831012
///
1013+
/// **Note:** This method is only available on platforms that support atomic
1014+
/// operations on pointers.
1015+
///
9841016
/// [`Ordering`]: enum.Ordering.html
9851017
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
9861018
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1017,6 +1049,9 @@ impl<T> AtomicPtr<T> {
10171049
/// Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
10181050
/// happens, and using [`Release`] makes the load part [`Relaxed`].
10191051
///
1052+
/// **Note:** This method is only available on platforms that support atomic
1053+
/// operations on pointers.
1054+
///
10201055
/// [`Ordering`]: enum.Ordering.html
10211056
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
10221057
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1058,6 +1093,9 @@ impl<T> AtomicPtr<T> {
10581093
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
10591094
/// and must be equivalent to or weaker than the success ordering.
10601095
///
1096+
/// **Note:** This method is only available on platforms that support atomic
1097+
/// operations on pointers.
1098+
///
10611099
/// [`Ordering`]: enum.Ordering.html
10621100
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
10631101
/// [`Release`]: enum.Ordering.html#variant.Release
@@ -1118,6 +1156,9 @@ impl<T> AtomicPtr<T> {
11181156
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
11191157
/// and must be equivalent to or weaker than the success ordering.
11201158
///
1159+
/// **Note:** This method is only available on platforms that support atomic
1160+
/// operations on pointers.
1161+
///
11211162
/// [`compare_exchange`]: #method.compare_exchange
11221163
/// [`Ordering`]: enum.Ordering.html
11231164
/// [`Relaxed`]: enum.Ordering.html#variant.Relaxed
@@ -1223,6 +1264,13 @@ macro_rules! atomic_int {
12231264
/// non-atomic types as well as information about the portability of
12241265
/// this type, please see the [module-level documentation].
12251266
///
1267+
/// **Note:** This type is only available on platforms that support
1268+
/// atomic loads and stores of [`
1269+
#[doc = $s_int_type]
1270+
/// `](
1271+
#[doc = $int_ref]
1272+
/// ).
1273+
///
12261274
/// [module-level documentation]: index.html
12271275
#[$stable]
12281276
#[repr(C, align($align))]
@@ -1408,6 +1456,9 @@ of this operation. All ordering modes are possible. Note that using
14081456
[`Acquire`] makes the store part of this operation [`Relaxed`], and
14091457
using [`Release`] makes the load part [`Relaxed`].
14101458
1459+
**Note**: This method is only available on platforms that support atomic
1460+
operations on [`", $s_int_type, "`](", $int_ref, ").
1461+
14111462
[`Ordering`]: enum.Ordering.html
14121463
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
14131464
[`Release`]: enum.Ordering.html#variant.Release
@@ -1444,6 +1495,9 @@ might fail and hence just perform an `Acquire` load, but not have `Release` sema
14441495
Using [`Acquire`] makes the store part of this operation [`Relaxed`] if it
14451496
happens, and using [`Release`] makes the load part [`Relaxed`].
14461497
1498+
**Note**: This method is only available on platforms that support atomic
1499+
operations on [`", $s_int_type, "`](", $int_ref, ").
1500+
14471501
[`Ordering`]: enum.Ordering.html
14481502
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
14491503
[`Release`]: enum.Ordering.html#variant.Release
@@ -1496,6 +1550,9 @@ of this operation [`Relaxed`], and using [`Release`] makes the successful load
14961550
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
14971551
and must be equivalent to or weaker than the success ordering.
14981552
1553+
**Note**: This method is only available on platforms that support atomic
1554+
operations on [`", $s_int_type, "`](", $int_ref, ").
1555+
14991556
[`Ordering`]: enum.Ordering.html
15001557
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
15011558
[`Release`]: enum.Ordering.html#variant.Release
@@ -1558,6 +1615,9 @@ and must be equivalent to or weaker than the success ordering.
15581615
[`Acquire`]: enum.Ordering.html#variant.Acquire
15591616
[`SeqCst`]: enum.Ordering.html#variant.SeqCst
15601617
1618+
**Note**: This method is only available on platforms that support atomic
1619+
operations on [`", $s_int_type, "`](", $int_ref, ").
1620+
15611621
# Examples
15621622
15631623
```
@@ -1599,6 +1659,9 @@ of this operation. All ordering modes are possible. Note that using
15991659
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16001660
using [`Release`] makes the load part [`Relaxed`].
16011661
1662+
**Note**: This method is only available on platforms that support atomic
1663+
operations on [`", $s_int_type, "`](", $int_ref, ").
1664+
16021665
[`Ordering`]: enum.Ordering.html
16031666
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16041667
[`Release`]: enum.Ordering.html#variant.Release
@@ -1632,6 +1695,9 @@ of this operation. All ordering modes are possible. Note that using
16321695
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16331696
using [`Release`] makes the load part [`Relaxed`].
16341697
1698+
**Note**: This method is only available on platforms that support atomic
1699+
operations on [`", $s_int_type, "`](", $int_ref, ").
1700+
16351701
[`Ordering`]: enum.Ordering.html
16361702
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16371703
[`Release`]: enum.Ordering.html#variant.Release
@@ -1668,6 +1734,9 @@ of this operation. All ordering modes are possible. Note that using
16681734
[`Acquire`] makes the store part of this operation [`Relaxed`], and
16691735
using [`Release`] makes the load part [`Relaxed`].
16701736
1737+
**Note**: This method is only available on platforms that support atomic
1738+
operations on [`", $s_int_type, "`](", $int_ref, ").
1739+
16711740
[`Ordering`]: enum.Ordering.html
16721741
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
16731742
[`Release`]: enum.Ordering.html#variant.Release
@@ -1704,6 +1773,9 @@ of this operation. All ordering modes are possible. Note that using
17041773
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17051774
using [`Release`] makes the load part [`Relaxed`].
17061775
1776+
**Note**: This method is only available on platforms that support atomic
1777+
operations on [`", $s_int_type, "`](", $int_ref, ").
1778+
17071779
[`Ordering`]: enum.Ordering.html
17081780
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17091781
[`Release`]: enum.Ordering.html#variant.Release
@@ -1741,6 +1813,9 @@ of this operation. All ordering modes are possible. Note that using
17411813
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17421814
using [`Release`] makes the load part [`Relaxed`].
17431815
1816+
**Note**: This method is only available on platforms that support atomic
1817+
operations on [`", $s_int_type, "`](", $int_ref, ").
1818+
17441819
[`Ordering`]: enum.Ordering.html
17451820
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17461821
[`Release`]: enum.Ordering.html#variant.Release
@@ -1777,6 +1852,9 @@ of this operation. All ordering modes are possible. Note that using
17771852
[`Acquire`] makes the store part of this operation [`Relaxed`], and
17781853
using [`Release`] makes the load part [`Relaxed`].
17791854
1855+
**Note**: This method is only available on platforms that support atomic
1856+
operations on [`", $s_int_type, "`](", $int_ref, ").
1857+
17801858
[`Ordering`]: enum.Ordering.html
17811859
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
17821860
[`Release`]: enum.Ordering.html#variant.Release
@@ -1819,6 +1897,9 @@ of this operation [`Relaxed`], and using [`Release`] makes the final successful
18191897
[`Relaxed`]. The (failed) load ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
18201898
and must be equivalent to or weaker than the success ordering.
18211899
1900+
**Note**: This method is only available on platforms that support atomic
1901+
operations on [`", $s_int_type, "`](", $int_ref, ").
1902+
18221903
[`bool`]: ../../../std/primitive.bool.html
18231904
[`compare_exchange`]: #method.compare_exchange
18241905
[`Ordering`]: enum.Ordering.html
@@ -1870,6 +1951,9 @@ of this operation. All ordering modes are possible. Note that using
18701951
[`Acquire`] makes the store part of this operation [`Relaxed`], and
18711952
using [`Release`] makes the load part [`Relaxed`].
18721953
1954+
**Note**: This method is only available on platforms that support atomic
1955+
operations on [`", $s_int_type, "`](", $int_ref, ").
1956+
18731957
[`Ordering`]: enum.Ordering.html
18741958
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
18751959
[`Release`]: enum.Ordering.html#variant.Release
@@ -1917,6 +2001,9 @@ of this operation. All ordering modes are possible. Note that using
19172001
[`Acquire`] makes the store part of this operation [`Relaxed`], and
19182002
using [`Release`] makes the load part [`Relaxed`].
19192003
2004+
**Note**: This method is only available on platforms that support atomic
2005+
operations on [`", $s_int_type, "`](", $int_ref, ").
2006+
19202007
[`Ordering`]: enum.Ordering.html
19212008
[`Relaxed`]: enum.Ordering.html#variant.Relaxed
19222009
[`Release`]: enum.Ordering.html#variant.Release

0 commit comments

Comments
 (0)