]>
Commit | Line | Data |
---|---|---|
8215c9ec | 1 | /* Checking macros for wchar functions. |
04277e02 | 2 | Copyright (C) 2005-2019 Free Software Foundation, Inc. |
8215c9ec UD |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
8215c9ec UD |
18 | |
19 | #ifndef _WCHAR_H | |
de1c3ebb | 20 | # error "Never include <bits/wchar2.h> directly; use <wchar.h> instead." |
8215c9ec UD |
21 | #endif |
22 | ||
23 | ||
24 | extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1, | |
a784e502 | 25 | const wchar_t *__restrict __s2, size_t __n, |
8215c9ec | 26 | size_t __ns1) __THROW; |
22870975 UD |
27 | extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias, |
28 | (wchar_t *__restrict __s1, | |
a784e502 | 29 | const wchar_t *__restrict __s2, size_t __n), |
22870975 | 30 | wmemcpy); |
d6cd6bf4 UD |
31 | extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn, |
32 | (wchar_t *__restrict __s1, | |
a784e502 | 33 | const wchar_t *__restrict __s2, size_t __n, |
d6cd6bf4 UD |
34 | size_t __ns1), __wmemcpy_chk) |
35 | __warnattr ("wmemcpy called with length bigger than size of destination " | |
36 | "buffer"); | |
8215c9ec | 37 | |
5ac3ea17 | 38 | __fortify_function wchar_t * |
a784e502 | 39 | __NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, |
dc4bb1c2 | 40 | size_t __n)) |
8215c9ec UD |
41 | { |
42 | if (__bos0 (__s1) != (size_t) -1) | |
d6cd6bf4 UD |
43 | { |
44 | if (!__builtin_constant_p (__n)) | |
45 | return __wmemcpy_chk (__s1, __s2, __n, | |
46 | __bos0 (__s1) / sizeof (wchar_t)); | |
47 | ||
48 | if (__n > __bos0 (__s1) / sizeof (wchar_t)) | |
49 | return __wmemcpy_chk_warn (__s1, __s2, __n, | |
50 | __bos0 (__s1) / sizeof (wchar_t)); | |
51 | } | |
8215c9ec UD |
52 | return __wmemcpy_alias (__s1, __s2, __n); |
53 | } | |
54 | ||
55 | ||
a784e502 | 56 | extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2, |
8215c9ec | 57 | size_t __n, size_t __ns1) __THROW; |
22870975 | 58 | extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1, |
a784e502 | 59 | const wchar_t *__s2, |
22870975 | 60 | size_t __n), wmemmove); |
d6cd6bf4 | 61 | extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn, |
a784e502 | 62 | (wchar_t *__s1, const wchar_t *__s2, |
4f197237 | 63 | size_t __n, size_t __ns1), __wmemmove_chk) |
d6cd6bf4 UD |
64 | __warnattr ("wmemmove called with length bigger than size of destination " |
65 | "buffer"); | |
8215c9ec | 66 | |
5ac3ea17 | 67 | __fortify_function wchar_t * |
a784e502 | 68 | __NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)) |
8215c9ec UD |
69 | { |
70 | if (__bos0 (__s1) != (size_t) -1) | |
d6cd6bf4 UD |
71 | { |
72 | if (!__builtin_constant_p (__n)) | |
73 | return __wmemmove_chk (__s1, __s2, __n, | |
74 | __bos0 (__s1) / sizeof (wchar_t)); | |
75 | ||
76 | if (__n > __bos0 (__s1) / sizeof (wchar_t)) | |
77 | return __wmemmove_chk_warn (__s1, __s2, __n, | |
78 | __bos0 (__s1) / sizeof (wchar_t)); | |
79 | } | |
8215c9ec UD |
80 | return __wmemmove_alias (__s1, __s2, __n); |
81 | } | |
82 | ||
83 | ||
84 | #ifdef __USE_GNU | |
85 | extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1, | |
a784e502 | 86 | const wchar_t *__restrict __s2, size_t __n, |
8215c9ec | 87 | size_t __ns1) __THROW; |
22870975 UD |
88 | extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias, |
89 | (wchar_t *__restrict __s1, | |
a784e502 | 90 | const wchar_t *__restrict __s2, |
22870975 | 91 | size_t __n), wmempcpy); |
d6cd6bf4 UD |
92 | extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn, |
93 | (wchar_t *__restrict __s1, | |
a784e502 | 94 | const wchar_t *__restrict __s2, size_t __n, |
d6cd6bf4 UD |
95 | size_t __ns1), __wmempcpy_chk) |
96 | __warnattr ("wmempcpy called with length bigger than size of destination " | |
97 | "buffer"); | |
8215c9ec | 98 | |
5ac3ea17 | 99 | __fortify_function wchar_t * |
a784e502 | 100 | __NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2, |
dc4bb1c2 | 101 | size_t __n)) |
8215c9ec UD |
102 | { |
103 | if (__bos0 (__s1) != (size_t) -1) | |
d6cd6bf4 UD |
104 | { |
105 | if (!__builtin_constant_p (__n)) | |
106 | return __wmempcpy_chk (__s1, __s2, __n, | |
107 | __bos0 (__s1) / sizeof (wchar_t)); | |
108 | ||
109 | if (__n > __bos0 (__s1) / sizeof (wchar_t)) | |
110 | return __wmempcpy_chk_warn (__s1, __s2, __n, | |
111 | __bos0 (__s1) / sizeof (wchar_t)); | |
112 | } | |
8215c9ec UD |
113 | return __wmempcpy_alias (__s1, __s2, __n); |
114 | } | |
115 | #endif | |
116 | ||
117 | ||
118 | extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n, | |
119 | size_t __ns) __THROW; | |
22870975 UD |
120 | extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, |
121 | size_t __n), wmemset); | |
d6cd6bf4 UD |
122 | extern wchar_t *__REDIRECT_NTH (__wmemset_chk_warn, |
123 | (wchar_t *__s, wchar_t __c, size_t __n, | |
124 | size_t __ns), __wmemset_chk) | |
125 | __warnattr ("wmemset called with length bigger than size of destination " | |
126 | "buffer"); | |
8215c9ec | 127 | |
5ac3ea17 | 128 | __fortify_function wchar_t * |
4f197237 | 129 | __NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n)) |
8215c9ec UD |
130 | { |
131 | if (__bos0 (__s) != (size_t) -1) | |
d6cd6bf4 UD |
132 | { |
133 | if (!__builtin_constant_p (__n)) | |
134 | return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t)); | |
135 | ||
136 | if (__n > __bos0 (__s) / sizeof (wchar_t)) | |
137 | return __wmemset_chk_warn (__s, __c, __n, | |
138 | __bos0 (__s) / sizeof (wchar_t)); | |
139 | } | |
8215c9ec UD |
140 | return __wmemset_alias (__s, __c, __n); |
141 | } | |
142 | ||
143 | ||
144 | extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest, | |
a784e502 | 145 | const wchar_t *__restrict __src, |
8215c9ec | 146 | size_t __n) __THROW; |
22870975 UD |
147 | extern wchar_t *__REDIRECT_NTH (__wcscpy_alias, |
148 | (wchar_t *__restrict __dest, | |
a784e502 | 149 | const wchar_t *__restrict __src), wcscpy); |
8215c9ec | 150 | |
5ac3ea17 | 151 | __fortify_function wchar_t * |
a784e502 | 152 | __NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
8215c9ec UD |
153 | { |
154 | if (__bos (__dest) != (size_t) -1) | |
155 | return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); | |
156 | return __wcscpy_alias (__dest, __src); | |
157 | } | |
158 | ||
159 | ||
4f197237 | 160 | extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest, |
a784e502 | 161 | const wchar_t *__restrict __src, |
8215c9ec | 162 | size_t __destlen) __THROW; |
4f197237 AS |
163 | extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias, |
164 | (wchar_t *__restrict __dest, | |
a784e502 | 165 | const wchar_t *__restrict __src), wcpcpy); |
8215c9ec | 166 | |
5ac3ea17 | 167 | __fortify_function wchar_t * |
a784e502 | 168 | __NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
8215c9ec UD |
169 | { |
170 | if (__bos (__dest) != (size_t) -1) | |
171 | return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); | |
172 | return __wcpcpy_alias (__dest, __src); | |
173 | } | |
174 | ||
175 | ||
176 | extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest, | |
a784e502 | 177 | const wchar_t *__restrict __src, size_t __n, |
8215c9ec | 178 | size_t __destlen) __THROW; |
22870975 UD |
179 | extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias, |
180 | (wchar_t *__restrict __dest, | |
a784e502 | 181 | const wchar_t *__restrict __src, |
22870975 | 182 | size_t __n), wcsncpy); |
d6cd6bf4 UD |
183 | extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn, |
184 | (wchar_t *__restrict __dest, | |
a784e502 | 185 | const wchar_t *__restrict __src, |
d6cd6bf4 UD |
186 | size_t __n, size_t __destlen), __wcsncpy_chk) |
187 | __warnattr ("wcsncpy called with length bigger than size of destination " | |
188 | "buffer"); | |
8215c9ec | 189 | |
5ac3ea17 | 190 | __fortify_function wchar_t * |
a784e502 | 191 | __NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
4f197237 | 192 | size_t __n)) |
8215c9ec | 193 | { |
d6cd6bf4 UD |
194 | if (__bos (__dest) != (size_t) -1) |
195 | { | |
196 | if (!__builtin_constant_p (__n)) | |
197 | return __wcsncpy_chk (__dest, __src, __n, | |
198 | __bos (__dest) / sizeof (wchar_t)); | |
199 | if (__n > __bos (__dest) / sizeof (wchar_t)) | |
200 | return __wcsncpy_chk_warn (__dest, __src, __n, | |
201 | __bos (__dest) / sizeof (wchar_t)); | |
202 | } | |
8215c9ec UD |
203 | return __wcsncpy_alias (__dest, __src, __n); |
204 | } | |
205 | ||
206 | ||
207 | extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest, | |
a784e502 | 208 | const wchar_t *__restrict __src, size_t __n, |
8215c9ec | 209 | size_t __destlen) __THROW; |
22870975 UD |
210 | extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias, |
211 | (wchar_t *__restrict __dest, | |
a784e502 | 212 | const wchar_t *__restrict __src, |
22870975 | 213 | size_t __n), wcpncpy); |
d6cd6bf4 UD |
214 | extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn, |
215 | (wchar_t *__restrict __dest, | |
a784e502 | 216 | const wchar_t *__restrict __src, |
d6cd6bf4 UD |
217 | size_t __n, size_t __destlen), __wcpncpy_chk) |
218 | __warnattr ("wcpncpy called with length bigger than size of destination " | |
219 | "buffer"); | |
8215c9ec | 220 | |
5ac3ea17 | 221 | __fortify_function wchar_t * |
a784e502 | 222 | __NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
4f197237 | 223 | size_t __n)) |
8215c9ec | 224 | { |
d6cd6bf4 UD |
225 | if (__bos (__dest) != (size_t) -1) |
226 | { | |
227 | if (!__builtin_constant_p (__n)) | |
228 | return __wcpncpy_chk (__dest, __src, __n, | |
229 | __bos (__dest) / sizeof (wchar_t)); | |
230 | if (__n > __bos (__dest) / sizeof (wchar_t)) | |
231 | return __wcpncpy_chk_warn (__dest, __src, __n, | |
232 | __bos (__dest) / sizeof (wchar_t)); | |
233 | } | |
8215c9ec UD |
234 | return __wcpncpy_alias (__dest, __src, __n); |
235 | } | |
236 | ||
237 | ||
238 | extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest, | |
a784e502 | 239 | const wchar_t *__restrict __src, |
8215c9ec | 240 | size_t __destlen) __THROW; |
22870975 UD |
241 | extern wchar_t *__REDIRECT_NTH (__wcscat_alias, |
242 | (wchar_t *__restrict __dest, | |
a784e502 | 243 | const wchar_t *__restrict __src), wcscat); |
8215c9ec | 244 | |
5ac3ea17 | 245 | __fortify_function wchar_t * |
a784e502 | 246 | __NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src)) |
8215c9ec UD |
247 | { |
248 | if (__bos (__dest) != (size_t) -1) | |
249 | return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); | |
250 | return __wcscat_alias (__dest, __src); | |
251 | } | |
252 | ||
253 | ||
254 | extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest, | |
a784e502 | 255 | const wchar_t *__restrict __src, |
8215c9ec | 256 | size_t __n, size_t __destlen) __THROW; |
22870975 UD |
257 | extern wchar_t *__REDIRECT_NTH (__wcsncat_alias, |
258 | (wchar_t *__restrict __dest, | |
a784e502 | 259 | const wchar_t *__restrict __src, |
22870975 | 260 | size_t __n), wcsncat); |
8215c9ec | 261 | |
5ac3ea17 | 262 | __fortify_function wchar_t * |
a784e502 | 263 | __NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src, |
4f197237 | 264 | size_t __n)) |
8215c9ec UD |
265 | { |
266 | if (__bos (__dest) != (size_t) -1) | |
267 | return __wcsncat_chk (__dest, __src, __n, | |
268 | __bos (__dest) / sizeof (wchar_t)); | |
269 | return __wcsncat_alias (__dest, __src, __n); | |
270 | } | |
271 | ||
272 | ||
273 | extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n, | |
274 | int __flag, size_t __s_len, | |
a784e502 | 275 | const wchar_t *__restrict __format, ...) |
8215c9ec UD |
276 | __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */; |
277 | ||
ac97dec1 UD |
278 | extern int __REDIRECT_NTH_LDBL (__swprintf_alias, |
279 | (wchar_t *__restrict __s, size_t __n, | |
a784e502 | 280 | const wchar_t *__restrict __fmt, ...), |
ac97dec1 | 281 | swprintf); |
de1c3ebb UD |
282 | |
283 | #ifdef __va_arg_pack | |
5ac3ea17 | 284 | __fortify_function int |
de1c3ebb | 285 | __NTH (swprintf (wchar_t *__restrict __s, size_t __n, |
a784e502 | 286 | const wchar_t *__restrict __fmt, ...)) |
de1c3ebb UD |
287 | { |
288 | if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) | |
d6cd6bf4 UD |
289 | return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
290 | __bos (__s) / sizeof (wchar_t), | |
de1c3ebb UD |
291 | __fmt, __va_arg_pack ()); |
292 | return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ()); | |
293 | } | |
294 | #elif !defined __cplusplus | |
8215c9ec | 295 | /* XXX We might want to have support in gcc for swprintf. */ |
de1c3ebb | 296 | # define swprintf(s, n, ...) \ |
8215c9ec | 297 | (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \ |
d6cd6bf4 UD |
298 | ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, \ |
299 | __bos (s) / sizeof (wchar_t), __VA_ARGS__) \ | |
757beee1 | 300 | : swprintf (s, n, __VA_ARGS__)) |
de1c3ebb | 301 | #endif |
8215c9ec UD |
302 | |
303 | extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n, | |
304 | int __flag, size_t __s_len, | |
a784e502 | 305 | const wchar_t *__restrict __format, |
8215c9ec UD |
306 | __gnuc_va_list __arg) |
307 | __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */; | |
8215c9ec | 308 | |
ac97dec1 UD |
309 | extern int __REDIRECT_NTH_LDBL (__vswprintf_alias, |
310 | (wchar_t *__restrict __s, size_t __n, | |
a784e502 | 311 | const wchar_t *__restrict __fmt, |
ac97dec1 | 312 | __gnuc_va_list __ap), vswprintf); |
de1c3ebb | 313 | |
5ac3ea17 | 314 | __fortify_function int |
de1c3ebb | 315 | __NTH (vswprintf (wchar_t *__restrict __s, size_t __n, |
a784e502 | 316 | const wchar_t *__restrict __fmt, __gnuc_va_list __ap)) |
de1c3ebb UD |
317 | { |
318 | if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) | |
d6cd6bf4 UD |
319 | return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, |
320 | __bos (__s) / sizeof (wchar_t), __fmt, __ap); | |
de1c3ebb UD |
321 | return __vswprintf_alias (__s, __n, __fmt, __ap); |
322 | } | |
8215c9ec UD |
323 | |
324 | ||
325 | #if __USE_FORTIFY_LEVEL > 1 | |
326 | ||
76c98ee2 | 327 | extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag, |
a784e502 UD |
328 | const wchar_t *__restrict __format, ...); |
329 | extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format, | |
8215c9ec | 330 | ...); |
76c98ee2 | 331 | extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag, |
a784e502 | 332 | const wchar_t *__restrict __format, |
24452349 | 333 | __gnuc_va_list __ap); |
a784e502 | 334 | extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format, |
24452349 | 335 | __gnuc_va_list __ap); |
8215c9ec | 336 | |
de1c3ebb | 337 | # ifdef __va_arg_pack |
5ac3ea17 | 338 | __fortify_function int |
a784e502 | 339 | wprintf (const wchar_t *__restrict __fmt, ...) |
de1c3ebb UD |
340 | { |
341 | return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); | |
342 | } | |
343 | ||
5ac3ea17 | 344 | __fortify_function int |
a784e502 | 345 | fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...) |
de1c3ebb UD |
346 | { |
347 | return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, | |
348 | __va_arg_pack ()); | |
349 | } | |
350 | # elif !defined __cplusplus | |
351 | # define wprintf(...) \ | |
8215c9ec | 352 | __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
de1c3ebb | 353 | # define fwprintf(stream, ...) \ |
8215c9ec | 354 | __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
de1c3ebb UD |
355 | # endif |
356 | ||
5ac3ea17 | 357 | __fortify_function int |
a784e502 | 358 | vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap) |
de1c3ebb UD |
359 | { |
360 | return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap); | |
361 | } | |
362 | ||
5ac3ea17 | 363 | __fortify_function int |
de1c3ebb | 364 | vfwprintf (__FILE *__restrict __stream, |
a784e502 | 365 | const wchar_t *__restrict __fmt, __gnuc_va_list __ap) |
de1c3ebb UD |
366 | { |
367 | return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); | |
368 | } | |
8215c9ec UD |
369 | |
370 | #endif | |
371 | ||
372 | extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n, | |
76c98ee2 | 373 | __FILE *__restrict __stream) __wur; |
8215c9ec UD |
374 | extern wchar_t *__REDIRECT (__fgetws_alias, |
375 | (wchar_t *__restrict __s, int __n, | |
76c98ee2 | 376 | __FILE *__restrict __stream), fgetws) __wur; |
d6cd6bf4 UD |
377 | extern wchar_t *__REDIRECT (__fgetws_chk_warn, |
378 | (wchar_t *__restrict __s, size_t __size, int __n, | |
379 | __FILE *__restrict __stream), __fgetws_chk) | |
380 | __wur __warnattr ("fgetws called with bigger size than length " | |
381 | "of destination buffer"); | |
8215c9ec | 382 | |
5ac3ea17 | 383 | __fortify_function __wur wchar_t * |
76c98ee2 | 384 | fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) |
8215c9ec | 385 | { |
d6cd6bf4 UD |
386 | if (__bos (__s) != (size_t) -1) |
387 | { | |
388 | if (!__builtin_constant_p (__n) || __n <= 0) | |
389 | return __fgetws_chk (__s, __bos (__s) / sizeof (wchar_t), | |
390 | __n, __stream); | |
391 | ||
392 | if ((size_t) __n > __bos (__s) / sizeof (wchar_t)) | |
393 | return __fgetws_chk_warn (__s, __bos (__s) / sizeof (wchar_t), | |
394 | __n, __stream); | |
395 | } | |
8215c9ec UD |
396 | return __fgetws_alias (__s, __n, __stream); |
397 | } | |
398 | ||
399 | #ifdef __USE_GNU | |
400 | extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size, | |
76c98ee2 | 401 | int __n, __FILE *__restrict __stream) |
8215c9ec UD |
402 | __wur; |
403 | extern wchar_t *__REDIRECT (__fgetws_unlocked_alias, | |
404 | (wchar_t *__restrict __s, int __n, | |
76c98ee2 | 405 | __FILE *__restrict __stream), fgetws_unlocked) |
8215c9ec | 406 | __wur; |
d6cd6bf4 UD |
407 | extern wchar_t *__REDIRECT (__fgetws_unlocked_chk_warn, |
408 | (wchar_t *__restrict __s, size_t __size, int __n, | |
409 | __FILE *__restrict __stream), | |
410 | __fgetws_unlocked_chk) | |
411 | __wur __warnattr ("fgetws_unlocked called with bigger size than length " | |
412 | "of destination buffer"); | |
8215c9ec | 413 | |
5ac3ea17 | 414 | __fortify_function __wur wchar_t * |
76c98ee2 | 415 | fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream) |
8215c9ec | 416 | { |
d6cd6bf4 UD |
417 | if (__bos (__s) != (size_t) -1) |
418 | { | |
419 | if (!__builtin_constant_p (__n) || __n <= 0) | |
420 | return __fgetws_unlocked_chk (__s, __bos (__s) / sizeof (wchar_t), | |
421 | __n, __stream); | |
422 | ||
423 | if ((size_t) __n > __bos (__s) / sizeof (wchar_t)) | |
424 | return __fgetws_unlocked_chk_warn (__s, __bos (__s) / sizeof (wchar_t), | |
425 | __n, __stream); | |
426 | } | |
8215c9ec UD |
427 | return __fgetws_unlocked_alias (__s, __n, __stream); |
428 | } | |
429 | #endif | |
df6f8969 UD |
430 | |
431 | ||
4f197237 AS |
432 | extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar, |
433 | mbstate_t *__restrict __p, | |
434 | size_t __buflen) __THROW __wur; | |
df6f8969 UD |
435 | extern size_t __REDIRECT_NTH (__wcrtomb_alias, |
436 | (char *__restrict __s, wchar_t __wchar, | |
437 | mbstate_t *__restrict __ps), wcrtomb) __wur; | |
438 | ||
5ac3ea17 | 439 | __fortify_function __wur size_t |
4f197237 AS |
440 | __NTH (wcrtomb (char *__restrict __s, wchar_t __wchar, |
441 | mbstate_t *__restrict __ps)) | |
df6f8969 UD |
442 | { |
443 | /* We would have to include <limits.h> to get a definition of MB_LEN_MAX. | |
444 | But this would only disturb the namespace. So we define our own | |
445 | version here. */ | |
446 | #define __WCHAR_MB_LEN_MAX 16 | |
447 | #if defined MB_LEN_MAX && MB_LEN_MAX != __WCHAR_MB_LEN_MAX | |
448 | # error "Assumed value of MB_LEN_MAX wrong" | |
449 | #endif | |
450 | if (__bos (__s) != (size_t) -1 && __WCHAR_MB_LEN_MAX > __bos (__s)) | |
451 | return __wcrtomb_chk (__s, __wchar, __ps, __bos (__s)); | |
452 | return __wcrtomb_alias (__s, __wchar, __ps); | |
453 | } | |
454 | ||
455 | ||
456 | extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst, | |
a784e502 | 457 | const char **__restrict __src, |
df6f8969 UD |
458 | size_t __len, mbstate_t *__restrict __ps, |
459 | size_t __dstlen) __THROW; | |
460 | extern size_t __REDIRECT_NTH (__mbsrtowcs_alias, | |
461 | (wchar_t *__restrict __dst, | |
a784e502 | 462 | const char **__restrict __src, |
df6f8969 UD |
463 | size_t __len, mbstate_t *__restrict __ps), |
464 | mbsrtowcs); | |
d6cd6bf4 UD |
465 | extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn, |
466 | (wchar_t *__restrict __dst, | |
a784e502 | 467 | const char **__restrict __src, |
d6cd6bf4 UD |
468 | size_t __len, mbstate_t *__restrict __ps, |
469 | size_t __dstlen), __mbsrtowcs_chk) | |
470 | __warnattr ("mbsrtowcs called with dst buffer smaller than len " | |
471 | "* sizeof (wchar_t)"); | |
df6f8969 | 472 | |
5ac3ea17 | 473 | __fortify_function size_t |
a784e502 | 474 | __NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, |
dc4bb1c2 | 475 | size_t __len, mbstate_t *__restrict __ps)) |
df6f8969 | 476 | { |
d6cd6bf4 UD |
477 | if (__bos (__dst) != (size_t) -1) |
478 | { | |
479 | if (!__builtin_constant_p (__len)) | |
480 | return __mbsrtowcs_chk (__dst, __src, __len, __ps, | |
481 | __bos (__dst) / sizeof (wchar_t)); | |
482 | ||
483 | if (__len > __bos (__dst) / sizeof (wchar_t)) | |
484 | return __mbsrtowcs_chk_warn (__dst, __src, __len, __ps, | |
485 | __bos (__dst) / sizeof (wchar_t)); | |
486 | } | |
df6f8969 UD |
487 | return __mbsrtowcs_alias (__dst, __src, __len, __ps); |
488 | } | |
489 | ||
490 | ||
491 | extern size_t __wcsrtombs_chk (char *__restrict __dst, | |
a784e502 | 492 | const wchar_t **__restrict __src, |
df6f8969 UD |
493 | size_t __len, mbstate_t *__restrict __ps, |
494 | size_t __dstlen) __THROW; | |
495 | extern size_t __REDIRECT_NTH (__wcsrtombs_alias, | |
496 | (char *__restrict __dst, | |
a784e502 | 497 | const wchar_t **__restrict __src, |
df6f8969 UD |
498 | size_t __len, mbstate_t *__restrict __ps), |
499 | wcsrtombs); | |
d6cd6bf4 UD |
500 | extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn, |
501 | (char *__restrict __dst, | |
a784e502 | 502 | const wchar_t **__restrict __src, |
d6cd6bf4 UD |
503 | size_t __len, mbstate_t *__restrict __ps, |
504 | size_t __dstlen), __wcsrtombs_chk) | |
505 | __warnattr ("wcsrtombs called with dst buffer smaller than len"); | |
df6f8969 | 506 | |
5ac3ea17 | 507 | __fortify_function size_t |
a784e502 | 508 | __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src, |
dc4bb1c2 | 509 | size_t __len, mbstate_t *__restrict __ps)) |
df6f8969 | 510 | { |
d6cd6bf4 UD |
511 | if (__bos (__dst) != (size_t) -1) |
512 | { | |
513 | if (!__builtin_constant_p (__len)) | |
514 | return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst)); | |
515 | ||
516 | if (__len > __bos (__dst)) | |
517 | return __wcsrtombs_chk_warn (__dst, __src, __len, __ps, __bos (__dst)); | |
518 | } | |
df6f8969 UD |
519 | return __wcsrtombs_alias (__dst, __src, __len, __ps); |
520 | } | |
521 | ||
522 | ||
523 | #ifdef __USE_GNU | |
524 | extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst, | |
a784e502 | 525 | const char **__restrict __src, size_t __nmc, |
df6f8969 UD |
526 | size_t __len, mbstate_t *__restrict __ps, |
527 | size_t __dstlen) __THROW; | |
528 | extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias, | |
529 | (wchar_t *__restrict __dst, | |
a784e502 | 530 | const char **__restrict __src, size_t __nmc, |
df6f8969 UD |
531 | size_t __len, mbstate_t *__restrict __ps), |
532 | mbsnrtowcs); | |
d6cd6bf4 UD |
533 | extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn, |
534 | (wchar_t *__restrict __dst, | |
a784e502 | 535 | const char **__restrict __src, size_t __nmc, |
d6cd6bf4 UD |
536 | size_t __len, mbstate_t *__restrict __ps, |
537 | size_t __dstlen), __mbsnrtowcs_chk) | |
538 | __warnattr ("mbsnrtowcs called with dst buffer smaller than len " | |
539 | "* sizeof (wchar_t)"); | |
df6f8969 | 540 | |
5ac3ea17 | 541 | __fortify_function size_t |
a784e502 | 542 | __NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src, |
dc4bb1c2 | 543 | size_t __nmc, size_t __len, mbstate_t *__restrict __ps)) |
df6f8969 | 544 | { |
d6cd6bf4 UD |
545 | if (__bos (__dst) != (size_t) -1) |
546 | { | |
547 | if (!__builtin_constant_p (__len)) | |
548 | return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, | |
549 | __bos (__dst) / sizeof (wchar_t)); | |
550 | ||
551 | if (__len > __bos (__dst) / sizeof (wchar_t)) | |
552 | return __mbsnrtowcs_chk_warn (__dst, __src, __nmc, __len, __ps, | |
553 | __bos (__dst) / sizeof (wchar_t)); | |
554 | } | |
df6f8969 UD |
555 | return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps); |
556 | } | |
557 | ||
558 | ||
559 | extern size_t __wcsnrtombs_chk (char *__restrict __dst, | |
a784e502 | 560 | const wchar_t **__restrict __src, |
df6f8969 UD |
561 | size_t __nwc, size_t __len, |
562 | mbstate_t *__restrict __ps, size_t __dstlen) | |
563 | __THROW; | |
564 | extern size_t __REDIRECT_NTH (__wcsnrtombs_alias, | |
565 | (char *__restrict __dst, | |
a784e502 | 566 | const wchar_t **__restrict __src, |
df6f8969 UD |
567 | size_t __nwc, size_t __len, |
568 | mbstate_t *__restrict __ps), wcsnrtombs); | |
d6cd6bf4 UD |
569 | extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn, |
570 | (char *__restrict __dst, | |
a784e502 | 571 | const wchar_t **__restrict __src, |
d6cd6bf4 UD |
572 | size_t __nwc, size_t __len, |
573 | mbstate_t *__restrict __ps, | |
574 | size_t __dstlen), __wcsnrtombs_chk) | |
575 | __warnattr ("wcsnrtombs called with dst buffer smaller than len"); | |
df6f8969 | 576 | |
5ac3ea17 | 577 | __fortify_function size_t |
a784e502 | 578 | __NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src, |
dc4bb1c2 | 579 | size_t __nwc, size_t __len, mbstate_t *__restrict __ps)) |
df6f8969 | 580 | { |
d6cd6bf4 UD |
581 | if (__bos (__dst) != (size_t) -1) |
582 | { | |
583 | if (!__builtin_constant_p (__len)) | |
584 | return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps, | |
585 | __bos (__dst)); | |
586 | ||
587 | if (__len > __bos (__dst)) | |
588 | return __wcsnrtombs_chk_warn (__dst, __src, __nwc, __len, __ps, | |
589 | __bos (__dst)); | |
590 | } | |
df6f8969 UD |
591 | return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps); |
592 | } | |
593 | #endif |