14da5e29imp/*-
24736ccfpfg * SPDX-License-Identifier: BSD-3-Clause
34736ccfpfg *
4496d600ugen * Copyright (c) 1989, 1993
5496d600ugen *	The Regents of the University of California.  All rights reserved.
6496d600ugen *
7496d600ugen * Redistribution and use in source and binary forms, with or without
8496d600ugen * modification, are permitted provided that the following conditions
9496d600ugen * are met:
10496d600ugen * 1. Redistributions of source code must retain the above copyright
11496d600ugen *    notice, this list of conditions and the following disclaimer.
12496d600ugen * 2. Redistributions in binary form must reproduce the above copyright
13496d600ugen *    notice, this list of conditions and the following disclaimer in the
14496d600ugen *    documentation and/or other materials provided with the distribution.
158d13dcadelphij * 3. Neither the name of the University nor the names of its contributors
16496d600ugen *    may be used to endorse or promote products derived from this software
17496d600ugen *    without specific prior written permission.
18496d600ugen *
19496d600ugen * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20496d600ugen * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21496d600ugen * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22496d600ugen * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23496d600ugen * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24496d600ugen * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25496d600ugen * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26496d600ugen * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27496d600ugen * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28496d600ugen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29496d600ugen * SUCH DAMAGE.
30496d600ugen */
31496d600ugen
328b64eb1obrien#include <sys/cdefs.h>
338b64eb1obrien__FBSDID("$FreeBSD$");
348b64eb1obrien
357c4d6e4jhb#include <sys/libkern.h>
36496d600ugen
37496d600ugenint
388d13dcadelphijstrncmp(const char *s1, const char *s2, size_t n)
39496d600ugen{
40496d600ugen
41496d600ugen	if (n == 0)
42496d600ugen		return (0);
43496d600ugen	do {
44496d600ugen		if (*s1 != *s2++)
45070eb30bde			return (*(const unsigned char *)s1 -
46070eb30bde				*(const unsigned char *)(s2 - 1));
478d13dcadelphij		if (*s1++ == '\0')
48496d600ugen			break;
49496d600ugen	} while (--n != 0);
50496d600ugen	return (0);
51496d600ugen}
52