home *** CD-ROM | disk | FTP | other *** search
- #ifdef __STDC__
- static char sccs_id[] = "@(#) memcmp.c 1.0 " __DATE__ " HJR";
- #else
- static char sccs_id[] = "@(#) memcmp.c 1.0 26/9/90 HJR";
- #endif
-
- /* memcmp.c (c) Copyright 1990 H.Rogers */
-
- #include <string.h>
-
- #ifdef __STDC__
- int
- memcmp (const void *s1, const void *s2, register size_t n)
- #else
- int
- memcmp (s1, s2, n)
- const void *s1;
- const void *s2;
- register size_t n;
- #endif
- {
- register unsigned char *_s1 = (unsigned char *) s1, *_s2 = (unsigned char *) s2;
-
- while (n & 0x07)
- {
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- n--;
- }
- n >>= 3;
- while (n)
- {
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- if (*_s1 != *_s2)
- goto differs;
- _s1++, _s2++;
- n--;
- }
-
- if (n == 0)
- return 0;
-
- differs:
- return (*_s1 - *_s2);
- }
-
- #ifdef __STDC__
- int (bcmp) (register const void *s1, register const void *s2, register size_t n)
- #else
- int (bcmp) (s1, s2, n)
- register const void *s1;
- register const void *s2;
- register size_t n;
- #endif
- {
- return (bcmp (s1, s2, n));
- }
-