Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ fn show_ui(boot_services: &BootServices) -> Option<bool> {
Some(!settings.standalone_mode && require_inputmodules)
}

/// Since Rust 1.99 (LLVM 23), loops that search for a NUL u16, like in
/// `CStr16::from_ptr`, are turned into calls to wcslen.
/// There's no libc on UEFI and compiler_builtins doesn't provide it.
///
/// # Safety
/// `s` must point to a NUL-terminated UCS-2 string
#[no_mangle]
pub unsafe extern "C" fn wcslen(s: *const u16) -> usize {
let mut len = 0;
// Volatile read, so LLVM can't turn this loop into a call to itself
while core::ptr::read_volatile(s.add(len)) != 0 {
len += 1;
}
len
}

#[entry]
fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
let event = uefi_services::init(&mut system_table).unwrap();
Expand Down
Loading