mailing list of musl libc
 help / color / mirror / code / Atom feed
98b5e586498f028f8ad1f7c5ee6f17abfc66461b blob 812 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
30
31
32
33
34
35
 
#include <stddef.h>
#include <stdint.h>
#include <string.h>

#define HIGHS(x) ((x) - ((x)*0-1) / 255 * 128)
#define LOWS(x) (((x)*0-1) / 255)
#define has_zero(x) ((x) - LOWS(x) & ~(x) & HIGHS(x))

#undef strcmp
int strcmp(const char *l, const char *r)
{
	const size_t *wl;
	const size_t *wr;

	if ((uintptr_t)l % sizeof(size_t) != (uintptr_t)r % sizeof(size_t))
		goto bytewise;

	for (; (uintptr_t)l % sizeof(size_t); l++, r++) {
		if (*l != *r || !*l || !*r) {
			return *(unsigned char *)l
			       - *(unsigned char *)r;
		}
	}

	for (wl = (const size_t *)l, wr = (const size_t *)r
	     ; has_zero(*wl) || has_zero(*wr) && *wl == *wr
	     ; wl++, wr++);
	l = (const char *)wl;
	r = (const char *)wr;

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

	return *(unsigned char *)l - *(unsigned char *)r;
}
debug log:

solving 98b5e58 ...
found 98b5e58 in https://inbox.vuxu.org/musl/1365280696-16525-2-git-send-email-nwmcsween@gmail.com/
found 91eb740 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 91eb7404fd2bc127c7db8b65038356b1c2ec7873	src/string/strcmp.c

applying [1/1] https://inbox.vuxu.org/musl/1365280696-16525-2-git-send-email-nwmcsween@gmail.com/
diff --git a/src/string/strcmp.c b/src/string/strcmp.c
index 91eb740..98b5e58 100644

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

index at:
100644 98b5e586498f028f8ad1f7c5ee6f17abfc66461b	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).