Skip to content

Commit 7525088

Browse files
authored
Merge pull request #507 from rust-osdev/fix/gate-handlers
gate HandlerFunc behind target_arch = "x86{_64}"
2 parents 3fc9106 + 0b5476e commit 7525088

File tree

1 file changed

+44
-11
lines changed

1 file changed

+44
-11
lines changed

src/structures/idt.rs

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -712,52 +712,82 @@ impl<T> PartialEq for Entry<T> {
712712
/// A handler function for an interrupt or an exception without error code.
713713
///
714714
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled.
715-
#[cfg(feature = "abi_x86_interrupt")]
715+
#[cfg(all(
716+
any(target_arch = "x86", target_arch = "x86_64"),
717+
feature = "abi_x86_interrupt"
718+
))]
716719
pub type HandlerFunc = extern "x86-interrupt" fn(InterruptStackFrame);
717720
/// This type is not usable without the `abi_x86_interrupt` feature.
718-
#[cfg(not(feature = "abi_x86_interrupt"))]
721+
#[cfg(not(all(
722+
any(target_arch = "x86", target_arch = "x86_64"),
723+
feature = "abi_x86_interrupt"
724+
)))]
719725
#[derive(Copy, Clone, Debug)]
720726
pub struct HandlerFunc(());
721727

722728
/// A handler function for an exception that pushes an error code.
723729
///
724730
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled.
725-
#[cfg(feature = "abi_x86_interrupt")]
731+
#[cfg(all(
732+
any(target_arch = "x86", target_arch = "x86_64"),
733+
feature = "abi_x86_interrupt"
734+
))]
726735
pub type HandlerFuncWithErrCode = extern "x86-interrupt" fn(InterruptStackFrame, error_code: u64);
727736
/// This type is not usable without the `abi_x86_interrupt` feature.
728-
#[cfg(not(feature = "abi_x86_interrupt"))]
737+
#[cfg(not(all(
738+
any(target_arch = "x86", target_arch = "x86_64"),
739+
feature = "abi_x86_interrupt"
740+
)))]
729741
#[derive(Copy, Clone, Debug)]
730742
pub struct HandlerFuncWithErrCode(());
731743

732744
/// A page fault handler function that pushes a page fault error code.
733745
///
734746
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled.
735-
#[cfg(feature = "abi_x86_interrupt")]
747+
#[cfg(all(
748+
any(target_arch = "x86", target_arch = "x86_64"),
749+
feature = "abi_x86_interrupt"
750+
))]
736751
pub type PageFaultHandlerFunc =
737752
extern "x86-interrupt" fn(InterruptStackFrame, error_code: PageFaultErrorCode);
738753
/// This type is not usable without the `abi_x86_interrupt` feature.
739-
#[cfg(not(feature = "abi_x86_interrupt"))]
754+
#[cfg(not(all(
755+
any(target_arch = "x86", target_arch = "x86_64"),
756+
feature = "abi_x86_interrupt"
757+
)))]
740758
#[derive(Copy, Clone, Debug)]
741759
pub struct PageFaultHandlerFunc(());
742760

743761
/// A handler function that must not return, e.g. for a machine check exception.
744762
///
745763
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled.
746-
#[cfg(feature = "abi_x86_interrupt")]
764+
#[cfg(all(
765+
any(target_arch = "x86", target_arch = "x86_64"),
766+
feature = "abi_x86_interrupt"
767+
))]
747768
pub type DivergingHandlerFunc = extern "x86-interrupt" fn(InterruptStackFrame) -> !;
748769
/// This type is not usable without the `abi_x86_interrupt` feature.
749-
#[cfg(not(feature = "abi_x86_interrupt"))]
770+
#[cfg(not(all(
771+
any(target_arch = "x86", target_arch = "x86_64"),
772+
feature = "abi_x86_interrupt"
773+
)))]
750774
#[derive(Copy, Clone, Debug)]
751775
pub struct DivergingHandlerFunc(());
752776

753777
/// A handler function with an error code that must not return, e.g. for a double fault exception.
754778
///
755779
/// This type alias is only usable with the `abi_x86_interrupt` feature enabled.
756-
#[cfg(feature = "abi_x86_interrupt")]
780+
#[cfg(all(
781+
any(target_arch = "x86", target_arch = "x86_64"),
782+
feature = "abi_x86_interrupt"
783+
))]
757784
pub type DivergingHandlerFuncWithErrCode =
758785
extern "x86-interrupt" fn(InterruptStackFrame, error_code: u64) -> !;
759786
/// This type is not usable without the `abi_x86_interrupt` feature.
760-
#[cfg(not(feature = "abi_x86_interrupt"))]
787+
#[cfg(not(all(
788+
any(target_arch = "x86", target_arch = "x86_64"),
789+
feature = "abi_x86_interrupt"
790+
)))]
761791
#[derive(Copy, Clone, Debug)]
762792
pub struct DivergingHandlerFuncWithErrCode(());
763793

@@ -853,7 +883,10 @@ pub unsafe trait HandlerFuncType {
853883

854884
macro_rules! impl_handler_func_type {
855885
($f:ty) => {
856-
#[cfg(feature = "abi_x86_interrupt")]
886+
#[cfg(all(
887+
any(target_arch = "x86", target_arch = "x86_64"),
888+
feature = "abi_x86_interrupt"
889+
))]
857890
unsafe impl HandlerFuncType for $f {
858891
#[inline]
859892
fn to_virt_addr(self) -> VirtAddr {

0 commit comments

Comments
 (0)