mailing list of musl libc
 help / color / mirror / code / Atom feed
7d2e8077dedfa4c277d96f18f2c242a8b99caf84 blob 709 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__))

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

	if (n < sizeof(size_t) * 3 || ((uintptr_t)l | (uintptr_t)r)
	    & sizeof(size_t) - 1) goto bytewise;

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

	wl = (const void *)l;
	wr = (const void *)r;
	for (; n >= sizeof(size_t) && *wl == *wr
	     ; wl++, wr++, n -= sizeof(size_t));
	l = (const void *)wl;
	r = (const void *)wr;

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

	return n ? *l - *r : 0;
}
debug log:

solving 7d2e8077 ...
found 7d2e8077 in https://inbox.vuxu.org/musl/20170715195541.3136-2-nwmcsween@gmail.com/
found bdbce9f0 in https://git.vuxu.org/mirror/musl/
preparing index
index prepared:
100644 bdbce9f0f563cc957b971ef1f2b9dd88421f772a	src/string/memcmp.c

applying [1/1] https://inbox.vuxu.org/musl/20170715195541.3136-2-nwmcsween@gmail.com/
diff --git a/src/string/memcmp.c b/src/string/memcmp.c
index bdbce9f0..7d2e8077 100644

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

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