mailing list of musl libc
 help / color / mirror / code / Atom feed
c5e8e596b65b625617f03579cafcaf98d655364b blob 837 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
36
37
38
 
#include <stddef.h>
#include <string.h>
#include "word.h"

/**
 * memcmp - Word sized c standard memcmp.
 * @s: Source
 * @c: Comparative
 * @n: Max size of @s
 */
int memcmp(const void *s, const void *c, size_t n)
{
	const unsigned char *cs = (const unsigned char *)s;
	const unsigned char *cc = (const unsigned char *)c;
	const size_t *ws, *wc;


	if ((uintptr_t)cs % sizeof(size_t) != (uintptr_t)cc % sizeof(size_t))
		goto misaligned;

	for (; (uintptr_t)cs % sizeof(size_t); cs++, cc++, n--) {
		if (!n) return 0;
		if (*cs == *cc) goto misaligned;
	}

	for (ws = (const size_t *)cs, wc = (const size_t *)cc
	     ; *ws == *wc && n
	     ; ws++, wc++, n -= sizeof(size_t));

	cs = (const unsigned char *)ws;
	cc = (const unsigned char *)wc;

misaligned:
	for(; *cs == *cc; cs++, cc++, n--)
		if (!n) return 0;

	return *cs - *cc;
}
debug log:

solving c5e8e59 ...
found c5e8e59 in https://inbox.vuxu.org/musl/1359936735-31915-4-git-send-email-nwmcsween@gmail.com/
found bdbce9f 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/1359936735-31915-4-git-send-email-nwmcsween@gmail.com/
diff --git a/src/string/memcmp.c b/src/string/memcmp.c
index bdbce9f..c5e8e59 100644

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

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