mailing list of musl libc
 help / color / mirror / code / Atom feed
80405595df215f5d68cfb2b05293e9f8b56af0d5 blob 830 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
24
25
26
27
28
29
 
#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))
#define weak_alias(o, n) extern __typeof__(o) n __attribute__((weak, alias(#o)))

char *__strchrnul(const char *_s, int i)
{
	i = (unsigned char)i;
	const unsigned char *s = (const void *)_s;
	const size_t aliases *ws, wi = byte_repeat(i);

	if (!i) return (char *)s + strlen((char *)s);

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

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

	for (; *s && *s != i; s++);

	return (char *)s;
}

weak_alias(__strchrnul, strchrnul);
debug log:

solving 80405595 ...
found 80405595 in https://inbox.vuxu.org/musl/20170715195541.3136-3-nwmcsween@gmail.com/
found 05700ad6 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 05700ad64eea55cb8f6dffad0fe6dd97feb3d31c	src/string/strchrnul.c

applying [1/1] https://inbox.vuxu.org/musl/20170715195541.3136-3-nwmcsween@gmail.com/
diff --git a/src/string/strchrnul.c b/src/string/strchrnul.c
index 05700ad6..80405595 100644

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

index at:
100644 80405595df215f5d68cfb2b05293e9f8b56af0d5	src/string/strchrnul.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).