Skip to content

Add a test for #[repr] as used in arrayvec - #1

Merged
bluss merged 1 commit into
bluss:doc-enum-reprfrom
SimonSapin:patch-9
May 27, 2015
Merged

Add a test for #[repr] as used in arrayvec#1
bluss merged 1 commit into
bluss:doc-enum-reprfrom
SimonSapin:patch-9

Conversation

@SimonSapin

Copy link
Copy Markdown

This test would fail with Option. Should we also assert that?

assert!(matchSome(zero){Some(_) => false,None => true// Not really expected, but demonstrates the issue.});

bluss added a commit that referenced this pull request May 27, 2015
Add a test for #[repr] as used in arrayvec
@bluss
bluss merged commit e57f69f into bluss:doc-enum-reprMay 27, 2015
bluss pushed a commit that referenced this pull request Aug 2, 2015
bluss pushed a commit that referenced this pull request Dec 6, 2015
bluss pushed a commit that referenced this pull request Feb 6, 2016
bluss added a commit that referenced this pull request Feb 26, 2016
Change import a trait suggestion from:
help: candidate #1: use `std::io::Write`
to
help: candidate #1: `use std::io::Write`
so that the code can be copied directly.
bluss pushed a commit that referenced this pull request Mar 4, 2016
suggest: Put the `use` in suggested code inside the quotes
Change import a trait suggestion from:
help: candidate #1: use `std::io::Write`
to
help: candidate #1: `use std::io::Write`
so that the code can be copied directly.
Fixesrust-lang#31864
bluss pushed a commit that referenced this pull request Jun 14, 2016
bluss pushed a commit that referenced this pull request Aug 21, 2016
rustc_trans: don't Assert(Overflow(Neg)) when overflow checks are off.
Generic functions using `Neg` on primitive types would panic even in release mode, with MIR trans.
The solution is a bit hacky, as I'm checking the message, since there's no dedicated `CheckedUnOp`.
Blocks Servo rustup ([failure #1](http://build.servo.org/builders/linux-rel/builds/2477/steps/test_3/logs/stdio), [failure #2](http://build.servo.org/builders/mac-rel-css/builds/2364/steps/test/logs/stdio)) - this should be the last hurdle, it affects only one test.
bluss pushed a commit that referenced this pull request Oct 25, 2017
…crichton
Allow atomic operations up to 32 bits
The ARMv5te platform does not have instruction-level support for atomics, however the kernel provides [user space helpers] which can be used to perform atomic operations. When linked with `libgcc`, the atomic symbols needed by Rust will be provided, rather than CPU level intrinsics.
[user space helpers]: https://www.kernel.org/doc/Documentation/arm/kernel_user_helpers.txt
32-bit versions of these kernel level helpers were introduced in Linux Kernel 2.6.12, and 64-bit version of these kernel level helpers were introduced in Linux Kernel 3.1. I have selected 32 bit versions as std currently only requires Linux version 2.6.18 and above as far as I am aware.
As this target is specifically linux and gnueabi, it is reasonable to assume the Linux Kernel and libc will be available for the target. There is a large performance penalty, as we are not using CPU level intrinsics, however this penalty is likely preferable to not having the target at all.
I have used this change in a custom target (along with xargo) to build std, as well as a number of higher level crates.
## Additional information
For reference, here is what a a code snippet decompiles to:
```rust
use std::sync::atomic::{AtomicIsize, Ordering};
#[no_mangle]
pub extern fn foo(a: &AtomicIsize) -> isize {
a.fetch_add(1, Ordering::SeqCst)
}
```
```
Disassembly of section .text.foo:
00000000 <foo>:
0:	e92d4800 push	{fp, lr}
4:	e3a01001 mov	r1, #1
8:	ebfffffe bl	0 <__sync_fetch_and_add_4>
c:	e8bd8800 pop	{fp, pc}
```
Which in turn is provided by `libgcc.a`, which has code which looks like this:
```
Disassembly of section .text:
00000000 <__sync_fetch_and_add_4>:
0:	e92d40f8 push	{r3, r4, r5, r6, r7, lr}
4:	e1a05000 mov	r5, r0
8:	e1a07001 mov	r7, r1
c:	e59f6028 ldr	r6, [pc, rust-lang#40]	; 3c <__sync_fetch_and_add_4+0x3c>
10:	e5954000 ldr	r4, [r5]
14:	e1a02005 mov	r2, r5
18:	e1a00004 mov	r0, r4
1c:	e0841007 add	r1, r4, r7
20:	e1a0e00f mov	lr, pc
24:	e12fff16 bx	r6
28:	e3500000 cmp	r0, #0
2c:	1afffff7 bne	10 <__sync_fetch_and_add_4+0x10>
30:	e1a00004 mov	r0, r4
34:	e8bd40f8 pop	{r3, r4, r5, r6, r7, lr}
38:	e12fff1e bx	lr
3c:	ffff0fc0 .word	0xffff0fc0
```
Where you can see the reference to `0xffff0fc0`, which is provided by the [user space helpers].
bluss pushed a commit that referenced this pull request Jan 13, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@SimonSapin@bluss