@@ -945,6 +945,7 @@ macro_rules! atomic_int {
945
945
$stable_debug: meta,
946
946
$stable_access: meta,
947
947
$stable_from: meta,
948
+ $stable_nand: meta,
948
949
$s_int_type: expr, $int_ref: expr,
949
950
$int_type: ident $atomic_type: ident $atomic_init: ident) => {
950
951
/// An integer type which can be safely shared between threads.
@@ -1325,6 +1326,29 @@ macro_rules! atomic_int {
1325
1326
unsafe { atomic_and( self . v. get( ) , val, order) }
1326
1327
}
1327
1328
1329
+ /// Bitwise "nand" with the current value.
1330
+ ///
1331
+ /// Performs a bitwise "nand" operation on the current value and the argument `val`, and
1332
+ /// sets the new value to the result.
1333
+ ///
1334
+ /// Returns the previous value.
1335
+ ///
1336
+ /// # Examples
1337
+ ///
1338
+ /// ```
1339
+ /// #![feature(atomic_nand)]
1340
+ ///
1341
+ /// use std::sync::atomic::{AtomicIsize, Ordering};
1342
+ ///
1343
+ /// let foo = AtomicIsize::new(0xf731);
1344
+ /// assert_eq!(foo.fetch_nand(0x137f, Ordering::SeqCst), 0xf731);
1345
+ /// assert_eq!(foo.load(Ordering::SeqCst), !(0xf731 & 0x137f));
1346
+ #[ inline]
1347
+ #[ $stable_nand]
1348
+ pub fn fetch_nand( & self , val: $int_type, order: Ordering ) -> $int_type {
1349
+ unsafe { atomic_nand( self . v. get( ) , val, order) }
1350
+ }
1351
+
1328
1352
/// Bitwise "or" with the current value.
1329
1353
///
1330
1354
/// Performs a bitwise "or" operation on the current value and the argument `val`, and
@@ -1377,6 +1401,7 @@ atomic_int! {
1377
1401
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1378
1402
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1379
1403
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1404
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1380
1405
"i8" , "../../../std/primitive.i8.html" ,
1381
1406
i8 AtomicI8 ATOMIC_I8_INIT
1382
1407
}
@@ -1387,6 +1412,7 @@ atomic_int! {
1387
1412
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1388
1413
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1389
1414
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1415
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1390
1416
"u8" , "../../../std/primitive.u8.html" ,
1391
1417
u8 AtomicU8 ATOMIC_U8_INIT
1392
1418
}
@@ -1397,6 +1423,7 @@ atomic_int! {
1397
1423
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1398
1424
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1399
1425
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1426
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1400
1427
"i16" , "../../../std/primitive.i16.html" ,
1401
1428
i16 AtomicI16 ATOMIC_I16_INIT
1402
1429
}
@@ -1407,6 +1434,7 @@ atomic_int! {
1407
1434
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1408
1435
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1409
1436
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1437
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1410
1438
"u16" , "../../../std/primitive.u16.html" ,
1411
1439
u16 AtomicU16 ATOMIC_U16_INIT
1412
1440
}
@@ -1417,6 +1445,7 @@ atomic_int! {
1417
1445
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1418
1446
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1419
1447
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1448
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1420
1449
"i32" , "../../../std/primitive.i32.html" ,
1421
1450
i32 AtomicI32 ATOMIC_I32_INIT
1422
1451
}
@@ -1427,6 +1456,7 @@ atomic_int! {
1427
1456
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1428
1457
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1429
1458
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1459
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1430
1460
"u32" , "../../../std/primitive.u32.html" ,
1431
1461
u32 AtomicU32 ATOMIC_U32_INIT
1432
1462
}
@@ -1437,6 +1467,7 @@ atomic_int! {
1437
1467
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1438
1468
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1439
1469
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1470
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1440
1471
"i64" , "../../../std/primitive.i64.html" ,
1441
1472
i64 AtomicI64 ATOMIC_I64_INIT
1442
1473
}
@@ -1447,6 +1478,7 @@ atomic_int! {
1447
1478
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1448
1479
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1449
1480
unstable( feature = "integer_atomics" , issue = "32976" ) ,
1481
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1450
1482
"u64" , "../../../std/primitive.u64.html" ,
1451
1483
u64 AtomicU64 ATOMIC_U64_INIT
1452
1484
}
@@ -1457,6 +1489,7 @@ atomic_int!{
1457
1489
stable( feature = "atomic_debug" , since = "1.3.0" ) ,
1458
1490
stable( feature = "atomic_access" , since = "1.15.0" ) ,
1459
1491
stable( feature = "atomic_from" , since = "1.23.0" ) ,
1492
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1460
1493
"isize" , "../../../std/primitive.isize.html" ,
1461
1494
isize AtomicIsize ATOMIC_ISIZE_INIT
1462
1495
}
@@ -1467,6 +1500,7 @@ atomic_int!{
1467
1500
stable( feature = "atomic_debug" , since = "1.3.0" ) ,
1468
1501
stable( feature = "atomic_access" , since = "1.15.0" ) ,
1469
1502
stable( feature = "atomic_from" , since = "1.23.0" ) ,
1503
+ unstable( feature = "atomic_nand" , issue = "13226" ) ,
1470
1504
"usize" , "../../../std/primitive.usize.html" ,
1471
1505
usize AtomicUsize ATOMIC_USIZE_INIT
1472
1506
}
@@ -1609,6 +1643,18 @@ unsafe fn atomic_and<T>(dst: *mut T, val: T, order: Ordering) -> T {
1609
1643
}
1610
1644
}
1611
1645
1646
+ #[ inline]
1647
+ unsafe fn atomic_nand < T > ( dst : * mut T , val : T , order : Ordering ) -> T {
1648
+ match order {
1649
+ Acquire => intrinsics:: atomic_nand_acq ( dst, val) ,
1650
+ Release => intrinsics:: atomic_nand_rel ( dst, val) ,
1651
+ AcqRel => intrinsics:: atomic_nand_acqrel ( dst, val) ,
1652
+ Relaxed => intrinsics:: atomic_nand_relaxed ( dst, val) ,
1653
+ SeqCst => intrinsics:: atomic_nand ( dst, val) ,
1654
+ __Nonexhaustive => panic ! ( "invalid memory ordering" ) ,
1655
+ }
1656
+ }
1657
+
1612
1658
#[ inline]
1613
1659
unsafe fn atomic_or < T > ( dst : * mut T , val : T , order : Ordering ) -> T {
1614
1660
match order {
0 commit comments