diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-05-15 22:29:38 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-05-15 22:29:38 +0000 |
commit | 859ad3fd43b3b8289799fc07b91f705e3d60625b (patch) | |
tree | 01cc41843eee0eade93009f1a1ec1031e4dae81c | |
parent | 1750c6aec5fb331bfdc2147cc368f7b3925351f2 (diff) |
Make index/rindex weak aliases of strchr/strrchr since they are not
part of the ISO C standard and have also been dropped from POSIX.
OK guenther@ kettenis@
-rw-r--r-- | lib/libc/arch/alpha/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/strchr.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/amd64/string/strrchr.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/arm/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/hppa/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/hppa64/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/i386/string/strchr.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/i386/string/strrchr.S | 4 | ||||
-rw-r--r-- | lib/libc/arch/m88k/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/strchr.S | 5 | ||||
-rw-r--r-- | lib/libc/arch/mips64/string/strrchr.S | 5 | ||||
-rw-r--r-- | lib/libc/arch/powerpc/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/sh/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/sparc/string/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/string/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/arch/vax/string/Makefile.inc | 4 | ||||
-rw-r--r-- | lib/libc/arch/vax/string/strchr.S | 4 | ||||
-rw-r--r-- | lib/libc/string/index.c | 43 | ||||
-rw-r--r-- | lib/libc/string/rindex.c | 45 | ||||
-rw-r--r-- | lib/libc/string/strchr.c | 4 | ||||
-rw-r--r-- | lib/libc/string/strrchr.c | 4 |
21 files changed, 44 insertions, 126 deletions
diff --git a/lib/libc/arch/alpha/string/Makefile.inc b/lib/libc/arch/alpha/string/Makefile.inc index ddb3d1ccd79..c925a3755ee 100644 --- a/lib/libc/arch/alpha/string/Makefile.inc +++ b/lib/libc/arch/alpha/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.8 2014/11/30 19:43:54 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.9 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.S memcpy.c memmove.S \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bzero.S ffs.S \ memchr.c memcmp.c memset.c strcat.c bcmp.c \ strcmp.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \ diff --git a/lib/libc/arch/amd64/string/strchr.S b/lib/libc/arch/amd64/string/strchr.S index 0415b0379c2..1abef2e629d 100644 --- a/lib/libc/arch/amd64/string/strchr.S +++ b/lib/libc/arch/amd64/string/strchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.S,v 1.4 2014/12/09 15:10:39 reyk Exp $ */ +/* $OpenBSD: strchr.S,v 1.5 2015/05/15 22:29:37 millert Exp $ */ /* $NetBSD: strchr.S,v 1.7 2014/03/22 19:16:34 jakllsch Exp $ */ /*- @@ -34,7 +34,7 @@ #include <machine/asm.h> -STRONG_ALIAS(index, strchr) +WEAK_ALIAS(index, strchr) /* * On entry %rdi is the buffer and the low byte of %rsi (%sil) the diff --git a/lib/libc/arch/amd64/string/strrchr.S b/lib/libc/arch/amd64/string/strrchr.S index 342ab89c5cb..6aa8041dc0a 100644 --- a/lib/libc/arch/amd64/string/strrchr.S +++ b/lib/libc/arch/amd64/string/strrchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strrchr.S,v 1.4 2014/12/09 15:10:39 reyk Exp $ */ +/* $OpenBSD: strrchr.S,v 1.5 2015/05/15 22:29:37 millert Exp $ */ /* $NetBSD: strrchr.S,v 1.3 2014/03/22 19:16:34 jakllsch Exp $ */ /* @@ -8,7 +8,7 @@ #include <machine/asm.h> -STRONG_ALIAS(rindex, strrchr) +WEAK_ALIAS(rindex, strrchr) ENTRY(strrchr) movzbq %sil,%rcx diff --git a/lib/libc/arch/arm/string/Makefile.inc b/lib/libc/arch/arm/string/Makefile.inc index 62bf85c164d..31d00db19c3 100644 --- a/lib/libc/arch/arm/string/Makefile.inc +++ b/lib/libc/arch/arm/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.7 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.8 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.S memcpy.c memmove.S _memcpy.S \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c bzero.S ffs.S memchr.c memcmp.S memset.S \ strcmp.S strncmp.S \ strcat.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \ diff --git a/lib/libc/arch/hppa/string/Makefile.inc b/lib/libc/arch/hppa/string/Makefile.inc index 7dc5311d52a..41064652c70 100644 --- a/lib/libc/arch/hppa/string/Makefile.inc +++ b/lib/libc/arch/hppa/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.9 2014/12/05 01:30:44 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.10 2015/05/15 22:29:37 millert Exp $ SRCS+= memmove.S memcpy.c \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c bzero.c ffs.c memchr.c memcmp.c \ memset.c strcat.c strcmp.c strcpy.c strcspn.c strlen.c \ strlcat.c strlcpy.c strncat.c strncmp.c strncpy.c \ diff --git a/lib/libc/arch/hppa64/string/Makefile.inc b/lib/libc/arch/hppa64/string/Makefile.inc index c15d3a9e7e9..87894646865 100644 --- a/lib/libc/arch/hppa64/string/Makefile.inc +++ b/lib/libc/arch/hppa64/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.3 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.4 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.c memcpy.c memmove.c \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c bzero.c ffs.c memchr.c memcmp.c \ memset.c strcat.c strcmp.c strcpy.c strcspn.c strlen.c \ strlcat.c strlcpy.c strncat.c strncmp.c strncpy.c \ diff --git a/lib/libc/arch/i386/string/strchr.S b/lib/libc/arch/i386/string/strchr.S index 6d36a589d19..f8cd8e6589a 100644 --- a/lib/libc/arch/i386/string/strchr.S +++ b/lib/libc/arch/i386/string/strchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.S,v 1.5 2015/05/14 21:40:37 kettenis Exp $ */ +/* $OpenBSD: strchr.S,v 1.6 2015/05/15 22:29:37 millert Exp $ */ /* * Written by J.T. Conklin <jtc@netbsd.org>. * Public domain. @@ -6,7 +6,7 @@ #include <machine/asm.h> -STRONG_ALIAS(index, strchr) +WEAK_ALIAS(index, strchr) ENTRY(strchr) movl 4(%esp),%eax diff --git a/lib/libc/arch/i386/string/strrchr.S b/lib/libc/arch/i386/string/strrchr.S index 8507e6ce43c..738c369b378 100644 --- a/lib/libc/arch/i386/string/strrchr.S +++ b/lib/libc/arch/i386/string/strrchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strrchr.S,v 1.5 2015/05/14 21:40:37 kettenis Exp $ */ +/* $OpenBSD: strrchr.S,v 1.6 2015/05/15 22:29:37 millert Exp $ */ /* * Written by J.T. Conklin <jtc@netbsd.org>. * Public domain. @@ -6,7 +6,7 @@ #include <machine/asm.h> -STRONG_ALIAS(rindex, strrchr) +WEAK_ALIAS(rindex, strrchr) ENTRY(strrchr) pushl %ebx diff --git a/lib/libc/arch/m88k/string/Makefile.inc b/lib/libc/arch/m88k/string/Makefile.inc index 7b625a40761..e04f156a233 100644 --- a/lib/libc/arch/m88k/string/Makefile.inc +++ b/lib/libc/arch/m88k/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.6 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.c memcpy.c memmove.c \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c bzero.c ffs.c memchr.c memcmp.c \ memset.c strcat.c strcmp.c strcpy.c strcspn.c \ strlen.c strlcat.c strlcpy.c strncat.c strncmp.c \ diff --git a/lib/libc/arch/mips64/string/strchr.S b/lib/libc/arch/mips64/string/strchr.S index 7add0c9218f..a5a12c53940 100644 --- a/lib/libc/arch/mips64/string/strchr.S +++ b/lib/libc/arch/mips64/string/strchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.S,v 1.1 2014/11/30 19:43:56 deraadt Exp $ */ +/* $OpenBSD: strchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +33,9 @@ #include <machine/asm.h> +WEAK_ALIAS(index, strchr) + LEAF(strchr, 0) -ALEAF(index) .set reorder 0: lbu a2, 0(a0) # get a byte diff --git a/lib/libc/arch/mips64/string/strrchr.S b/lib/libc/arch/mips64/string/strrchr.S index 7797d3af0ad..a7f5b74c320 100644 --- a/lib/libc/arch/mips64/string/strrchr.S +++ b/lib/libc/arch/mips64/string/strrchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strrchr.S,v 1.1 2014/11/30 19:43:56 deraadt Exp $ */ +/* $OpenBSD: strrchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -33,8 +33,9 @@ #include <machine/asm.h> +WEAK_ALIAS(rindex, strrchr) + LEAF(strrchr, 0) -ALEAF(rindex) .set reorder move v0, zero # default if not found 1: diff --git a/lib/libc/arch/powerpc/string/Makefile.inc b/lib/libc/arch/powerpc/string/Makefile.inc index 2ebd39efb71..4a97429a2c3 100644 --- a/lib/libc/arch/powerpc/string/Makefile.inc +++ b/lib/libc/arch/powerpc/string/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.5 2014/12/04 12:10:26 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.6 2015/05/15 22:29:37 millert Exp $ SRCS+= memcpy.c memmove.S \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c bzero.c ffs.c memchr.c memcmp.c memset.c strcat.c \ strcmp.c strcpy.c strcspn.c strlen.c strlcat.c strlcpy.c \ strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \ diff --git a/lib/libc/arch/sh/string/Makefile.inc b/lib/libc/arch/sh/string/Makefile.inc index 92fb923cf52..e18591ff667 100644 --- a/lib/libc/arch/sh/string/Makefile.inc +++ b/lib/libc/arch/sh/string/Makefile.inc @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile.inc,v 1.4 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.S memcpy.c memmove.S \ bzero.S ffs.S memset.S \ - index.c rindex.c strchr.c strrchr.c \ + strchr.c strrchr.c \ bcmp.c memcmp.c memchr.c strcat.c strcmp.c strcpy.c strcspn.c \ strlen.c strlcat.c strlcpy.c strncat.c strncmp.c strncpy.c \ strpbrk.c strsep.c strspn.c strstr.c swab.c diff --git a/lib/libc/arch/sparc/string/Makefile.inc b/lib/libc/arch/sparc/string/Makefile.inc index 7210c950c49..93aac247a4b 100644 --- a/lib/libc/arch/sparc/string/Makefile.inc +++ b/lib/libc/arch/sparc/string/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.6 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.7 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.c memcpy.c memmove.c \ ffs.S strlen.S bzero.S \ - bcmp.c index.c memchr.c memcmp.c \ - memset.c rindex.c strcat.c strchr.c \ + bcmp.c memchr.c memcmp.c \ + memset.c strcat.c strchr.c \ strcmp.c strcpy.c strcspn.c strlcat.c strlcpy.c \ strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \ strspn.c strstr.c swab.c diff --git a/lib/libc/arch/sparc64/string/Makefile.inc b/lib/libc/arch/sparc64/string/Makefile.inc index ede646f31d8..58341fe3858 100644 --- a/lib/libc/arch/sparc64/string/Makefile.inc +++ b/lib/libc/arch/sparc64/string/Makefile.inc @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile.inc,v 1.4 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.5 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.c memcpy.c memmove.c \ ffs.S \ strlen.S \ - bcmp.c bzero.c index.c memchr.c memcmp.c \ - memset.c rindex.c strcat.c strchr.c \ + bcmp.c bzero.c memchr.c memcmp.c \ + memset.c strcat.c strchr.c \ strcmp.c strcpy.c strcspn.c strlcat.c strlcpy.c \ strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \ strspn.c strstr.c swab.c diff --git a/lib/libc/arch/vax/string/Makefile.inc b/lib/libc/arch/vax/string/Makefile.inc index 220353865f7..a246341aed2 100644 --- a/lib/libc/arch/vax/string/Makefile.inc +++ b/lib/libc/arch/vax/string/Makefile.inc @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile.inc,v 1.9 2014/11/30 19:43:56 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.10 2015/05/15 22:29:37 millert Exp $ SRCS+= bcopy.S memcpy.c memmove.S \ bcmp.S bzero.S ffs.S memchr.c memcmp.S \ memset.S \ - strchr.S rindex.c strrchr.c \ + strchr.S strrchr.c \ strcat.c strcmp.c strcpy.c strcspn.c strlen.c strlcat.c \ strlcpy.c strncat.c strncmp.c strncpy.c strpbrk.c \ strsep.c strspn.c strstr.c swab.c diff --git a/lib/libc/arch/vax/string/strchr.S b/lib/libc/arch/vax/string/strchr.S index c4be0974dfb..9d1b75423e7 100644 --- a/lib/libc/arch/vax/string/strchr.S +++ b/lib/libc/arch/vax/string/strchr.S @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.S,v 1.1 2014/11/30 19:43:56 deraadt Exp $ */ +/* $OpenBSD: strchr.S,v 1.2 2015/05/15 22:29:37 millert Exp $ */ /* * Copyright (c) 1980, 1993 * The Regents of the University of California. All rights reserved. @@ -38,7 +38,7 @@ /* Alas not quite twice as fast as the generic C version on a uvax2 */ -STRONG_ALIAS(index, strchr) +WEAK_ALIAS(index, strchr) ENTRY(strchr, 0) movq 4(%ap),%r0 # r0 = cp; r1 = c tstb %r1 # special case, looking for '\0' diff --git a/lib/libc/string/index.c b/lib/libc/string/index.c deleted file mode 100644 index ebae15afe7e..00000000000 --- a/lib/libc/string/index.c +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: index.c,v 1.6 2014/11/30 19:43:56 deraadt Exp $ */ -/*- - * Copyright (c) 1990 The 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. 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 <string.h> - -char * -index(const char *p, int ch) -{ - for (;; ++p) { - if (*p == ch) - return((char *)p); - if (!*p) - return((char *)NULL); - } - /* NOTREACHED */ -} diff --git a/lib/libc/string/rindex.c b/lib/libc/string/rindex.c deleted file mode 100644 index 23716f6af32..00000000000 --- a/lib/libc/string/rindex.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: rindex.c,v 1.7 2014/11/30 19:43:56 deraadt 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. 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 <string.h> - -char * -rindex(const char *p, int ch) -{ - char *save; - - for (save = NULL;; ++p) { - if (*p == ch) - save = (char *)p; - if (!*p) - return(save); - } - /* NOTREACHED */ -} diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c index 20f2faeb111..596e407c9bd 100644 --- a/lib/libc/string/strchr.c +++ b/lib/libc/string/strchr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.c,v 1.1 2014/11/30 19:43:57 deraadt Exp $ */ +/* $OpenBSD: strchr.c,v 1.2 2015/05/15 22:29:37 millert Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -30,6 +30,8 @@ #include <string.h> +__weak_alias(index, strchr); + char * strchr(const char *p, int ch) { diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c index b2f17fba287..181f56ea698 100644 --- a/lib/libc/string/strrchr.c +++ b/lib/libc/string/strrchr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strrchr.c,v 1.1 2014/11/30 19:43:57 deraadt Exp $ */ +/* $OpenBSD: strrchr.c,v 1.2 2015/05/15 22:29:37 millert Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -30,6 +30,8 @@ #include <string.h> +__weak_alias(rindex, strrchr); + char * strrchr(const char *p, int ch) { |