Module Name:    src
Committed By:   dsl
Date:           Fri Jul 17 19:37:57 UTC 2009

Modified Files:
        src/common/lib/libc/arch/i386/string: strchr.S strrchr.S
        src/common/lib/libc/arch/m68k/string: strchr.S strrchr.S
        src/common/lib/libc/arch/mips/string: strchr.S
        src/common/lib/libc/arch/x86_64/string: strchr.S strrchr.S
        src/common/lib/libc/string: strchr.c strrchr.c

Log Message:
Change all archs so that strchr.[cS] and strrchr.[cS] exist and generate
duplicate symbols for index() and rindex().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/i386/string/strchr.S \
    src/common/lib/libc/arch/i386/string/strrchr.S
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/m68k/string/strchr.S \
    src/common/lib/libc/arch/m68k/string/strrchr.S
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/mips/string/strchr.S
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/arch/x86_64/string/strchr.S \
    src/common/lib/libc/arch/x86_64/string/strrchr.S
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/string/strchr.c
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/string/strrchr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/i386/string/strchr.S
diff -u src/common/lib/libc/arch/i386/string/strchr.S:1.1 src/common/lib/libc/arch/i386/string/strchr.S:1.2
--- src/common/lib/libc/arch/i386/string/strchr.S:1.1	Tue Dec 20 19:28:49 2005
+++ src/common/lib/libc/arch/i386/string/strchr.S	Fri Jul 17 19:37:57 2009
@@ -6,14 +6,10 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+	RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
 #endif
 
-#ifdef INDEX
-ENTRY(index)
-#else
 ENTRY(strchr)
-#endif
 	pushl	%esi
 	pushl	%ebx
 	movl	12(%esp),%eax
@@ -103,3 +99,5 @@
 	popl	%ebx
 	popl	%esi
 	ret
+
+STRONG_ALIAS(index,strchr)
Index: src/common/lib/libc/arch/i386/string/strrchr.S
diff -u src/common/lib/libc/arch/i386/string/strrchr.S:1.1 src/common/lib/libc/arch/i386/string/strrchr.S:1.2
--- src/common/lib/libc/arch/i386/string/strrchr.S:1.1	Tue Dec 20 19:28:49 2005
+++ src/common/lib/libc/arch/i386/string/strrchr.S	Fri Jul 17 19:37:57 2009
@@ -6,14 +6,10 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: strrchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $")
+	RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
 #endif
 
-#ifdef RINDEX
-ENTRY(rindex)
-#else
 ENTRY(strrchr)
-#endif
 	pushl	%esi
 	pushl	%edi
 	pushl	%ebx
@@ -96,3 +92,5 @@
 	popl	%edi
 	popl	%esi
 	ret
+
+STRONG_ALIAS(rindex,strrchr)

Index: src/common/lib/libc/arch/m68k/string/strchr.S
diff -u src/common/lib/libc/arch/m68k/string/strchr.S:1.1 src/common/lib/libc/arch/m68k/string/strchr.S:1.2
--- src/common/lib/libc/arch/m68k/string/strchr.S:1.1	Tue Dec 20 19:28:49 2005
+++ src/common/lib/libc/arch/m68k/string/strchr.S	Fri Jul 17 19:37:57 2009
@@ -1,4 +1,63 @@
-/*	$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+/*	$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $	*/
 
-#define STRCHR
-#include "index.S"
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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. 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 <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)index.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strchr)
+	movl	%sp@(4),%a0		| string
+	movb	%sp@(11),%d0		| char to look for
+ixloop:
+	cmpb	%a0@,%d0		| found our char?
+	jeq	ixfound			| yes, break out
+	tstb	%...@+			| null?
+	jne	ixloop			| no, keep going
+	moveq	#0,%d0			| not found, return null
+#ifdef __SVR4_ABI__
+	moveal	%d0,%a0
+#endif
+	rts
+ixfound:
+	movl	%a0,%d0			| found, return pointer
+	rts
+
+STRONG_ALIAS(index,strchr)
Index: src/common/lib/libc/arch/m68k/string/strrchr.S
diff -u src/common/lib/libc/arch/m68k/string/strrchr.S:1.1 src/common/lib/libc/arch/m68k/string/strrchr.S:1.2
--- src/common/lib/libc/arch/m68k/string/strrchr.S:1.1	Tue Dec 20 19:28:49 2005
+++ src/common/lib/libc/arch/m68k/string/strrchr.S	Fri Jul 17 19:37:57 2009
@@ -1,4 +1,60 @@
-/*	$NetBSD: strrchr.S,v 1.1 2005/12/20 19:28:49 christos Exp $	*/
+/*	$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $	*/
 
-#define STRRCHR
-#include "rindex.S"
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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. 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 <machine/asm.h>
+
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+	RCSID("from: @(#)rindex.s	5.1 (Berkeley) 5/12/90")
+#else
+	RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+ENTRY(strrchr)
+	movl	%sp@(4),%a1		| string
+	movb	%sp@(11),%d0		| char to look for
+	subl	%a0,%a0			| clear rindex pointer
+rixloop:
+	cmpb	%a1@,%d0		| found our char?
+	jne	rixnope			| no, check for null
+	movl	%a1,%a0			| yes, remember location
+rixnope:
+	tstb	%...@+			| null?
+	jne	rixloop			| no, keep going
+	movl	%a0,%d0			| return value
+	rts
+
+STRONG_ALIAS(rindex,strrchr)

Index: src/common/lib/libc/arch/mips/string/strchr.S
diff -u src/common/lib/libc/arch/mips/string/strchr.S:1.1 src/common/lib/libc/arch/mips/string/strchr.S:1.2
--- src/common/lib/libc/arch/mips/string/strchr.S:1.1	Thu Jul 16 21:25:36 2009
+++ src/common/lib/libc/arch/mips/string/strchr.S	Fri Jul 17 19:37:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: strchr.S,v 1.1 2009/07/16 21:25:36 dsl Exp $	*/
+/*	$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -36,14 +36,14 @@
 
 #if defined(LIBC_SCCS) && !defined(lint)
 	ASMSTR("from: @(#)index.s	8.1 (Berkeley) 6/4/93")
-	ASMSTR("$NetBSD: strchr.S,v 1.1 2009/07/16 21:25:36 dsl Exp $")
+	ASMSTR("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
 #endif /* LIBC_SCCS and not lint */
 
 #ifdef __ABICALLS__
 	.abicalls
 #endif
 
-LEAF(strstr)
+LEAF(strchr)
 XLEAF(index)
 1:
 	lbu	a2, 0(a0)		# get a byte
@@ -56,4 +56,4 @@
 fnd:
 	subu	v0, a0, 1
 	j	ra
-END(strstr)
+END(strchr)

Index: src/common/lib/libc/arch/x86_64/string/strchr.S
diff -u src/common/lib/libc/arch/x86_64/string/strchr.S:1.1 src/common/lib/libc/arch/x86_64/string/strchr.S:1.2
--- src/common/lib/libc/arch/x86_64/string/strchr.S:1.1	Tue Dec 20 19:28:51 2005
+++ src/common/lib/libc/arch/x86_64/string/strchr.S	Fri Jul 17 19:37:57 2009
@@ -6,14 +6,10 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: strchr.S,v 1.1 2005/12/20 19:28:51 christos Exp $")
+	RCSID("$NetBSD: strchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
 #endif
 
-#ifdef INDEX
-ENTRY(index)
-#else
 ENTRY(strchr)
-#endif
 	movzbq	%sil,%rcx
 
 	/*
@@ -134,3 +130,4 @@
 .Ldone:
 	movq	%rdi,%rax
 	ret
+STRONG_ALIAS(index,strchr)
Index: src/common/lib/libc/arch/x86_64/string/strrchr.S
diff -u src/common/lib/libc/arch/x86_64/string/strrchr.S:1.1 src/common/lib/libc/arch/x86_64/string/strrchr.S:1.2
--- src/common/lib/libc/arch/x86_64/string/strrchr.S:1.1	Tue Dec 20 19:28:51 2005
+++ src/common/lib/libc/arch/x86_64/string/strrchr.S	Fri Jul 17 19:37:57 2009
@@ -6,14 +6,10 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-	RCSID("$NetBSD: strrchr.S,v 1.1 2005/12/20 19:28:51 christos Exp $")
+	RCSID("$NetBSD: strrchr.S,v 1.2 2009/07/17 19:37:57 dsl Exp $")
 #endif
 
-#ifdef RINDEX
-ENTRY(rindex)
-#else
 ENTRY(strrchr)
-#endif
 	movzbq	%sil,%rcx
 
 	/* zero return value */
@@ -124,3 +120,5 @@
 
 .Ldone:
 	ret
+
+STRONG_ALIAS(rindex,strrchr)

Index: src/common/lib/libc/string/strchr.c
diff -u src/common/lib/libc/string/strchr.c:1.3 src/common/lib/libc/string/strchr.c:1.4
--- src/common/lib/libc/string/strchr.c:1.3	Tue Jan  8 21:57:06 2008
+++ src/common/lib/libc/string/strchr.c	Fri Jul 17 19:37:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: strchr.c,v 1.3 2008/01/08 21:57:06 martin Exp $	*/
+/*	$NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)index.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: strchr.c,v 1.3 2008/01/08 21:57:06 martin Exp $");
+__RCSID("$NetBSD: strchr.c,v 1.4 2009/07/17 19:37:57 dsl Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -46,12 +46,9 @@
 #include <lib/libkern/libkern.h>
 #endif
 
+__strong_alias(index, strchr)
 char *
-#ifdef INDEX
-index(const char *p, int ch)
-#else
 strchr(const char *p, int ch)
-#endif
 {
 	const char cmp = ch;
 	_DIAGASSERT(p != NULL);

Index: src/common/lib/libc/string/strrchr.c
diff -u src/common/lib/libc/string/strrchr.c:1.4 src/common/lib/libc/string/strrchr.c:1.5
--- src/common/lib/libc/string/strrchr.c:1.4	Tue Jan  8 21:57:06 2008
+++ src/common/lib/libc/string/strrchr.c	Fri Jul 17 19:37:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: strrchr.c,v 1.4 2008/01/08 21:57:06 martin Exp $	*/
+/*	$NetBSD: strrchr.c,v 1.5 2009/07/17 19:37:57 dsl Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)rindex.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: strrchr.c,v 1.4 2008/01/08 21:57:06 martin Exp $");
+__RCSID("$NetBSD: strrchr.c,v 1.5 2009/07/17 19:37:57 dsl Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -45,12 +45,9 @@
 #include <lib/libkern/libkern.h>
 #endif
 
+__strong_alias(rindex, strrchr)
 char *
-#ifdef RINDEX
-rindex(const char *p, int ch)
-#else
 strrchr(const char *p, int ch)
-#endif
 {
 	char *save;
 	const char c = ch;

Reply via email to