File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -381,10 +381,10 @@ impl<'c> Translation<'c> {
381381 }
382382
383383 "__builtin_ia32_pause" => {
384- // `spin_loop()` is implemented as ` _mm_pause()` (the `pause` instruction) on `x86`/`x86_64`,
385- // but it's the safe and cross-platform version of it, so prefer it.
386- let spin_loop = mk ( ) . abs_path_expr ( vec ! [ "core" , "hint" , "spin_loop" ] ) ;
387- let call = mk ( ) . call_expr ( spin_loop , vec ! [ ] ) ;
384+ let fn_name = " _mm_pause" ;
385+ self . import_simd_function ( fn_name ) ? ;
386+ let ident = mk ( ) . ident_expr ( fn_name ) ;
387+ let call = mk ( ) . call_expr ( ident , vec ! [ ] ) ;
388388 self . convert_side_effects_expr (
389389 ctx,
390390 WithStmts :: new_val ( call) ,
Original file line number Diff line number Diff line change 77 unused_assignments,
88 unused_mut
99) ]
10+ #![ feature( stdsimd) ]
11+ #[ cfg( target_arch = "x86" ) ]
12+ pub use core:: arch:: x86:: _mm_pause;
13+ #[ cfg( target_arch = "x86_64" ) ]
14+ pub use core:: arch:: x86_64:: _mm_pause;
1015#[ no_mangle]
1116pub unsafe extern "C" fn spin ( ) {
12- :: core :: hint :: spin_loop ( ) ;
17+ _mm_pause ( ) ;
1318}
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ input_file: c2rust-transpile/tests/snapshots/arch-specific/spin.c
1212 unused_assignments ,
1313 unused_mut
1414)]
15+ #! [feature (stdsimd )]
16+ #[cfg (target_arch = " x86" )]
17+ pub use core ::arch ::x86 ::_mm_pause ;
18+ #[cfg (target_arch = " x86_64" )]
19+ pub use core ::arch ::x86_64 ::_mm_pause ;
1520#[no_mangle ]
1621pub unsafe extern " C" fn spin () {
17- :: core :: hint :: spin_loop ();
22+ _mm_pause ();
1823}
You can’t perform that action at this time.
0 commit comments