memchr/arch/aarch64/
memchr.rs
1macro_rules! defraw {
10 ($ty:ident, $find:ident, $start:ident, $end:ident, $($needles:ident),+) => {{
11 #[cfg(target_feature = "neon")]
12 {
13 use crate::arch::aarch64::neon::memchr::$ty;
14
15 debug!("chose neon for {}", stringify!($ty));
16 debug_assert!($ty::is_available());
17 $ty::new_unchecked($($needles),+).$find($start, $end)
21 }
22 #[cfg(not(target_feature = "neon"))]
23 {
24 use crate::arch::all::memchr::$ty;
25
26 debug!(
27 "no neon feature available, using fallback for {}",
28 stringify!($ty),
29 );
30 $ty::new($($needles),+).$find($start, $end)
31 }
32 }}
33}
34
35#[inline(always)]
41pub(crate) unsafe fn memchr_raw(
42 n1: u8,
43 start: *const u8,
44 end: *const u8,
45) -> Option<*const u8> {
46 defraw!(One, find_raw, start, end, n1)
47}
48
49#[inline(always)]
55pub(crate) unsafe fn memrchr_raw(
56 n1: u8,
57 start: *const u8,
58 end: *const u8,
59) -> Option<*const u8> {
60 defraw!(One, rfind_raw, start, end, n1)
61}
62
63#[inline(always)]
69pub(crate) unsafe fn memchr2_raw(
70 n1: u8,
71 n2: u8,
72 start: *const u8,
73 end: *const u8,
74) -> Option<*const u8> {
75 defraw!(Two, find_raw, start, end, n1, n2)
76}
77
78#[inline(always)]
84pub(crate) unsafe fn memrchr2_raw(
85 n1: u8,
86 n2: u8,
87 start: *const u8,
88 end: *const u8,
89) -> Option<*const u8> {
90 defraw!(Two, rfind_raw, start, end, n1, n2)
91}
92
93#[inline(always)]
99pub(crate) unsafe fn memchr3_raw(
100 n1: u8,
101 n2: u8,
102 n3: u8,
103 start: *const u8,
104 end: *const u8,
105) -> Option<*const u8> {
106 defraw!(Three, find_raw, start, end, n1, n2, n3)
107}
108
109#[inline(always)]
115pub(crate) unsafe fn memrchr3_raw(
116 n1: u8,
117 n2: u8,
118 n3: u8,
119 start: *const u8,
120 end: *const u8,
121) -> Option<*const u8> {
122 defraw!(Three, rfind_raw, start, end, n1, n2, n3)
123}
124
125#[inline(always)]
131pub(crate) unsafe fn count_raw(
132 n1: u8,
133 start: *const u8,
134 end: *const u8,
135) -> usize {
136 defraw!(One, count_raw, start, end, n1)
137}