MCPcopy Create free account
hub / github.com/coreboot/coreboot / memcmp

Function memcmp

payloads/libpayload/libc/memory.c:127–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125 */
126
127int memcmp(const void *s1, const void *s2, size_t n)
128{
129 size_t i = 0;
130 const unsigned long *w1 = s1, *w2 = s2;
131
132 if (IS_ALIGNED((uintptr_t)s1, sizeof(unsigned long)) &&
133 IS_ALIGNED((uintptr_t)s2, sizeof(unsigned long)))
134 for (; i < n / sizeof(unsigned long); i++)
135 if (w1[i] != w2[i])
136 break; /* fall through to find differing byte */
137
138 for (i *= sizeof(unsigned long); i < n; i++)
139 if (((u8 *)s1)[i] != ((u8 *)s2)[i])
140 return ((u8 *)s1)[i] - ((u8 *)s2)[i];
141
142 return 0;
143}
144
145void *memchr(const void *s, int c, size_t n)
146{

Callers 6

strstrFunction · 0.70
fmap_is_signature_validFunction · 0.70
lookup_cmos_entryFunction · 0.50
lookup_cmos_enum_coreFunction · 0.50
vb2_hash_verifyFunction · 0.50

Calls

no outgoing calls

Tested by 1

vb2_hash_verifyFunction · 0.40