From owner-svn-src-head@FreeBSD.ORG Tue Jan 3 07:14:02 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B47BB106566B; Tue, 3 Jan 2012 07:14:02 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9FEE38FC0C; Tue, 3 Jan 2012 07:14:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q037E2js010139; Tue, 3 Jan 2012 07:14:02 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q037E2qq010125; Tue, 3 Jan 2012 07:14:02 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201201030714.q037E2qq010125@svn.freebsd.org> From: Ed Schouten Date: Tue, 3 Jan 2012 07:14:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229368 - in head: lib/libc lib/libc/arm/string lib/libc/i386/string lib/libc/mips/string lib/libc/string lib/libstand sys/boot/userboot/libstand X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2012 07:14:02 -0000 Author: ed Date: Tue Jan 3 07:14:01 2012 New Revision: 229368 URL: http://svn.freebsd.org/changeset/base/229368 Log: Merge index() and strchr() together. As I looked through the C library, I noticed the FreeBSD MIPS port has a hand-written version of index(). This is nice, if it weren't for the fact that most applications call strchr() instead. Also, on the other architectures index() and strchr() are identical, meaning we have two identical pieces of code in the C library and statically linked applications. Solve this by naming the actual file strchr.[cS] and let it use __strong_reference()/STRONG_ALIAS() to provide the index() routine. Do the same for rindex()/strrchr(). This seems to make the C libraries and static binaries slightly smaller, but this reduction in size seems negligible. Added: head/lib/libc/mips/string/strchr.S - copied, changed from r229111, head/lib/libc/mips/string/index.S head/lib/libc/mips/string/strrchr.S - copied, changed from r229111, head/lib/libc/mips/string/rindex.S Replaced: head/lib/libc/string/strchr.c - copied, changed from r229111, head/lib/libc/string/index.c head/lib/libc/string/strrchr.c - copied, changed from r229111, head/lib/libc/string/rindex.c Deleted: head/lib/libc/i386/string/index.S head/lib/libc/i386/string/rindex.S head/lib/libc/mips/string/index.S head/lib/libc/mips/string/rindex.S head/lib/libc/string/index.c head/lib/libc/string/rindex.c Modified: head/lib/libc/Makefile head/lib/libc/arm/string/Makefile.inc head/lib/libc/i386/string/Makefile.inc head/lib/libc/i386/string/strchr.S head/lib/libc/i386/string/strrchr.S head/lib/libc/mips/string/Makefile.inc head/lib/libc/string/Makefile.inc head/lib/libstand/Makefile head/sys/boot/userboot/libstand/Makefile Modified: head/lib/libc/Makefile ============================================================================== --- head/lib/libc/Makefile Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/Makefile Tue Jan 3 07:14:01 2012 (r229368) @@ -127,8 +127,8 @@ SRCS+= ${_src} KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \ subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c -KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c index.c mcount.c rindex.c \ - strcat.c strcmp.c strcpy.c strlen.c strncpy.c +KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \ + strcmp.c strcpy.c strlen.c strncpy.c strrchr.c libkern: libkern.gen libkern.${LIBC_ARCH} Modified: head/lib/libc/arm/string/Makefile.inc ============================================================================== --- head/lib/libc/arm/string/Makefile.inc Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/arm/string/Makefile.inc Tue Jan 3 07:14:01 2012 (r229368) @@ -1,7 +1,6 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD$ -MDSRCS+=bcmp.c bcopy.S bzero.S ffs.S index.c memchr.c memcmp.S memcpy.S \ - memmove.S memset.S rindex.c strcat.c strchr.c strcmp.S strcpy.c \ - strlen.S strncmp.S strrchr.c swab.c wcschr.c wcscmp.c wcslen.c \ - wmemchr.c +MDSRCS+=bcmp.c bcopy.S bzero.S ffs.S memchr.c memcmp.S memcpy.S \ + memmove.S memset.S strcat.c strchr.c strcmp.S strcpy.c strlen.S \ + strncmp.S strrchr.c swab.c wcschr.c wcscmp.c wcslen.c wmemchr.c Modified: head/lib/libc/i386/string/Makefile.inc ============================================================================== --- head/lib/libc/i386/string/Makefile.inc Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/i386/string/Makefile.inc Tue Jan 3 07:14:01 2012 (r229368) @@ -1,7 +1,6 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD$ -MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S index.S memchr.S memcmp.S memcpy.S \ - memmove.S memset.S rindex.S strcat.S strchr.S strcmp.S strcpy.S \ - strncmp.S strrchr.S swab.S wcschr.S wcscmp.S wcslen.S \ - wmemchr.S +MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S memchr.S memcmp.S memcpy.S memmove.S \ + memset.S strcat.S strchr.S strcmp.S strcpy.S strncmp.S strrchr.S \ + swab.S wcschr.S wcscmp.S wcslen.S wmemchr.S Modified: head/lib/libc/i386/string/strchr.S ============================================================================== --- head/lib/libc/i386/string/strchr.S Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/i386/string/strchr.S Tue Jan 3 07:14:01 2012 (r229368) @@ -63,4 +63,6 @@ L2: ret END(strchr) +STRONG_ALIAS(index, strchr) + .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/i386/string/strrchr.S ============================================================================== --- head/lib/libc/i386/string/strrchr.S Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/i386/string/strrchr.S Tue Jan 3 07:14:01 2012 (r229368) @@ -64,4 +64,6 @@ L2: ret END(strrchr) +STRONG_ALIAS(rindex, strrchr) + .section .note.GNU-stack,"",%progbits Modified: head/lib/libc/mips/string/Makefile.inc ============================================================================== --- head/lib/libc/mips/string/Makefile.inc Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/mips/string/Makefile.inc Tue Jan 3 07:14:01 2012 (r229368) @@ -1,8 +1,8 @@ # $NetBSD: Makefile.inc,v 1.2 2000/10/10 21:51:54 jeffs Exp $ # $FreeBSD$ -SRCS+= bcmp.S bcopy.S bzero.S ffs.S index.S memchr.c memcmp.c memset.c \ +SRCS+= bcmp.S bcopy.S bzero.S ffs.S memchr.c memcmp.c memset.c \ memcpy.S memmove.S \ - rindex.S strcat.c strcmp.S strcpy.c strcspn.c strlen.S \ - strncat.c strncmp.c strncpy.c strpbrk.c strsep.c \ + strcat.c strchr.S strcmp.S strcpy.c strcspn.c strlen.S \ + strncat.c strncmp.c strncpy.c strrchr.S strpbrk.c strsep.c \ strspn.c strstr.c swab.c Copied and modified: head/lib/libc/mips/string/strchr.S (from r229111, head/lib/libc/mips/string/index.S) ============================================================================== --- head/lib/libc/mips/string/index.S Sat Dec 31 14:57:52 2011 (r229111, copy source) +++ head/lib/libc/mips/string/strchr.S Tue Jan 3 07:14:01 2012 (r229368) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); .abicalls #endif -LEAF(index) +LEAF(strchr) 1: lbu a2, 0(a0) # get a byte PTR_ADDU a0, a0, 1 @@ -56,4 +56,6 @@ notfnd: fnd: PTR_SUBU v0, a0, 1 j ra -END(index) +END(strchr) + +STRONG_ALIAS(index, strchr) Copied and modified: head/lib/libc/mips/string/strrchr.S (from r229111, head/lib/libc/mips/string/rindex.S) ============================================================================== --- head/lib/libc/mips/string/rindex.S Sat Dec 31 14:57:52 2011 (r229111, copy source) +++ head/lib/libc/mips/string/strrchr.S Tue Jan 3 07:14:01 2012 (r229368) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); .abicalls #endif -LEAF(rindex) +LEAF(strrchr) move v0, zero # default if not found 1: lbu a3, 0(a0) # get a byte @@ -54,4 +54,6 @@ LEAF(rindex) 2: bne a3, zero, 1b # continue if not end j ra -END(rindex) +END(strrchr) + +STRONG_ALIAS(rindex, strrchr) Modified: head/lib/libc/string/Makefile.inc ============================================================================== --- head/lib/libc/string/Makefile.inc Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libc/string/Makefile.inc Tue Jan 3 07:14:01 2012 (r229368) @@ -7,8 +7,8 @@ CFLAGS+= -I${.CURDIR}/locale # machine-independent string sources MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \ - index.c memccpy.c memchr.c memrchr.c memcmp.c \ - memcpy.c memmem.c memmove.c memset.c rindex.c \ + memccpy.c memchr.c memrchr.c memcmp.c \ + memcpy.c memmem.c memmove.c memset.c \ stpcpy.c stpncpy.c strcasecmp.c \ strcat.c strcasestr.c strchr.c strcmp.c strcoll.c strcpy.c strcspn.c \ strdup.c strerror.c strlcat.c strlcpy.c strlen.c strmode.c strncat.c \ Copied and modified: head/lib/libc/string/strchr.c (from r229111, head/lib/libc/string/index.c) ============================================================================== --- head/lib/libc/string/index.c Sat Dec 31 14:57:52 2011 (r229111, copy source) +++ head/lib/libc/string/strchr.c Tue Jan 3 07:14:01 2012 (r229368) @@ -34,19 +34,10 @@ static char sccsid[] = "@(#)index.c 8.1 __FBSDID("$FreeBSD$"); #include - -#ifdef STRCHR #include char * -strchr -#else -#include - -char * -index -#endif -(const char *p, int ch) +strchr(const char *p, int ch) { char c; @@ -59,3 +50,5 @@ index } /* NOTREACHED */ } + +__strong_reference(strchr, index); Copied and modified: head/lib/libc/string/strrchr.c (from r229111, head/lib/libc/string/rindex.c) ============================================================================== --- head/lib/libc/string/rindex.c Sat Dec 31 14:57:52 2011 (r229111, copy source) +++ head/lib/libc/string/strrchr.c Tue Jan 3 07:14:01 2012 (r229368) @@ -34,19 +34,10 @@ static char sccsid[] = "@(#)rindex.c 8.1 __FBSDID("$FreeBSD$"); #include - -#ifdef STRRCHR #include char * -strrchr -#else -#include - -char * -rindex -#endif -(const char *p, int ch) +strrchr(const char *p, int ch) { char *save; char c; @@ -60,3 +51,5 @@ rindex } /* NOTREACHED */ } + +__strong_reference(strrchr, rindex); Modified: head/lib/libstand/Makefile ============================================================================== --- head/lib/libstand/Makefile Tue Jan 3 07:06:35 2012 (r229367) +++ head/lib/libstand/Makefile Tue Jan 3 07:14:01 2012 (r229368) @@ -54,10 +54,10 @@ SRCS+= ntoh.c .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \ ${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" -SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ - memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \ - strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \ - strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c +SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ + memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ + strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \ + strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c .endif .if ${MACHINE_CPUARCH} == "arm" .PATH: ${.CURDIR}/../libc/arm/gen @@ -65,10 +65,9 @@ SRCS+= divsi3.S .endif .if ${MACHINE_CPUARCH} == "ia64" .PATH: ${.CURDIR}/../libc/ia64/string -SRCS+= bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \ - memcpy.S memmove.S memset.c rindex.c strcat.c strchr.c \ - strcmp.c strcpy.c strcspn.c strlen.c \ - strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \ +SRCS+= bcmp.c bcopy.S bzero.S ffs.S memccpy.c memchr.c memcmp.c memcpy.S \ + memmove.S memset.c strcat.c strchr.c strcmp.c strcpy.c strcspn.c \ + strlen.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strsep.c \ strspn.c strstr.c strtok.c swab.c .PATH: ${.CURDIR}/../libc/ia64/gen Modified: head/sys/boot/userboot/libstand/Makefile ============================================================================== --- head/sys/boot/userboot/libstand/Makefile Tue Jan 3 07:06:35 2012 (r229367) +++ head/sys/boot/userboot/libstand/Makefile Tue Jan 3 07:14:01 2012 (r229368) @@ -60,10 +60,10 @@ SRCS+= ntoh.c .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "powerpc" || \ ${MACHINE_CPUARCH} == "sparc64" || ${MACHINE_CPUARCH} == "amd64" || \ ${MACHINE_CPUARCH} == "arm" -SRCS+= bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \ - memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \ - strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \ - strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c +SRCS+= bcmp.c bcopy.c bzero.c ffs.c memccpy.c memchr.c memcmp.c memcpy.c \ + memmove.c memset.c qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \ + strcspn.c strlen.c strncat.c strncmp.c strncpy.c strpbrk.c \ + strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c .endif .if ${MACHINE_CPUARCH} == "arm" .PATH: ${LIBC}/arm/gen