@@ -174,17 +174,16 @@ fn emit_func(func: ItemFn, sig: &ParsedSig, errno: bool) -> Result<ItemFn> {
174174
175175 #kernel_func
176176
177- #[ cfg( not( any(
178- target_arch = "riscv64" ,
179- feature = "common-os"
180- ) ) ) ]
181- unsafe { crate :: arch:: kernel:: kernel_stack:: #kernel_function_ident( #kernel_ident, #( #args) , * ) }
182-
183- #[ cfg( any(
184- target_arch = "riscv64" ,
185- feature = "common-os"
186- ) ) ]
187- #unsafety { #kernel_ident( #( #args) , * ) }
177+ cfg_if:: cfg_if! {
178+ if #[ cfg( all(
179+ feature = "kernel-stack" ,
180+ not( any( target_arch = "riscv64" , feature = "common-os" ) )
181+ ) ) ] {
182+ unsafe { crate :: arch:: kernel:: kernel_stack:: #kernel_function_ident( #kernel_ident, #( #args) , * ) }
183+ } else {
184+ #unsafety { #kernel_ident( #( #args) , * ) }
185+ }
186+ }
188187 } } ,
189188 ..func
190189 } ;
@@ -255,17 +254,16 @@ mod tests {
255254 ret
256255 }
257256
258- #[ cfg( not( any(
259- target_arch = "riscv64" ,
260- feature = "common-os"
261- ) ) ) ]
262- unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
263-
264- #[ cfg( any(
265- target_arch = "riscv64" ,
266- feature = "common-os"
267- ) ) ]
268- { _sys_test( a, b) }
257+ cfg_if:: cfg_if! {
258+ if #[ cfg( all(
259+ feature = "kernel-stack" ,
260+ not( any( target_arch = "riscv64" , feature = "common-os" ) )
261+ ) ) ] {
262+ unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
263+ } else {
264+ { _sys_test( a, b) }
265+ }
266+ }
269267 }
270268 } ;
271269
@@ -324,17 +322,16 @@ mod tests {
324322 ret
325323 }
326324
327- #[ cfg( not( any(
328- target_arch = "riscv64" ,
329- feature = "common-os"
330- ) ) ) ]
331- unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
332-
333- #[ cfg( any(
334- target_arch = "riscv64" ,
335- feature = "common-os"
336- ) ) ]
337- unsafe { _sys_test( a, b) }
325+ cfg_if:: cfg_if! {
326+ if #[ cfg( all(
327+ feature = "kernel-stack" ,
328+ not( any( target_arch = "riscv64" , feature = "common-os" ) )
329+ ) ) ] {
330+ unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
331+ } else {
332+ unsafe { _sys_test( a, b) }
333+ }
334+ }
338335 }
339336 } ;
340337
@@ -395,17 +392,16 @@ mod tests {
395392 ret
396393 }
397394
398- #[ cfg( not( any(
399- target_arch = "riscv64" ,
400- feature = "common-os"
401- ) ) ) ]
402- unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
403-
404- #[ cfg( any(
405- target_arch = "riscv64" ,
406- feature = "common-os"
407- ) ) ]
408- { _sys_test( a, b) }
395+ cfg_if:: cfg_if! {
396+ if #[ cfg( all(
397+ feature = "kernel-stack" ,
398+ not( any( target_arch = "riscv64" , feature = "common-os" ) )
399+ ) ) ] {
400+ unsafe { crate :: arch:: kernel:: kernel_stack:: kernel_function2( _sys_test, a, b) }
401+ } else {
402+ { _sys_test( a, b) }
403+ }
404+ }
409405 }
410406 } ;
411407
0 commit comments