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> {
381
381
}
382
382
383
383
"__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 ! [ ] ) ;
388
388
self . convert_side_effects_expr (
389
389
ctx,
390
390
WithStmts :: new_val ( call) ,
Original file line number Diff line number Diff line change 7
7
unused_assignments,
8
8
unused_mut
9
9
) ]
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;
10
15
#[ no_mangle]
11
16
pub unsafe extern "C" fn spin ( ) {
12
- :: core :: hint :: spin_loop ( ) ;
17
+ _mm_pause ( ) ;
13
18
}
Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ input_file: c2rust-transpile/tests/snapshots/arch-specific/spin.c
12
12
unused_assignments ,
13
13
unused_mut
14
14
)]
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 ;
15
20
#[no_mangle ]
16
21
pub unsafe extern " C" fn spin () {
17
- :: core :: hint :: spin_loop ();
22
+ _mm_pause ();
18
23
}
You can’t perform that action at this time.
0 commit comments