add rules like those in libc to build strchr() and strrchr() (the latter
is being added to libkern by this commit). remove strchr.c from archs' Makefile.inc files to go along with this. (If an arch has a .S version, it should be copied down and added to the apropriate Makefile.inc.)
This commit is contained in:
parent
61a021f836
commit
4369378a6c
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.37 1997/11/04 20:34:46 gwr Exp $
|
||||
# $NetBSD: Makefile,v 1.38 1998/01/21 21:23:18 cgd Exp $
|
||||
|
||||
LIB= kern
|
||||
NOPIC=
|
||||
|
@ -25,10 +25,58 @@ SRCS+= md5c.c
|
|||
# Files to clean up
|
||||
CLEANFILES+= lib${LIB}.o lib${LIB}.po
|
||||
|
||||
#
|
||||
# Special rules for certain objects
|
||||
#
|
||||
|
||||
# mcount cannot be compiled with profiling
|
||||
mcount.po: mcount.o
|
||||
cp mcount.o mcount.po
|
||||
|
||||
# if no machine specific strchr(3), build one out of index(3).
|
||||
.if empty(SRCS:Mstrchr.S)
|
||||
OBJS+= strchr.o
|
||||
strchr.o: index.c
|
||||
${COMPILE.c} -DSTRCHR ${.ALLSRC} -o ${.TARGET}
|
||||
@${LD} -x -r ${.TARGET}
|
||||
@mv a.out ${.TARGET}
|
||||
|
||||
strchr.po: index.c
|
||||
${COMPILE.c} -DSTRCHR -p ${.ALLSRC} -o ${.TARGET}
|
||||
@${LD} -X -r ${.TARGET}
|
||||
@mv a.out ${.TARGET}
|
||||
|
||||
strchr.so: index.c
|
||||
${COMPILE.c} ${PICFLAG} -DPIC -DSTRCHR ${.ALLSRC} -o ${.TARGET}
|
||||
|
||||
LOBJS+= strchr.ln
|
||||
strchr.ln: index.c
|
||||
${LINT} -DSTRCHR ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i -o ${.TARGET} \
|
||||
${.ALLSRC}
|
||||
.endif
|
||||
|
||||
# if no machine specific strrchr(3), build one out of rindex(3).
|
||||
.if empty(SRCS:Mstrrchr.S)
|
||||
OBJS+= strrchr.o
|
||||
strrchr.o: rindex.c
|
||||
${COMPILE.c} -DSTRRCHR ${.ALLSRC} -o ${.TARGET}
|
||||
@${LD} -x -r ${.TARGET}
|
||||
@mv a.out ${.TARGET}
|
||||
|
||||
strrchr.po: rindex.c
|
||||
${COMPILE.c} -DSTRRCHR -p ${.ALLSRC} -o ${.TARGET}
|
||||
@${LD} -X -r ${.TARGET}
|
||||
@mv a.out ${.TARGET}
|
||||
|
||||
strrchr.so: rindex.c
|
||||
${COMPILE.c} ${PICFLAG} -DPIC -DSTRRCHR ${.ALLSRC} -o ${.TARGET}
|
||||
|
||||
LOBJS+= strrchr.ln
|
||||
strrchr.ln: rindex.c
|
||||
${LINT} -DSTRRCHR ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i -o ${.TARGET} \
|
||||
${.ALLSRC}
|
||||
.endif
|
||||
|
||||
# only needed during build
|
||||
libinstall::
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# $NetBSD: Makefile.inc,v 1.12 1997/10/24 15:32:25 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.13 1998/01/21 21:23:22 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.S bswap32.S bswap64.c memchr.c \
|
||||
bcmp.c bzero.S ffs.S strcat.c strcmp.c strcpy.c strlen.c strncmp.c \
|
||||
strncpy.c scanc.c skpc.c htonl.S htons.S ntohl.S ntohs.S \
|
||||
random.c strncasecmp.c __assert.c strchr.c
|
||||
random.c strncasecmp.c __assert.c
|
||||
|
||||
# `source' files built from m4 source
|
||||
SRCS+= __divqu.S __divq.S __divlu.S __divl.S
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile.inc,v 1.9 1997/10/24 15:32:26 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.10 1998/01/21 21:23:22 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.c bswap32.c bswap64.c bcmp.c ffs.c strcat.c strcmp.c \
|
||||
strcpy.c strlen.c strncmp.c strncpy.c scanc.c skpc.c random.c \
|
||||
strncasecmp.c __assert.c strchr.c
|
||||
strncasecmp.c __assert.c
|
||||
SRCS+= divsi3.S htons.S htonl.S ntohs.S ntohl.S
|
||||
SRCS+= _memcpy.S memcpy.S bcopy.S memset.S bzero.S memchr.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile.inc,v 1.15 1997/10/24 15:32:27 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.16 1998/01/21 21:23:23 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.S bswap32.S bswap64.c memchr.S \
|
||||
bcmp.S ffs.S strcat.S strcmp.S strcpy.S strlen.S strncmp.c \
|
||||
strncpy.c scanc.S skpc.S htonl.S htons.S ntohl.S ntohs.S \
|
||||
strncasecmp.c __assert.c strchr.c
|
||||
strncasecmp.c __assert.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile.inc,v 1.15 1997/10/24 15:32:29 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.16 1998/01/21 21:23:24 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.S bswap32.S bswap64.S memchr.c \
|
||||
bcmp.S bzero.S ffs.S strcat.S strcmp.S strcpy.S strlen.S strncmp.S \
|
||||
strncpy.S htonl.S htons.S ntohl.S ntohs.S scanc.S skpc.S \
|
||||
strncasecmp.c __assert.c strchr.c
|
||||
strncasecmp.c __assert.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile.inc,v 1.8 1997/10/24 15:32:30 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.9 1998/01/21 21:23:25 cgd Exp $
|
||||
#
|
||||
# There are likely more that we will notice when we go native
|
||||
|
||||
SRCS+= random.c scanc.c skpc.c strcat.c strcpy.c strncmp.c strncpy.c \
|
||||
bswap16.c bswap32.c bswap64.c memchr.c \
|
||||
strncasecmp.c __assert.c strchr.c
|
||||
strncasecmp.c __assert.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile.inc,v 1.13 1997/10/24 15:32:31 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.14 1998/01/21 21:23:26 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.c bswap32.c bswap64.c memchr.S \
|
||||
bcmp.S bcopy.S bzero.S ffs.S strcat.S strcmp.S strcpy.S strlen.S \
|
||||
strncmp.S strncpy.S htonl.S htons.S ntohl.S ntohs.S \
|
||||
scanc.c skpc.c strncasecmp.c __assert.c strchr.c
|
||||
scanc.c skpc.c strncasecmp.c __assert.c
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# $NetBSD: Makefile.inc,v 1.4 1997/10/24 15:32:33 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.5 1998/01/21 21:23:27 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.c bswap32.c bswap64.c memchr.c \
|
||||
bcmp.c bzero.c ffs.c scanc.c skpc.c \
|
||||
strcat.c strcmp.c strcpy.c strlen.c strncmp.c strncpy.c \
|
||||
random.c __assert.c strchr.c
|
||||
random.c __assert.c
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# $NetBSD: Makefile.inc,v 1.17 1997/10/24 15:32:34 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.18 1998/01/21 21:23:27 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.c bswap32.c bswap64.c memchr.c \
|
||||
bcmp.c bzero.S strcat.c strcmp.c strcpy.c strlen.S strncmp.c \
|
||||
strncpy.c htonl.S htons.S ntohl.S ntohs.S scanc.c skpc.c \
|
||||
strncasecmp.c __assert.c strchr.c
|
||||
strncasecmp.c __assert.c
|
||||
|
||||
SRCS+= umul.S mul.S rem.S sdiv.S udiv.S umul.S urem.S
|
||||
SRCS+= mul.S saveregs.S umul.S
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile.inc,v 1.7 1997/10/24 15:32:34 chuck Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.8 1998/01/21 21:23:28 cgd Exp $
|
||||
|
||||
SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \
|
||||
bswap16.c bswap32.c bswap64.c memchr.c \
|
||||
strcat.c strcmp.c strcpy.c strlen.c strncmp.c \
|
||||
strncpy.c scanc.c skpc.c strncasecmp.c __assert.c strchr.c
|
||||
strncpy.c scanc.c skpc.c strncasecmp.c __assert.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: strchr.c,v 1.3 1998/01/21 19:43:23 cgd Exp $ */
|
||||
/* $NetBSD: index.c,v 1.1 1998/01/21 21:23:19 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -38,20 +38,10 @@
|
|||
#if 0
|
||||
static char *sccsid = "@(#)index.c 5.7 (Berkeley) 2/24/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: strchr.c,v 1.3 1998/01/21 19:43:23 cgd Exp $");
|
||||
__RCSID("$NetBSD: index.c,v 1.1 1998/01/21 21:23:19 cgd Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
* XXX This file copied from libc's "index.c", but with the
|
||||
* "#define STRCHR" and the #ifndef _KERNEL goop added below.
|
||||
*
|
||||
* It'd be nice to include the file here unchanged from the libc
|
||||
* version (and, preferably, with the same name) but I didn't want to
|
||||
* include the baroque strchr/index + asm/C rules here in libkern.
|
||||
*/
|
||||
#define STRCHR
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include <string.h>
|
||||
#else
|
|
@ -0,0 +1,69 @@
|
|||
/* $NetBSD: rindex.c,v 1.1 1998/01/21 21:23:19 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char *sccsid = "@(#)rindex.c 5.9 (Berkeley) 2/24/91";
|
||||
#else
|
||||
__RCSID("$NetBSD: rindex.c,v 1.1 1998/01/21 21:23:19 cgd Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#ifndef _KERNEL
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <lib/libkern/libkern.h>
|
||||
#define NULL ((char *)0)
|
||||
#endif
|
||||
|
||||
char *
|
||||
#ifdef STRRCHR
|
||||
strrchr(p, ch)
|
||||
#else
|
||||
rindex(p, ch)
|
||||
#endif
|
||||
register const char *p, ch;
|
||||
{
|
||||
register char *save;
|
||||
|
||||
for (save = NULL;; ++p) {
|
||||
if (*p == ch)
|
||||
save = (char *)p;
|
||||
if (!*p)
|
||||
return(save);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
Loading…
Reference in New Issue