* wcsmbs/bits/wchar2.h (swprintf): Remove format argument.
[glibc/history.git] / wcsmbs / bits / wchar2.h
blob8dd5b88014b225f198b15cc3b62cb668d98136b8
1 /* Checking macros for wchar functions.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _WCHAR_H
21 # error "Never include <bits/wchar.h> directly; use <wchar.h> instead."
22 #endif
25 extern wchar_t *__wmemcpy_chk (wchar_t *__restrict __s1,
26 __const wchar_t *__restrict __s2, size_t __n,
27 size_t __ns1) __THROW;
28 extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias,
29 (wchar_t *__restrict __s1,
30 __const wchar_t *__restrict __s2, size_t __n),
31 wmemcpy);
33 extern __always_inline wchar_t *
34 wmemcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2,
35 size_t __n)
37 if (__bos0 (__s1) != (size_t) -1)
38 return __wmemcpy_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t));
39 return __wmemcpy_alias (__s1, __s2, __n);
43 extern wchar_t *__wmemmove_chk (wchar_t *__s1, __const wchar_t *__s2,
44 size_t __n, size_t __ns1) __THROW;
45 extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1,
46 __const wchar_t *__s2,
47 size_t __n), wmemmove);
49 extern __always_inline wchar_t *
50 wmemmove (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2,
51 size_t __n)
53 if (__bos0 (__s1) != (size_t) -1)
54 return __wmemmove_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t));
55 return __wmemmove_alias (__s1, __s2, __n);
59 #ifdef __USE_GNU
60 extern wchar_t *__wmempcpy_chk (wchar_t *__restrict __s1,
61 __const wchar_t *__restrict __s2, size_t __n,
62 size_t __ns1) __THROW;
63 extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias,
64 (wchar_t *__restrict __s1,
65 __const wchar_t *__restrict __s2,
66 size_t __n), wmempcpy);
68 extern __always_inline wchar_t *
69 wmempcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2,
70 size_t __n)
72 if (__bos0 (__s1) != (size_t) -1)
73 return __wmempcpy_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t));
74 return __wmempcpy_alias (__s1, __s2, __n);
76 #endif
79 extern wchar_t *__wmemset_chk (wchar_t *__s, wchar_t __c, size_t __n,
80 size_t __ns) __THROW;
81 extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c,
82 size_t __n), wmemset);
84 extern __always_inline wchar_t *
85 wmemset (wchar_t *__restrict __s, wchar_t __c, size_t __n)
87 if (__bos0 (__s) != (size_t) -1)
88 return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t));
89 return __wmemset_alias (__s, __c, __n);
93 extern wchar_t *__wcscpy_chk (wchar_t *__restrict __dest,
94 __const wchar_t *__restrict __src,
95 size_t __n) __THROW;
96 extern wchar_t *__REDIRECT_NTH (__wcscpy_alias,
97 (wchar_t *__restrict __dest,
98 __const wchar_t *__restrict __src), wcscpy);
100 extern __always_inline wchar_t *
101 wcscpy (wchar_t *__dest, __const wchar_t *__src)
103 if (__bos (__dest) != (size_t) -1)
104 return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
105 return __wcscpy_alias (__dest, __src);
109 extern wchar_t *__wcpcpy_chk (wchar_t *__dest, __const wchar_t *__src,
110 size_t __destlen) __THROW;
111 extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias, (wchar_t *__dest,
112 __const wchar_t *__src),
113 wcpcpy);
115 extern __always_inline wchar_t *
116 wcpcpy (wchar_t *__dest, __const wchar_t *__src)
118 if (__bos (__dest) != (size_t) -1)
119 return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
120 return __wcpcpy_alias (__dest, __src);
124 extern wchar_t *__wcsncpy_chk (wchar_t *__restrict __dest,
125 __const wchar_t *__restrict __src, size_t __n,
126 size_t __destlen) __THROW;
127 extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias,
128 (wchar_t *__restrict __dest,
129 __const wchar_t *__restrict __src,
130 size_t __n), wcsncpy);
132 extern __always_inline wchar_t *
133 wcsncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
135 if (__bos (__dest) != (size_t) -1
136 && (!__builtin_constant_p (__n) || __bos (__dest) >= __n))
137 return __wcsncpy_chk (__dest, __src, __n,
138 __bos (__dest) / sizeof (wchar_t));
139 return __wcsncpy_alias (__dest, __src, __n);
143 extern wchar_t *__wcpncpy_chk (wchar_t *__restrict __dest,
144 __const wchar_t *__restrict __src, size_t __n,
145 size_t __destlen) __THROW;
146 extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias,
147 (wchar_t *__restrict __dest,
148 __const wchar_t *__restrict __src,
149 size_t __n), wcpncpy);
151 extern __always_inline wchar_t *
152 wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)
154 if (__bos (__dest) != (size_t) -1
155 && (!__builtin_constant_p (__n) || __bos (__dest) >= __n))
156 return __wcpncpy_chk (__dest, __src, __n,
157 __bos (__dest) / sizeof (wchar_t));
158 return __wcpncpy_alias (__dest, __src, __n);
162 extern wchar_t *__wcscat_chk (wchar_t *__restrict __dest,
163 __const wchar_t *__restrict __src,
164 size_t __destlen) __THROW;
165 extern wchar_t *__REDIRECT_NTH (__wcscat_alias,
166 (wchar_t *__restrict __dest,
167 __const wchar_t *__restrict __src), wcscat);
169 extern __always_inline wchar_t *
170 wcscat (wchar_t *__dest, __const wchar_t *__src)
172 if (__bos (__dest) != (size_t) -1)
173 return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t));
174 return __wcscat_alias (__dest, __src);
178 extern wchar_t *__wcsncat_chk (wchar_t *__restrict __dest,
179 __const wchar_t *__restrict __src,
180 size_t __n, size_t __destlen) __THROW;
181 extern wchar_t *__REDIRECT_NTH (__wcsncat_alias,
182 (wchar_t *__restrict __dest,
183 __const wchar_t *__restrict __src,
184 size_t __n), wcsncat);
186 extern __always_inline wchar_t *
187 wcsncat (wchar_t *__dest, __const wchar_t *__src, size_t __n)
189 if (__bos (__dest) != (size_t) -1)
190 return __wcsncat_chk (__dest, __src, __n,
191 __bos (__dest) / sizeof (wchar_t));
192 return __wcsncat_alias (__dest, __src, __n);
196 extern int __swprintf_chk (wchar_t *__restrict __s, size_t __n,
197 int __flag, size_t __s_len,
198 __const wchar_t *__restrict __format, ...)
199 __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 6))) */;
201 /* XXX We might want to have support in gcc for swprintf. */
202 #define swprintf(s, n, ...) \
203 (__bos (s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1 \
204 ? __swprintf_chk (s, n, __USE_FORTIFY_LEVEL - 1, __bos (s), __VA_ARGS__) \
205 : swprintf (s, n, __VA_ARGS__))
208 extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
209 int __flag, size_t __s_len,
210 __const wchar_t *__restrict __format,
211 __gnuc_va_list __arg)
212 __THROW /* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
213 extern int __REDIRECT_NTH (__vswprintf_alias,
214 (wchar_t *__restrict __s, size_t __n,
215 __const wchar_t *__restrict __format,
216 __gnuc_va_list __arg), vswprintf)
217 /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
220 extern __always_inline int
221 vswprintf (wchar_t *__s, size_t __n, __const wchar_t *__format,
222 __gnuc_va_list __arg)
224 if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1)
225 return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, __bos (__s),
226 __format, __arg);
227 return vswprintf (__s, __n, __format, __arg);
231 #if __USE_FORTIFY_LEVEL > 1
233 extern int __fwprintf_chk (FILE *__restrict __stream, int __flag,
234 __const wchar_t *__restrict __format, ...);
235 extern int __wprintf_chk (int __flag, __const wchar_t *__restrict __format,
236 ...);
237 extern int __vfwprintf_chk (FILE *__restrict __stream, int __flag,
238 __const wchar_t *__restrict __format,
239 _G_va_list __ap);
240 extern int __vwprintf_chk (int __flag, __const wchar_t *__restrict __format,
241 _G_va_list __ap);
243 # define wprintf(...) \
244 __wprintf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
245 # define fwprintf(stream, ...) \
246 __fwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__)
247 # define vwprintf(format, ap) \
248 __vwprintf_chk (__USE_FORTIFY_LEVEL - 1, format, ap)
249 # define vfwprintf(stream, format, ap) \
250 __vfwprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, format, ap)
252 #endif
254 extern wchar_t *__fgetws_chk (wchar_t *__restrict __s, size_t __size, int __n,
255 FILE *__restrict __stream) __wur;
256 extern wchar_t *__REDIRECT (__fgetws_alias,
257 (wchar_t *__restrict __s, int __n,
258 FILE *__restrict __stream), fgetws) __wur;
260 extern __always_inline __wur wchar_t *
261 fgetws (wchar_t *__restrict __s, int __n, FILE *__restrict __stream)
263 if (__bos (__s) != (size_t) -1
264 && (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s)))
265 return __fgetws_chk (__s, __bos (__s), __n, __stream);
266 return __fgetws_alias (__s, __n, __stream);
269 #ifdef __USE_GNU
270 extern wchar_t *__fgetws_unlocked_chk (wchar_t *__restrict __s, size_t __size,
271 int __n, FILE *__restrict __stream)
272 __wur;
273 extern wchar_t *__REDIRECT (__fgetws_unlocked_alias,
274 (wchar_t *__restrict __s, int __n,
275 FILE *__restrict __stream), fgetws_unlocked)
276 __wur;
278 extern __always_inline __wur wchar_t *
279 fgetws_unlocked (wchar_t *__restrict __s, int __n, FILE *__restrict __stream)
281 if (__bos (__s) != (size_t) -1
282 && (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s)))
283 return __fgetws_unlocked_chk (__s, __bos (__s), __n, __stream);
284 return __fgetws_unlocked_alias (__s, __n, __stream);
286 #endif
289 extern size_t __wcrtomb_chk (char *__s, wchar_t __wchar, mbstate_t *__p,
290 size_t __buflen) __THROW __wur;
291 extern size_t __REDIRECT_NTH (__wcrtomb_alias,
292 (char *__restrict __s, wchar_t __wchar,
293 mbstate_t *__restrict __ps), wcrtomb) __wur;
295 extern __always_inline __wur size_t
296 wcrtomb (char *__s, wchar_t __wchar, mbstate_t *__ps)
298 /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
299 But this would only disturb the namespace. So we define our own
300 version here. */
301 #define __WCHAR_MB_LEN_MAX 16
302 #if defined MB_LEN_MAX && MB_LEN_MAX != __WCHAR_MB_LEN_MAX
303 # error "Assumed value of MB_LEN_MAX wrong"
304 #endif
305 if (__bos (__s) != (size_t) -1 && __WCHAR_MB_LEN_MAX > __bos (__s))
306 return __wcrtomb_chk (__s, __wchar, __ps, __bos (__s));
307 return __wcrtomb_alias (__s, __wchar, __ps);
311 extern size_t __mbsrtowcs_chk (wchar_t *__restrict __dst,
312 __const char **__restrict __src,
313 size_t __len, mbstate_t *__restrict __ps,
314 size_t __dstlen) __THROW;
315 extern size_t __REDIRECT_NTH (__mbsrtowcs_alias,
316 (wchar_t *__restrict __dst,
317 __const char **__restrict __src,
318 size_t __len, mbstate_t *__restrict __ps),
319 mbsrtowcs);
321 extern __always_inline size_t
322 mbsrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src,
323 size_t __len, mbstate_t *__restrict __ps)
325 if (__bos (__dst) != (size_t) -1
326 && (!__builtin_constant_p (__len)
327 || __len * sizeof (wchar_t) > __bos (__dst)))
328 return __mbsrtowcs_chk (__dst, __src, __len, __ps, __bos (__dst));
329 return __mbsrtowcs_alias (__dst, __src, __len, __ps);
333 extern size_t __wcsrtombs_chk (char *__restrict __dst,
334 __const wchar_t **__restrict __src,
335 size_t __len, mbstate_t *__restrict __ps,
336 size_t __dstlen) __THROW;
337 extern size_t __REDIRECT_NTH (__wcsrtombs_alias,
338 (char *__restrict __dst,
339 __const wchar_t **__restrict __src,
340 size_t __len, mbstate_t *__restrict __ps),
341 wcsrtombs);
343 extern __always_inline size_t
344 wcsrtombs (char *__restrict __dst, __const wchar_t **__restrict __src,
345 size_t __len, mbstate_t *__restrict __ps)
347 if (__bos (__dst) != (size_t) -1
348 && (!__builtin_constant_p (__len) || __len > __bos (__dst)))
349 return __wcsrtombs_chk (__dst, __src, __len, __ps, __bos (__dst));
350 return __wcsrtombs_alias (__dst, __src, __len, __ps);
354 #ifdef __USE_GNU
355 extern size_t __mbsnrtowcs_chk (wchar_t *__restrict __dst,
356 __const char **__restrict __src, size_t __nmc,
357 size_t __len, mbstate_t *__restrict __ps,
358 size_t __dstlen) __THROW;
359 extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias,
360 (wchar_t *__restrict __dst,
361 __const char **__restrict __src, size_t __nmc,
362 size_t __len, mbstate_t *__restrict __ps),
363 mbsnrtowcs);
365 extern __always_inline size_t
366 mbsnrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src,
367 size_t __nmc, size_t __len, mbstate_t *__restrict __ps)
369 if (__bos (__dst) != (size_t) -1
370 && (!__builtin_constant_p (__len)
371 || __len * sizeof (wchar_t) > __bos (__dst)))
372 return __mbsnrtowcs_chk (__dst, __src, __nmc, __len, __ps, __bos (__dst));
373 return __mbsnrtowcs_alias (__dst, __src, __nmc, __len, __ps);
377 extern size_t __wcsnrtombs_chk (char *__restrict __dst,
378 __const wchar_t **__restrict __src,
379 size_t __nwc, size_t __len,
380 mbstate_t *__restrict __ps, size_t __dstlen)
381 __THROW;
382 extern size_t __REDIRECT_NTH (__wcsnrtombs_alias,
383 (char *__restrict __dst,
384 __const wchar_t **__restrict __src,
385 size_t __nwc, size_t __len,
386 mbstate_t *__restrict __ps), wcsnrtombs);
388 extern __always_inline size_t
389 wcsnrtombs (char *__restrict __dst, __const wchar_t **__restrict __src,
390 size_t __nwc, size_t __len, mbstate_t *__restrict __ps)
392 if (__bos (__dst) != (size_t) -1
393 && (!__builtin_constant_p (__len) || __len > __bos (__dst)))
394 return __wcsnrtombs_chk (__dst, __src, __nwc, __len, __ps, __bos (__dst));
395 return __wcsnrtombs_alias (__dst, __src, __nwc, __len, __ps);
397 #endif