Skip to content

Commit 3178d43

Browse files
committed
Auto merge of #41156 - TimNN:rollup, r=TimNN
Rollup of 4 pull requests - Successful merges: #41135, #41143, #41146, #41152 - Failed merges:
2 parents 547c12b + c04b39f commit 3178d43

File tree

8 files changed

+149
-18
lines changed

8 files changed

+149
-18
lines changed

src/bootstrap/bootstrap.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,10 @@ def build_triple(self):
472472
cputype = 'i686'
473473
elif cputype in {'xscale', 'arm'}:
474474
cputype = 'arm'
475-
elif cputype in {'armv6l', 'armv7l', 'armv8l'}:
475+
elif cputype == 'armv6l':
476476
cputype = 'arm'
477477
ostype += 'eabihf'
478-
elif cputype == 'armv7l':
478+
elif cputype in {'armv7l', 'armv8l'}:
479479
cputype = 'armv7'
480480
ostype += 'eabihf'
481481
elif cputype == 'aarch64':

src/doc/unstable-book/src/abi-msp430-interrupt.md

+35
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,38 @@ The tracking issue for this feature is: [#38487]
55
[#38487]: https://github.com/rust-lang/rust/issues/38487
66

77
------------------------
8+
9+
In the MSP430 architecture, interrupt handlers have a special calling
10+
convention. You can use the `"msp430-interrupt"` ABI to make the compiler apply
11+
the right calling convention to the interrupt handlers you define.
12+
13+
<!-- NOTE(ignore) this example is specific to the msp430 target -->
14+
15+
``` rust,ignore
16+
#![feature(abi_msp430_interrupt)]
17+
#![no_std]
18+
19+
// Place the interrupt handler at the appropriate memory address
20+
// (Alternatively, you can use `#[used]` and remove `pub` and `#[no_mangle]`)
21+
#[link_section = "__interrupt_vector_10"]
22+
#[no_mangle]
23+
pub static TIM0_VECTOR: extern "msp430-interrupt" fn() = tim0;
24+
25+
// The interrupt handler
26+
extern "msp430-interrupt" fn tim0() {
27+
// ..
28+
}
29+
```
30+
31+
``` text
32+
$ msp430-elf-objdump -CD ./target/msp430/release/app
33+
Disassembly of section __interrupt_vector_10:
34+
35+
0000fff2 <TIM0_VECTOR>:
36+
fff2: 00 c0 interrupt service routine at 0xc000
37+
38+
Disassembly of section .text:
39+
40+
0000c000 <int::tim0>:
41+
c000: 00 13 reti
42+
```

src/doc/unstable-book/src/abi-ptx.md

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,60 @@
11
# `abi_ptx`
22

3-
The tracking issue for this feature is: None.
3+
The tracking issue for this feature is: [#38788]
4+
5+
[#38788]: https://github.com/rust-lang/rust/issues/38788
46

57
------------------------
8+
9+
When emitting PTX code, all vanilla Rust functions (`fn`) get translated to
10+
"device" functions. These functions are *not* callable from the host via the
11+
CUDA API so a crate with only device functions is not too useful!
12+
13+
OTOH, "global" functions *can* be called by the host; you can think of them
14+
as the real public API of your crate. To produce a global function use the
15+
`"ptx-kernel"` ABI.
16+
17+
<!-- NOTE(ignore) this example is specific to the nvptx targets -->
18+
19+
``` rust,ignore
20+
#![feature(abi_ptx)]
21+
#![no_std]
22+
23+
pub unsafe extern "ptx-kernel" fn global_function() {
24+
device_function();
25+
}
26+
27+
pub fn device_function() {
28+
// ..
29+
}
30+
```
31+
32+
``` text
33+
$ xargo rustc --target nvptx64-nvidia-cuda --release -- --emit=asm
34+
35+
$ cat $(find -name '*.s')
36+
//
37+
// Generated by LLVM NVPTX Back-End
38+
//
39+
40+
.version 3.2
41+
.target sm_20
42+
.address_size 64
43+
44+
// .globl _ZN6kernel15global_function17h46111ebe6516b382E
45+
46+
.visible .entry _ZN6kernel15global_function17h46111ebe6516b382E()
47+
{
48+
49+
50+
ret;
51+
}
52+
53+
// .globl _ZN6kernel15device_function17hd6a0e4993bbf3f78E
54+
.visible .func _ZN6kernel15device_function17hd6a0e4993bbf3f78E()
55+
{
56+
57+
58+
ret;
59+
}
60+
```
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
# `compiler_builtins_lib`
22

3-
This feature is internal to the Rust compiler and is not intended for general use.
3+
The tracking issue for this feature is: None.
44

55
------------------------
6+
7+
This feature is required to link to the `compiler_builtins` crate which contains
8+
"compiler intrinsics". Compiler intrinsics are software implementations of basic
9+
operations like multiplication of `u64`s. These intrinsics are only required on
10+
platforms where these operations don't directly map to a hardware instruction.
11+
12+
You should never need to explicitly link to the `compiler_builtins` crate when
13+
building "std" programs as `compiler_builtins` is already in the dependency
14+
graph of `std`. But you may need it when building `no_std` **binary** crates. If
15+
you get a *linker* error like:
16+
17+
``` text
18+
$PWD/src/main.rs:11: undefined reference to `__aeabi_lmul'
19+
$PWD/src/main.rs:11: undefined reference to `__aeabi_uldivmod'
20+
```
21+
22+
That means that you need to link to this crate.
23+
24+
When you link to this crate, make sure it only appears once in your crate
25+
dependency graph. Also, it doesn't matter where in the dependency graph, you
26+
place the `compiler_builtins` crate.
27+
28+
<!-- NOTE(ignore) doctests don't support `no_std` binaries -->
29+
30+
``` rust,ignore
31+
#![feature(compiler_builtins_lib)]
32+
#![no_std]
33+
34+
extern crate compiler_builtins;
35+
```
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# `compiler_builtins`
22

3-
The tracking issue for this feature is: None.
3+
This feature is internal to the Rust compiler and is not intended for general use.
44

55
------------------------
6-

src/libcore/sync/atomic.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -539,17 +539,16 @@ impl AtomicBool {
539539
// We can't use atomic_nand here because it can result in a bool with
540540
// an invalid value. This happens because the atomic operation is done
541541
// with an 8-bit integer internally, which would set the upper 7 bits.
542-
// So we just use a compare-exchange loop instead, which is what the
543-
// intrinsic actually expands to anyways on many platforms.
544-
let mut old = self.load(Relaxed);
545-
loop {
546-
let new = !(old && val);
547-
match self.compare_exchange_weak(old, new, order, Relaxed) {
548-
Ok(_) => break,
549-
Err(x) => old = x,
550-
}
542+
// So we just use fetch_xor or swap instead.
543+
if val {
544+
// !(x & true) == !x
545+
// We must invert the bool.
546+
self.fetch_xor(true, order)
547+
} else {
548+
// !(x & false) == true
549+
// We must set the bool to true.
550+
self.swap(true, order)
551551
}
552-
old
553552
}
554553

555554
/// Logical "or" with a boolean value.

src/libcore/tests/atomic.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,23 @@ fn bool_() {
2424
#[test]
2525
fn bool_and() {
2626
let a = AtomicBool::new(true);
27-
assert_eq!(a.fetch_and(false, SeqCst),true);
27+
assert_eq!(a.fetch_and(false, SeqCst), true);
2828
assert_eq!(a.load(SeqCst),false);
2929
}
3030

31+
#[test]
32+
fn bool_nand() {
33+
let a = AtomicBool::new(false);
34+
assert_eq!(a.fetch_nand(false, SeqCst), false);
35+
assert_eq!(a.load(SeqCst), true);
36+
assert_eq!(a.fetch_nand(false, SeqCst), true);
37+
assert_eq!(a.load(SeqCst), true);
38+
assert_eq!(a.fetch_nand(true, SeqCst), true);
39+
assert_eq!(a.load(SeqCst), false);
40+
assert_eq!(a.fetch_nand(true, SeqCst), false);
41+
assert_eq!(a.load(SeqCst), true);
42+
}
43+
3144
#[test]
3245
fn uint_and() {
3346
let x = AtomicUsize::new(0xf731);

src/libsyntax/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ declare_features! (
408408
// Allows the definition recursive static items.
409409
(accepted, static_recursion, "1.17.0", Some(29719)),
410410
// pub(restricted) visibilities (RFC 1422)
411-
(accepted, pub_restricted, "1.17.0", Some(32409)),
411+
(accepted, pub_restricted, "1.18.0", Some(32409)),
412412
// The #![windows_subsystem] attribute
413413
(accepted, windows_subsystem, "1.18.0", Some(37499)),
414414
);

0 commit comments

Comments
 (0)