source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/string/strchrnul.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: 635 bytes
Line 
1#include <string.h>
2#include <stdint.h>
3#include <limits.h>
4#include "libc.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
11char *__strchrnul(const char *s, int c)
12{
13 size_t *w, k;
14
15 c = (unsigned char)c;
16 if (!c) return (char *)s + strlen(s);
17
18 for (; (uintptr_t)s % ALIGN; s++)
19 if (!*s || *(unsigned char *)s == c) return (char *)s;
20 k = ONES * c;
21 for (w = (void *)s; !HASZERO(*w) && !HASZERO(*w^k); w++);
22 for (s = (void *)w; *s && *(unsigned char *)s != c; s++);
23 return (char *)s;
24}
25
26weak_alias(__strchrnul, strchrnul);
Note: See TracBrowser for help on using the repository browser.