]> git.lizzy.rs Git - rust.git/blob - tests/run-make/wasm-stringify-ints-small/foo.rs
Rollup merge of #106605 - notriddle:notriddle/outdated-rustbook, r=GuillaumeGomez
[rust.git] / tests / run-make / wasm-stringify-ints-small / foo.rs
1 #![crate_type = "cdylib"]
2
3 extern "C" {
4     fn observe(ptr: *const u8, len: usize);
5 }
6
7 macro_rules! s {
8     ( $( $f:ident -> $t:ty );* $(;)* ) => {
9         $(
10             extern "C" {
11                 fn $f() -> $t;
12             }
13             let s = $f().to_string();
14             observe(s.as_ptr(), s.len());
15         )*
16     };
17 }
18
19 #[no_mangle]
20 pub unsafe extern "C" fn foo() {
21     s! {
22         get_u8 -> u8;
23         get_i8 -> i8;
24         get_u16 -> u16;
25         get_i16 -> i16;
26         get_u32 -> u32;
27         get_i32 -> i32;
28         get_u64 -> u64;
29         get_i64 -> i64;
30         get_usize -> usize;
31         get_isize -> isize;
32     }
33 }