extern-fn-explicit-align test: cleanup
This commit is contained in:
parent
5f4472e451
commit
bc9d26aee6
1 changed files with 6 additions and 4 deletions
|
@ -1,9 +1,9 @@
|
||||||
// Issue #80127: Passing structs via FFI should work with explicit alignment.
|
// Issue #80127: Passing structs via FFI should work with explicit alignment.
|
||||||
|
|
||||||
use std::ffi::{CString, c_char};
|
use std::ffi::{CStr, c_char};
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[repr(align(16))]
|
#[repr(align(16))]
|
||||||
pub struct TwoU64s {
|
pub struct TwoU64s {
|
||||||
|
@ -12,7 +12,7 @@ pub struct TwoU64s {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct BoolAndU32 {
|
pub struct BoolAndU32 {
|
||||||
pub a: bool,
|
pub a: bool,
|
||||||
pub b: u32,
|
pub b: u32,
|
||||||
|
@ -37,10 +37,12 @@ extern "C" {
|
||||||
) -> i32;
|
) -> i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const STRING: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Hello world\0") };
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let two_u64s = TwoU64s { a: 1, b: 2 };
|
let two_u64s = TwoU64s { a: 1, b: 2 };
|
||||||
let bool_and_u32 = BoolAndU32 { a: true, b: 3 };
|
let bool_and_u32 = BoolAndU32 { a: true, b: 3 };
|
||||||
let string = CString::new("Hello world").unwrap();
|
let string = STRING;
|
||||||
unsafe {
|
unsafe {
|
||||||
many_args(
|
many_args(
|
||||||
null_mut(),
|
null_mut(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue