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] = [
42
42
#[ export_name = "_dispatch_exception" ]
43
43
#[ inline]
44
44
unsafe 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) ,
52
48
}
53
49
}
Original file line number Diff line number Diff line change @@ -28,13 +28,9 @@ pub static __CORE_INTERRUPTS: [Option<unsafe extern "C" fn()>; 12] = [
28
28
#[ export_name = "_dispatch_core_interrupt" ]
29
29
#[ inline]
30
30
unsafe 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 ( ) ,
38
34
}
39
35
}
40
36
Original file line number Diff line number Diff line change @@ -121,20 +121,17 @@ impl PacEnumItem {
121
121
} ;
122
122
for v in variants. iter ( ) {
123
123
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
+ }
135
131
_ => panic ! ( "All variant discriminants must be unsigned integers" ) ,
136
132
} ,
137
- _ => panic ! ( "Variant must have a discriminant" ) ,
133
+ None => panic ! ( "Variant must have a discriminant" ) ,
134
+ _ => panic ! ( "All variant discriminants must be literal expressions" ) ,
138
135
} ;
139
136
140
137
if numbers. insert ( value, ident) . is_some ( ) {
Original file line number Diff line number Diff line change @@ -192,10 +192,12 @@ where
192
192
}
193
193
194
194
// Restore MSTATUS.PIE, MSTATUS.MPP, and SEPC
195
+ let mut after_mstatus = mstatus:: read ( ) ;
195
196
if mstatus. mpie ( ) {
196
- mstatus :: set_mpie ( ) ;
197
+ after_mstatus . set_mpie ( mstatus . mpie ( ) ) ;
197
198
}
198
- mstatus:: set_mpp ( mstatus. mpp ( ) ) ;
199
+ after_mstatus. set_mpp ( mstatus. mpp ( ) ) ;
200
+ mstatus:: write ( after_mstatus) ;
199
201
mepc:: write ( mepc) ;
200
202
201
203
r
You can’t perform that action at this time.
0 commit comments