123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include <string.h>
- #ifdef _TLIBC_USE_INTEL_FAST_STRING_
- extern int _intel_fast_strncmp(const char *, const char *, size_t);
- #endif
- int
- strncmp(const char *s1, const char *s2, size_t n)
- {
- #ifdef _TLIBC_USE_INTEL_FAST_STRING_
- return _intel_fast_strncmp(s1, s2, n);
- #else
- if (n == 0)
- return (0);
- do {
- if (*s1 != *s2++)
- return (*(unsigned char *)s1 - *(unsigned char *)--s2);
- if (*s1++ == 0)
- break;
- } while (--n != 0);
- return (0);
- #endif
- }
|