summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authordg199075 <none@none>2006-11-22 08:04:27 -0800
committerdg199075 <none@none>2006-11-22 08:04:27 -0800
commitadecd3c68045d04dc367d30faf2eb5cac1f45d5a (patch)
tree9424c458db71c461ce377a83b5a8ba77eca9fd4d /usr/src
parent1039f409262fcc394c002cfbadf60149156d2bcb (diff)
downloadillumos-joyent-adecd3c68045d04dc367d30faf2eb5cac1f45d5a.tar.gz
PSARC/2006/617 strnlen()
6478299 Add strnlen Contributed by Richard L. Hamilton
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/head/apptrace_impl.h9
-rw-r--r--usr/src/head/string.h2
-rw-r--r--usr/src/lib/abi/apptrace/common/interceptlib.c21
-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
10 files changed, 63 insertions, 24 deletions
diff --git a/usr/src/head/apptrace_impl.h b/usr/src/head/apptrace_impl.h
index 82c22e8a98..cf92bb2b2e 100644
--- a/usr/src/head/apptrace_impl.h
+++ b/usr/src/head/apptrace_impl.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -52,7 +51,6 @@ extern sigset_t abisigset;
extern void abilock(sigset_t *);
extern void abiunlock(sigset_t *);
-extern size_t strnlen(char const *, size_t);
extern int is_empty_string(char const *);
extern int (*abi_thr_main)(void);
@@ -66,7 +64,6 @@ extern int (*abi_mutex_unlock)(mutex_t *);
extern void abilock();
extern void abiunlock();
-extern size_t strnlen();
extern int is_empty_string();
extern int (*abi_thr_main)();
extern thread_t (*abi_thr_self)();
diff --git a/usr/src/head/string.h b/usr/src/head/string.h
index 3c4528ac1e..08b6d3da28 100644
--- a/usr/src/head/string.h
+++ b/usr/src/head/string.h
@@ -94,6 +94,7 @@ extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD,
extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
extern char *strsignal(int);
+extern size_t strnlen(const char *, size_t);
extern int ffs(int);
extern int strcasecmp(const char *, const char *);
extern int strncasecmp(const char *, const char *, size_t);
@@ -128,6 +129,7 @@ extern void *memccpy();
extern int uucopy();
extern int uucopystr();
extern char *strsignal();
+extern size_t strnlen();
extern int ffs();
extern int strcasecmp();
extern int strncasecmp();
diff --git a/usr/src/lib/abi/apptrace/common/interceptlib.c b/usr/src/lib/abi/apptrace/common/interceptlib.c
index a2ea131ce9..c17f0767a3 100644
--- a/usr/src/lib/abi/apptrace/common/interceptlib.c
+++ b/usr/src/lib/abi/apptrace/common/interceptlib.c
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * 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.
@@ -20,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -48,20 +47,6 @@ static lwp_mutex_t abi_stdio_mutex = DEFAULTMUTEX;
static volatile thread_t locktid = NOTID;
static volatile int count;
-size_t
-strnlen(const char *s, size_t n)
-{
- char *ptr;
-
- if (s == NULL)
- return (n);
- ptr = memchr(s, 0, n);
- if (ptr == NULL)
- return (n);
-
- return ((ptr - s) + 1);
-}
-
/* Return true on empty */
int
is_empty_string(char const *s)
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