strcmp.c revision 319286
1251881Speter/*- 2251881Speter * Copyright (c) 1990, 1993 3251881Speter * The Regents of the University of California. All rights reserved. 4251881Speter * 5251881Speter * This code is derived from software contributed to Berkeley by 6251881Speter * Chris Torek. 7251881Speter * 8251881Speter * Redistribution and use in source and binary forms, with or without 9251881Speter * modification, are permitted provided that the following conditions 10251881Speter * are met: 11251881Speter * 1. Redistributions of source code must retain the above copyright 12251881Speter * notice, this list of conditions and the following disclaimer. 13251881Speter * 2. Redistributions in binary form must reproduce the above copyright 14251881Speter * notice, this list of conditions and the following disclaimer in the 15251881Speter * documentation and/or other materials provided with the distribution. 16251881Speter * 4. Neither the name of the University nor the names of its contributors 17251881Speter * may be used to endorse or promote products derived from this software 18251881Speter * without specific prior written permission. 19251881Speter * 20251881Speter * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21251881Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22251881Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23251881Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24251881Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25251881Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26251881Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27251881Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28251881Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29251881Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30251881Speter * SUCH DAMAGE. 31251881Speter */ 32251881Speter 33251881Speter#include <sys/cdefs.h> 34251881Speter__FBSDID("$FreeBSD: stable/10/sys/libkern/strcmp.c 319286 2017-05-31 06:00:14Z delphij $"); 35251881Speter 36251881Speter#include <sys/libkern.h> 37251881Speter 38251881Speter/* 39251881Speter * Compare strings. 40251881Speter */ 41251881Speterint 42251881Speterstrcmp(s1, s2) 43251881Speter const char *s1, *s2; 44251881Speter{ 45251881Speter while (*s1 == *s2++) 46251881Speter if (*s1++ == 0) 47251881Speter return (0); 48251881Speter return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); 49251881Speter} 50251881Speter