141952Sbostic /*- 241952Sbostic * Copyright (c) 1990 The Regents of the University of California. 334479Sbostic * All rights reserved. 434479Sbostic * 541952Sbostic * This code is derived from software contributed to Berkeley by 641952Sbostic * Chris Torek. 741952Sbostic * 841952Sbostic * %sccs.include.redist.c% 924195Skre */ 1024195Skre 1126527Sdonn #if defined(LIBC_SCCS) && !defined(lint) 12*46144Sbostic static char sccsid[] = "@(#)memcmp.c 5.6 (Berkeley) 01/26/91"; 1334479Sbostic #endif /* LIBC_SCCS and not lint */ 1424195Skre 15*46144Sbostic #include <sys/cdefs.h> 1641952Sbostic #include <string.h> 1741952Sbostic 1841952Sbostic /* 1941952Sbostic * Compare memory regions. 2041952Sbostic */ 2141952Sbostic int 2224195Skre memcmp(s1, s2, n) 2341952Sbostic const void *s1, *s2; 2441952Sbostic size_t n; 2524195Skre { 2641952Sbostic if (n != 0) { 2741952Sbostic register const unsigned char *p1 = s1, *p2 = s2; 2841952Sbostic 2941952Sbostic do { 3041952Sbostic if (*p1++ != *p2++) 3141952Sbostic return (*--p1 - *--p2); 3241952Sbostic } while (--n != 0); 3341952Sbostic } 3424195Skre return (0); 3524195Skre } 36