diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index ecc8042e9404f..a78482171a0de 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -943,6 +943,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 min_atomic_width = sess.target.target.min_atomic_width(); let max_atomic_width = sess.target.target.max_atomic_width(); let mut ret = HashSet::new(); @@ -963,7 +964,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { ret.insert((Symbol::intern("target_thread_local"), None)); } for &i in &[8, 16, 32, 64, 128] { - if i <= max_atomic_width { + if i >= min_atomic_width && i <= max_atomic_width { let s = i.to_string(); ret.insert((Symbol::intern("target_has_atomic"), Some(Symbol::intern(&s)))); if &s == wordsz { diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 8c37eb6986a7c..6a409edf0fecc 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -376,6 +376,9 @@ pub struct TargetOptions { // file pub no_integrated_as: bool, + /// Don't use this field; instead use the `.min_atomic_width()` method. + pub min_atomic_width: Option, + /// Don't use this field; instead use the `.max_atomic_width()` method. pub max_atomic_width: Option, @@ -439,6 +442,7 @@ impl Default for TargetOptions { has_elf_tls: false, obj_is_bitcode: false, no_integrated_as: false, + min_atomic_width: None, max_atomic_width: None, panic_strategy: PanicStrategy::Unwind, abi_blacklist: vec![], @@ -462,6 +466,12 @@ impl Target { } } + /// Minimum integer size in bits that this target can perform atomic + /// operations on. + pub fn min_atomic_width(&self) -> u64 { + self.options.min_atomic_width.unwrap_or(8) + } + /// Maximum integer size in bits that this target can perform atomic /// operations on. pub fn max_atomic_width(&self) -> u64 { @@ -604,6 +614,7 @@ impl Target { key!(obj_is_bitcode, bool); key!(no_integrated_as, bool); key!(max_atomic_width, Option); + key!(min_atomic_width, Option); try!(key!(panic_strategy, PanicStrategy)); key!(crt_static_default, bool); @@ -766,6 +777,7 @@ impl ToJson for Target { target_option_val!(has_elf_tls); target_option_val!(obj_is_bitcode); target_option_val!(no_integrated_as); + target_option_val!(min_atomic_width); target_option_val!(max_atomic_width); target_option_val!(panic_strategy); target_option_val!(crt_static_default);