4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
33 #include <iso/string_iso.h>
36 * Allow global visibility for symbols defined in
37 * C++ "std" namespace in <iso/string_iso.h>.
39 #if __cplusplus >= 199711L
69 #if defined(__EXTENSIONS__) || \
70 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
71 defined(_XPG6) || defined(_REENTRANT)
72 extern int strerror_r(int, char *, size_t);
75 #if defined(__EXTENSIONS__) || \
76 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
77 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
78 extern char *strtok_r(char *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
,
79 char **_RESTRICT_KYWD
);
82 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
83 defined(__XOPEN_OR_POSIX)
84 extern void *memccpy(void *_RESTRICT_KYWD
, const void *_RESTRICT_KYWD
,
88 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
90 extern char *stpcpy(char *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
);
91 extern char *stpncpy(char *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
, size_t);
92 extern char *strndup(const char *, size_t);
93 extern size_t strnlen(const char *, size_t);
94 extern char *strsignal(int);
98 typedef struct _locale
*locale_t
;
101 extern int strcoll_l(const char *, const char *, locale_t
);
102 extern size_t strxfrm_l(char *_RESTRICT_KYWD
, const char *_RESTRICT_KYWD
,
104 extern int strcasecmp_l(const char *, const char *, locale_t
);
105 extern int strncasecmp_l(const char *, const char *, size_t, locale_t
);
106 extern char *strerror_l(int, locale_t
);
108 #endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */
110 #if !defined(_STRICT_SYMBOLS)
112 /* Note that some of these are also declared in strings.h for XPG4_2+ */
113 extern void explicit_bzero(void *, size_t);
114 extern int uucopy(const void *_RESTRICT_KYWD
, void *_RESTRICT_KYWD
, size_t);
115 extern int uucopystr(const void *_RESTRICT_KYWD
, void *_RESTRICT_KYWD
, size_t);
117 extern int ffsl(long);
118 extern int ffsll(long long);
120 extern int flsl(long);
121 extern int flsll(long long);
122 extern void *memmem(const void *, size_t, const void *, size_t);
123 extern char *strcasestr(const char *, const char *);
124 extern char *strnstr(const char *, const char *, size_t);
125 extern size_t strlcpy(char *, const char *, size_t);
126 extern size_t strlcat(char *, const char *, size_t);
127 extern char *strsep(char **stringp
, const char *delim
);
128 extern char *strchrnul(const char *, int);
129 extern char *strcasestr_l(const char *, const char *, locale_t
);
130 extern int strcasecmp(const char *, const char *);
131 extern int strncasecmp(const char *, const char *, size_t);
132 #endif /* defined(__EXTENSIONS__)... */
134 #if defined(__EXTENSIONS__) || \
135 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
137 extern char *strdup(const char *);
140 #if defined(__EXTENSIONS__) || \
141 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
142 #if defined(__GNUC__)
145 * gcc provides this inlining facility but Studio C does not.
146 * We should use it exclusively once Studio C also provides it.
148 extern void *__builtin_alloca(size_t);
153 char *__str = (char *)(s); \
154 strcpy((char *)__builtin_alloca(strlen(__str) + 1), __str); \
157 #define strndupa(s, n) \
160 char *__str = (char *)(s); \
161 size_t __len = strnlen(__str, (n)); \
162 (__str = strncpy((char *)__builtin_alloca(__len + 1), \
164 __str[__len] = '\0', __str); \
169 #if defined(unix) /* excludes c99 */
171 * Studio C currently can't do the gcc-style inlining,
172 * so we use thread-local storage instead.
174 extern void *__builtin_alloca(size_t);
175 extern __thread
char *__strdupa_str
;
176 extern __thread
size_t __strdupa_len
;
179 (__strdupa_str = (char *)(s), \
180 strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \
183 #define strndupa(s, n) \
184 (__strdupa_str = (char *)(s), \
185 __strdupa_len = strnlen(__strdupa_str, (n)), \
186 __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \
187 __strdupa_str, __strdupa_len), \
188 __strdupa_str[__strdupa_len] = '\0', __strdupa_str)
191 #endif /* __GNUC__ */
192 #endif /* __EXTENSIONS__ ... */
198 #endif /* _STRING_H */