source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/string/strlen.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 437 bytes
Line 
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4
5#define ALIGN (sizeof(size_t))
6#define ONES ((size_t)-1/UCHAR_MAX)
7#define HIGHS (ONES * (UCHAR_MAX/2+1))
8#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
9
10size_t strlen(const char *s)
11{
12 const char *a = s;
13 const size_t *w;
14 for (; (uintptr_t)s % ALIGN; s++) if (!*s) return s-a;
15 for (w = (const void *)s; !HASZERO(*w); w++);
16 for (s = (const void *)w; *s; s++);
17 return s-a;
18}
Note: See TracBrowser for help on using the repository browser.