repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
PR tree-optimization/81384 - built-in form of strnlen missing
[official-gcc.git]
/
gcc
/
testsuite
/
gcc.c-torture
/
execute
/
builtins
/
lib
/
strnlen.c
blob
73ada14eb952e528e530b312ba3b781577f34032
1
typedef
__SIZE_TYPE__
size_t
;
2
3
extern
void
abort
(
void
);
4
extern
int
inside_main
;
5
6
__attribute__
((
__noinline__
))
7
size_t
8
strnlen
(
const char
*
s
,
size_t
n
)
9
{
10
size_t
i
;
11
12
#ifdef __OPTIMIZE__
13
if
(
inside_main
)
14
abort
();
15
#endif
16
17
i
=
0
;
18
while
(
s
[
i
] !=
0
&&
n
--)
19
i
++;
20
21
return
i
;
22
}