Support non-blocking pipe I/O in write() on native Windows.
[gnulib.git] / lib / stdio.in.h
1 /* A GNU-like <stdio.h>.
2
3    Copyright (C) 2004, 2007-2011 Free Software Foundation, Inc.
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2, or (at your option)
8    any later version.
9
10    This program 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
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 #if __GNUC__ >= 3
20 @PRAGMA_SYSTEM_HEADER@
21 #endif
22 @PRAGMA_COLUMNS@
23
24 #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
25 /* Special invocation convention:
26    - Inside glibc header files.
27    - On OSF/1 5.1 we have a sequence of nested includes
28      <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
29      <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
30      In this situation, the functions are not yet declared, therefore we cannot
31      provide the C++ aliases.  */
32
33 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
34
35 #else
36 /* Normal invocation convention.  */
37
38 #ifndef _GL_STDIO_H
39
40 #define _GL_ALREADY_INCLUDING_STDIO_H
41
42 /* The include_next requires a split double-inclusion guard.  */
43 #@INCLUDE_NEXT@ @NEXT_STDIO_H@
44
45 #undef _GL_ALREADY_INCLUDING_STDIO_H
46
47 #ifndef _GL_STDIO_H
48 #define _GL_STDIO_H
49
50 /* Get va_list.  Needed on many systems, including glibc 2.8.  */
51 #include <stdarg.h>
52
53 #include <stddef.h>
54
55 /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8
56    and eglibc 2.11.2.  */
57 #include <sys/types.h>
58
59 /* The __attribute__ feature is available in gcc versions 2.5 and later.
60    The __-protected variants of the attributes 'format' and 'printf' are
61    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
62    We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
63    gnulib and libintl do '#define printf __printf__' when they override
64    the 'printf' function.  */
65 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
66 # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
67 #else
68 # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
69 #endif
70
71 /* _GL_ATTRIBUTE_FORMAT_PRINTF
72    indicates to GCC that the function takes a format string and arguments,
73    where the format string directives are the ones standardized by ISO C99
74    and POSIX.  */
75 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
76 # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
77    _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
78 #else
79 # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
80    _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
81 #endif
82
83 /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
84    except that it indicates to GCC that the supported format string directives
85    are the ones of the system printf(), rather than the ones standardized by
86    ISO C99 and POSIX.  */
87 #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
88   _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
89
90 /* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>.  */
91 /* But in any case avoid namespace pollution on glibc systems.  */
92 #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
93     && ! defined __GLIBC__
94 # include <unistd.h>
95 #endif
96
97
98 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
99
100 /* The definition of _GL_ARG_NONNULL is copied here.  */
101
102 /* The definition of _GL_WARN_ON_USE is copied here.  */
103
104 /* Macros for stringification.  */
105 #define _GL_STDIO_STRINGIZE(token) #token
106 #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
107
108
109 #if @GNULIB_DPRINTF@
110 # if @REPLACE_DPRINTF@
111 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
112 #   define dprintf rpl_dprintf
113 #  endif
114 _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
115                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
116                                 _GL_ARG_NONNULL ((2)));
117 _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
118 # else
119 #  if !@HAVE_DPRINTF@
120 _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
121                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
122                                 _GL_ARG_NONNULL ((2)));
123 #  endif
124 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
125 # endif
126 _GL_CXXALIASWARN (dprintf);
127 #elif defined GNULIB_POSIXCHECK
128 # undef dprintf
129 # if HAVE_RAW_DECL_DPRINTF
130 _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
131                  "use gnulib module dprintf for portability");
132 # endif
133 #endif
134
135 #if @GNULIB_FCLOSE@
136 /* Close STREAM and its underlying file descriptor.  */
137 # if @REPLACE_FCLOSE@
138 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
139 #   define fclose rpl_fclose
140 #  endif
141 _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
142 _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
143 # else
144 _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
145 # endif
146 _GL_CXXALIASWARN (fclose);
147 #elif defined GNULIB_POSIXCHECK
148 # undef fclose
149 /* Assume fclose is always declared.  */
150 _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
151                  "use gnulib module fclose for portable POSIX compliance");
152 #endif
153
154 #if @GNULIB_FFLUSH@
155 /* Flush all pending data on STREAM according to POSIX rules.  Both
156    output and seekable input streams are supported.
157    Note! LOSS OF DATA can occur if fflush is applied on an input stream
158    that is _not_seekable_ or on an update stream that is _not_seekable_
159    and in which the most recent operation was input.  Seekability can
160    be tested with lseek(fileno(fp),0,SEEK_CUR).  */
161 # if @REPLACE_FFLUSH@
162 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 #   define fflush rpl_fflush
164 #  endif
165 _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
166 _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
167 # else
168 _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
169 # endif
170 _GL_CXXALIASWARN (fflush);
171 #elif defined GNULIB_POSIXCHECK
172 # undef fflush
173 /* Assume fflush is always declared.  */
174 _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
175                  "use gnulib module fflush for portable POSIX compliance");
176 #endif
177
178 /* It is very rare that the developer ever has full control of stdin,
179    so any use of gets warrants an unconditional warning.  Assume it is
180    always declared, since it is required by C89.  */
181 #undef gets
182 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
183
184 #if @GNULIB_FOPEN@
185 # if @REPLACE_FOPEN@
186 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
187 #   undef fopen
188 #   define fopen rpl_fopen
189 #  endif
190 _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
191                                  _GL_ARG_NONNULL ((1, 2)));
192 _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
193 # else
194 _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
195 # endif
196 _GL_CXXALIASWARN (fopen);
197 #elif defined GNULIB_POSIXCHECK
198 # undef fopen
199 /* Assume fopen is always declared.  */
200 _GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
201                  "use gnulib module fopen for portability");
202 #endif
203
204 #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
205 # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
206      || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
207 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
208 #   define fprintf rpl_fprintf
209 #  endif
210 #  define GNULIB_overrides_fprintf 1
211 #  if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
212 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
213                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
214                                 _GL_ARG_NONNULL ((1, 2)));
215 #  else
216 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
217                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
218                                 _GL_ARG_NONNULL ((1, 2)));
219 #  endif
220 _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
221 # else
222 _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
223 # endif
224 _GL_CXXALIASWARN (fprintf);
225 #endif
226 #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
227 # if !GNULIB_overrides_fprintf
228 #  undef fprintf
229 # endif
230 /* Assume fprintf is always declared.  */
231 _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
232                  "use gnulib module fprintf-posix for portable "
233                  "POSIX compliance");
234 #endif
235
236 #if @GNULIB_FPURGE@
237 /* Discard all pending buffered I/O data on STREAM.
238    STREAM must not be wide-character oriented.
239    When discarding pending output, the file position is set back to where it
240    was before the write calls.  When discarding pending input, the file
241    position is advanced to match the end of the previously read input.
242    Return 0 if successful.  Upon error, return -1 and set errno.  */
243 # if @REPLACE_FPURGE@
244 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
245 #   define fpurge rpl_fpurge
246 #  endif
247 _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
248 _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
249 # else
250 #  if !@HAVE_DECL_FPURGE@
251 _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
252 #  endif
253 _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
254 # endif
255 _GL_CXXALIASWARN (fpurge);
256 #elif defined GNULIB_POSIXCHECK
257 # undef fpurge
258 # if HAVE_RAW_DECL_FPURGE
259 _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
260                  "use gnulib module fpurge for portability");
261 # endif
262 #endif
263
264 #if @GNULIB_FPUTC@
265 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
266 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267 #   undef fputc
268 #   define fputc rpl_fputc
269 #  endif
270 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
271 _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
272 # else
273 _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
274 # endif
275 _GL_CXXALIASWARN (fputc);
276 #endif
277
278 #if @GNULIB_FPUTS@
279 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
280 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
281 #   undef fputs
282 #   define fputs rpl_fputs
283 #  endif
284 _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
285                               _GL_ARG_NONNULL ((1, 2)));
286 _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
287 # else
288 _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
289 # endif
290 _GL_CXXALIASWARN (fputs);
291 #endif
292
293 #if @GNULIB_FREOPEN@
294 # if @REPLACE_FREOPEN@
295 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
296 #   undef freopen
297 #   define freopen rpl_freopen
298 #  endif
299 _GL_FUNCDECL_RPL (freopen, FILE *,
300                   (const char *filename, const char *mode, FILE *stream)
301                   _GL_ARG_NONNULL ((2, 3)));
302 _GL_CXXALIAS_RPL (freopen, FILE *,
303                   (const char *filename, const char *mode, FILE *stream));
304 # else
305 _GL_CXXALIAS_SYS (freopen, FILE *,
306                   (const char *filename, const char *mode, FILE *stream));
307 # endif
308 _GL_CXXALIASWARN (freopen);
309 #elif defined GNULIB_POSIXCHECK
310 # undef freopen
311 /* Assume freopen is always declared.  */
312 _GL_WARN_ON_USE (freopen,
313                  "freopen on Win32 platforms is not POSIX compatible - "
314                  "use gnulib module freopen for portability");
315 #endif
316
317
318 /* Set up the following warnings, based on which modules are in use.
319    GNU Coding Standards discourage the use of fseek, since it imposes
320    an arbitrary limitation on some 32-bit hosts.  Remember that the
321    fseek module depends on the fseeko module, so we only have three
322    cases to consider:
323
324    1. The developer is not using either module.  Issue a warning under
325    GNULIB_POSIXCHECK for both functions, to remind them that both
326    functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
327    impact on this warning.
328
329    2. The developer is using both modules.  They may be unaware of the
330    arbitrary limitations of fseek, so issue a warning under
331    GNULIB_POSIXCHECK.  On the other hand, they may be using both
332    modules intentionally, so the developer can define
333    _GL_NO_LARGE_FILES in the compilation units where the use of fseek
334    is safe, to silence the warning.
335
336    3. The developer is using the fseeko module, but not fseek.  Gnulib
337    guarantees that fseek will still work around platform bugs in that
338    case, but we presume that the developer is aware of the pitfalls of
339    fseek and was trying to avoid it, so issue a warning even when
340    GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
341    defined to silence the warning in particular compilation units.
342    In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
343    fseek gets defined as a macro, it is recommended that the developer
344    uses the fseek module, even if he is not calling the fseek function.
345
346    Most gnulib clients that perform stream operations should fall into
347    category 3.  */
348
349 #if @GNULIB_FSEEK@
350 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
351 #  define _GL_FSEEK_WARN /* Category 2, above.  */
352 #  undef fseek
353 # endif
354 # if @REPLACE_FSEEK@
355 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
356 #   undef fseek
357 #   define fseek rpl_fseek
358 #  endif
359 _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
360                               _GL_ARG_NONNULL ((1)));
361 _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
362 # else
363 _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
364 # endif
365 _GL_CXXALIASWARN (fseek);
366 #endif
367
368 #if @GNULIB_FSEEKO@
369 # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
370 #  define _GL_FSEEK_WARN /* Category 3, above.  */
371 #  undef fseek
372 # endif
373 # if @REPLACE_FSEEKO@
374 /* Provide an fseeko function that is aware of a preceding fflush(), and which
375    detects pipes.  */
376 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377 #   undef fseeko
378 #   define fseeko rpl_fseeko
379 #  endif
380 _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
381                                _GL_ARG_NONNULL ((1)));
382 _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
383 # else
384 #  if ! @HAVE_DECL_FSEEKO@
385 _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
386                                _GL_ARG_NONNULL ((1)));
387 #  endif
388 _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
389 # endif
390 _GL_CXXALIASWARN (fseeko);
391 # if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
392    /* Provide an fseek function that is consistent with fseeko.  */
393    /* In order to avoid that fseek gets defined as a macro here, the
394       developer can request the 'fseek' module.  */
395 #  if !GNULIB_defined_fseek_function
396 #   undef fseek
397 #   define fseek rpl_fseek
398 static inline int _GL_ARG_NONNULL ((1))
399 rpl_fseek (FILE *fp, long offset, int whence)
400 {
401 #   if @REPLACE_FSEEKO@
402   return rpl_fseeko (fp, offset, whence);
403 #   else
404   return fseeko (fp, offset, whence);
405 #   endif
406 }
407 #   define GNULIB_defined_fseek_function 1
408 #  endif
409 # endif
410 #elif defined GNULIB_POSIXCHECK
411 # define _GL_FSEEK_WARN /* Category 1, above.  */
412 # undef fseek
413 # undef fseeko
414 # if HAVE_RAW_DECL_FSEEKO
415 _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
416                  "use gnulib module fseeko for portability");
417 # endif
418 #endif
419
420 #ifdef _GL_FSEEK_WARN
421 # undef _GL_FSEEK_WARN
422 /* Here, either fseek is undefined (but C89 guarantees that it is
423    declared), or it is defined as rpl_fseek (declared above).  */
424 _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
425                  "on 32-bit platforms - "
426                  "use fseeko function for handling of large files");
427 #endif
428
429
430 /* ftell, ftello.  See the comments on fseek/fseeko.  */
431
432 #if @GNULIB_FTELL@
433 # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
434 #  define _GL_FTELL_WARN /* Category 2, above.  */
435 #  undef ftell
436 # endif
437 # if @REPLACE_FTELL@
438 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
439 #   undef ftell
440 #   define ftell rpl_ftell
441 #  endif
442 _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
443 _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
444 # else
445 _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
446 # endif
447 _GL_CXXALIASWARN (ftell);
448 #endif
449
450 #if @GNULIB_FTELLO@
451 # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
452 #  define _GL_FTELL_WARN /* Category 3, above.  */
453 #  undef ftell
454 # endif
455 # if @REPLACE_FTELLO@
456 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
457 #   undef ftello
458 #   define ftello rpl_ftello
459 #  endif
460 _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
461 _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
462 # else
463 #  if ! @HAVE_DECL_FTELLO@
464 _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
465 #  endif
466 _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
467 # endif
468 _GL_CXXALIASWARN (ftello);
469 # if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
470    /* Provide an ftell function that is consistent with ftello.  */
471    /* In order to avoid that ftell gets defined as a macro here, the
472       developer can request the 'ftell' module.  */
473 #  if !GNULIB_defined_ftell_function
474 #   undef ftell
475 #   define ftell rpl_ftell
476 static inline long _GL_ARG_NONNULL ((1))
477 rpl_ftell (FILE *f)
478 {
479 #   if @REPLACE_FTELLO@
480   return rpl_ftello (f);
481 #   else
482   return ftello (f);
483 #   endif
484 }
485 #   define GNULIB_defined_ftell_function 1
486 #  endif
487 # endif
488 #elif defined GNULIB_POSIXCHECK
489 # define _GL_FTELL_WARN /* Category 1, above.  */
490 # undef ftell
491 # undef ftello
492 # if HAVE_RAW_DECL_FTELLO
493 _GL_WARN_ON_USE (ftello, "ftello is unportable - "
494                  "use gnulib module ftello for portability");
495 # endif
496 #endif
497
498 #ifdef _GL_FTELL_WARN
499 # undef _GL_FTELL_WARN
500 /* Here, either ftell is undefined (but C89 guarantees that it is
501    declared), or it is defined as rpl_ftell (declared above).  */
502 _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
503                  "on 32-bit platforms - "
504                  "use ftello function for handling of large files");
505 #endif
506
507
508 #if @GNULIB_FWRITE@
509 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
510 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
511 #   undef fwrite
512 #   define fwrite rpl_fwrite
513 #  endif
514 _GL_FUNCDECL_RPL (fwrite, size_t,
515                   (const void *ptr, size_t s, size_t n, FILE *stream)
516                   _GL_ARG_NONNULL ((1, 4)));
517 _GL_CXXALIAS_RPL (fwrite, size_t,
518                   (const void *ptr, size_t s, size_t n, FILE *stream));
519 # else
520 _GL_CXXALIAS_SYS (fwrite, size_t,
521                   (const void *ptr, size_t s, size_t n, FILE *stream));
522
523 /* Work around glibc bug 11959
524    <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
525    which sometimes causes an unwanted diagnostic for fwrite calls.
526    This affects only function declaration attributes, so it's not
527    needed for C++.  */
528 #  if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
529 static inline size_t _GL_ARG_NONNULL ((1, 4))
530 rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
531 {
532   size_t r = fwrite (ptr, s, n, stream);
533   (void) r;
534   return r;
535 }
536 #   undef fwrite
537 #   define fwrite rpl_fwrite
538 #  endif
539 # endif
540 _GL_CXXALIASWARN (fwrite);
541 #endif
542
543 #if @GNULIB_GETDELIM@
544 /* Read input, up to (and including) the next occurrence of DELIMITER, from
545    STREAM, store it in *LINEPTR (and NUL-terminate it).
546    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
547    bytes of space.  It is realloc'd as necessary.
548    Return the number of bytes read and stored at *LINEPTR (not including the
549    NUL terminator), or -1 on error or EOF.  */
550 # if @REPLACE_GETDELIM@
551 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
552 #   undef getdelim
553 #   define getdelim rpl_getdelim
554 #  endif
555 _GL_FUNCDECL_RPL (getdelim, ssize_t,
556                   (char **lineptr, size_t *linesize, int delimiter,
557                    FILE *stream)
558                   _GL_ARG_NONNULL ((1, 2, 4)));
559 _GL_CXXALIAS_RPL (getdelim, ssize_t,
560                   (char **lineptr, size_t *linesize, int delimiter,
561                    FILE *stream));
562 # else
563 #  if !@HAVE_DECL_GETDELIM@
564 _GL_FUNCDECL_SYS (getdelim, ssize_t,
565                   (char **lineptr, size_t *linesize, int delimiter,
566                    FILE *stream)
567                   _GL_ARG_NONNULL ((1, 2, 4)));
568 #  endif
569 _GL_CXXALIAS_SYS (getdelim, ssize_t,
570                   (char **lineptr, size_t *linesize, int delimiter,
571                    FILE *stream));
572 # endif
573 _GL_CXXALIASWARN (getdelim);
574 #elif defined GNULIB_POSIXCHECK
575 # undef getdelim
576 # if HAVE_RAW_DECL_GETDELIM
577 _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
578                  "use gnulib module getdelim for portability");
579 # endif
580 #endif
581
582 #if @GNULIB_GETLINE@
583 /* Read a line, up to (and including) the next newline, from STREAM, store it
584    in *LINEPTR (and NUL-terminate it).
585    *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
586    bytes of space.  It is realloc'd as necessary.
587    Return the number of bytes read and stored at *LINEPTR (not including the
588    NUL terminator), or -1 on error or EOF.  */
589 # if @REPLACE_GETLINE@
590 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
591 #   undef getline
592 #   define getline rpl_getline
593 #  endif
594 _GL_FUNCDECL_RPL (getline, ssize_t,
595                   (char **lineptr, size_t *linesize, FILE *stream)
596                   _GL_ARG_NONNULL ((1, 2, 3)));
597 _GL_CXXALIAS_RPL (getline, ssize_t,
598                   (char **lineptr, size_t *linesize, FILE *stream));
599 # else
600 #  if !@HAVE_DECL_GETLINE@
601 _GL_FUNCDECL_SYS (getline, ssize_t,
602                   (char **lineptr, size_t *linesize, FILE *stream)
603                   _GL_ARG_NONNULL ((1, 2, 3)));
604 #  endif
605 _GL_CXXALIAS_SYS (getline, ssize_t,
606                   (char **lineptr, size_t *linesize, FILE *stream));
607 # endif
608 # if @HAVE_DECL_GETLINE@
609 _GL_CXXALIASWARN (getline);
610 # endif
611 #elif defined GNULIB_POSIXCHECK
612 # undef getline
613 # if HAVE_RAW_DECL_GETLINE
614 _GL_WARN_ON_USE (getline, "getline is unportable - "
615                  "use gnulib module getline for portability");
616 # endif
617 #endif
618
619 #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
620 struct obstack;
621 /* Grow an obstack with formatted output.  Return the number of
622    bytes added to OBS.  No trailing nul byte is added, and the
623    object should be closed with obstack_finish before use.  Upon
624    memory allocation error, call obstack_alloc_failed_handler.  Upon
625    other error, return -1.  */
626 # if @REPLACE_OBSTACK_PRINTF@
627 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
628 #   define obstack_printf rpl_obstack_printf
629 #  endif
630 _GL_FUNCDECL_RPL (obstack_printf, int,
631                   (struct obstack *obs, const char *format, ...)
632                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
633                   _GL_ARG_NONNULL ((1, 2)));
634 _GL_CXXALIAS_RPL (obstack_printf, int,
635                   (struct obstack *obs, const char *format, ...));
636 # else
637 #  if !@HAVE_DECL_OBSTACK_PRINTF@
638 _GL_FUNCDECL_SYS (obstack_printf, int,
639                   (struct obstack *obs, const char *format, ...)
640                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
641                   _GL_ARG_NONNULL ((1, 2)));
642 #  endif
643 _GL_CXXALIAS_SYS (obstack_printf, int,
644                   (struct obstack *obs, const char *format, ...));
645 # endif
646 _GL_CXXALIASWARN (obstack_printf);
647 # if @REPLACE_OBSTACK_PRINTF@
648 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649 #   define obstack_vprintf rpl_obstack_vprintf
650 #  endif
651 _GL_FUNCDECL_RPL (obstack_vprintf, int,
652                   (struct obstack *obs, const char *format, va_list args)
653                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
654                   _GL_ARG_NONNULL ((1, 2)));
655 _GL_CXXALIAS_RPL (obstack_vprintf, int,
656                   (struct obstack *obs, const char *format, va_list args));
657 # else
658 #  if !@HAVE_DECL_OBSTACK_PRINTF@
659 _GL_FUNCDECL_SYS (obstack_vprintf, int,
660                   (struct obstack *obs, const char *format, va_list args)
661                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
662                   _GL_ARG_NONNULL ((1, 2)));
663 #  endif
664 _GL_CXXALIAS_SYS (obstack_vprintf, int,
665                   (struct obstack *obs, const char *format, va_list args));
666 # endif
667 _GL_CXXALIASWARN (obstack_vprintf);
668 #endif
669
670 #if @GNULIB_PERROR@
671 /* Print a message to standard error, describing the value of ERRNO,
672    (if STRING is not NULL and not empty) prefixed with STRING and ": ",
673    and terminated with a newline.  */
674 # if @REPLACE_PERROR@
675 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
676 #   define perror rpl_perror
677 #  endif
678 _GL_FUNCDECL_RPL (perror, void, (const char *string));
679 _GL_CXXALIAS_RPL (perror, void, (const char *string));
680 # else
681 _GL_CXXALIAS_SYS (perror, void, (const char *string));
682 # endif
683 _GL_CXXALIASWARN (perror);
684 #elif defined GNULIB_POSIXCHECK
685 # undef perror
686 /* Assume perror is always declared.  */
687 _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
688                  "use gnulib module perror for portability");
689 #endif
690
691 #if @GNULIB_POPEN@
692 # if @REPLACE_POPEN@
693 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
694 #   undef popen
695 #   define popen rpl_popen
696 #  endif
697 _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
698                                  _GL_ARG_NONNULL ((1, 2)));
699 _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
700 # else
701 _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
702 # endif
703 _GL_CXXALIASWARN (popen);
704 #elif defined GNULIB_POSIXCHECK
705 # undef popen
706 # if HAVE_RAW_DECL_POPEN
707 _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
708                  "use gnulib module popen or pipe for more portability");
709 # endif
710 #endif
711
712 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
713 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
714      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
715 #  if defined __GNUC__
716 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
717 /* Don't break __attribute__((format(printf,M,N))).  */
718 #    define printf __printf__
719 #   endif
720 #   if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
721 _GL_FUNCDECL_RPL_1 (__printf__, int,
722                     (const char *format, ...)
723                     __asm__ (@ASM_SYMBOL_PREFIX@
724                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
725                     _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
726                     _GL_ARG_NONNULL ((1)));
727 #   else
728 _GL_FUNCDECL_RPL_1 (__printf__, int,
729                     (const char *format, ...)
730                     __asm__ (@ASM_SYMBOL_PREFIX@
731                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
732                     _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
733                     _GL_ARG_NONNULL ((1)));
734 #   endif
735 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
736 #  else
737 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
738 #    define printf rpl_printf
739 #   endif
740 _GL_FUNCDECL_RPL (printf, int,
741                   (const char *format, ...)
742                   _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
743                   _GL_ARG_NONNULL ((1)));
744 _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
745 #  endif
746 #  define GNULIB_overrides_printf 1
747 # else
748 _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
749 # endif
750 _GL_CXXALIASWARN (printf);
751 #endif
752 #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
753 # if !GNULIB_overrides_printf
754 #  undef printf
755 # endif
756 /* Assume printf is always declared.  */
757 _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
758                  "use gnulib module printf-posix for portable "
759                  "POSIX compliance");
760 #endif
761
762 #if @GNULIB_PUTC@
763 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
764 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
765 #   undef putc
766 #   define putc rpl_fputc
767 #  endif
768 _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
769 _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
770 # else
771 _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
772 # endif
773 _GL_CXXALIASWARN (putc);
774 #endif
775
776 #if @GNULIB_PUTCHAR@
777 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
778 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
779 #   undef putchar
780 #   define putchar rpl_putchar
781 #  endif
782 _GL_FUNCDECL_RPL (putchar, int, (int c));
783 _GL_CXXALIAS_RPL (putchar, int, (int c));
784 # else
785 _GL_CXXALIAS_SYS (putchar, int, (int c));
786 # endif
787 _GL_CXXALIASWARN (putchar);
788 #endif
789
790 #if @GNULIB_PUTS@
791 # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
792 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
793 #   undef puts
794 #   define puts rpl_puts
795 #  endif
796 _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
797 _GL_CXXALIAS_RPL (puts, int, (const char *string));
798 # else
799 _GL_CXXALIAS_SYS (puts, int, (const char *string));
800 # endif
801 _GL_CXXALIASWARN (puts);
802 #endif
803
804 #if @GNULIB_REMOVE@
805 # if @REPLACE_REMOVE@
806 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
807 #   undef remove
808 #   define remove rpl_remove
809 #  endif
810 _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
811 _GL_CXXALIAS_RPL (remove, int, (const char *name));
812 # else
813 _GL_CXXALIAS_SYS (remove, int, (const char *name));
814 # endif
815 _GL_CXXALIASWARN (remove);
816 #elif defined GNULIB_POSIXCHECK
817 # undef remove
818 /* Assume remove is always declared.  */
819 _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
820                  "use gnulib module remove for more portability");
821 #endif
822
823 #if @GNULIB_RENAME@
824 # if @REPLACE_RENAME@
825 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
826 #   undef rename
827 #   define rename rpl_rename
828 #  endif
829 _GL_FUNCDECL_RPL (rename, int,
830                   (const char *old_filename, const char *new_filename)
831                   _GL_ARG_NONNULL ((1, 2)));
832 _GL_CXXALIAS_RPL (rename, int,
833                   (const char *old_filename, const char *new_filename));
834 # else
835 _GL_CXXALIAS_SYS (rename, int,
836                   (const char *old_filename, const char *new_filename));
837 # endif
838 _GL_CXXALIASWARN (rename);
839 #elif defined GNULIB_POSIXCHECK
840 # undef rename
841 /* Assume rename is always declared.  */
842 _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
843                  "use gnulib module rename for more portability");
844 #endif
845
846 #if @GNULIB_RENAMEAT@
847 # if @REPLACE_RENAMEAT@
848 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
849 #   undef renameat
850 #   define renameat rpl_renameat
851 #  endif
852 _GL_FUNCDECL_RPL (renameat, int,
853                   (int fd1, char const *file1, int fd2, char const *file2)
854                   _GL_ARG_NONNULL ((2, 4)));
855 _GL_CXXALIAS_RPL (renameat, int,
856                   (int fd1, char const *file1, int fd2, char const *file2));
857 # else
858 #  if !@HAVE_RENAMEAT@
859 _GL_FUNCDECL_SYS (renameat, int,
860                   (int fd1, char const *file1, int fd2, char const *file2)
861                   _GL_ARG_NONNULL ((2, 4)));
862 #  endif
863 _GL_CXXALIAS_SYS (renameat, int,
864                   (int fd1, char const *file1, int fd2, char const *file2));
865 # endif
866 _GL_CXXALIASWARN (renameat);
867 #elif defined GNULIB_POSIXCHECK
868 # undef renameat
869 # if HAVE_RAW_DECL_RENAMEAT
870 _GL_WARN_ON_USE (renameat, "renameat is not portable - "
871                  "use gnulib module renameat for portability");
872 # endif
873 #endif
874
875 #if @GNULIB_SNPRINTF@
876 # if @REPLACE_SNPRINTF@
877 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
878 #   define snprintf rpl_snprintf
879 #  endif
880 _GL_FUNCDECL_RPL (snprintf, int,
881                   (char *str, size_t size, const char *format, ...)
882                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
883                   _GL_ARG_NONNULL ((3)));
884 _GL_CXXALIAS_RPL (snprintf, int,
885                   (char *str, size_t size, const char *format, ...));
886 # else
887 #  if !@HAVE_DECL_SNPRINTF@
888 _GL_FUNCDECL_SYS (snprintf, int,
889                   (char *str, size_t size, const char *format, ...)
890                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
891                   _GL_ARG_NONNULL ((3)));
892 #  endif
893 _GL_CXXALIAS_SYS (snprintf, int,
894                   (char *str, size_t size, const char *format, ...));
895 # endif
896 _GL_CXXALIASWARN (snprintf);
897 #elif defined GNULIB_POSIXCHECK
898 # undef snprintf
899 # if HAVE_RAW_DECL_SNPRINTF
900 _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
901                  "use gnulib module snprintf for portability");
902 # endif
903 #endif
904
905 /* Some people would argue that sprintf should be handled like gets
906    (for example, OpenBSD issues a link warning for both functions),
907    since both can cause security holes due to buffer overruns.
908    However, we believe that sprintf can be used safely, and is more
909    efficient than snprintf in those safe cases; and as proof of our
910    belief, we use sprintf in several gnulib modules.  So this header
911    intentionally avoids adding a warning to sprintf except when
912    GNULIB_POSIXCHECK is defined.  */
913
914 #if @GNULIB_SPRINTF_POSIX@
915 # if @REPLACE_SPRINTF@
916 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
917 #   define sprintf rpl_sprintf
918 #  endif
919 _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
920                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
921                                 _GL_ARG_NONNULL ((1, 2)));
922 _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
923 # else
924 _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
925 # endif
926 _GL_CXXALIASWARN (sprintf);
927 #elif defined GNULIB_POSIXCHECK
928 # undef sprintf
929 /* Assume sprintf is always declared.  */
930 _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
931                  "use gnulib module sprintf-posix for portable "
932                  "POSIX compliance");
933 #endif
934
935 #if @GNULIB_TMPFILE@
936 # if @REPLACE_TMPFILE@
937 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
938 #   define tmpfile rpl_tmpfile
939 #  endif
940 _GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
941 _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
942 # else
943 _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
944 # endif
945 _GL_CXXALIASWARN (tmpfile);
946 #elif defined GNULIB_POSIXCHECK
947 # undef tmpfile
948 # if HAVE_RAW_DECL_TMPFILE
949 _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
950                  "use gnulib module tmpfile for portability");
951 # endif
952 #endif
953
954 #if @GNULIB_VASPRINTF@
955 /* Write formatted output to a string dynamically allocated with malloc().
956    If the memory allocation succeeds, store the address of the string in
957    *RESULT and return the number of resulting bytes, excluding the trailing
958    NUL.  Upon memory allocation error, or some other error, return -1.  */
959 # if @REPLACE_VASPRINTF@
960 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
961 #   define asprintf rpl_asprintf
962 #  endif
963 _GL_FUNCDECL_RPL (asprintf, int,
964                   (char **result, const char *format, ...)
965                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
966                   _GL_ARG_NONNULL ((1, 2)));
967 _GL_CXXALIAS_RPL (asprintf, int,
968                   (char **result, const char *format, ...));
969 # else
970 #  if !@HAVE_VASPRINTF@
971 _GL_FUNCDECL_SYS (asprintf, int,
972                   (char **result, const char *format, ...)
973                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
974                   _GL_ARG_NONNULL ((1, 2)));
975 #  endif
976 _GL_CXXALIAS_SYS (asprintf, int,
977                   (char **result, const char *format, ...));
978 # endif
979 _GL_CXXALIASWARN (asprintf);
980 # if @REPLACE_VASPRINTF@
981 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
982 #   define vasprintf rpl_vasprintf
983 #  endif
984 _GL_FUNCDECL_RPL (vasprintf, int,
985                   (char **result, const char *format, va_list args)
986                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
987                   _GL_ARG_NONNULL ((1, 2)));
988 _GL_CXXALIAS_RPL (vasprintf, int,
989                   (char **result, const char *format, va_list args));
990 # else
991 #  if !@HAVE_VASPRINTF@
992 _GL_FUNCDECL_SYS (vasprintf, int,
993                   (char **result, const char *format, va_list args)
994                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
995                   _GL_ARG_NONNULL ((1, 2)));
996 #  endif
997 _GL_CXXALIAS_SYS (vasprintf, int,
998                   (char **result, const char *format, va_list args));
999 # endif
1000 _GL_CXXALIASWARN (vasprintf);
1001 #endif
1002
1003 #if @GNULIB_VDPRINTF@
1004 # if @REPLACE_VDPRINTF@
1005 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1006 #   define vdprintf rpl_vdprintf
1007 #  endif
1008 _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
1009                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1010                                  _GL_ARG_NONNULL ((2)));
1011 _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
1012 # else
1013 #  if !@HAVE_VDPRINTF@
1014 _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
1015                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1016                                  _GL_ARG_NONNULL ((2)));
1017 #  endif
1018 /* Need to cast, because on Solaris, the third parameter will likely be
1019                                                     __va_list args.  */
1020 _GL_CXXALIAS_SYS_CAST (vdprintf, int,
1021                        (int fd, const char *format, va_list args));
1022 # endif
1023 _GL_CXXALIASWARN (vdprintf);
1024 #elif defined GNULIB_POSIXCHECK
1025 # undef vdprintf
1026 # if HAVE_RAW_DECL_VDPRINTF
1027 _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
1028                  "use gnulib module vdprintf for portability");
1029 # endif
1030 #endif
1031
1032 #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
1033 # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
1034      || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1035 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1036 #   define vfprintf rpl_vfprintf
1037 #  endif
1038 #  define GNULIB_overrides_vfprintf 1
1039 #  if @GNULIB_VFPRINTF_POSIX@
1040 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1041                                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1042                                  _GL_ARG_NONNULL ((1, 2)));
1043 #  else
1044 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1045                                  _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
1046                                  _GL_ARG_NONNULL ((1, 2)));
1047 #  endif
1048 _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
1049 # else
1050 /* Need to cast, because on Solaris, the third parameter is
1051                                                       __va_list args
1052    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1053 _GL_CXXALIAS_SYS_CAST (vfprintf, int,
1054                        (FILE *fp, const char *format, va_list args));
1055 # endif
1056 _GL_CXXALIASWARN (vfprintf);
1057 #endif
1058 #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1059 # if !GNULIB_overrides_vfprintf
1060 #  undef vfprintf
1061 # endif
1062 /* Assume vfprintf is always declared.  */
1063 _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
1064                  "use gnulib module vfprintf-posix for portable "
1065                       "POSIX compliance");
1066 #endif
1067
1068 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
1069 # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
1070      || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
1071 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1072 #   define vprintf rpl_vprintf
1073 #  endif
1074 #  define GNULIB_overrides_vprintf 1
1075 #  if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
1076 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1077                                 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
1078                                 _GL_ARG_NONNULL ((1)));
1079 #  else
1080 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1081                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1082                                 _GL_ARG_NONNULL ((1)));
1083 #  endif
1084 _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
1085 # else
1086 /* Need to cast, because on Solaris, the second parameter is
1087                                                           __va_list args
1088    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1089 _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
1090 # endif
1091 _GL_CXXALIASWARN (vprintf);
1092 #endif
1093 #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
1094 # if !GNULIB_overrides_vprintf
1095 #  undef vprintf
1096 # endif
1097 /* Assume vprintf is always declared.  */
1098 _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1099                  "use gnulib module vprintf-posix for portable "
1100                  "POSIX compliance");
1101 #endif
1102
1103 #if @GNULIB_VSNPRINTF@
1104 # if @REPLACE_VSNPRINTF@
1105 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1106 #   define vsnprintf rpl_vsnprintf
1107 #  endif
1108 _GL_FUNCDECL_RPL (vsnprintf, int,
1109                   (char *str, size_t size, const char *format, va_list args)
1110                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1111                   _GL_ARG_NONNULL ((3)));
1112 _GL_CXXALIAS_RPL (vsnprintf, int,
1113                   (char *str, size_t size, const char *format, va_list args));
1114 # else
1115 #  if !@HAVE_DECL_VSNPRINTF@
1116 _GL_FUNCDECL_SYS (vsnprintf, int,
1117                   (char *str, size_t size, const char *format, va_list args)
1118                   _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1119                   _GL_ARG_NONNULL ((3)));
1120 #  endif
1121 _GL_CXXALIAS_SYS (vsnprintf, int,
1122                   (char *str, size_t size, const char *format, va_list args));
1123 # endif
1124 _GL_CXXALIASWARN (vsnprintf);
1125 #elif defined GNULIB_POSIXCHECK
1126 # undef vsnprintf
1127 # if HAVE_RAW_DECL_VSNPRINTF
1128 _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1129                  "use gnulib module vsnprintf for portability");
1130 # endif
1131 #endif
1132
1133 #if @GNULIB_VSPRINTF_POSIX@
1134 # if @REPLACE_VSPRINTF@
1135 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1136 #   define vsprintf rpl_vsprintf
1137 #  endif
1138 _GL_FUNCDECL_RPL (vsprintf, int,
1139                   (char *str, const char *format, va_list args)
1140                   _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1141                   _GL_ARG_NONNULL ((1, 2)));
1142 _GL_CXXALIAS_RPL (vsprintf, int,
1143                   (char *str, const char *format, va_list args));
1144 # else
1145 /* Need to cast, because on Solaris, the third parameter is
1146                                                        __va_list args
1147    and GCC's fixincludes did not change this to __gnuc_va_list.  */
1148 _GL_CXXALIAS_SYS_CAST (vsprintf, int,
1149                        (char *str, const char *format, va_list args));
1150 # endif
1151 _GL_CXXALIASWARN (vsprintf);
1152 #elif defined GNULIB_POSIXCHECK
1153 # undef vsprintf
1154 /* Assume vsprintf is always declared.  */
1155 _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1156                  "use gnulib module vsprintf-posix for portable "
1157                       "POSIX compliance");
1158 #endif
1159
1160
1161 #endif /* _GL_STDIO_H */
1162 #endif /* _GL_STDIO_H */
1163 #endif