Print this page
12705 remove __builtin_alloca() declaration from string.h
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/string.h
+++ new/usr/src/head/string.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 + * Copyright 2020 Joyent, Inc.
25 26 */
26 27
27 28 /* Copyright (c) 1988 AT&T */
28 29 /* All Rights Reserved */
29 30
30 31 #ifndef _STRING_H
31 32 #define _STRING_H
32 33
33 34 #include <iso/string_iso.h>
34 35
35 36 /*
36 37 * Allow global visibility for symbols defined in
37 38 * C++ "std" namespace in <iso/string_iso.h>.
38 39 */
39 40 #if __cplusplus >= 199711L
40 41 using std::size_t;
41 42 using std::memchr;
42 43 using std::memcmp;
43 44 using std::memcpy;
44 45 using std::memmove;
45 46 using std::memset;
46 47 using std::strcat;
47 48 using std::strchr;
48 49 using std::strcmp;
49 50 using std::strcoll;
50 51 using std::strcpy;
51 52 using std::strcspn;
52 53 using std::strerror;
53 54 using std::strlen;
54 55 using std::strncat;
55 56 using std::strncmp;
56 57 using std::strncpy;
57 58 using std::strpbrk;
58 59 using std::strrchr;
59 60 using std::strspn;
60 61 using std::strstr;
61 62 using std::strtok;
62 63 using std::strxfrm;
63 64 #endif
64 65
65 66 #ifdef __cplusplus
66 67 extern "C" {
67 68 #endif
68 69
69 70 #if defined(__EXTENSIONS__) || \
70 71 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
71 72 defined(_XPG6) || defined(_REENTRANT)
72 73 extern int strerror_r(int, char *, size_t);
73 74 #endif
74 75
75 76 #if defined(__EXTENSIONS__) || \
76 77 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
77 78 (_POSIX_C_SOURCE - 0 >= 199506L) || defined(_REENTRANT)
78 79 extern char *strtok_r(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
79 80 char **_RESTRICT_KYWD);
80 81 #endif
81 82
82 83 #if defined(__EXTENSIONS__) || !defined(_STRICT_STDC) || \
83 84 defined(__XOPEN_OR_POSIX)
84 85 extern void *memccpy(void *_RESTRICT_KYWD, const void *_RESTRICT_KYWD,
85 86 int, size_t);
86 87 #endif
87 88
88 89 #if !defined(_STRICT_SYMBOLS) || defined(_XPG7)
89 90
90 91 extern char *stpcpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD);
91 92 extern char *stpncpy(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD, size_t);
92 93 extern char *strndup(const char *, size_t);
93 94 extern size_t strnlen(const char *, size_t);
94 95 extern char *strsignal(int);
95 96
96 97 #ifndef _LOCALE_T
97 98 #define _LOCALE_T
98 99 typedef struct _locale *locale_t;
99 100 #endif
100 101
101 102 extern int strcoll_l(const char *, const char *, locale_t);
102 103 extern size_t strxfrm_l(char *_RESTRICT_KYWD, const char *_RESTRICT_KYWD,
103 104 size_t, locale_t);
104 105 extern int strcasecmp_l(const char *, const char *, locale_t);
105 106 extern int strncasecmp_l(const char *, const char *, size_t, locale_t);
106 107 extern char *strerror_l(int, locale_t);
107 108
108 109 #endif /* defined(_STRICT_SYMBOLS) || defined(_XPG7) */
109 110
110 111 #if !defined(_STRICT_SYMBOLS)
111 112
112 113 /* Note that some of these are also declared in strings.h for XPG4_2+ */
113 114 extern void explicit_bzero(void *, size_t);
114 115 extern int uucopy(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
115 116 extern int uucopystr(const void *_RESTRICT_KYWD, void *_RESTRICT_KYWD, size_t);
116 117 extern int ffs(int);
117 118 extern int ffsl(long);
118 119 extern int ffsll(long long);
119 120 extern int fls(int);
120 121 extern int flsl(long);
121 122 extern int flsll(long long);
122 123 extern void *memmem(const void *, size_t, const void *, size_t);
123 124 extern char *strcasestr(const char *, const char *);
124 125 extern char *strnstr(const char *, const char *, size_t);
125 126 extern size_t strlcpy(char *, const char *, size_t);
126 127 extern size_t strlcat(char *, const char *, size_t);
127 128 extern char *strsep(char **stringp, const char *delim);
128 129 extern char *strchrnul(const char *, int);
129 130 extern char *strcasestr_l(const char *, const char *, locale_t);
130 131 extern int strcasecmp(const char *, const char *);
131 132 extern int strncasecmp(const char *, const char *, size_t);
↓ open down ↓ |
97 lines elided |
↑ open up ↑ |
132 133 #endif /* defined(__EXTENSIONS__)... */
133 134
134 135 #if defined(__EXTENSIONS__) || \
135 136 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX)) || \
136 137 defined(_XPG4_2)
137 138 extern char *strdup(const char *);
138 139 #endif
139 140
140 141 #if defined(__EXTENSIONS__) || \
141 142 (!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
143 +
142 144 #if defined(__GNUC__)
143 145
144 -/*
145 - * gcc provides this inlining facility but Studio C does not.
146 - * We should use it exclusively once Studio C also provides it.
147 - */
148 -extern void *__builtin_alloca(size_t);
149 -
150 146 #define strdupa(s) \
151 147 (__extension__( \
152 148 { \
153 149 char *__str = (char *)(s); \
154 150 strcpy((char *)__builtin_alloca(strlen(__str) + 1), __str); \
155 151 }))
156 152
157 153 #define strndupa(s, n) \
158 154 (__extension__( \
159 155 { \
160 156 char *__str = (char *)(s); \
161 157 size_t __len = strnlen(__str, (n)); \
162 158 (__str = strncpy((char *)__builtin_alloca(__len + 1), \
163 159 __str, __len), \
164 160 __str[__len] = '\0', __str); \
165 161 }))
166 162
167 163 #else /* __GNUC__ */
168 164
169 165 #if defined(unix) /* excludes c99 */
170 166 /*
171 167 * Studio C currently can't do the gcc-style inlining,
172 168 * so we use thread-local storage instead.
173 169 */
174 170 extern void *__builtin_alloca(size_t);
175 171 extern __thread char *__strdupa_str;
176 172 extern __thread size_t __strdupa_len;
177 173
178 174 #define strdupa(s) \
179 175 (__strdupa_str = (char *)(s), \
180 176 strcpy((char *)__builtin_alloca(strlen(__strdupa_str) + 1), \
181 177 __strdupa_str))
182 178
183 179 #define strndupa(s, n) \
184 180 (__strdupa_str = (char *)(s), \
185 181 __strdupa_len = strnlen(__strdupa_str, (n)), \
186 182 __strdupa_str = strncpy((char *)__builtin_alloca(__strdupa_len + 1), \
187 183 __strdupa_str, __strdupa_len), \
188 184 __strdupa_str[__strdupa_len] = '\0', __strdupa_str)
189 185 #endif /* unix */
190 186
191 187 #endif /* __GNUC__ */
192 188 #endif /* __EXTENSIONS__ ... */
193 189
194 190 #ifdef __cplusplus
195 191 }
196 192 #endif
197 193
198 194 #endif /* _STRING_H */
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX