summaryrefslogtreecommitdiffstats
path: root/lib/libc/mips
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2012-01-03 07:14:01 +0000
committered <ed@FreeBSD.org>2012-01-03 07:14:01 +0000
commit6014007e0092971acca93d674c9cc07855981aef (patch)
tree8ab3a468a2bb64fe48da5a2fa68950bee0300453 /lib/libc/mips
parent29cd68a581450e8d265ffcd2f82de6bcd65778c6 (diff)
downloadFreeBSD-src-6014007e0092971acca93d674c9cc07855981aef.zip
FreeBSD-src-6014007e0092971acca93d674c9cc07855981aef.tar.gz
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.
Diffstat (limited to 'lib/libc/mips')
-rw-r--r--lib/libc/mips/string/Makefile.inc6
-rw-r--r--lib/libc/mips/string/strchr.S (renamed from lib/libc/mips/string/index.S)6
-rw-r--r--lib/libc/mips/string/strrchr.S (renamed from lib/libc/mips/string/rindex.S)6
3 files changed, 11 insertions, 7 deletions
diff --git a/lib/libc/mips/string/Makefile.inc b/lib/libc/mips/string/Makefile.inc
index 48111e5..f37b9af 100644
--- a/lib/libc/mips/string/Makefile.inc
+++ b/lib/libc/mips/string/Makefile.inc
@@ -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
diff --git a/lib/libc/mips/string/index.S b/lib/libc/mips/string/strchr.S
index d1df540..9a9f8dc 100644
--- a/lib/libc/mips/string/index.S
+++ b/lib/libc/mips/string/strchr.S
@@ -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)
diff --git a/lib/libc/mips/string/rindex.S b/lib/libc/mips/string/strrchr.S
index e50379e..a742b35 100644
--- a/lib/libc/mips/string/rindex.S
+++ b/lib/libc/mips/string/strrchr.S
@@ -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)
OpenPOWER on IntegriCloud