mailing list of musl libc
 help / color / mirror / code / Atom feed
19ba310a5290f15c7f5cb7f21bd92e0548490e83 blob 505 bytes (raw)

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

#define aliases __attribute__((__may_alias__))
#define byte_repeat(x) ((size_t)~0 / 0xff * (x))
#define word_has_zero(x) (((x) - byte_repeat(0x01)) & ~(x) & byte_repeat(0x80))

size_t strlen(const char *s)
{
	const char *const s0 = s;
	const size_t aliases *ws;

	for (; (uintptr_t)s & sizeof(size_t) - 1 && *s; s++);
	if (!*s) return s - s0;

	ws = (const void *)s;
	for (; !word_has_zero(*ws); ws++);
	s = (const void *)ws;

	for (; *s; s++);

	return s - s0;
}
debug log:

solving 19ba310a ...
found 19ba310a in https://inbox.vuxu.org/musl/20170715195541.3136-3-nwmcsween@gmail.com/
found 929ddcbc in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 929ddcbc1c2594762c7b44cdfd5edf0f2955d1f6	src/string/strlen.c

applying [1/1] https://inbox.vuxu.org/musl/20170715195541.3136-3-nwmcsween@gmail.com/
diff --git a/src/string/strlen.c b/src/string/strlen.c
index 929ddcbc..19ba310a 100644

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

index at:
100644 19ba310a5290f15c7f5cb7f21bd92e0548490e83	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).