@@ -23,37 +23,37 @@ use core::mem;
23
23
// means we can effectively skip the _mm_cmpeq_epi8 step and jump straight to
24
24
// _mm_movemask_epi8.
25
25
26
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
26
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
27
27
const USIZE_BYTES : usize = mem:: size_of :: < usize > ( ) ;
28
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
28
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
29
29
const FALLBACK_LOOP_SIZE : usize = 2 * USIZE_BYTES ;
30
30
31
31
// This is a mask where the most significant bit of each byte in the usize
32
32
// is set. We test this bit to determine whether a character is ASCII or not.
33
33
// Namely, a single byte is regarded as an ASCII codepoint if and only if it's
34
34
// most significant bit is not set.
35
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
35
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
36
36
const ASCII_MASK_U64 : u64 = 0x8080808080808080 ;
37
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
37
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
38
38
const ASCII_MASK : usize = ASCII_MASK_U64 as usize ;
39
39
40
40
/// Returns the index of the first non ASCII byte in the given slice.
41
41
///
42
42
/// If slice only contains ASCII bytes, then the length of the slice is
43
43
/// returned.
44
44
pub fn first_non_ascii_byte ( slice : & [ u8 ] ) -> usize {
45
- #[ cfg( not( target_arch = "x86_64" ) ) ]
45
+ #[ cfg( any ( miri , not( target_arch = "x86_64" ) ) ) ]
46
46
{
47
47
first_non_ascii_byte_fallback ( slice)
48
48
}
49
49
50
- #[ cfg( target_arch = "x86_64" ) ]
50
+ #[ cfg( all ( not ( miri ) , target_arch = "x86_64" ) ) ]
51
51
{
52
52
first_non_ascii_byte_sse2 ( slice)
53
53
}
54
54
}
55
55
56
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
56
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
57
57
fn first_non_ascii_byte_fallback ( slice : & [ u8 ] ) -> usize {
58
58
let align = USIZE_BYTES - 1 ;
59
59
let start_ptr = slice. as_ptr ( ) ;
@@ -115,7 +115,7 @@ fn first_non_ascii_byte_fallback(slice: &[u8]) -> usize {
115
115
}
116
116
}
117
117
118
- #[ cfg( target_arch = "x86_64" ) ]
118
+ #[ cfg( all ( not ( miri ) , target_arch = "x86_64" ) ) ]
119
119
fn first_non_ascii_byte_sse2 ( slice : & [ u8 ] ) -> usize {
120
120
use core:: arch:: x86_64:: * ;
121
121
@@ -221,7 +221,7 @@ unsafe fn first_non_ascii_byte_slow(
221
221
/// bytes is not an ASCII byte.
222
222
///
223
223
/// The position returned is always in the inclusive range [0, 7].
224
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
224
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
225
225
fn first_non_ascii_byte_mask ( mask : usize ) -> usize {
226
226
#[ cfg( target_endian = "little" ) ]
227
227
{
@@ -245,7 +245,7 @@ unsafe fn ptr_sub(ptr: *const u8, amt: usize) -> *const u8 {
245
245
ptr. offset ( ( amt as isize ) . wrapping_neg ( ) )
246
246
}
247
247
248
- #[ cfg( any( test, not( target_arch = "x86_64" ) ) ) ]
248
+ #[ cfg( any( test, miri , not( target_arch = "x86_64" ) ) ) ]
249
249
unsafe fn read_unaligned_usize ( ptr : * const u8 ) -> usize {
250
250
use core:: ptr;
251
251
@@ -286,6 +286,7 @@ mod tests {
286
286
287
287
#[ test]
288
288
#[ cfg( target_arch = "x86_64" ) ]
289
+ #[ cfg( not( miri) ) ]
289
290
fn positive_sse2_forward ( ) {
290
291
for i in 0 ..517 {
291
292
let b = "a" . repeat ( i) . into_bytes ( ) ;
@@ -294,6 +295,7 @@ mod tests {
294
295
}
295
296
296
297
#[ test]
298
+ #[ cfg( not( miri) ) ]
297
299
fn negative_fallback_forward ( ) {
298
300
for i in 0 ..517 {
299
301
for align in 0 ..65 {
@@ -315,6 +317,7 @@ mod tests {
315
317
316
318
#[ test]
317
319
#[ cfg( target_arch = "x86_64" ) ]
320
+ #[ cfg( not( miri) ) ]
318
321
fn negative_sse2_forward ( ) {
319
322
for i in 0 ..517 {
320
323
for align in 0 ..65 {
0 commit comments