141952Sbostic /*- 2*61193Sbostic * Copyright (c) 1990, 1993 3*61193Sbostic * The Regents of the University of California. 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*61193Sbostic static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 06/04/93"; 1334479Sbostic #endif /* LIBC_SCCS and not lint */ 1424195Skre 1546144Sbostic #include <sys/cdefs.h> 1641952Sbostic #include <string.h> 1741952Sbostic 1841952Sbostic /* 1941952Sbostic * Compare memory regions. 2041952Sbostic */ 2141952Sbostic int memcmp(s1,s2,n)2224195Skrememcmp(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