mailing list of musl libc
 help / color / mirror / code / Atom feed
a2f358a9e69081ccac45a44849e488320ff2f37c blob 787 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
 
#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))

int strcmp(const char *_l, const char *_r)
{
	const unsigned char *l = (const void *)_l, *r = (const void *)_r;
	const size_t aliases *wl, aliases *wr;

	if (((uintptr_t)l | (uintptr_t)r) & sizeof(size_t) - 1) goto bytewise;

	for (; (uintptr_t)l & sizeof(size_t) - 1 && *l && *l == *r; l++, r++);
	if ((uintptr_t)l & sizeof(size_t) - 1) return *l - *r;

	wl = (const void *)l;
	wr = (const void *)r;
	for (; !word_has_zero(*wl) && *wl == *wr; wl++, wr++);
	l = (const void *)wl;
	r = (const void *)wr;

bytewise:
	for (; *l && *l == *r; l++, r++);

	return *l - *r;
}
debug log:

solving a2f358a9 ...
found a2f358a9 in https://inbox.vuxu.org/musl/20170715195541.3136-2-nwmcsween@gmail.com/
found 808bd837 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 808bd8370ddeca3a2cfc124601cbd6012be89f80	src/string/strcmp.c

applying [1/1] https://inbox.vuxu.org/musl/20170715195541.3136-2-nwmcsween@gmail.com/
diff --git a/src/string/strcmp.c b/src/string/strcmp.c
index 808bd837..a2f358a9 100644

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

index at:
100644 a2f358a9e69081ccac45a44849e488320ff2f37c	src/string/strcmp.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).