mailing list of musl libc
 help / color / mirror / code / Atom feed
92784ea42c93c330cb81f7df8e635369374fb61a blob 459 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <limits.h>

#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)

size_t strlen(const char *s)
{
	const char *a = s;
	const size_t *w;
	for (; (uintptr_t)s & ALIGN; s++) if (!*s) return s-a;
	for (w = (const void *)s; !HASZERO(*w); w++);
	for (s = (const void *)w; *s; s++);
	return s-a;
}
debug log:

solving 92784ea ...
found 92784ea in https://inbox.vuxu.org/musl/CAMRJFfL3ZnFdiW9_JS2p3mpvSLp_28zwmZDu3GbmNo+jkfdqsA@mail.gmail.com/
found d6f8631 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 d6f8631d59dd1ba47334d955fc1fe6e94106dcf3	src/string/strlen.c

applying [1/1] https://inbox.vuxu.org/musl/CAMRJFfL3ZnFdiW9_JS2p3mpvSLp_28zwmZDu3GbmNo+jkfdqsA@mail.gmail.com/
diff --git a/src/string/strlen.c b/src/string/strlen.c
index d6f8631..92784ea 100644

Checking patch src/string/strlen.c...
Applied patch src/string/strlen.c cleanly.

index at:
100644 92784ea42c93c330cb81f7df8e635369374fb61a	src/string/strlen.c

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).