Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
Main Page
Related Pages
+
Classes
Class List
Class Index
+
Class Members
+
All
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Variables
_
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
+
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
p
q
r
s
t
u
v
w
+
Variables
_
b
c
d
e
f
h
i
l
n
p
t
v
w
+
Typedefs
_
a
b
c
d
f
i
j
n
s
t
u
v
w
Enumerator
+
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerator
Macros
Pages
strcspn.c
Go to the documentation of this file.
1
#include "
strchrnul.h
"
2
#include <
stdint.h
>
3
#include <
string.h
>
4
5
#define BITOP(a, b, op) \
6
((a)[(size_t)(b) / (8 * sizeof *(a))] op(size_t) 1 << ((size_t)(b) % (8 * sizeof *(a))))
7
8
size_t
strcspn
(
const
char
* s,
const
char
* c)
9
{
10
const
char
* a = s;
11
size_t
byteset[32 /
sizeof
(size_t)];
12
13
if
(!c[0] || !c[1])
14
{
15
return
(uintptr_t)(
__strchrnul
(s, *c) - (uintptr_t)a);
16
}
17
18
memset
(byteset, 0,
sizeof
byteset);
19
for
(; *c &&
BITOP
(byteset, *(
const
unsigned
char
*)c, |=); c++)
20
{
21
{
22
;
23
}
24
}
25
for
(; *s && !
BITOP
(byteset, *(
const
unsigned
char
*)s, &); s++)
26
{
27
{
28
;
29
}
30
}
31
return
(uintptr_t)s - (uintptr_t)a;
32
}
strcspn
size_t strcspn(const char *s, const char *c)
Definition:
strcspn.c:8
string.h
__strchrnul
char * __strchrnul(const char *, int)
Definition:
strchrnul.c:13
BITOP
#define BITOP(a, b, op)
Definition:
strcspn.c:5
memset
void * memset(void *dest, int c, size_t n)
Copies the value c into each of the first n characters of the object pointed to by dest.
stdint.h
strchrnul.h
src
string
strcspn.c
Generated by
1.8.15