1 #![no_std] 2 #![no_main] 3 #![feature(default_alloc_error_handler)] 4 5 // Include flatbuffers purely to check that it compiles in a no_std binary 6 #[allow(unused_imports)] 7 use flatbuffers; 8 9 // The rest is just no_std boilerplate 10 11 use core::alloc::{GlobalAlloc, Layout}; 12 13 struct NullAllocator; 14 unsafe impl GlobalAlloc for NullAllocator { alloc(&self, _lt: Layout) -> *mut u815 unsafe fn alloc(&self, _lt: Layout) -> *mut u8 { 16 core::ptr::null_mut() 17 } dealloc(&self, _ptr: *mut u8, _lt: Layout)18 unsafe fn dealloc(&self, _ptr: *mut u8, _lt: Layout) { 19 panic!("won't deallocate: we never allocated!"); 20 } 21 } 22 23 #[global_allocator] 24 static A: NullAllocator = NullAllocator; 25 26 #[panic_handler] panic(_info: &core::panic::PanicInfo) -> !27fn panic(_info: &core::panic::PanicInfo) -> ! { 28 loop {} 29 } 30 31 #[no_mangle] main(_argc: i32, _argv: *const *const u8) -> i3232pub extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 { 33 0 34 } 35