File tree Expand file tree Collapse file tree 4 files changed +19
-28
lines changed Expand file tree Collapse file tree 4 files changed +19
-28
lines changed Original file line number Diff line number Diff line change @@ -42,12 +42,8 @@ pub static __EXCEPTIONS: [Option<unsafe extern "C" fn(&TrapFrame)>; 16] = [
4242#[ export_name = "_dispatch_exception" ]
4343#[ inline]
4444unsafe extern "C" fn dispatch_exception ( trap_frame : & TrapFrame , code : usize ) {
45- if code < __EXCEPTIONS. len ( ) {
46- match & __EXCEPTIONS[ code] {
47- Some ( handler) => handler ( trap_frame) ,
48- None => ExceptionHandler ( trap_frame) ,
49- }
50- } else {
51- ExceptionHandler ( trap_frame) ;
45+ match __EXCEPTIONS. get ( code) {
46+ Some ( Some ( handler) ) => handler ( trap_frame) ,
47+ _ => ExceptionHandler ( trap_frame) ,
5248 }
5349}
Original file line number Diff line number Diff line change @@ -28,13 +28,9 @@ pub static __CORE_INTERRUPTS: [Option<unsafe extern "C" fn()>; 12] = [
2828#[ export_name = "_dispatch_core_interrupt" ]
2929#[ inline]
3030unsafe extern "C" fn dispatch_core_interrupt ( code : usize ) {
31- if code < __CORE_INTERRUPTS. len ( ) {
32- match & __CORE_INTERRUPTS[ code] {
33- Some ( handler) => handler ( ) ,
34- None => DefaultHandler ( ) ,
35- }
36- } else {
37- DefaultHandler ( ) ;
31+ match __CORE_INTERRUPTS. get ( code) {
32+ Some ( Some ( handler) ) => handler ( ) ,
33+ _ => DefaultHandler ( ) ,
3834 }
3935}
4036
Original file line number Diff line number Diff line change @@ -121,20 +121,17 @@ impl PacEnumItem {
121121 } ;
122122 for v in variants. iter ( ) {
123123 let ident = v. ident . clone ( ) ;
124- let value = match & v. discriminant {
125- Some ( d) => match & d. 1 {
126- syn:: Expr :: Lit ( expr_lit) => match & expr_lit. lit {
127- syn:: Lit :: Int ( lit_int) => match lit_int. base10_parse :: < usize > ( ) {
128- Ok ( num) => num,
129- Err ( _) => {
130- panic ! ( "All variant discriminants must be unsigned integers" )
131- }
132- } ,
133- _ => panic ! ( "All variant discriminants must be unsigned integers" ) ,
134- } ,
124+ let value = match v. discriminant . as_ref ( ) {
125+ Some ( ( _, syn:: Expr :: Lit ( expr_lit) ) ) => match & expr_lit. lit {
126+ syn:: Lit :: Int ( lit_int) => {
127+ lit_int. base10_parse :: < usize > ( ) . unwrap_or_else ( |_| {
128+ panic ! ( "All variant discriminants must be unsigned integers" )
129+ } )
130+ }
135131 _ => panic ! ( "All variant discriminants must be unsigned integers" ) ,
136132 } ,
137- _ => panic ! ( "Variant must have a discriminant" ) ,
133+ None => panic ! ( "Variant must have a discriminant" ) ,
134+ _ => panic ! ( "All variant discriminants must be literal expressions" ) ,
138135 } ;
139136
140137 if numbers. insert ( value, ident) . is_some ( ) {
Original file line number Diff line number Diff line change @@ -192,10 +192,12 @@ where
192192 }
193193
194194 // Restore MSTATUS.PIE, MSTATUS.MPP, and SEPC
195+ let mut after_mstatus = mstatus:: read ( ) ;
195196 if mstatus. mpie ( ) {
196- mstatus :: set_mpie ( ) ;
197+ after_mstatus . set_mpie ( mstatus . mpie ( ) ) ;
197198 }
198- mstatus:: set_mpp ( mstatus. mpp ( ) ) ;
199+ after_mstatus. set_mpp ( mstatus. mpp ( ) ) ;
200+ mstatus:: write ( after_mstatus) ;
199201 mepc:: write ( mepc) ;
200202
201203 r
You can’t perform that action at this time.
0 commit comments