summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/amd64/Makefile1
-rw-r--r--usr/src/lib/libc/i386/Makefile.com1
-rw-r--r--usr/src/lib/libc/inc/synonyms.h1
-rw-r--r--usr/src/lib/libc/port/gen/strnlen.c49
-rw-r--r--usr/src/lib/libc/port/mapfile-vers1
-rw-r--r--usr/src/lib/libc/sparc/Makefile1
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile1
7 files changed, 55 insertions, 0 deletions
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index d074ae071b..8af48c4361 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -125,6 +125,7 @@ GENOBJS= \
strlen.o \
strncmp.o \
strncpy.o \
+ strnlen.o \
sync_instruction_memory.o
# Preserved solely to ease maintenance of 32-bit and 64-bit library builds
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index c745580ab4..153937921b 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -133,6 +133,7 @@ GENOBJS= \
strncat.o \
strncmp.o \
strncpy.o \
+ strnlen.o \
strrchr.o \
sync_instruction_memory.o
diff --git a/usr/src/lib/libc/inc/synonyms.h b/usr/src/lib/libc/inc/synonyms.h
index 78ec1cb30f..30f17eb6cb 100644
--- a/usr/src/lib/libc/inc/synonyms.h
+++ b/usr/src/lib/libc/inc/synonyms.h
@@ -987,6 +987,7 @@ extern "C" {
#define strerror _strerror
#define strfmon _strfmon
#define string_to_decimal _string_to_decimal
+#define strnlen _strnlen
#define strptime _strptime
#define strtok_r _strtok_r
#define strtoll _strtoll
diff --git a/usr/src/lib/libc/port/gen/strnlen.c b/usr/src/lib/libc/port/gen/strnlen.c
new file mode 100644
index 0000000000..01b554e17a
--- /dev/null
+++ b/usr/src/lib/libc/port/gen/strnlen.c
@@ -0,0 +1,49 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright 2006 Sun Microsystems, Inc.
+ * All rights reserved. Use is subject to license terms.
+ */
+
+#pragma ident "%Z%%M% %I% %E% SMI"
+
+#pragma weak strnlen = _strnlen
+
+#include "synonyms.h"
+#include <string.h>
+#include <sys/types.h>
+
+/*
+ * Returns the number of non-NULL bytes in string argument,
+ * but not more than maxlen. Does not look past str + maxlen.
+ */
+size_t
+strnlen(const char *str, size_t maxlen)
+{
+ const char *ptr;
+
+ ptr = memchr(str, 0, maxlen);
+ if (ptr == NULL)
+ return (maxlen);
+
+ return (ptr - str);
+}
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 00b826fd08..bafd47ab0e 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -101,6 +101,7 @@ SUNW_1.23 { # SunOS 5.11 (Solaris 11)
sigqueue;
sigtimedwait;
sigwaitinfo;
+ strnlen;
timer_create;
timer_delete;
timer_getoverrun;
diff --git a/usr/src/lib/libc/sparc/Makefile b/usr/src/lib/libc/sparc/Makefile
index 580c8ac7cd..452b116802 100644
--- a/usr/src/lib/libc/sparc/Makefile
+++ b/usr/src/lib/libc/sparc/Makefile
@@ -149,6 +149,7 @@ GENOBJS= \
strlen.o \
strncmp.o \
strncpy.o \
+ strnlen.o \
swapctxt.o \
sync_instruction_memory.o
diff --git a/usr/src/lib/libc/sparcv9/Makefile b/usr/src/lib/libc/sparcv9/Makefile
index 9d5a72ddec..bfbb37f2d8 100644
--- a/usr/src/lib/libc/sparcv9/Makefile
+++ b/usr/src/lib/libc/sparcv9/Makefile
@@ -148,6 +148,7 @@ GENOBJS= \
strlen.o \
strncmp.o \
strncpy.o \
+ strnlen.o \
swapctxt.o \
sync_instruction_memory.o