|
136 | 136 | //! |
137 | 137 | //! Supports `no_std` environments. Use `default-features = false` in Cargo.toml. |
138 | 138 |
|
| 139 | +// Provide a panic handler for no_std library checks/builds |
| 140 | +// This is only used when checking the library itself; final binaries must provide their own |
| 141 | +#[cfg(all(not(feature = "std"), not(test), not(doctest)))] |
| 142 | +#[panic_handler] |
| 143 | +fn panic(_info: &core::panic::PanicInfo) -> ! { |
| 144 | + loop {} |
| 145 | +} |
| 146 | + |
| 147 | +// Provide a global allocator for no_std + alloc library checks/builds |
| 148 | +// This is only used when checking the library itself; final binaries must provide their own |
| 149 | +#[cfg(all(feature = "alloc", not(feature = "std"), not(test), not(doctest)))] |
| 150 | +#[global_allocator] |
| 151 | +static ALLOCATOR: LibcAllocator = LibcAllocator; |
| 152 | + |
| 153 | +#[cfg(all(feature = "alloc", not(feature = "std"), not(test), not(doctest)))] |
| 154 | +struct LibcAllocator; |
| 155 | + |
| 156 | +#[cfg(all(feature = "alloc", not(feature = "std"), not(test), not(doctest)))] |
| 157 | +unsafe impl core::alloc::GlobalAlloc for LibcAllocator { |
| 158 | + unsafe fn alloc(&self, _layout: core::alloc::Layout) -> *mut u8 { |
| 159 | + core::ptr::null_mut() |
| 160 | + } |
| 161 | + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: core::alloc::Layout) {} |
| 162 | +} |
| 163 | + |
139 | 164 | use crate::crc32::consts::{ |
140 | 165 | CRC32_AIXM, CRC32_AUTOSAR, CRC32_BASE91_D, CRC32_BZIP2, CRC32_CD_ROM_EDC, CRC32_CKSUM, |
141 | 166 | CRC32_ISCSI, CRC32_ISO_HDLC, CRC32_JAMCRC, CRC32_MEF, CRC32_MPEG_2, CRC32_XFER, |
|
0 commit comments