@@ -62,11 +62,14 @@ use minicore::*;
6262#[ no_mangle]
6363#[ unsafe( naked) ]
6464pub extern "C" fn naked_empty ( ) {
65- #[ cfg( not( all( target_arch = "arm" , target_feature = "thumb-mode" ) ) ) ]
66- naked_asm ! ( "ret" ) ;
67-
68- #[ cfg( all( target_arch = "arm" , target_feature = "thumb-mode" ) ) ]
69- naked_asm ! ( "bx lr" ) ;
65+ cfg_select ! {
66+ all( target_arch = "arm" , target_feature = "thumb-mode" ) => {
67+ naked_asm!( "bx lr" ) ;
68+ }
69+ _ => {
70+ naked_asm!( "ret" ) ;
71+ }
72+ }
7073}
7174
7275// linux,win: .intel_syntax
@@ -116,19 +119,16 @@ pub extern "C" fn naked_empty() {
116119#[ no_mangle]
117120#[ unsafe( naked) ]
118121pub extern "C" fn naked_with_args_and_return ( a : isize , b : isize ) -> isize {
119- #[ cfg( any( target_os = "windows" , target_os = "linux" ) ) ]
120- {
121- naked_asm ! ( "lea rax, [rdi + rsi]" , "ret" )
122- }
123-
124- #[ cfg( target_os = "macos" ) ]
125- {
126- naked_asm ! ( "add x0, x0, x1" , "ret" )
127- }
128-
129- #[ cfg( all( target_arch = "arm" , target_feature = "thumb-mode" ) ) ]
130- {
131- naked_asm ! ( "adds r0, r0, r1" , "bx lr" )
122+ cfg_select ! {
123+ any( target_arch = "x86_64" , target_arch = "x86" ) => {
124+ naked_asm!( "lea rax, [rdi + rsi]" , "ret" )
125+ }
126+ target_arch = "aarch64" => {
127+ naked_asm!( "add x0, x0, x1" , "ret" )
128+ }
129+ all( target_arch = "arm" , target_feature = "thumb-mode" ) => {
130+ naked_asm!( "adds r0, r0, r1" , "bx lr" )
131+ }
132132 }
133133}
134134
@@ -141,11 +141,14 @@ pub extern "C" fn naked_with_args_and_return(a: isize, b: isize) -> isize {
141141#[ unsafe( naked) ]
142142#[ link_section = ".text.some_different_name" ]
143143pub extern "C" fn test_link_section ( ) {
144- #[ cfg( not( all( target_arch = "arm" , target_feature = "thumb-mode" ) ) ) ]
145- naked_asm ! ( "ret" ) ;
146-
147- #[ cfg( all( target_arch = "arm" , target_feature = "thumb-mode" ) ) ]
148- naked_asm ! ( "bx lr" ) ;
144+ cfg_select ! {
145+ all( target_arch = "arm" , target_feature = "thumb-mode" ) => {
146+ naked_asm!( "bx lr" ) ;
147+ }
148+ _ => {
149+ naked_asm!( "ret" ) ;
150+ }
151+ }
149152}
150153
151154// win_x86: .def fastcall_cc
0 commit comments