Skip to content

Commit

Permalink
Rollup merge of rust-lang#38959 - Amanieu:atomic128, r=alexcrichton
Browse files Browse the repository at this point in the history
Add 128-bit atomics

This is currently only supported on AArch64 since that is the only target which unconditionally supports 128-bit atomic operations.

cc rust-lang#35118
  • Loading branch information
frewsxcv authored Feb 5, 2017
2 parents 6a4c906 + 9903975 commit c4c6c49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/libcore/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,24 @@ atomic_int! {
unstable(feature = "integer_atomics", issue = "32976"),
u64 AtomicU64 ATOMIC_U64_INIT
}
#[cfg(not(stage0))]
#[cfg(target_has_atomic = "128")]
atomic_int! {
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
i128 AtomicI128 ATOMIC_I128_INIT
}
#[cfg(not(stage0))]
#[cfg(target_has_atomic = "128")]
atomic_int! {
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
unstable(feature = "i128", issue = "35118"),
u128 AtomicU128 ATOMIC_U128_INIT
}
#[cfg(target_has_atomic = "ptr")]
atomic_int!{
stable(feature = "rust1", since = "1.0.0"),
Expand Down
10 changes: 9 additions & 1 deletion src/test/run-make/atomic-lock-free/atomic_lock_free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)]
#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items, i128_type)]
#![crate_type="rlib"]
#![no_core]

Expand Down Expand Up @@ -54,6 +54,14 @@ pub unsafe fn atomic_u64(x: *mut u64) {
pub unsafe fn atomic_i64(x: *mut i64) {
atomic_xadd(x, 1);
}
#[cfg(target_has_atomic = "128")]
pub unsafe fn atomic_u128(x: *mut u128) {
atomic_xadd(x, 1);
}
#[cfg(target_has_atomic = "128")]
pub unsafe fn atomic_i128(x: *mut i128) {
atomic_xadd(x, 1);
}
#[cfg(target_has_atomic = "ptr")]
pub unsafe fn atomic_usize(x: *mut usize) {
atomic_xadd(x, 1);
Expand Down

0 comments on commit c4c6c49

Please sign in to comment.