mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 19:23:50 +00:00
e8ce9fac85
Added run-make tests to verify that, between a Rust-C FFI boundary in both directions, any MTE tags included in a pointer are preserved for the following pointer types, as well as any information stored using TBI: - int - float - string - function
18 lines
466 B
Rust
18 lines
466 B
Rust
#![crate_type = "cdylib"]
|
|
#![crate_name = "foo"]
|
|
|
|
extern "C" fn ret32() -> i32 {
|
|
32
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn foo(ptr: extern "C" fn(extern "C" fn() -> i32)) {
|
|
assert_eq!((ptr as usize) >> 56, 0x1f);
|
|
|
|
// Store an arbitrary tag in the tag bits, and convert back to the correct pointer type.
|
|
let p = ((ret32 as usize) | (0x2f << 56)) as *const ();
|
|
let p: extern "C" fn() -> i32 = unsafe { std::mem::transmute(p) };
|
|
|
|
unsafe { ptr(p) }
|
|
}
|