PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
strlen.c
1
#define SYSCLIB_DISABLE_BUILTINS
2
#include <
sysclib.h
>
3
#include <stdint.h>
4
#include <limits.h>
5
6
#define ALIGN (sizeof(size_t))
7
#define ONES ((size_t)-1/UCHAR_MAX)
8
#define HIGHS (ONES * (UCHAR_MAX/2+1))
9
#define HASZERO(x) (((x)-ONES) & ~(x) & HIGHS)
10
11
size_t
strlen(
const
char
*s)
12
{
13
const
char
*a = s;
14
#ifdef __GNUC__
15
typedef
size_t
__attribute__
((__may_alias__)) word;
16
const
word *w;
17
for
(; (uintptr_t)s % ALIGN; s++)
if
(!*s)
return
s-a;
18
for
(w = (
const
void
*)s; !HASZERO(*w); w++);
19
s = (
const
void
*)w;
20
#endif
21
for
(; *s; s++);
22
return
s-a;
23
}
__attribute__
Definition
gif_registers.h:39
sysclib.h
iop
system
sysclib
src
musl
string
strlen.c
Generated on Thu Nov 14 2024 05:25:29 for PS2SDK by
1.9.8