Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.15-rc2 39 lines 797 B view raw
1// SPDX-License-Identifier: Apache-2.0 OR MIT 2 3use pin_init::*; 4 5// Struct with size over 1GiB 6#[derive(Debug)] 7pub struct BigStruct { 8 buf: [u8; 1024 * 1024 * 1024], 9 a: u64, 10 b: u64, 11 c: u64, 12 d: u64, 13 managed_buf: ManagedBuf, 14} 15 16#[derive(Debug)] 17pub struct ManagedBuf { 18 buf: [u8; 1024 * 1024], 19} 20 21impl ManagedBuf { 22 pub fn new() -> impl Init<Self> { 23 init!(ManagedBuf { buf <- zeroed() }) 24 } 25} 26 27fn main() { 28 // we want to initialize the struct in-place, otherwise we would get a stackoverflow 29 let buf: Box<BigStruct> = Box::init(init!(BigStruct { 30 buf <- zeroed(), 31 a: 7, 32 b: 186, 33 c: 7789, 34 d: 34, 35 managed_buf <- ManagedBuf::new(), 36 })) 37 .unwrap(); 38 println!("{}", core::mem::size_of_val(&*buf)); 39}