1*41952Sbostic /*- 2*41952Sbostic * Copyright (c) 1990 The Regents of the University of California. 334479Sbostic * All rights reserved. 434479Sbostic * 5*41952Sbostic * This code is derived from software contributed to Berkeley by 6*41952Sbostic * Chris Torek. 7*41952Sbostic * 8*41952Sbostic * %sccs.include.redist.c% 924195Skre */ 1024195Skre 1126527Sdonn #if defined(LIBC_SCCS) && !defined(lint) 12*41952Sbostic static char sccsid[] = "@(#)memcmp.c 5.5 (Berkeley) 05/15/90"; 1334479Sbostic #endif /* LIBC_SCCS and not lint */ 1424195Skre 15*41952Sbostic #include <string.h> 16*41952Sbostic #include <sys/stdc.h> 17*41952Sbostic 18*41952Sbostic /* 19*41952Sbostic * Compare memory regions. 20*41952Sbostic */ 21*41952Sbostic int 2224195Skre memcmp(s1, s2, n) 23*41952Sbostic const void *s1, *s2; 24*41952Sbostic size_t n; 2524195Skre { 26*41952Sbostic if (n != 0) { 27*41952Sbostic register const unsigned char *p1 = s1, *p2 = s2; 28*41952Sbostic 29*41952Sbostic do { 30*41952Sbostic if (*p1++ != *p2++) 31*41952Sbostic return (*--p1 - *--p2); 32*41952Sbostic } while (--n != 0); 33*41952Sbostic } 3424195Skre return (0); 3524195Skre } 36