@@ -35,11 +35,9 @@ pub fn device(
35
35
36
36
if * target != Target :: None {
37
37
items. push ( quote ! {
38
- #![ cfg_attr( feature = "rt" , feature( asm) ) ]
39
- #![ cfg_attr( feature = "rt" , feature( core_intrinsics) ) ]
38
+ #![ cfg_attr( feature = "rt" , feature( global_asm) ) ]
40
39
#![ cfg_attr( feature = "rt" , feature( linkage) ) ]
41
40
#![ cfg_attr( feature = "rt" , feature( macro_reexport) ) ]
42
- #![ cfg_attr( feature = "rt" , feature( naked_functions) ) ]
43
41
#![ cfg_attr( feature = "rt" , feature( used) ) ]
44
42
} ) ;
45
43
}
@@ -234,52 +232,45 @@ pub fn interrupt(
234
232
names. push ( name_uc) ;
235
233
}
236
234
235
+ let aliases = names. iter ( )
236
+ . map ( |n| format ! ( "
237
+ .weak {0}
238
+ {0} = DEFAULT_HANDLER" , n) )
239
+ . collect :: < Vec < _ > > ( )
240
+ . concat ( ) ;
241
+
237
242
let n = util:: unsuffixed ( u64 ( pos) ) ;
238
243
match * target {
239
244
Target :: CortexM => {
240
245
mod_items. push ( quote ! {
241
- #(
242
- #[ allow( non_snake_case) ]
243
- #[ allow( private_no_mangle_fns) ]
244
- #[ cfg( feature = "rt" ) ]
245
- #[ linkage = "weak" ]
246
- #[ naked]
247
- #[ no_mangle]
248
- extern "C" fn #names( ) {
249
- unsafe {
250
- asm!( "b DEFAULT_HANDLER" :: :: "volatile" ) ;
251
- :: core:: intrinsics:: unreachable( )
252
- }
253
- }
254
- ) *
246
+ #[ cfg( feature = "rt" ) ]
247
+ global_asm!( #aliases) ;
248
+
249
+ #[ cfg( feature = "rt" ) ]
250
+ extern "C" {
251
+ #( fn #names( ) ; ) *
252
+ }
255
253
256
254
#[ allow( private_no_mangle_statics) ]
257
255
#[ cfg( feature = "rt" ) ]
258
256
#[ doc( hidden) ]
259
257
#[ link_section = ".vector_table.interrupts" ]
260
258
#[ no_mangle]
261
259
#[ used]
262
- pub static INTERRUPTS : [ Option <extern "C" fn ( ) >; #n] = [
260
+ pub static INTERRUPTS : [ Option <unsafe extern "C" fn ( ) >; #n] = [
263
261
#( #elements, ) *
264
262
] ;
265
263
} ) ;
266
264
}
267
265
Target :: Msp430 => {
268
266
mod_items. push ( quote ! {
269
- #(
270
- #[ allow( non_snake_case) ]
271
- #[ allow( private_no_mangle_fns) ]
272
- #[ cfg( feature = "rt" ) ]
273
- #[ linkage = "weak" ]
274
- #[ naked]
275
- #[ no_mangle]
276
- extern "msp430-interrupt" fn #names( ) {
277
- unsafe {
278
- asm!( "jmp DEFAULT_HANDLER" :: :: "volatile" ) ;
279
- :: core:: intrinsics:: unreachable( )
280
- }
281
- }
282
- ) *
267
+ #[ cfg( feature = "rt" ) ]
268
+ global_asm!( #aliases) ;
269
+
270
+ #[ cfg( feature = "rt" ) ]
271
+ extern "msp430-interrupt" {
272
+ #( fn #names( ) ; ) *
273
+ }
283
274
284
275
#[ allow( private_no_mangle_statics) ]
285
276
#[ cfg( feature = "rt" ) ]
@@ -288,7 +279,7 @@ pub fn interrupt(
288
279
#[ no_mangle]
289
280
#[ used]
290
281
pub static INTERRUPTS :
291
- [ Option <extern "msp430-interrupt" fn ( ) >; #n] = [
282
+ [ Option <unsafe extern "msp430-interrupt" fn ( ) >; #n] = [
292
283
#( #elements, ) *
293
284
] ;
294
285
} ) ;
0 commit comments