Auto merge of #33048 - Amanieu:integer_atomics, r=alexcrichton
Add integer atomic types Tracking issue: #32976 RFC: rust-lang/rfcs#1543 The changes to AtomicBool in the RFC are not included, they are in a separate PR (#32365).
This commit is contained in:
commit
af0a433865
@ -2091,6 +2091,8 @@ The following configurations must be defined by the implementation:
|
||||
* `target_pointer_width = "..."` - Target pointer width in bits. This is set
|
||||
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
|
||||
64-bit pointers.
|
||||
* `target_has_atomic = "..."` - Set of integer sizes on which the target can perform
|
||||
atomic operations. Values are `"8"`, `"16"`, `"32"`, `"64"` and `"ptr"`.
|
||||
* `target_vendor = "..."` - Vendor of the target, for example `apple`, `pc`, or
|
||||
simply `"unknown"`.
|
||||
* `test` - Enabled when compiling the test harness (using the `--test` flag).
|
||||
@ -2295,6 +2297,9 @@ The currently implemented features of the reference compiler are:
|
||||
* `cfg_target_vendor` - Allows conditional compilation using the `target_vendor`
|
||||
matcher which is subject to change.
|
||||
|
||||
* `cfg_target_has_atomic` - Allows conditional compilation using the `target_has_atomic`
|
||||
matcher which is subject to change.
|
||||
|
||||
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
|
||||
ways insufficient for concatenating identifiers, and may be
|
||||
removed entirely for something more wholesome.
|
||||
|
@ -63,6 +63,7 @@
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(concat_idents)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(cfg_target_has_atomic)]
|
||||
#![feature(custom_attribute)]
|
||||
#![feature(fundamental)]
|
||||
#![feature(inclusive_range_syntax)]
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -695,6 +695,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||
let os = &sess.target.target.target_os;
|
||||
let env = &sess.target.target.target_env;
|
||||
let vendor = &sess.target.target.target_vendor;
|
||||
let max_atomic_width = sess.target.target.options.max_atomic_width;
|
||||
|
||||
let fam = if let Some(ref fam) = sess.target.target.options.target_family {
|
||||
intern(fam)
|
||||
@ -721,6 +722,15 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
|
||||
if sess.target.target.options.has_elf_tls {
|
||||
ret.push(attr::mk_word_item(InternedString::new("target_thread_local")));
|
||||
}
|
||||
for &i in &[8, 16, 32, 64, 128] {
|
||||
if i <= max_atomic_width {
|
||||
let s = i.to_string();
|
||||
ret.push(mk(InternedString::new("target_has_atomic"), intern(&s)));
|
||||
if &s == wordsz {
|
||||
ret.push(mk(InternedString::new("target_has_atomic"), intern("ptr")));
|
||||
}
|
||||
}
|
||||
}
|
||||
if sess.opts.debug_assertions {
|
||||
ret.push(attr::mk_word_item(InternedString::new("debug_assertions")));
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
features: "+neon,+fp-armv8,+cyclone".to_string(),
|
||||
eliminate_frame_pointer: false,
|
||||
max_atomic_width: 128,
|
||||
.. opts(Arch::Arm64)
|
||||
},
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
use target::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::android_base::opts();
|
||||
base.max_atomic_width = 128;
|
||||
Target {
|
||||
llvm_target: "aarch64-linux-android".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
@ -20,6 +22,6 @@ pub fn target() -> Target {
|
||||
target_os: "android".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "unknown".to_string(),
|
||||
options: super::android_base::opts(),
|
||||
options: base,
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@
|
||||
use target::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let base = super::linux_base::opts();
|
||||
let mut base = super::linux_base::opts();
|
||||
base.max_atomic_width = 128;
|
||||
Target {
|
||||
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::android_base::opts();
|
||||
base.features = "+v7,+vfp3,+d16".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "arm-linux-androideabi".to_string(),
|
||||
|
@ -11,7 +11,8 @@
|
||||
use target::{Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let base = super::linux_base::opts();
|
||||
let mut base = super::linux_base::opts();
|
||||
base.max_atomic_width = 64;
|
||||
Target {
|
||||
llvm_target: "arm-unknown-linux-gnueabi".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
|
@ -11,7 +11,8 @@
|
||||
use target::{Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let base = super::linux_base::opts();
|
||||
let mut base = super::linux_base::opts();
|
||||
base.max_atomic_width = 64;
|
||||
Target {
|
||||
llvm_target: "arm-unknown-linux-gnueabihf".to_string(),
|
||||
target_endian: "little".to_string(),
|
||||
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
||||
target_vendor: "apple".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp3,+neon".to_string(),
|
||||
max_atomic_width: 64,
|
||||
.. opts(Arch::Armv7)
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp3,+neon".to_string(),
|
||||
cpu: "cortex-a8".to_string(),
|
||||
max_atomic_width: 64,
|
||||
.. base
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
||||
target_vendor: "apple".to_string(),
|
||||
options: TargetOptions {
|
||||
features: "+v7,+vfp4,+neon".to_string(),
|
||||
max_atomic_width: 64,
|
||||
.. opts(Arch::Armv7s)
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ pub fn target() -> Target {
|
||||
linker_is_gnu: true,
|
||||
allow_asm: false,
|
||||
obj_is_bitcode: true,
|
||||
max_atomic_width: 32,
|
||||
.. Default::default()
|
||||
};
|
||||
Target {
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use target::Target;
|
||||
use target::{Target, TargetOptions};
|
||||
use super::apple_ios_base::{opts, Arch};
|
||||
|
||||
pub fn target() -> Target {
|
||||
@ -21,6 +21,9 @@ pub fn target() -> Target {
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "apple".to_string(),
|
||||
options: opts(Arch::I386)
|
||||
options: TargetOptions {
|
||||
max_atomic_width: 64,
|
||||
.. opts(Arch::I386)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::apple_base::opts();
|
||||
base.cpu = "yonah".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::android_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "i686-linux-android".to_string(),
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::windows_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
|
||||
// space available to x86 Windows binaries on x86_64.
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::windows_msvc_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
|
||||
// space available to x86 Windows binaries on x86_64.
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::dragonfly_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::freebsd_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "pentium4".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
base.pre_link_args.push("-Wl,-melf_i386".to_string());
|
||||
|
||||
|
@ -25,6 +25,7 @@ pub fn target() -> Target {
|
||||
no_compiler_rt: false,
|
||||
linker_is_gnu: true,
|
||||
allow_asm: false,
|
||||
max_atomic_width: 32,
|
||||
.. Default::default()
|
||||
};
|
||||
Target {
|
||||
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
cpu: "mips32r2".to_string(),
|
||||
features: "+mips32r2,+soft-float".to_string(),
|
||||
max_atomic_width: 32,
|
||||
..super::linux_base::opts()
|
||||
},
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
cpu: "mips32r2".to_string(),
|
||||
features: "+mips32r2,+soft-float".to_string(),
|
||||
max_atomic_width: 32,
|
||||
..super::linux_base::opts()
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
cpu: "mips32".to_string(),
|
||||
features: "+mips32".to_string(),
|
||||
max_atomic_width: 32,
|
||||
..super::linux_base::opts()
|
||||
},
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
cpu: "mips32".to_string(),
|
||||
features: "+mips32".to_string(),
|
||||
max_atomic_width: 32,
|
||||
..super::linux_base::opts()
|
||||
}
|
||||
}
|
||||
|
@ -292,6 +292,10 @@ pub struct TargetOptions {
|
||||
// If we give emcc .o files that are actually .bc files it
|
||||
// will 'just work'.
|
||||
pub obj_is_bitcode: bool,
|
||||
|
||||
/// Maximum integer size in bits that this target can perform atomic
|
||||
/// operations on.
|
||||
pub max_atomic_width: u64,
|
||||
}
|
||||
|
||||
impl Default for TargetOptions {
|
||||
@ -340,6 +344,7 @@ impl Default for TargetOptions {
|
||||
allow_asm: true,
|
||||
has_elf_tls: false,
|
||||
obj_is_bitcode: false,
|
||||
max_atomic_width: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,6 +397,9 @@ impl Target {
|
||||
options: Default::default(),
|
||||
};
|
||||
|
||||
// Default max-atomic-width to target-pointer-width
|
||||
base.options.max_atomic_width = base.target_pointer_width.parse().unwrap();
|
||||
|
||||
macro_rules! key {
|
||||
($key_name:ident) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
@ -404,6 +412,12 @@ impl Target {
|
||||
.map(|o| o.as_boolean()
|
||||
.map(|s| base.options.$key_name = s));
|
||||
} );
|
||||
($key_name:ident, u64) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(&name[..])
|
||||
.map(|o| o.as_u64()
|
||||
.map(|s| base.options.$key_name = s));
|
||||
} );
|
||||
($key_name:ident, list) => ( {
|
||||
let name = (stringify!($key_name)).replace("_", "-");
|
||||
obj.find(&name[..]).map(|o| o.as_array()
|
||||
@ -451,6 +465,7 @@ impl Target {
|
||||
key!(archive_format);
|
||||
key!(allow_asm, bool);
|
||||
key!(custom_unwind_resume, bool);
|
||||
key!(max_atomic_width, u64);
|
||||
|
||||
base
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ pub fn target() -> Target {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.cpu = "ppc64".to_string();
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "powerpc64-unknown-linux-gnu".to_string(),
|
||||
|
@ -14,6 +14,7 @@ pub fn target() -> Target {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.cpu = "ppc64le".to_string();
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "powerpc64le-unknown-linux-gnu".to_string(),
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.pre_link_args.push("-m32".to_string());
|
||||
base.max_atomic_width = 32;
|
||||
|
||||
Target {
|
||||
llvm_target: "powerpc-unknown-linux-gnu".to_string(),
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::apple_base::opts();
|
||||
base.cpu = "core2".to_string();
|
||||
base.max_atomic_width = 128; // core2 support cmpxchg16b
|
||||
base.eliminate_frame_pointer = false;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use target::Target;
|
||||
use target::{Target, TargetOptions};
|
||||
use super::apple_ios_base::{opts, Arch};
|
||||
|
||||
pub fn target() -> Target {
|
||||
@ -21,6 +21,9 @@ pub fn target() -> Target {
|
||||
target_os: "ios".to_string(),
|
||||
target_env: "".to_string(),
|
||||
target_vendor: "apple".to_string(),
|
||||
options: opts(Arch::X86_64)
|
||||
options: TargetOptions {
|
||||
max_atomic_width: 64,
|
||||
.. opts(Arch::X86_64)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ pub fn target() -> Target {
|
||||
let mut base = super::windows_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-gnu".to_string(),
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::windows_msvc_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-windows-msvc".to_string(),
|
||||
|
@ -15,6 +15,7 @@ pub fn target() -> Target {
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
|
||||
base.ar = "x86_64-rumprun-netbsd-ar".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
base.dynamic_linking = false;
|
||||
base.has_rpath = false;
|
||||
|
@ -14,6 +14,7 @@ pub fn target() -> Target {
|
||||
let mut base = super::solaris_base::opts();
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
|
||||
Target {
|
||||
llvm_target: "x86_64-pc-solaris".to_string(),
|
||||
|
@ -12,6 +12,7 @@ use target::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::bitrig_base::opts();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::dragonfly_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::freebsd_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::linux_musl_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -12,6 +12,7 @@ use target::Target;
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::netbsd_base::opts();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -13,6 +13,7 @@ use target::Target;
|
||||
pub fn target() -> Target {
|
||||
let mut base = super::openbsd_base::opts();
|
||||
base.cpu = "x86-64".to_string();
|
||||
base.max_atomic_width = 64;
|
||||
base.pre_link_args.push("-m64".to_string());
|
||||
|
||||
Target {
|
||||
|
@ -268,8 +268,11 @@ declare_features! (
|
||||
// pub(restricted) visibilities (RFC 1422)
|
||||
(active, pub_restricted, "1.9.0", Some(32409)),
|
||||
|
||||
// Allow Drop types in statics/const functions (RFC 1440)
|
||||
(active, drop_types_in_const, "1.9.0", Some(33156))
|
||||
// Allow Drop types in statics/const functions (RFC 1440)
|
||||
(active, drop_types_in_const, "1.9.0", Some(33156)),
|
||||
|
||||
// Allows cfg(target_has_atomic = "...").
|
||||
(active, cfg_target_has_atomic, "1.9.0", Some(32976))
|
||||
);
|
||||
|
||||
declare_features! (
|
||||
@ -577,6 +580,7 @@ const GATED_CFGS: &'static [(&'static str, &'static str, fn(&Features) -> bool)]
|
||||
("target_feature", "cfg_target_feature", cfg_fn!(cfg_target_feature)),
|
||||
("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)),
|
||||
("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)),
|
||||
("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)),
|
||||
];
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
30
src/test/run-make/atomic-lock-free/Makefile
Normal file
30
src/test/run-make/atomic-lock-free/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
-include ../tools.mk
|
||||
|
||||
# This tests ensure that atomic types are never lowered into runtime library calls that are not
|
||||
# guaranteed to be lock-free.
|
||||
|
||||
all:
|
||||
ifeq ($(UNAME),Linux)
|
||||
$(RUSTC) --target=i686-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=x86_64-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=arm-unknown-linux-gnueabi atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=arm-unknown-linux-gnueabihf atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=armv7-unknown-linux-gnueabihf atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=aarch64-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=mips-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=mipsel-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=powerpc-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=powerpc64-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
$(RUSTC) --target=powerpc64le-unknown-linux-gnu atomic_lock_free.rs
|
||||
nm "$(TMPDIR)/libatomic_lock_free.rlib" | grep -vq __atomic_fetch_add
|
||||
endif
|
62
src/test/run-make/atomic-lock-free/atomic_lock_free.rs
Normal file
62
src/test/run-make/atomic-lock-free/atomic_lock_free.rs
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// 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)]
|
||||
#![crate_type="rlib"]
|
||||
#![no_core]
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
fn atomic_xadd<T>(dst: *mut T, src: T) -> T;
|
||||
}
|
||||
|
||||
#[lang = "sized"]
|
||||
trait Sized {}
|
||||
|
||||
#[cfg(target_has_atomic = "8")]
|
||||
pub unsafe fn atomic_u8(x: *mut u8) {
|
||||
atomic_xadd(x, 1);
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "8")]
|
||||
pub unsafe fn atomic_i8(x: *mut i8) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "16")]
|
||||
pub unsafe fn atomic_u16(x: *mut u16) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "16")]
|
||||
pub unsafe fn atomic_i16(x: *mut i16) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "32")]
|
||||
pub unsafe fn atomic_u32(x: *mut u32) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "32")]
|
||||
pub unsafe fn atomic_i32(x: *mut i32) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
pub unsafe fn atomic_u64(x: *mut u64) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "64")]
|
||||
pub unsafe fn atomic_i64(x: *mut i64) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "ptr")]
|
||||
pub unsafe fn atomic_usize(x: *mut usize) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
||||
#[cfg(target_has_atomic = "ptr")]
|
||||
pub unsafe fn atomic_isize(x: *mut isize) {
|
||||
atomic_xadd(x, 1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user