16502 panic in zfs:abd_iter_map
[illumos-gate.git] / usr / src / head / string.h
blobb35962924f4283964d3d4f74c22e01a24df16a3e
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright 2020 Joyent, Inc.
26 * Copyright 2024 Oxide Computer company
29 /* Copyright (c) 1988 AT&T */
30 /* All Rights Reserved */
32 #ifndef _STRING_H
33 #define _STRING_H
35 #include <iso/string_iso.h>
38 * Allow global visibility for symbols defined in
39 * C++ "std" namespace in <iso/string_iso.h>.
41 #if __cplusplus >= 199711L
42 using std::size_t;
43 using std::memchr;
44 using std::memcmp;
45 using std::memcpy;
46 using std::memmove;
47 using std::memset;
48 using std::strcat;
49 using std::strchr;
50 using std::strcmp;
51 using std::strcoll;
52 using std::strcpy;
53 using std::strcspn;
54 using std::strerror;
55 using std::strlen;
56 using std::strncat;
57 using std::strncmp;
58 using std::strncpy;
59 using std::strpbrk;
60 using std::strrchr;
61 using std::strspn;
62 using std::strstr;
63 using std::strtok;
64 using std::strxfrm;
65 #endif
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
71 #if defined(__EXTENSIONS__) || \
72 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
73 defined(_XPG6) || defined(_REENTRANT)
74 extern int strerror_r(int, char *, size_t);
75 #endif
77 #if defined(__EXTENSIONS__) || \
78 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
79 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
80 extern char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
81 char **_RESTRICT_KYWD);
82 #endif
84 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
85 defined(__XOPEN_OR_POSIX)
86 extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD,
87 int, size_t);
88 #endif
90 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
92 extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
93 extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
94 extern char *strndup(const char *, size_t);
95 extern size_t strnlen(const char *, size_t);
96 extern char *strsignal(int);
98 #ifndef _LOCALE_T
99 #define _LOCALE_T
100 typedef struct _locale *locale_t;
101 #endif
103 extern int strcoll_l(const char *, const char *, locale_t);
104 extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
105 size_t, locale_t);
106 extern int strcasecmp_l(const char *, const char *, locale_t);
107 extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
108 extern char *strerror_l(int, locale_t);
110 #endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */
112 #if !defined(_STRICT_SYMBOLS)
114 /* Note that some of these are also declared in strings.h for XPG4_2+ */
115 extern void explicit_bzero(void *, size_t);
116 extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
117 extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
118 extern int ffs(int);
119 extern int ffsl(long);
120 extern int ffsll(long long);
121 extern int fls(int);
122 extern int flsl(long);
123 extern int flsll(long long);
124 extern void *memmem(const void *, size_t, const void *, size_t);
125 extern void *memrchr(const void *, int, size_t);
126 extern char *strcasestr(const char *, const char *);
127 extern char *strnstr(const char *, const char *, size_t);
128 extern size_t strlcpy(char *, const char *, size_t);
129 extern size_t strlcat(char *, const char *, size_t);
130 extern char *strsep(char **stringp, const char *delim);
131 extern char *strchrnul(const char *, int);
132 extern char *strcasestr_l(const char *, const char *, locale_t);
133 extern int strcasecmp(const char *, const char *);
134 extern int strncasecmp(const char *, const char *, size_t);
135 extern const char *strerrorname_np(int);
136 extern const char *strerrordesc_np(int);
137 #endif /* !defined(__STRICT_SYMBOLS) */
139 #if defined(__EXTENSIONS__) || \
140 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
141 defined(_XPG4_2)
142 extern char *strdup(const char *);
143 #endif
145 #if defined(__EXTENSIONS__) || \
146 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
148 #if defined(__GNUC__)
150 #define strdupa(s) \
151 (__extension__( \
153 char *__str = (char *)(s); \
154 (__str = strcpy((char *)__builtin_alloca(strlen(__str) + 1), \
155 __str), __str); \
158 #define strndupa(s, n) \
159 (__extension__( \
161 char *__str = (char *)(s); \
162 size_t __len = strnlen(__str, (n)); \
163 (__str = strncpy((char *)__builtin_alloca(__len + 1), \
164 __str, __len), \
165 __str[__len] = '\0', __str); \
168 #else /* __GNUC__ */
170 #if defined(unix) /* excludes c99 */
172 * Studio C currently can't do the gcc-style inlining,
173 * so we use thread-local storage instead.
175 extern void *__builtin_alloca(size_t);
176 extern __thread char *__strdupa_str;
177 extern __thread size_t __strdupa_len;
179 #define strdupa(s) \
180 (__strdupa_str = (char *)(s), \
181 strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \
182 __strdupa_str))
184 #define strndupa(s, n) \
185 (__strdupa_str = (char *)(s), \
186 __strdupa_len = strnlen(__strdupa_str, (n)), \
187 __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \
188 __strdupa_str, __strdupa_len), \
189 __strdupa_str[__strdupa_len] = '\0', __strdupa_str)
190 #endif /* unix */
192 #endif /* __GNUC__ */
193 #endif /* __EXTENSIONS__ ... */
195 #ifdef __cplusplus
197 #endif
199 #endif /* _STRING_H */