Skip to content

Commit

Permalink
Merge pull request #450 from Freax13/enhancement/idt
Browse files Browse the repository at this point in the history
make `HandlerFuncType` unsafe
  • Loading branch information
Freax13 authored Jan 14, 2024
2 parents 4fc44a6 + e7f53ac commit fb5416c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,15 +831,19 @@ impl<F: HandlerFuncType> Entry<F> {
}

/// A common trait for all handler functions usable in [`Entry`].
pub trait HandlerFuncType {
///
/// # Safety
///
/// Implementors have to ensure that `to_virt_addr` returns a valid address.
pub unsafe trait HandlerFuncType {
/// Get the virtual address of the handler function.
fn to_virt_addr(self) -> VirtAddr;
}

macro_rules! impl_handler_func_type {
($f:ty) => {
#[cfg(feature = "abi_x86_interrupt")]
impl HandlerFuncType for $f {
unsafe impl HandlerFuncType for $f {
#[inline]
fn to_virt_addr(self) -> VirtAddr {
VirtAddr::new(self as u64)
Expand Down

0 comments on commit fb5416c

Please sign in to comment.