Skip to content

Commit 817d6a0

Browse files
committed
Add a **Note**: comment in documentation when the type/method/function is not always available
1 parent 3d5d0f8 commit 817d6a0

File tree

1 file changed

+70
-13
lines changed

1 file changed

+70
-13
lines changed

src/libcore/sync/atomic.rs

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ pub fn spin_loop_hint() {
153153
///
154154
/// This type has the same in-memory representation as a [`bool`].
155155
///
156+
/// **Note**: This type may not be available on some platforms.
157+
///
156158
/// [`bool`]: ../../../std/primitive.bool.html
157159
#[cfg(target_has_atomic_load_store = "8")]
158160
#[stable(feature = "rust1", since = "1.0.0")]
@@ -178,6 +180,9 @@ unsafe impl Sync for AtomicBool {}
178180
/// A raw pointer type which can be safely shared between threads.
179181
///
180182
/// This type has the same in-memory representation as a `*mut T`.
183+
///
184+
/// **Note**: This type may not be available on some platforms. Its size depends
185+
/// on the target pointer's size.
181186
#[cfg(target_has_atomic_load_store = "ptr")]
182187
#[stable(feature = "rust1", since = "1.0.0")]
183188
#[cfg_attr(target_pointer_width = "16", repr(C, align(2)))]
@@ -462,6 +467,8 @@ impl AtomicBool {
462467
/// assert_eq!(some_bool.swap(false, Ordering::Relaxed), true);
463468
/// assert_eq!(some_bool.load(Ordering::Relaxed), false);
464469
/// ```
470+
///
471+
/// **Note**: This method may not be available on some platforms.
465472
#[inline]
466473
#[stable(feature = "rust1", since = "1.0.0")]
467474
#[cfg(target_has_atomic = "8")]
@@ -501,6 +508,8 @@ impl AtomicBool {
501508
/// assert_eq!(some_bool.compare_and_swap(true, true, Ordering::Relaxed), false);
502509
/// assert_eq!(some_bool.load(Ordering::Relaxed), false);
503510
/// ```
511+
///
512+
/// **Note**: This method may not be available on some platforms.
504513
#[inline]
505514
#[stable(feature = "rust1", since = "1.0.0")]
506515
#[cfg(target_has_atomic = "8")]
@@ -552,6 +561,8 @@ impl AtomicBool {
552561
/// Err(false));
553562
/// assert_eq!(some_bool.load(Ordering::Relaxed), false);
554563
/// ```
564+
///
565+
/// **Note**: This method may not be available on some platforms.
555566
#[inline]
556567
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
557568
#[cfg(target_has_atomic = "8")]
@@ -610,6 +621,8 @@ impl AtomicBool {
610621
/// }
611622
/// }
612623
/// ```
624+
///
625+
/// **Note**: This method may not be available on some platforms.
613626
#[inline]
614627
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
615628
#[cfg(target_has_atomic = "8")]
@@ -663,6 +676,8 @@ impl AtomicBool {
663676
/// assert_eq!(foo.fetch_and(false, Ordering::SeqCst), false);
664677
/// assert_eq!(foo.load(Ordering::SeqCst), false);
665678
/// ```
679+
///
680+
/// **Note**: This method may not be available on some platforms.
666681
#[inline]
667682
#[stable(feature = "rust1", since = "1.0.0")]
668683
#[cfg(target_has_atomic = "8")]
@@ -706,6 +721,8 @@ impl AtomicBool {
706721
/// assert_eq!(foo.fetch_nand(false, Ordering::SeqCst), false);
707722
/// assert_eq!(foo.load(Ordering::SeqCst), true);
708723
/// ```
724+
///
725+
/// **Note**: This method may not be available on some platforms.
709726
#[inline]
710727
#[stable(feature = "rust1", since = "1.0.0")]
711728
#[cfg(target_has_atomic = "8")]
@@ -759,6 +776,8 @@ impl AtomicBool {
759776
/// assert_eq!(foo.fetch_or(false, Ordering::SeqCst), false);
760777
/// assert_eq!(foo.load(Ordering::SeqCst), false);
761778
/// ```
779+
///
780+
/// **Note**: This method may not be available on some platforms.
762781
#[inline]
763782
#[stable(feature = "rust1", since = "1.0.0")]
764783
#[cfg(target_has_atomic = "8")]
@@ -801,6 +820,8 @@ impl AtomicBool {
801820
/// assert_eq!(foo.fetch_xor(false, Ordering::SeqCst), false);
802821
/// assert_eq!(foo.load(Ordering::SeqCst), false);
803822
/// ```
823+
///
824+
/// **Note**: This method may not be available on some platforms.
804825
#[inline]
805826
#[stable(feature = "rust1", since = "1.0.0")]
806827
#[cfg(target_has_atomic = "8")]
@@ -998,6 +1019,8 @@ impl<T> AtomicPtr<T> {
9981019
///
9991020
/// let value = some_ptr.swap(other_ptr, Ordering::Relaxed);
10001021
/// ```
1022+
///
1023+
/// **Note**: This method may not be available on some platforms.
10011024
#[inline]
10021025
#[stable(feature = "rust1", since = "1.0.0")]
10031026
#[cfg(target_has_atomic = "ptr")]
@@ -1035,6 +1058,8 @@ impl<T> AtomicPtr<T> {
10351058
///
10361059
/// let value = some_ptr.compare_and_swap(ptr, other_ptr, Ordering::Relaxed);
10371060
/// ```
1061+
///
1062+
/// **Note**: This method may not be available on some platforms.
10381063
#[inline]
10391064
#[stable(feature = "rust1", since = "1.0.0")]
10401065
#[cfg(target_has_atomic = "ptr")]
@@ -1077,6 +1102,8 @@ impl<T> AtomicPtr<T> {
10771102
/// let value = some_ptr.compare_exchange(ptr, other_ptr,
10781103
/// Ordering::SeqCst, Ordering::Relaxed);
10791104
/// ```
1105+
///
1106+
/// **Note**: This method may not be available on some platforms.
10801107
#[inline]
10811108
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
10821109
#[cfg(target_has_atomic = "ptr")]
@@ -1141,6 +1168,8 @@ impl<T> AtomicPtr<T> {
11411168
/// }
11421169
/// }
11431170
/// ```
1171+
///
1172+
/// **Note**: This method may not be available on some platforms.
11441173
#[inline]
11451174
#[stable(feature = "extended_compare_and_swap", since = "1.10.0")]
11461175
#[cfg(target_has_atomic = "ptr")]
@@ -1223,6 +1252,8 @@ macro_rules! atomic_int {
12231252
/// non-atomic types as well as information about the portability of
12241253
/// this type, please see the [module-level documentation].
12251254
///
1255+
/// **Note**: This type may not be available on some platforms.
1256+
///
12261257
/// [module-level documentation]: index.html
12271258
#[$stable]
12281259
#[repr(C, align($align))]
@@ -1421,7 +1452,9 @@ using [`Release`] makes the load part [`Relaxed`].
14211452
let some_var = ", stringify!($atomic_type), "::new(5);
14221453
14231454
assert_eq!(some_var.swap(10, Ordering::Relaxed), 5);
1424-
```"),
1455+
```
1456+
1457+
**Note**: This method may not be available on some platforms."),
14251458
#[inline]
14261459
#[$stable]
14271460
#[$cfg_cas]
@@ -1462,7 +1495,9 @@ assert_eq!(some_var.load(Ordering::Relaxed), 10);
14621495
14631496
assert_eq!(some_var.compare_and_swap(6, 12, Ordering::Relaxed), 10);
14641497
assert_eq!(some_var.load(Ordering::Relaxed), 10);
1465-
```"),
1498+
```
1499+
1500+
**Note**: This method may not be available on some platforms."),
14661501
#[inline]
14671502
#[$stable]
14681503
#[$cfg_cas]
@@ -1520,7 +1555,9 @@ assert_eq!(some_var.compare_exchange(6, 12,
15201555
Ordering::Acquire),
15211556
Err(10));
15221557
assert_eq!(some_var.load(Ordering::Relaxed), 10);
1523-
```"),
1558+
```
1559+
1560+
**Note**: This method may not be available on some platforms."),
15241561
#[inline]
15251562
#[$stable_cxchg]
15261563
#[$cfg_cas]
@@ -1573,7 +1610,9 @@ loop {
15731610
Err(x) => old = x,
15741611
}
15751612
}
1576-
```"),
1613+
```
1614+
1615+
**Note**: This method may not be available on some platforms."),
15771616
#[inline]
15781617
#[$stable_cxchg]
15791618
#[$cfg_cas]
@@ -1612,7 +1651,9 @@ using [`Release`] makes the load part [`Relaxed`].
16121651
let foo = ", stringify!($atomic_type), "::new(0);
16131652
assert_eq!(foo.fetch_add(10, Ordering::SeqCst), 0);
16141653
assert_eq!(foo.load(Ordering::SeqCst), 10);
1615-
```"),
1654+
```
1655+
1656+
**Note**: This method may not be available on some platforms."),
16161657
#[inline]
16171658
#[$stable]
16181659
#[$cfg_cas]
@@ -1645,7 +1686,9 @@ using [`Release`] makes the load part [`Relaxed`].
16451686
let foo = ", stringify!($atomic_type), "::new(20);
16461687
assert_eq!(foo.fetch_sub(10, Ordering::SeqCst), 20);
16471688
assert_eq!(foo.load(Ordering::SeqCst), 10);
1648-
```"),
1689+
```
1690+
1691+
**Note**: This method may not be available on some platforms."),
16491692
#[inline]
16501693
#[$stable]
16511694
#[$cfg_cas]
@@ -1681,7 +1724,9 @@ using [`Release`] makes the load part [`Relaxed`].
16811724
let foo = ", stringify!($atomic_type), "::new(0b101101);
16821725
assert_eq!(foo.fetch_and(0b110011, Ordering::SeqCst), 0b101101);
16831726
assert_eq!(foo.load(Ordering::SeqCst), 0b100001);
1684-
```"),
1727+
```
1728+
1729+
**Note**: This method may not be available on some platforms."),
16851730
#[inline]
16861731
#[$stable]
16871732
#[$cfg_cas]
@@ -1718,7 +1763,9 @@ use std::sync::atomic::{", stringify!($atomic_type), ", Ordering};
17181763
let foo = ", stringify!($atomic_type), "::new(0x13);
17191764
assert_eq!(foo.fetch_nand(0x31, Ordering::SeqCst), 0x13);
17201765
assert_eq!(foo.load(Ordering::SeqCst), !(0x13 & 0x31));
1721-
```"),
1766+
```
1767+
1768+
**Note**: This method may not be available on some platforms."),
17221769
#[inline]
17231770
#[$stable_nand]
17241771
#[$cfg_cas]
@@ -1754,7 +1801,9 @@ using [`Release`] makes the load part [`Relaxed`].
17541801
let foo = ", stringify!($atomic_type), "::new(0b101101);
17551802
assert_eq!(foo.fetch_or(0b110011, Ordering::SeqCst), 0b101101);
17561803
assert_eq!(foo.load(Ordering::SeqCst), 0b111111);
1757-
```"),
1804+
```
1805+
1806+
**Note**: This method may not be available on some platforms."),
17581807
#[inline]
17591808
#[$stable]
17601809
#[$cfg_cas]
@@ -1790,7 +1839,9 @@ using [`Release`] makes the load part [`Relaxed`].
17901839
let foo = ", stringify!($atomic_type), "::new(0b101101);
17911840
assert_eq!(foo.fetch_xor(0b110011, Ordering::SeqCst), 0b101101);
17921841
assert_eq!(foo.load(Ordering::SeqCst), 0b011110);
1793-
```"),
1842+
```
1843+
1844+
**Note**: This method may not be available on some platforms."),
17941845
#[inline]
17951846
#[$stable]
17961847
#[$cfg_cas]
@@ -1837,7 +1888,9 @@ assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |_| None), Err(7))
18371888
assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(7));
18381889
assert_eq!(x.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| Some(x + 1)), Ok(8));
18391890
assert_eq!(x.load(Ordering::SeqCst), 9);
1840-
```"),
1891+
```
1892+
1893+
**Note**: This method may not be available on some platforms."),
18411894
#[inline]
18421895
#[stable(feature = "no_more_cas", since = "1.45.0")]
18431896
#[$cfg_cas]
@@ -1894,7 +1947,9 @@ let foo = ", stringify!($atomic_type), "::new(23);
18941947
let bar = 42;
18951948
let max_foo = foo.fetch_max(bar, Ordering::SeqCst).max(bar);
18961949
assert!(max_foo == 42);
1897-
```"),
1950+
```
1951+
1952+
**Note**: This method may not be available on some platforms."),
18981953
#[inline]
18991954
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19001955
#[$cfg_cas]
@@ -1943,7 +1998,9 @@ let foo = ", stringify!($atomic_type), "::new(23);
19431998
let bar = 12;
19441999
let min_foo = foo.fetch_min(bar, Ordering::SeqCst).min(bar);
19452000
assert_eq!(min_foo, 12);
1946-
```"),
2001+
```
2002+
2003+
**Note**: This method may not be available on some platforms."),
19472004
#[inline]
19482005
#[stable(feature = "atomic_min_max", since = "1.45.0")]
19492006
#[$cfg_cas]

0 commit comments

Comments
 (0)