@@ -29,8 +29,14 @@ fn main() -> Result<(), Box<dyn Error>> {
2929
3030    let  is_avr = env:: var ( "CARGO_CFG_TARGET_ARCH" ) . as_deref ( )  == Ok ( "avr" ) ; 
3131
32+     // Set some cfg's depending on the target. 
33+     // - has_atomics: atomic load/store is available (either natively or through portable-atomic) 
34+     // - has_cas: atomic CAS is available (either natively or through portable-atomic) 
35+     // - use_portable_atomic: Use portable-atomic for all atomics (load/store and CAS). 
36+     // - use_portable_atomic_cas: Use portable-atomic for CAS atomic operations. Load/store can keep using core::sync:atomic. 
37+ 
3238    // built-in targets with no atomic / CAS support as of nightly-2022-01-13 
33-     // AND not supported by the atomic-polyfill  crate 
39+     // AND not supported by the portable-atomic  crate 
3440    // see the `no-atomics.sh` / `no-cas.sh` script sitting next to this file 
3541    if  is_avr { 
3642        // lacks cas 
@@ -39,11 +45,11 @@ fn main() -> Result<(), Box<dyn Error>> {
3945            "avr-unknown-gnu-atmega328" 
4046                | "bpfeb-unknown-none" 
4147                | "bpfel-unknown-none" 
42-                 | "msp430-none-elf" 
43-                 // | "riscv32i-unknown-none-elf"    // supported by atomic-polyfill  
44-                 // | "riscv32imc-unknown-none-elf"  // supported by atomic-polyfill  
45-                 | "thumbv4t-none-eabi" 
46-                 // | "thumbv6m-none-eabi"           // supported by atomic-polyfill  
48+                 //  | "msp430-none-elf"              // supported by portable-atomic 
49+                 // | "riscv32i-unknown-none-elf"    // supported by portable-atomic  
50+                 // | "riscv32imc-unknown-none-elf"  // supported by portable-atomic  
51+                 //  | "thumbv4t-none-eabi"           // supported by portable-atomic 
52+                 // | "thumbv6m-none-eabi"           // supported by portable-atomic  
4753                => { } 
4854
4955            _ => { 
@@ -55,34 +61,27 @@ fn main() -> Result<(), Box<dyn Error>> {
5561    if  is_avr { 
5662        // lacks atomics 
5763    }  else  { 
58-         match  & target[ ..]  { 
59-         "msp430-none-elf" 
60-         // | "riscv32i-unknown-none-elf"    // supported by atomic-polyfill 
61-         // | "riscv32imc-unknown-none-elf"  // supported by atomic-polyfill 
62-         => { } 
63- 
64-         _ => { 
65-             println ! ( "cargo:rustc-cfg=has_atomics" ) ; 
66-         } 
64+         println ! ( "cargo:rustc-cfg=has_atomics" ) ; 
6765    } 
68-     } ; 
6966
70-     // Let the code know if it should use atomic-polyfill  or not, and what aspects  
71-     // of polyfill it requires  
67+     // Let the code know if it should use portable-atomic  or not, for either  
68+     // only CAS, or for all atomics.  
7269    if  is_avr { 
73-         println ! ( "cargo:rustc-cfg=full_atomic_polyfill " ) ; 
74-         println ! ( "cargo:rustc-cfg=cas_atomic_polyfill " ) ; 
70+         println ! ( "cargo:rustc-cfg=use_portable_atomic " ) ; 
71+         println ! ( "cargo:rustc-cfg=use_portable_atomic_cas " ) ; 
7572    }  else  { 
7673        match  & target[ ..]  { 
7774            "riscv32i-unknown-none-elf" 
7875            | "riscv32imc-unknown-none-elf" 
79-             | "xtensa-esp32s2-none-elf"  => { 
80-                 println ! ( "cargo:rustc-cfg=full_atomic_polyfill" ) ; 
81-                 println ! ( "cargo:rustc-cfg=cas_atomic_polyfill" ) ; 
76+             | "xtensa-esp32s2-none-elf" 
77+             | "thumbv4t-none-eabi" 
78+             | "msp430-none-elf"  => { 
79+                 println ! ( "cargo:rustc-cfg=use_portable_atomic" ) ; 
80+                 println ! ( "cargo:rustc-cfg=use_portable_atomic_cas" ) ; 
8281            } 
8382
8483            "thumbv6m-none-eabi"  => { 
85-                 println ! ( "cargo:rustc-cfg=cas_atomic_polyfill " ) ; 
84+                 println ! ( "cargo:rustc-cfg=use_portable_atomic_cas " ) ; 
8685            } 
8786            _ => { } 
8887        } 
0 commit comments