Line data Source code
1 : /* Checking macros for wchar functions.
2 : Copyright (C) 2005-2020 Free Software Foundation, Inc.
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
16 : License along with the GNU C Library; if not, see
17 : <https://www.gnu.org/licenses/>. */
18 :
19 : #ifndef _WCHAR_H
20 : # error "Never include <bits/wchar2.h> directly; use <wchar.h> instead."
21 : #endif
22 :
23 :
24 : extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
25 : const wchar_t *__restrict __s2, size_t __n,
26 : size_t __ns1) __THROW;
27 : extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias,
28 : (wchar_t *__restrict __s1,
29 : const wchar_t *__restrict __s2, size_t __n),
30 : wmemcpy);
31 : extern wchar_t *__REDIRECT_NTH (__wmemcpy_chk_warn,
32 : (wchar_t *__restrict __s1,
33 : const wchar_t *__restrict __s2, size_t __n,
34 : size_t __ns1), __wmemcpy_chk)
35 : __warnattr ("wmemcpy called with length bigger than size of destination "
36 : "buffer");
37 :
38 : __fortify_function wchar_t *
39 0 : __NTH (wmemcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
40 : size_t __n))
41 : {
42 0 : if (__bos0 (__s1) != (size_t) -1)
43 : {
44 0 : if (!__builtin_constant_p (__n))
45 0 : return __wmemcpy_chk (__s1, __s2, __n,
46 0 : __bos0 (__s1) / sizeof (wchar_t));
47 :
48 0 : if (__n > __bos0 (__s1) / sizeof (wchar_t))
49 0 : return __wmemcpy_chk_warn (__s1, __s2, __n,
50 0 : __bos0 (__s1) / sizeof (wchar_t));
51 : }
52 0 : return __wmemcpy_alias (__s1, __s2, __n);
53 : }
54 :
55 :
56 : extern wchar_t *__wmemmove_chk (wchar_t *__s1, const wchar_t *__s2,
57 : size_t __n, size_t __ns1) __THROW;
58 : extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1,
59 : const wchar_t *__s2,
60 : size_t __n), wmemmove);
61 : extern wchar_t *__REDIRECT_NTH (__wmemmove_chk_warn,
62 : (wchar_t *__s1, const wchar_t *__s2,
63 : size_t __n, size_t __ns1), __wmemmove_chk)
64 : __warnattr ("wmemmove called with length bigger than size of destination "
65 : "buffer");
66 :
67 : __fortify_function wchar_t *
68 : __NTH (wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n))
69 : {
70 : if (__bos0 (__s1) != (size_t) -1)
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 : }
80 : return __wmemmove_alias (__s1, __s2, __n);
81 : }
82 :
83 :
84 : #ifdef __USE_GNU
85 : extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
86 : const wchar_t *__restrict __s2, size_t __n,
87 : size_t __ns1) __THROW;
88 : extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias,
89 : (wchar_t *__restrict __s1,
90 : const wchar_t *__restrict __s2,
91 : size_t __n), wmempcpy);
92 : extern wchar_t *__REDIRECT_NTH (__wmempcpy_chk_warn,
93 : (wchar_t *__restrict __s1,
94 : const wchar_t *__restrict __s2, size_t __n,
95 : size_t __ns1), __wmempcpy_chk)
96 : __warnattr ("wmempcpy called with length bigger than size of destination "
97 : "buffer");
98 :
99 : __fortify_function wchar_t *
100 : __NTH (wmempcpy (wchar_t *__restrict __s1, const wchar_t *__restrict __s2,
101 : size_t __n))
102 : {
103 : if (__bos0 (__s1) != (size_t) -1)
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 : }
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;
120 : extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
121 : size_t __n), wmemset);
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");
127 :
128 : __fortify_function wchar_t *
129 : __NTH (wmemset (wchar_t *__s, wchar_t __c, size_t __n))
130 : {
131 : if (__bos0 (__s) != (size_t) -1)
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 : }
140 : return __wmemset_alias (__s, __c, __n);
141 : }
142 :
143 :
144 : extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
145 : const wchar_t *__restrict __src,
146 : size_t __n) __THROW;
147 : extern wchar_t *__REDIRECT_NTH (__wcscpy_alias,
148 : (wchar_t *__restrict __dest,
149 : const wchar_t *__restrict __src), wcscpy);
150 :
151 : __fortify_function wchar_t *
152 : __NTH (wcscpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
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 :
160 : extern wchar_t *__wcpcpy_chk (wchar_t *__restrict __dest,
161 : const wchar_t *__restrict __src,
162 : size_t __destlen) __THROW;
163 : extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias,
164 : (wchar_t *__restrict __dest,
165 : const wchar_t *__restrict __src), wcpcpy);
166 :
167 : __fortify_function wchar_t *
168 : __NTH (wcpcpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
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,
177 : const wchar_t *__restrict __src, size_t __n,
178 : size_t __destlen) __THROW;
179 : extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias,
180 : (wchar_t *__restrict __dest,
181 : const wchar_t *__restrict __src,
182 : size_t __n), wcsncpy);
183 : extern wchar_t *__REDIRECT_NTH (__wcsncpy_chk_warn,
184 : (wchar_t *__restrict __dest,
185 : const wchar_t *__restrict __src,
186 : size_t __n, size_t __destlen), __wcsncpy_chk)
187 : __warnattr ("wcsncpy called with length bigger than size of destination "
188 : "buffer");
189 :
190 : __fortify_function wchar_t *
191 : __NTH (wcsncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
192 : size_t __n))
193 : {
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 : }
203 : return __wcsncpy_alias (__dest, __src, __n);
204 : }
205 :
206 :
207 : extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
208 : const wchar_t *__restrict __src, size_t __n,
209 : size_t __destlen) __THROW;
210 : extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias,
211 : (wchar_t *__restrict __dest,
212 : const wchar_t *__restrict __src,
213 : size_t __n), wcpncpy);
214 : extern wchar_t *__REDIRECT_NTH (__wcpncpy_chk_warn,
215 : (wchar_t *__restrict __dest,
216 : const wchar_t *__restrict __src,
217 : size_t __n, size_t __destlen), __wcpncpy_chk)
218 : __warnattr ("wcpncpy called with length bigger than size of destination "
219 : "buffer");
220 :
221 : __fortify_function wchar_t *
222 : __NTH (wcpncpy (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
223 : size_t __n))
224 : {
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 : }
234 : return __wcpncpy_alias (__dest, __src, __n);
235 : }
236 :
237 :
238 : extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
239 : const wchar_t *__restrict __src,
240 : size_t __destlen) __THROW;
241 : extern wchar_t *__REDIRECT_NTH (__wcscat_alias,
242 : (wchar_t *__restrict __dest,
243 : const wchar_t *__restrict __src), wcscat);
244 :
245 : __fortify_function wchar_t *
246 : __NTH (wcscat (wchar_t *__restrict __dest, const wchar_t *__restrict __src))
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,
255 : const wchar_t *__restrict __src,
256 : size_t __n, size_t __destlen) __THROW;
257 : extern wchar_t *__REDIRECT_NTH (__wcsncat_alias,
258 : (wchar_t *__restrict __dest,
259 : const wchar_t *__restrict __src,
260 : size_t __n), wcsncat);
261 :
262 : __fortify_function wchar_t *
263 : __NTH (wcsncat (wchar_t *__restrict __dest, const wchar_t *__restrict __src,
264 : size_t __n))
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,
275 : const wchar_t *__restrict __format, ...)
276 : __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
277 :
278 : extern int __REDIRECT_NTH_LDBL (__swprintf_alias,
279 : (wchar_t *__restrict __s, size_t __n,
280 : const wchar_t *__restrict __fmt, ...),
281 : swprintf);
282 :
283 : #ifdef __va_arg_pack
284 : __fortify_function int
285 : __NTH (swprintf (wchar_t *__restrict __s, size_t __n,
286 : const wchar_t *__restrict __fmt, ...))
287 : {
288 : if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
289 : return __swprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
290 : __bos (__s) / sizeof (wchar_t),
291 : __fmt, __va_arg_pack ());
292 : return __swprintf_alias (__s, __n, __fmt, __va_arg_pack ());
293 : }
294 : #elif !defined __cplusplus
295 : /* XXX We might want to have support in gcc for swprintf. */
296 : # define swprintf(s, n, ...) \
297 : (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \
298 : ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, \
299 : __bos (s) / sizeof (wchar_t), __VA_ARGS__) \
300 : : swprintf (s, n, __VA_ARGS__))
301 : #endif
302 :
303 : extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
304 : int __flag, size_t __s_len,
305 : const wchar_t *__restrict __format,
306 : __gnuc_va_list __arg)
307 : __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
308 :
309 : extern int __REDIRECT_NTH_LDBL (__vswprintf_alias,
310 : (wchar_t *__restrict __s, size_t __n,
311 : const wchar_t *__restrict __fmt,
312 : __gnuc_va_list __ap), vswprintf);
313 :
314 : __fortify_function int
315 : __NTH (vswprintf (wchar_t *__restrict __s, size_t __n,
316 : const wchar_t *__restrict __fmt, __gnuc_va_list __ap))
317 : {
318 : if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
319 : return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
320 : __bos (__s) / sizeof (wchar_t), __fmt, __ap);
321 : return __vswprintf_alias (__s, __n, __fmt, __ap);
322 : }
323 :
324 :
325 : #if __USE_FORTIFY_LEVEL > 1
326 :
327 : extern int __fwprintf_chk (__FILE *__restrict __stream, int __flag,
328 : const wchar_t *__restrict __format, ...);
329 : extern int __wprintf_chk (int __flag, const wchar_t *__restrict __format,
330 : ...);
331 : extern int __vfwprintf_chk (__FILE *__restrict __stream, int __flag,
332 : const wchar_t *__restrict __format,
333 : __gnuc_va_list __ap);
334 : extern int __vwprintf_chk (int __flag, const wchar_t *__restrict __format,
335 : __gnuc_va_list __ap);
336 :
337 : # ifdef __va_arg_pack
338 : __fortify_function int
339 : wprintf (const wchar_t *__restrict __fmt, ...)
340 : {
341 : return __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
342 : }
343 :
344 : __fortify_function int
345 : fwprintf (__FILE *__restrict __stream, const wchar_t *__restrict __fmt, ...)
346 : {
347 : return __fwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt,
348 : __va_arg_pack ());
349 : }
350 : # elif !defined __cplusplus
351 : # define wprintf(...) \
352 : __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
353 : # define fwprintf(stream, ...) \
354 : __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
355 : # endif
356 :
357 : __fortify_function int
358 : vwprintf (const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
359 : {
360 : return __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __ap);
361 : }
362 :
363 : __fortify_function int
364 : vfwprintf (__FILE *__restrict __stream,
365 : const wchar_t *__restrict __fmt, __gnuc_va_list __ap)
366 : {
367 : return __vfwprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
368 : }
369 :
370 : #endif
371 :
372 : extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
373 : __FILE *__restrict __stream) __wur;
374 : extern wchar_t *__REDIRECT (__fgetws_alias,
375 : (wchar_t *__restrict __s, int __n,
376 : __FILE *__restrict __stream), fgetws) __wur;
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");
382 :
383 : __fortify_function __wur wchar_t *
384 : fgetws (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
385 : {
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 : }
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,
401 : int __n, __FILE *__restrict __stream)
402 : __wur;
403 : extern wchar_t *__REDIRECT (__fgetws_unlocked_alias,
404 : (wchar_t *__restrict __s, int __n,
405 : __FILE *__restrict __stream), fgetws_unlocked)
406 : __wur;
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");
413 :
414 : __fortify_function __wur wchar_t *
415 : fgetws_unlocked (wchar_t *__restrict __s, int __n, __FILE *__restrict __stream)
416 : {
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 : }
427 : return __fgetws_unlocked_alias (__s, __n, __stream);
428 : }
429 : #endif
430 :
431 :
432 : extern size_t __wcrtomb_chk (char *__restrict __s, wchar_t __wchar,
433 : mbstate_t *__restrict __p,
434 : size_t __buflen) __THROW __wur;
435 : extern size_t __REDIRECT_NTH (__wcrtomb_alias,
436 : (char *__restrict __s, wchar_t __wchar,
437 : mbstate_t *__restrict __ps), wcrtomb) __wur;
438 :
439 : __fortify_function __wur size_t
440 : __NTH (wcrtomb (char *__restrict __s, wchar_t __wchar,
441 : mbstate_t *__restrict __ps))
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,
457 : const char **__restrict __src,
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,
462 : const char **__restrict __src,
463 : size_t __len, mbstate_t *__restrict __ps),
464 : mbsrtowcs);
465 : extern size_t __REDIRECT_NTH (__mbsrtowcs_chk_warn,
466 : (wchar_t *__restrict __dst,
467 : const char **__restrict __src,
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)");
472 :
473 : __fortify_function size_t
474 : __NTH (mbsrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
475 : size_t __len, mbstate_t *__restrict __ps))
476 : {
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 : }
487 : return __mbsrtowcs_alias (__dst, __src, __len, __ps);
488 : }
489 :
490 :
491 : extern size_t __wcsrtombs_chk (char *__restrict __dst,
492 : const wchar_t **__restrict __src,
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,
497 : const wchar_t **__restrict __src,
498 : size_t __len, mbstate_t *__restrict __ps),
499 : wcsrtombs);
500 : extern size_t __REDIRECT_NTH (__wcsrtombs_chk_warn,
501 : (char *__restrict __dst,
502 : const wchar_t **__restrict __src,
503 : size_t __len, mbstate_t *__restrict __ps,
504 : size_t __dstlen), __wcsrtombs_chk)
505 : __warnattr ("wcsrtombs called with dst buffer smaller than len");
506 :
507 : __fortify_function size_t
508 : __NTH (wcsrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
509 : size_t __len, mbstate_t *__restrict __ps))
510 : {
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 : }
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,
525 : const char **__restrict __src, size_t __nmc,
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,
530 : const char **__restrict __src, size_t __nmc,
531 : size_t __len, mbstate_t *__restrict __ps),
532 : mbsnrtowcs);
533 : extern size_t __REDIRECT_NTH (__mbsnrtowcs_chk_warn,
534 : (wchar_t *__restrict __dst,
535 : const char **__restrict __src, size_t __nmc,
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)");
540 :
541 : __fortify_function size_t
542 : __NTH (mbsnrtowcs (wchar_t *__restrict __dst, const char **__restrict __src,
543 : size_t __nmc, size_t __len, mbstate_t *__restrict __ps))
544 : {
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 : }
555 : return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps);
556 : }
557 :
558 :
559 : extern size_t __wcsnrtombs_chk (char *__restrict __dst,
560 : const wchar_t **__restrict __src,
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,
566 : const wchar_t **__restrict __src,
567 : size_t __nwc, size_t __len,
568 : mbstate_t *__restrict __ps), wcsnrtombs);
569 : extern size_t __REDIRECT_NTH (__wcsnrtombs_chk_warn,
570 : (char *__restrict __dst,
571 : const wchar_t **__restrict __src,
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");
576 :
577 : __fortify_function size_t
578 : __NTH (wcsnrtombs (char *__restrict __dst, const wchar_t **__restrict __src,
579 : size_t __nwc, size_t __len, mbstate_t *__restrict __ps))
580 : {
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 : }
591 : return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps);
592 : }
593 : #endif
|