@@ -685,6 +685,9 @@ pub type DivergingHandlerFuncWithErrCode =
685
685
#[ derive( Copy , Clone , Debug ) ]
686
686
pub struct DivergingHandlerFuncWithErrCode ( ( ) ) ;
687
687
688
+ /// A general handler function for an interrupt or an exception with the interrupt/exceptions's index and an optional error code.
689
+ pub type GeneralHandlerFunc = fn ( InterruptStackFrame , index : u8 , error_code : Option < u64 > ) ;
690
+
688
691
impl < F > Entry < F > {
689
692
/// Creates a non-present IDT entry (but sets the must-be-one bits).
690
693
#[ inline]
@@ -1153,13 +1156,22 @@ macro_rules! set_general_handler {
1153
1156
$crate:: set_general_handler!( $idt, $handler, $idx..=$idx) ;
1154
1157
} ;
1155
1158
( $idt: expr, $handler: ident, $range: expr) => { {
1156
- fn set_general_handler(
1157
- idt: & mut $crate:: structures:: idt:: InterruptDescriptorTable ,
1158
- range: impl core:: ops:: RangeBounds <usize >,
1159
- ) {
1160
- $crate:: set_general_handler_recursive_bits!( idt, $handler, range) ;
1159
+ /// This constant is used to avoid spamming the same compilation error ~200 times
1160
+ /// when the handler's signature is wrong.
1161
+ /// If we just passed `$handler` to `set_general_handler_recursive_bits`
1162
+ /// an error would be reported for every interrupt handler that tried to call it.
1163
+ /// With `GENERAL_HANDLER` the error is only reported once for this constant.
1164
+ const GENERAL_HANDLER : $crate:: structures:: idt:: GeneralHandlerFunc = $handler;
1165
+
1166
+ {
1167
+ fn set_general_handler(
1168
+ idt: & mut $crate:: structures:: idt:: InterruptDescriptorTable ,
1169
+ range: impl :: core:: ops:: RangeBounds <usize >,
1170
+ ) {
1171
+ $crate:: set_general_handler_recursive_bits!( idt, GENERAL_HANDLER , range) ;
1172
+ }
1173
+ set_general_handler( $idt, $range) ;
1161
1174
}
1162
- set_general_handler( $idt, $range) ;
1163
1175
} } ;
1164
1176
}
1165
1177
0 commit comments