@@ -174,17 +174,16 @@ fn emit_func(func: ItemFn, sig: &ParsedSig, errno: bool) -> Result<ItemFn> {
174
174
175
175
#kernel_func
176
176
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
+ }
188
187
} } ,
189
188
..func
190
189
} ;
@@ -255,17 +254,16 @@ mod tests {
255
254
ret
256
255
}
257
256
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
+ }
269
267
}
270
268
} ;
271
269
@@ -324,17 +322,16 @@ mod tests {
324
322
ret
325
323
}
326
324
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
+ }
338
335
}
339
336
} ;
340
337
@@ -395,17 +392,16 @@ mod tests {
395
392
ret
396
393
}
397
394
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
+ }
409
405
}
410
406
} ;
411
407
0 commit comments