extend extern tests to include FiveU16s
As described in the code, this extends just beyond a 64bit reg, but isn't a round number, so it triggers some edge cases in the cast ABI.
This commit is contained in:
parent
766bdce744
commit
4498cd6a8d
@ -118,6 +118,30 @@ rust_dbg_extern_identity_TwoDoubles(struct TwoDoubles u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
struct FiveU16s {
|
||||
uint16_t one;
|
||||
uint16_t two;
|
||||
uint16_t three;
|
||||
uint16_t four;
|
||||
uint16_t five;
|
||||
};
|
||||
|
||||
struct FiveU16s
|
||||
rust_dbg_extern_return_FiveU16s() {
|
||||
struct FiveU16s s;
|
||||
s.one = 10;
|
||||
s.two = 20;
|
||||
s.three = 30;
|
||||
s.four = 40;
|
||||
s.five = 50;
|
||||
return s;
|
||||
}
|
||||
|
||||
struct FiveU16s
|
||||
rust_dbg_extern_identity_FiveU16s(struct FiveU16s u) {
|
||||
return u;
|
||||
}
|
||||
|
||||
struct ManyInts {
|
||||
int8_t arg1;
|
||||
int16_t arg2;
|
||||
|
30
tests/ui/abi/extern/extern-pass-FiveU16s.rs
vendored
Normal file
30
tests/ui/abi/extern/extern-pass-FiveU16s.rs
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
// Test a foreign function that accepts and returns a struct by value.
|
||||
|
||||
// FiveU16s in particular is interesting because it is larger than a single 64 bit or 32 bit
|
||||
// register, which are used as cast destinations on some targets, but does not evenly divide those
|
||||
// sizes, causing there to be padding in the last element.
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub struct FiveU16s {
|
||||
one: u16,
|
||||
two: u16,
|
||||
three: u16,
|
||||
four: u16,
|
||||
five: u16,
|
||||
}
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern "C" {
|
||||
pub fn rust_dbg_extern_identity_FiveU16s(v: FiveU16s) -> FiveU16s;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let x = FiveU16s { one: 22, two: 23, three: 24, four: 25, five: 26 };
|
||||
let y = rust_dbg_extern_identity_FiveU16s(x);
|
||||
assert_eq!(x, y);
|
||||
}
|
||||
}
|
26
tests/ui/abi/extern/extern-return-FiveU16s.rs
vendored
Normal file
26
tests/ui/abi/extern/extern-return-FiveU16s.rs
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
pub struct FiveU16s {
|
||||
one: u16,
|
||||
two: u16,
|
||||
three: u16,
|
||||
four: u16,
|
||||
five: u16,
|
||||
}
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern "C" {
|
||||
pub fn rust_dbg_extern_return_FiveU16s() -> FiveU16s;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let y = rust_dbg_extern_return_FiveU16s();
|
||||
assert_eq!(y.one, 10);
|
||||
assert_eq!(y.two, 20);
|
||||
assert_eq!(y.three, 30);
|
||||
assert_eq!(y.four, 40);
|
||||
assert_eq!(y.five, 50);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user