1c6fdaa73SAntonio Nino Diaz /*- 2c6fdaa73SAntonio Nino Diaz * SPDX-License-Identifier: BSD-3-Clause 3c6fdaa73SAntonio Nino Diaz * 4c6fdaa73SAntonio Nino Diaz * Copyright (c) 1990, 1993 5c6fdaa73SAntonio Nino Diaz * The Regents of the University of California. All rights reserved. 6c6fdaa73SAntonio Nino Diaz * 7c6fdaa73SAntonio Nino Diaz * This code is derived from software contributed to Berkeley by 8c6fdaa73SAntonio Nino Diaz * Chris Torek. 9c6fdaa73SAntonio Nino Diaz * 10c6fdaa73SAntonio Nino Diaz * Redistribution and use in source and binary forms, with or without 11c6fdaa73SAntonio Nino Diaz * modification, are permitted provided that the following conditions 12c6fdaa73SAntonio Nino Diaz * are met: 13c6fdaa73SAntonio Nino Diaz * 1. Redistributions of source code must retain the above copyright 14c6fdaa73SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer. 15c6fdaa73SAntonio Nino Diaz * 2. Redistributions in binary form must reproduce the above copyright 16c6fdaa73SAntonio Nino Diaz * notice, this list of conditions and the following disclaimer in the 17c6fdaa73SAntonio Nino Diaz * documentation and/or other materials provided with the distribution. 18c6fdaa73SAntonio Nino Diaz * 3. Neither the name of the University nor the names of its contributors 19c6fdaa73SAntonio Nino Diaz * may be used to endorse or promote products derived from this software 20c6fdaa73SAntonio Nino Diaz * without specific prior written permission. 21c6fdaa73SAntonio Nino Diaz * 22c6fdaa73SAntonio Nino Diaz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23c6fdaa73SAntonio Nino Diaz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24c6fdaa73SAntonio Nino Diaz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25c6fdaa73SAntonio Nino Diaz * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26c6fdaa73SAntonio Nino Diaz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27c6fdaa73SAntonio Nino Diaz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28c6fdaa73SAntonio Nino Diaz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29c6fdaa73SAntonio Nino Diaz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30c6fdaa73SAntonio Nino Diaz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31c6fdaa73SAntonio Nino Diaz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32c6fdaa73SAntonio Nino Diaz * SUCH DAMAGE. 33c6fdaa73SAntonio Nino Diaz */ 34c6fdaa73SAntonio Nino Diaz 352c5aca6eSAntonio Nino Diaz /* 36*34d7f196SBoyan Karatotev * Portions copyright (c) 2018-2025, Arm Limited and Contributors. 372c5aca6eSAntonio Nino Diaz * All rights reserved. 382c5aca6eSAntonio Nino Diaz */ 39c6fdaa73SAntonio Nino Diaz 40*34d7f196SBoyan Karatotev #include <string_private.h> 41c6fdaa73SAntonio Nino Diaz 42c6fdaa73SAntonio Nino Diaz /* 43c6fdaa73SAntonio Nino Diaz * Compare strings. 44c6fdaa73SAntonio Nino Diaz */ 45c6fdaa73SAntonio Nino Diaz int 46c6fdaa73SAntonio Nino Diaz strcmp(const char *s1, const char *s2) 47c6fdaa73SAntonio Nino Diaz { 48c6fdaa73SAntonio Nino Diaz while (*s1 == *s2++) 49c6fdaa73SAntonio Nino Diaz if (*s1++ == '\0') 50c6fdaa73SAntonio Nino Diaz return (0); 51c6fdaa73SAntonio Nino Diaz return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); 52c6fdaa73SAntonio Nino Diaz } 53