3
A brief file description
5
@section license License
7
Licensed to the Apache Software Foundation (ASF) under one
8
or more contributor license agreements. See the NOTICE file
9
distributed with this work for additional information
10
regarding copyright ownership. The ASF licenses this file
11
to you under the Apache License, Version 2.0 (the
12
"License"); you may not use this file except in compliance
13
with the License. You may obtain a copy of the License at
15
http://www.apache.org/licenses/LICENSE-2.0
17
Unless required by applicable law or agreed to in writing, software
18
distributed under the License is distributed on an "AS IS" BASIS,
19
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
See the License for the specific language governing permissions and
21
limitations under the License.
30
ink_memchr(const void *as, int ac, size_t an)
32
unsigned char c = (unsigned char) ac;
33
unsigned char *s = (unsigned char *) as;
37
int i_len = (int)(((uintptr_t) 8 - (uintptr_t) as) & 7);
39
// too short to concern us
41
if ((int) an < i_len) {
42
for (int i = 0; i < (int) an; i++)
68
unsigned int im = 0x7efefeff;
70
unsigned int ibp = *(unsigned int *) s;
71
unsigned int ibb = ibp ^ ib;
72
ibb = ((ibb + im) ^ ~ibb) & ~im;
86
uint64_t m = 0x7efefefefefefeffLL;
87
uint64_t b = ((uint64_t) ib);
89
uint64_t *p = (uint64_t *) s;
90
unsigned int n = (((unsigned int) an) - (s - (unsigned char *) as)) >> 3;
91
uint64_t *end = p + n;
95
bb = ((bb + m) ^ ~bb) & ~m;
97
s = (unsigned char *) p;
120
i_len = an - (((unsigned char *) p) - ((unsigned char *) as));
121
s = (unsigned char *) p;
126
unsigned int ibp = *(unsigned int *) s;
127
unsigned int ibb = ibp ^ ib;
128
ibb = ((ibb + im) ^ ~ibb) & ~im;
160
#define MEMCHR(_s,_c) ink_memchr(_s,_c,strlen(_s))?:""
164
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkdufla asdfj3i", ' '));
165
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkdufla asdfj3i", '3'));
166
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkdufla asdfj3i", '\n'));
167
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalk$uflaE$$dfj3i", '$'));
168
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkd#####asdfj3i", '#'));
169
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkdufla a^^sdfj3i", '^'));
170
printf("%d %s\n", i++, MEMCHR("a;ldkfjoiwenalkdufla asd*************fj3i", '*'));