Commit | Line | Data |
---|---|---|
e8d4f560 KB |
1 | /*- |
2 | * Copyright (c) 1990 The Regents of the University of California. | |
317e5946 KB |
3 | * All rights reserved. |
4 | * | |
e8d4f560 KB |
5 | * This code is derived from software contributed to Berkeley by |
6 | * Chris Torek. | |
7 | * | |
8 | * %sccs.include.redist.c% | |
3fd49469 RE |
9 | */ |
10 | ||
2ce81398 | 11 | #if defined(LIBC_SCCS) && !defined(lint) |
a64329b4 | 12 | static char sccsid[] = "@(#)memcmp.c 5.6 (Berkeley) %G%"; |
317e5946 | 13 | #endif /* LIBC_SCCS and not lint */ |
3fd49469 | 14 | |
a64329b4 | 15 | #include <sys/cdefs.h> |
e8d4f560 | 16 | #include <string.h> |
e8d4f560 KB |
17 | |
18 | /* | |
19 | * Compare memory regions. | |
20 | */ | |
21 | int | |
3fd49469 | 22 | memcmp(s1, s2, n) |
e8d4f560 KB |
23 | const void *s1, *s2; |
24 | size_t n; | |
3fd49469 | 25 | { |
e8d4f560 KB |
26 | if (n != 0) { |
27 | register const unsigned char *p1 = s1, *p2 = s2; | |
28 | ||
29 | do { | |
30 | if (*p1++ != *p2++) | |
31 | return (*--p1 - *--p2); | |
32 | } while (--n != 0); | |
33 | } | |
3fd49469 RE |
34 | return (0); |
35 | } |