]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/pass/miri-alloc.rs
Auto merge of #104915 - weihanglo:update-cargo, r=ehuss
[rust.git] / src / tools / miri / tests / pass / miri-alloc.rs
1 #![feature(lang_items, start)]
2 #![no_std]
3 // windows tls dtors go through libstd right now, thus this test
4 // cannot pass. When windows tls dtors go through the special magic
5 // windows linker section, we can run this test on windows again.
6 //@ignore-target-windows: no-std not supported on Windows
7
8 extern "Rust" {
9     fn miri_alloc(size: usize, align: usize) -> *mut u8;
10     fn miri_dealloc(ptr: *mut u8, size: usize, align: usize);
11 }
12
13 #[start]
14 fn start(_: isize, _: *const *const u8) -> isize {
15     unsafe {
16         let ptr = miri_alloc(123, 1);
17         core::ptr::write_bytes(ptr, 0u8, 123);
18         miri_dealloc(ptr, 123, 1);
19     }
20     0
21 }
22
23 #[panic_handler]
24 fn panic_handler(_: &core::panic::PanicInfo) -> ! {
25     loop {}
26 }
27
28 #[lang = "eh_personality"]
29 fn eh_personality() {}