2 * strcmp.c -- strcmp function. On at least some MIPS chips, a strcmp that is
3 * unrolled twice is faster than the 'optimized' C version in newlib.
5 * Copyright (c) 2001 Red Hat, Inc.
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
22 strcmp (const char *s1
, const char *s2
)
24 unsigned const char *us1
= (unsigned const char *)s1
;
25 unsigned const char *us2
= (unsigned const char *)s2
;
29 /* If the pointers aren't both aligned to a 16-byte boundary, do the
30 comparison byte by byte, so that we don't get an invalid page fault if we
31 are comparing a string whose null byte is at the last byte on the last
33 if (((((long)us1
) | ((long)us2
)) & 1) == 0)
66 while (c1a
!= '\0' && c1a
== c1b
);