(root)/
tar-1.35/
gnu/
stdio.in.h
       1  /* A GNU-like <stdio.h>.
       2  
       3     Copyright (C) 2004, 2007-2023 Free Software Foundation, Inc.
       4  
       5     This file is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU Lesser General Public License as
       7     published by the Free Software Foundation; either version 2.1 of the
       8     License, or (at your option) any later version.
       9  
      10     This file 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 Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  #if __GNUC__ >= 3
      19  @PRAGMA_SYSTEM_HEADER@
      20  #endif
      21  @PRAGMA_COLUMNS@
      22  
      23  #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
      24  /* Special invocation convention:
      25     - Inside glibc header files.
      26     - On OSF/1 5.1 we have a sequence of nested includes
      27       <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
      28       <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
      29       In this situation, the functions are not yet declared, therefore we cannot
      30       provide the C++ aliases.  */
      31  
      32  #@INCLUDE_NEXT@ @NEXT_STDIO_H@
      33  
      34  #else
      35  /* Normal invocation convention.  */
      36  
      37  #ifndef _@GUARD_PREFIX@_STDIO_H
      38  
      39  /* Suppress macOS deprecation warnings for sprintf and vsprintf.  */
      40  #if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
      41  # define _POSIX_C_SOURCE 200809L
      42  # define _GL_DEFINED__POSIX_C_SOURCE
      43  #endif
      44  
      45  #define _GL_ALREADY_INCLUDING_STDIO_H
      46  
      47  /* The include_next requires a split double-inclusion guard.  */
      48  #@INCLUDE_NEXT@ @NEXT_STDIO_H@
      49  
      50  #undef _GL_ALREADY_INCLUDING_STDIO_H
      51  
      52  #ifdef _GL_DEFINED__POSIX_C_SOURCE
      53  # undef _GL_DEFINED__POSIX_C_SOURCE
      54  # undef _POSIX_C_SOURCE
      55  #endif
      56  
      57  #ifndef _@GUARD_PREFIX@_STDIO_H
      58  #define _@GUARD_PREFIX@_STDIO_H
      59  
      60  /* This file uses _GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_FORMAT,
      61     _GL_ATTRIBUTE_MALLOC, GNULIB_POSIXCHECK, HAVE_RAW_DECL_*.  */
      62  #if !_GL_CONFIG_H_INCLUDED
      63   #error "Please include config.h first."
      64  #endif
      65  
      66  /* Get va_list.  Needed on many systems, including glibc 2.8.  */
      67  #include <stdarg.h>
      68  
      69  #include <stddef.h>
      70  
      71  /* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8
      72     and eglibc 2.11.2.
      73     May also define off_t to a 64-bit type on native Windows.  */
      74  #include <sys/types.h>
      75  
      76  /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>.  */
      77  /* But in any case avoid namespace pollution on glibc systems.  */
      78  #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
      79      && ! defined __GLIBC__
      80  # include <unistd.h>
      81  #endif
      82  
      83  /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
      84  /* But in any case avoid namespace pollution on glibc systems.  */
      85  #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
      86      && ! defined __GLIBC__
      87  # include <sys/stat.h>
      88  #endif
      89  
      90  /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
      91     it before we  #define perror rpl_perror.  */
      92  /* But in any case avoid namespace pollution on glibc systems.  */
      93  #if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \
      94      && (defined _WIN32 && ! defined __CYGWIN__) \
      95      && ! defined __GLIBC__
      96  # include <stdlib.h>
      97  #endif
      98  
      99  /* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
     100     it before we  #define remove rpl_remove.  */
     101  /* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  We must include
     102     it before we  #define rename rpl_rename.  */
     103  /* But in any case avoid namespace pollution on glibc systems.  */
     104  #if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \
     105      && (defined _WIN32 && ! defined __CYGWIN__) \
     106      && ! defined __GLIBC__
     107  # include <io.h>
     108  #endif
     109  
     110  
     111  /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
     112     that can be freed by passing them as the Ith argument to the
     113     function F.  */
     114  #ifndef _GL_ATTRIBUTE_DEALLOC
     115  # if __GNUC__ >= 11
     116  #  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
     117  # else
     118  #  define _GL_ATTRIBUTE_DEALLOC(f, i)
     119  # endif
     120  #endif
     121  
     122  /* The __attribute__ feature is available in gcc versions 2.5 and later.
     123     The __-protected variants of the attributes 'format' and 'printf' are
     124     accepted by gcc versions 2.6.4 (effectively 2.7) and later.
     125     We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
     126     gnulib and libintl do '#define printf __printf__' when they override
     127     the 'printf' function.  */
     128  #ifndef _GL_ATTRIBUTE_FORMAT
     129  # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) || defined __clang__
     130  #  define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
     131  # else
     132  #  define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
     133  # endif
     134  #endif
     135  
     136  /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
     137     allocated memory.  */
     138  #ifndef _GL_ATTRIBUTE_MALLOC
     139  # if __GNUC__ >= 3 || defined __clang__
     140  #  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
     141  # else
     142  #  define _GL_ATTRIBUTE_MALLOC
     143  # endif
     144  #endif
     145  
     146  /* An __attribute__ __format__ specifier for a function that takes a format
     147     string and arguments, where the format string directives are the ones
     148     standardized by ISO C99 and POSIX.
     149     _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD  */
     150  /* __gnu_printf__ is supported in GCC >= 4.4.  */
     151  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
     152  # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__
     153  #else
     154  # define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__
     155  #endif
     156  
     157  /* An __attribute__ __format__ specifier for a function that takes a format
     158     string and arguments, where the format string directives are the ones of the
     159     system printf(), rather than the ones standardized by ISO C99 and POSIX.
     160     _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM  */
     161  /* On mingw, Gnulib sets __USE_MINGW_ANSI_STDIO in order to get closer to
     162     the standards.  The macro GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU indicates
     163     whether this change is effective.  On older mingw, it is not.  */
     164  #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU
     165  # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD
     166  #else
     167  # define _GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM __printf__
     168  #endif
     169  
     170  /* _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD
     171     indicates to GCC that the function takes a format string and arguments,
     172     where the format string directives are the ones standardized by ISO C99
     173     and POSIX.  */
     174  #define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(formatstring_parameter, first_argument) \
     175    _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, formatstring_parameter, first_argument))
     176  
     177  /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD,
     178     except that it indicates to GCC that the supported format string directives
     179     are the ones of the system printf(), rather than the ones standardized by
     180     ISO C99 and POSIX.  */
     181  #define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
     182    _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM, formatstring_parameter, first_argument))
     183  
     184  /* _GL_ATTRIBUTE_FORMAT_SCANF
     185     indicates to GCC that the function takes a format string and arguments,
     186     where the format string directives are the ones standardized by ISO C99
     187     and POSIX.  */
     188  #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
     189  # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
     190     _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
     191  #else
     192  # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
     193     _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
     194  #endif
     195  
     196  /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
     197     except that it indicates to GCC that the supported format string directives
     198     are the ones of the system scanf(), rather than the ones standardized by
     199     ISO C99 and POSIX.  */
     200  #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
     201    _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
     202  
     203  /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
     204  
     205  /* The definition of _GL_ARG_NONNULL is copied here.  */
     206  
     207  /* The definition of _GL_WARN_ON_USE is copied here.  */
     208  
     209  /* Macros for stringification.  */
     210  #define _GL_STDIO_STRINGIZE(token) #token
     211  #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
     212  
     213  /* When also using extern inline, suppress the use of static inline in
     214     standard headers of problematic Apple configurations, as Libc at
     215     least through Libc-825.26 (2013-04-09) mishandles it; see, e.g.,
     216     <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>.
     217     Perhaps Apple will fix this some day.  */
     218  #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \
     219       && defined __GNUC__ && defined __STDC__)
     220  # undef putc_unlocked
     221  #endif
     222  
     223  
     224  /* Maximum number of characters produced by printing a NaN value.  */
     225  #ifndef _PRINTF_NAN_LEN_MAX
     226  # if defined __FreeBSD__ || defined __DragonFly__ \
     227       || defined __NetBSD__ \
     228       || (defined __APPLE__ && defined __MACH__)
     229  /* On BSD systems, a NaN value prints as just "nan", without a sign.  */
     230  #  define _PRINTF_NAN_LEN_MAX 3
     231  # elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __OpenBSD__ || defined __sun || defined __CYGWIN__
     232  /* glibc, musl libc, OpenBSD, Solaris libc, and Cygwin produce "[-]nan".  */
     233  #  define _PRINTF_NAN_LEN_MAX 4
     234  # elif defined _AIX
     235  /* AIX produces "[-]NaNQ".  */
     236  #  define _PRINTF_NAN_LEN_MAX 5
     237  # elif defined _WIN32 && !defined __CYGWIN__
     238  /* On native Windows, the output can be:
     239     - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
     240     - with mingw: "[-]1.#IND" or "[-]1.#QNAN".  */
     241  #  define _PRINTF_NAN_LEN_MAX 10
     242  # elif defined __sgi
     243  /* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
     244     digits.  */
     245  #  define _PRINTF_NAN_LEN_MAX 14
     246  # else
     247  /* We don't know, but 32 should be a safe maximum.  */
     248  #  define _PRINTF_NAN_LEN_MAX 32
     249  # endif
     250  #endif
     251  
     252  
     253  #if @GNULIB_DPRINTF@
     254  # if @REPLACE_DPRINTF@
     255  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     256  #   define dprintf rpl_dprintf
     257  #  endif
     258  _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *restrict format, ...)
     259                                  _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
     260                                  _GL_ARG_NONNULL ((2)));
     261  _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *restrict format, ...));
     262  # else
     263  #  if !@HAVE_DPRINTF@
     264  _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
     265                                  _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
     266                                  _GL_ARG_NONNULL ((2)));
     267  #  endif
     268  _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
     269  # endif
     270  # if __GLIBC__ >= 2
     271  _GL_CXXALIASWARN (dprintf);
     272  # endif
     273  #elif defined GNULIB_POSIXCHECK
     274  # undef dprintf
     275  # if HAVE_RAW_DECL_DPRINTF
     276  _GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
     277                   "use gnulib module dprintf for portability");
     278  # endif
     279  #endif
     280  
     281  #if @GNULIB_FCLOSE@
     282  /* Close STREAM and its underlying file descriptor.  */
     283  # if @REPLACE_FCLOSE@
     284  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     285  #   define fclose rpl_fclose
     286  #  endif
     287  _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
     288  _GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
     289  # else
     290  _GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
     291  # endif
     292  # if __GLIBC__ >= 2
     293  _GL_CXXALIASWARN (fclose);
     294  # endif
     295  #elif defined GNULIB_POSIXCHECK
     296  # undef fclose
     297  /* Assume fclose is always declared.  */
     298  _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
     299                   "use gnulib module fclose for portable POSIX compliance");
     300  #endif
     301  
     302  #if @GNULIB_MDA_FCLOSEALL@
     303  /* On native Windows, map 'fcloseall' to '_fcloseall', so that -loldnames is
     304     not required.  In C++ with GNULIB_NAMESPACE, avoid differences between
     305     platforms by defining GNULIB_NAMESPACE::fcloseall on all platforms that have
     306     it.  */
     307  # if defined _WIN32 && !defined __CYGWIN__
     308  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     309  #   undef fcloseall
     310  #   define fcloseall _fcloseall
     311  #  endif
     312  _GL_CXXALIAS_MDA (fcloseall, int, (void));
     313  # else
     314  #  if @HAVE_DECL_FCLOSEALL@
     315  #   if defined __FreeBSD__ || defined __DragonFly__
     316  _GL_CXXALIAS_SYS (fcloseall, void, (void));
     317  #   else
     318  _GL_CXXALIAS_SYS (fcloseall, int, (void));
     319  #   endif
     320  #  endif
     321  # endif
     322  # if (defined _WIN32 && !defined __CYGWIN__) || @HAVE_DECL_FCLOSEALL@
     323  _GL_CXXALIASWARN (fcloseall);
     324  # endif
     325  #endif
     326  
     327  #if @GNULIB_FDOPEN@
     328  # if @REPLACE_FDOPEN@
     329  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     330  #   undef fdopen
     331  #   define fdopen rpl_fdopen
     332  #  endif
     333  _GL_FUNCDECL_RPL (fdopen, FILE *,
     334                    (int fd, const char *mode)
     335                    _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
     336                    _GL_ATTRIBUTE_MALLOC);
     337  _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
     338  # elif defined _WIN32 && !defined __CYGWIN__
     339  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     340  #   undef fdopen
     341  #   define fdopen _fdopen
     342  #  endif
     343  _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
     344  # else
     345  #  if __GNUC__ >= 11
     346  /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose.  */
     347  _GL_FUNCDECL_SYS (fdopen, FILE *,
     348                    (int fd, const char *mode)
     349                    _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
     350                    _GL_ATTRIBUTE_MALLOC);
     351  #  endif
     352  _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
     353  # endif
     354  _GL_CXXALIASWARN (fdopen);
     355  #else
     356  # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fdopen
     357  /* For -Wmismatched-dealloc: Associate fdopen with fclose or rpl_fclose.  */
     358  _GL_FUNCDECL_SYS (fdopen, FILE *,
     359                    (int fd, const char *mode)
     360                    _GL_ARG_NONNULL ((2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
     361                    _GL_ATTRIBUTE_MALLOC);
     362  # endif
     363  # if defined GNULIB_POSIXCHECK
     364  #  undef fdopen
     365  /* Assume fdopen is always declared.  */
     366  _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
     367                   "use gnulib module fdopen for portability");
     368  # elif @GNULIB_MDA_FDOPEN@
     369  /* On native Windows, map 'fdopen' to '_fdopen', so that -loldnames is not
     370     required.  In C++ with GNULIB_NAMESPACE, avoid differences between
     371     platforms by defining GNULIB_NAMESPACE::fdopen always.  */
     372  #  if defined _WIN32 && !defined __CYGWIN__
     373  #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     374  #    undef fdopen
     375  #    define fdopen _fdopen
     376  #   endif
     377  _GL_CXXALIAS_MDA (fdopen, FILE *, (int fd, const char *mode));
     378  #  else
     379  _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
     380  #  endif
     381  _GL_CXXALIASWARN (fdopen);
     382  # endif
     383  #endif
     384  
     385  #if @GNULIB_FFLUSH@
     386  /* Flush all pending data on STREAM according to POSIX rules.  Both
     387     output and seekable input streams are supported.
     388     Note! LOSS OF DATA can occur if fflush is applied on an input stream
     389     that is _not_seekable_ or on an update stream that is _not_seekable_
     390     and in which the most recent operation was input.  Seekability can
     391     be tested with lseek(fileno(fp),0,SEEK_CUR).  */
     392  # if @REPLACE_FFLUSH@
     393  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     394  #   define fflush rpl_fflush
     395  #  endif
     396  _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
     397  _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
     398  # else
     399  _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
     400  # endif
     401  # if __GLIBC__ >= 2
     402  _GL_CXXALIASWARN (fflush);
     403  # endif
     404  #elif defined GNULIB_POSIXCHECK
     405  # undef fflush
     406  /* Assume fflush is always declared.  */
     407  _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
     408                   "use gnulib module fflush for portable POSIX compliance");
     409  #endif
     410  
     411  #if @GNULIB_FGETC@
     412  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     413  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     414  #   undef fgetc
     415  #   define fgetc rpl_fgetc
     416  #  endif
     417  _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
     418  _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
     419  # else
     420  _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
     421  # endif
     422  # if __GLIBC__ >= 2
     423  _GL_CXXALIASWARN (fgetc);
     424  # endif
     425  #endif
     426  
     427  #if @GNULIB_FGETS@
     428  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     429  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     430  #   undef fgets
     431  #   define fgets rpl_fgets
     432  #  endif
     433  _GL_FUNCDECL_RPL (fgets, char *,
     434                    (char *restrict s, int n, FILE *restrict stream)
     435                    _GL_ARG_NONNULL ((1, 3)));
     436  _GL_CXXALIAS_RPL (fgets, char *,
     437                    (char *restrict s, int n, FILE *restrict stream));
     438  # else
     439  _GL_CXXALIAS_SYS (fgets, char *,
     440                    (char *restrict s, int n, FILE *restrict stream));
     441  # endif
     442  # if __GLIBC__ >= 2
     443  _GL_CXXALIASWARN (fgets);
     444  # endif
     445  #endif
     446  
     447  #if @GNULIB_MDA_FILENO@
     448  /* On native Windows, map 'fileno' to '_fileno', so that -loldnames is not
     449     required.  In C++ with GNULIB_NAMESPACE, avoid differences between
     450     platforms by defining GNULIB_NAMESPACE::fileno always.  */
     451  # if defined _WIN32 && !defined __CYGWIN__
     452  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     453  #   undef fileno
     454  #   define fileno _fileno
     455  #  endif
     456  _GL_CXXALIAS_MDA (fileno, int, (FILE *restrict stream));
     457  # else
     458  _GL_CXXALIAS_SYS (fileno, int, (FILE *restrict stream));
     459  # endif
     460  _GL_CXXALIASWARN (fileno);
     461  #endif
     462  
     463  #if @GNULIB_FOPEN@
     464  # if (@GNULIB_FOPEN@ && @REPLACE_FOPEN@) \
     465       || (@GNULIB_FOPEN_GNU@ && @REPLACE_FOPEN_FOR_FOPEN_GNU@)
     466  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     467  #   undef fopen
     468  #   define fopen rpl_fopen
     469  #  endif
     470  _GL_FUNCDECL_RPL (fopen, FILE *,
     471                    (const char *restrict filename, const char *restrict mode)
     472                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1)
     473                    _GL_ATTRIBUTE_MALLOC);
     474  _GL_CXXALIAS_RPL (fopen, FILE *,
     475                    (const char *restrict filename, const char *restrict mode));
     476  # else
     477  #  if __GNUC__ >= 11
     478  /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose.  */
     479  _GL_FUNCDECL_SYS (fopen, FILE *,
     480                    (const char *restrict filename, const char *restrict mode)
     481                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
     482  #  endif
     483  _GL_CXXALIAS_SYS (fopen, FILE *,
     484                    (const char *restrict filename, const char *restrict mode));
     485  # endif
     486  # if __GLIBC__ >= 2
     487  _GL_CXXALIASWARN (fopen);
     488  # endif
     489  #else
     490  # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined fopen
     491  /* For -Wmismatched-dealloc: Associate fopen with fclose or rpl_fclose.  */
     492  _GL_FUNCDECL_SYS (fopen, FILE *,
     493                    (const char *restrict filename, const char *restrict mode)
     494                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (fclose, 1));
     495  # endif
     496  # if defined GNULIB_POSIXCHECK
     497  #  undef fopen
     498  /* Assume fopen is always declared.  */
     499  _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
     500                   "use gnulib module fopen for portability");
     501  # endif
     502  #endif
     503  
     504  #if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
     505  # if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
     506       || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
     507  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     508  #   define fprintf rpl_fprintf
     509  #  endif
     510  #  define GNULIB_overrides_fprintf 1
     511  #  if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
     512  _GL_FUNCDECL_RPL (fprintf, int,
     513                    (FILE *restrict fp, const char *restrict format, ...)
     514                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
     515                    _GL_ARG_NONNULL ((1, 2)));
     516  #  else
     517  _GL_FUNCDECL_RPL (fprintf, int,
     518                    (FILE *restrict fp, const char *restrict format, ...)
     519                    _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
     520                    _GL_ARG_NONNULL ((1, 2)));
     521  #  endif
     522  _GL_CXXALIAS_RPL (fprintf, int,
     523                    (FILE *restrict fp, const char *restrict format, ...));
     524  # else
     525  _GL_CXXALIAS_SYS (fprintf, int,
     526                    (FILE *restrict fp, const char *restrict format, ...));
     527  # endif
     528  # if __GLIBC__ >= 2
     529  _GL_CXXALIASWARN (fprintf);
     530  # endif
     531  #endif
     532  #if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
     533  # if !GNULIB_overrides_fprintf
     534  #  undef fprintf
     535  # endif
     536  /* Assume fprintf is always declared.  */
     537  _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
     538                   "use gnulib module fprintf-posix for portable "
     539                   "POSIX compliance");
     540  #endif
     541  
     542  #if @GNULIB_FPURGE@
     543  /* Discard all pending buffered I/O data on STREAM.
     544     STREAM must not be wide-character oriented.
     545     When discarding pending output, the file position is set back to where it
     546     was before the write calls.  When discarding pending input, the file
     547     position is advanced to match the end of the previously read input.
     548     Return 0 if successful.  Upon error, return -1 and set errno.  */
     549  # if @REPLACE_FPURGE@
     550  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     551  #   define fpurge rpl_fpurge
     552  #  endif
     553  _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
     554  _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
     555  # else
     556  #  if !@HAVE_DECL_FPURGE@
     557  _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
     558  #  endif
     559  _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
     560  # endif
     561  _GL_CXXALIASWARN (fpurge);
     562  #elif defined GNULIB_POSIXCHECK
     563  # undef fpurge
     564  # if HAVE_RAW_DECL_FPURGE
     565  _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
     566                   "use gnulib module fpurge for portability");
     567  # endif
     568  #endif
     569  
     570  #if @GNULIB_FPUTC@
     571  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
     572  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     573  #   undef fputc
     574  #   define fputc rpl_fputc
     575  #  endif
     576  _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
     577  _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
     578  # else
     579  _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
     580  # endif
     581  # if __GLIBC__ >= 2
     582  _GL_CXXALIASWARN (fputc);
     583  # endif
     584  #endif
     585  
     586  #if @GNULIB_FPUTS@
     587  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
     588  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     589  #   undef fputs
     590  #   define fputs rpl_fputs
     591  #  endif
     592  _GL_FUNCDECL_RPL (fputs, int,
     593                    (const char *restrict string, FILE *restrict stream)
     594                    _GL_ARG_NONNULL ((1, 2)));
     595  _GL_CXXALIAS_RPL (fputs, int,
     596                    (const char *restrict string, FILE *restrict stream));
     597  # else
     598  _GL_CXXALIAS_SYS (fputs, int,
     599                    (const char *restrict string, FILE *restrict stream));
     600  # endif
     601  # if __GLIBC__ >= 2
     602  _GL_CXXALIASWARN (fputs);
     603  # endif
     604  #endif
     605  
     606  #if @GNULIB_FREAD@
     607  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     608  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     609  #   undef fread
     610  #   define fread rpl_fread
     611  #  endif
     612  _GL_FUNCDECL_RPL (fread, size_t,
     613                    (void *restrict ptr, size_t s, size_t n,
     614                     FILE *restrict stream)
     615                    _GL_ARG_NONNULL ((4)));
     616  _GL_CXXALIAS_RPL (fread, size_t,
     617                    (void *restrict ptr, size_t s, size_t n,
     618                     FILE *restrict stream));
     619  # else
     620  _GL_CXXALIAS_SYS (fread, size_t,
     621                    (void *restrict ptr, size_t s, size_t n,
     622                     FILE *restrict stream));
     623  # endif
     624  # if __GLIBC__ >= 2
     625  _GL_CXXALIASWARN (fread);
     626  # endif
     627  #endif
     628  
     629  #if @GNULIB_FREOPEN@
     630  # if @REPLACE_FREOPEN@
     631  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     632  #   undef freopen
     633  #   define freopen rpl_freopen
     634  #  endif
     635  _GL_FUNCDECL_RPL (freopen, FILE *,
     636                    (const char *restrict filename, const char *restrict mode,
     637                     FILE *restrict stream)
     638                    _GL_ARG_NONNULL ((2, 3)));
     639  _GL_CXXALIAS_RPL (freopen, FILE *,
     640                    (const char *restrict filename, const char *restrict mode,
     641                     FILE *restrict stream));
     642  # else
     643  _GL_CXXALIAS_SYS (freopen, FILE *,
     644                    (const char *restrict filename, const char *restrict mode,
     645                     FILE *restrict stream));
     646  # endif
     647  # if __GLIBC__ >= 2
     648  _GL_CXXALIASWARN (freopen);
     649  # endif
     650  #elif defined GNULIB_POSIXCHECK
     651  # undef freopen
     652  /* Assume freopen is always declared.  */
     653  _GL_WARN_ON_USE (freopen,
     654                   "freopen on native Windows platforms is not POSIX compliant - "
     655                   "use gnulib module freopen for portability");
     656  #endif
     657  
     658  #if @GNULIB_FSCANF@
     659  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     660  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     661  #   undef fscanf
     662  #   define fscanf rpl_fscanf
     663  #  endif
     664  _GL_FUNCDECL_RPL (fscanf, int,
     665                    (FILE *restrict stream, const char *restrict format, ...)
     666                    _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
     667                    _GL_ARG_NONNULL ((1, 2)));
     668  _GL_CXXALIAS_RPL (fscanf, int,
     669                    (FILE *restrict stream, const char *restrict format, ...));
     670  # else
     671  _GL_CXXALIAS_SYS (fscanf, int,
     672                    (FILE *restrict stream, const char *restrict format, ...));
     673  # endif
     674  # if __GLIBC__ >= 2
     675  _GL_CXXALIASWARN (fscanf);
     676  # endif
     677  #endif
     678  
     679  
     680  /* Set up the following warnings, based on which modules are in use.
     681     GNU Coding Standards discourage the use of fseek, since it imposes
     682     an arbitrary limitation on some 32-bit hosts.  Remember that the
     683     fseek module depends on the fseeko module, so we only have three
     684     cases to consider:
     685  
     686     1. The developer is not using either module.  Issue a warning under
     687     GNULIB_POSIXCHECK for both functions, to remind them that both
     688     functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
     689     impact on this warning.
     690  
     691     2. The developer is using both modules.  They may be unaware of the
     692     arbitrary limitations of fseek, so issue a warning under
     693     GNULIB_POSIXCHECK.  On the other hand, they may be using both
     694     modules intentionally, so the developer can define
     695     _GL_NO_LARGE_FILES in the compilation units where the use of fseek
     696     is safe, to silence the warning.
     697  
     698     3. The developer is using the fseeko module, but not fseek.  Gnulib
     699     guarantees that fseek will still work around platform bugs in that
     700     case, but we presume that the developer is aware of the pitfalls of
     701     fseek and was trying to avoid it, so issue a warning even when
     702     GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
     703     defined to silence the warning in particular compilation units.
     704     In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
     705     fseek gets defined as a macro, it is recommended that the developer
     706     uses the fseek module, even if he is not calling the fseek function.
     707  
     708     Most gnulib clients that perform stream operations should fall into
     709     category 3.  */
     710  
     711  #if @GNULIB_FSEEK@
     712  # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
     713  #  define _GL_FSEEK_WARN /* Category 2, above.  */
     714  #  undef fseek
     715  # endif
     716  # if @REPLACE_FSEEK@
     717  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     718  #   undef fseek
     719  #   define fseek rpl_fseek
     720  #  endif
     721  _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
     722                                _GL_ARG_NONNULL ((1)));
     723  _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
     724  # else
     725  _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
     726  # endif
     727  # if __GLIBC__ >= 2
     728  _GL_CXXALIASWARN (fseek);
     729  # endif
     730  #endif
     731  
     732  #if @GNULIB_FSEEKO@
     733  # if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
     734  #  define _GL_FSEEK_WARN /* Category 3, above.  */
     735  #  undef fseek
     736  # endif
     737  # if @REPLACE_FSEEKO@
     738  /* Provide an fseeko function that is aware of a preceding fflush(), and which
     739     detects pipes.  */
     740  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     741  #   undef fseeko
     742  #   define fseeko rpl_fseeko
     743  #  endif
     744  _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
     745                                 _GL_ARG_NONNULL ((1)));
     746  _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
     747  # else
     748  #  if ! @HAVE_DECL_FSEEKO@
     749  _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
     750                                 _GL_ARG_NONNULL ((1)));
     751  #  endif
     752  _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
     753  # endif
     754  _GL_CXXALIASWARN (fseeko);
     755  #elif defined GNULIB_POSIXCHECK
     756  # define _GL_FSEEK_WARN /* Category 1, above.  */
     757  # undef fseek
     758  # undef fseeko
     759  # if HAVE_RAW_DECL_FSEEKO
     760  _GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
     761                   "use gnulib module fseeko for portability");
     762  # endif
     763  #endif
     764  
     765  #ifdef _GL_FSEEK_WARN
     766  # undef _GL_FSEEK_WARN
     767  /* Here, either fseek is undefined (but C89 guarantees that it is
     768     declared), or it is defined as rpl_fseek (declared above).  */
     769  _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
     770                   "on 32-bit platforms - "
     771                   "use fseeko function for handling of large files");
     772  #endif
     773  
     774  
     775  /* ftell, ftello.  See the comments on fseek/fseeko.  */
     776  
     777  #if @GNULIB_FTELL@
     778  # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
     779  #  define _GL_FTELL_WARN /* Category 2, above.  */
     780  #  undef ftell
     781  # endif
     782  # if @REPLACE_FTELL@
     783  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     784  #   undef ftell
     785  #   define ftell rpl_ftell
     786  #  endif
     787  _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
     788  _GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
     789  # else
     790  _GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
     791  # endif
     792  # if __GLIBC__ >= 2
     793  _GL_CXXALIASWARN (ftell);
     794  # endif
     795  #endif
     796  
     797  #if @GNULIB_FTELLO@
     798  # if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
     799  #  define _GL_FTELL_WARN /* Category 3, above.  */
     800  #  undef ftell
     801  # endif
     802  # if @REPLACE_FTELLO@
     803  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     804  #   undef ftello
     805  #   define ftello rpl_ftello
     806  #  endif
     807  _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
     808  _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
     809  # else
     810  #  if ! @HAVE_DECL_FTELLO@
     811  _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
     812  #  endif
     813  _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
     814  # endif
     815  _GL_CXXALIASWARN (ftello);
     816  #elif defined GNULIB_POSIXCHECK
     817  # define _GL_FTELL_WARN /* Category 1, above.  */
     818  # undef ftell
     819  # undef ftello
     820  # if HAVE_RAW_DECL_FTELLO
     821  _GL_WARN_ON_USE (ftello, "ftello is unportable - "
     822                   "use gnulib module ftello for portability");
     823  # endif
     824  #endif
     825  
     826  #ifdef _GL_FTELL_WARN
     827  # undef _GL_FTELL_WARN
     828  /* Here, either ftell is undefined (but C89 guarantees that it is
     829     declared), or it is defined as rpl_ftell (declared above).  */
     830  _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
     831                   "on 32-bit platforms - "
     832                   "use ftello function for handling of large files");
     833  #endif
     834  
     835  
     836  #if @GNULIB_FWRITE@
     837  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
     838  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     839  #   undef fwrite
     840  #   define fwrite rpl_fwrite
     841  #  endif
     842  _GL_FUNCDECL_RPL (fwrite, size_t,
     843                    (const void *restrict ptr, size_t s, size_t n,
     844                     FILE *restrict stream)
     845                    _GL_ARG_NONNULL ((1, 4)));
     846  _GL_CXXALIAS_RPL (fwrite, size_t,
     847                    (const void *restrict ptr, size_t s, size_t n,
     848                     FILE *restrict stream));
     849  # else
     850  _GL_CXXALIAS_SYS (fwrite, size_t,
     851                    (const void *restrict ptr, size_t s, size_t n,
     852                     FILE *restrict stream));
     853  
     854  /* Work around bug 11959 when fortifying glibc 2.4 through 2.15
     855     <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>,
     856     which sometimes causes an unwanted diagnostic for fwrite calls.
     857     This affects only function declaration attributes under certain
     858     versions of gcc and clang, and is not needed for C++.  */
     859  #  if (0 < __USE_FORTIFY_LEVEL                                          \
     860         && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
     861         && 3 < __GNUC__ + (4 <= __GNUC_MINOR__)                          \
     862         && !defined __cplusplus)
     863  #   undef fwrite
     864  #   undef fwrite_unlocked
     865  extern size_t __REDIRECT (rpl_fwrite,
     866                            (const void *__restrict, size_t, size_t,
     867                             FILE *__restrict),
     868                            fwrite);
     869  extern size_t __REDIRECT (rpl_fwrite_unlocked,
     870                            (const void *__restrict, size_t, size_t,
     871                             FILE *__restrict),
     872                            fwrite_unlocked);
     873  #   define fwrite rpl_fwrite
     874  #   define fwrite_unlocked rpl_fwrite_unlocked
     875  #  endif
     876  # endif
     877  # if __GLIBC__ >= 2
     878  _GL_CXXALIASWARN (fwrite);
     879  # endif
     880  #endif
     881  
     882  #if @GNULIB_GETC@
     883  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     884  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     885  #   undef getc
     886  #   define getc rpl_fgetc
     887  #  endif
     888  _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
     889  _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
     890  # else
     891  _GL_CXXALIAS_SYS (getc, int, (FILE *stream));
     892  # endif
     893  # if __GLIBC__ >= 2
     894  _GL_CXXALIASWARN (getc);
     895  # endif
     896  #endif
     897  
     898  #if @GNULIB_GETCHAR@
     899  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
     900  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     901  #   undef getchar
     902  #   define getchar rpl_getchar
     903  #  endif
     904  _GL_FUNCDECL_RPL (getchar, int, (void));
     905  _GL_CXXALIAS_RPL (getchar, int, (void));
     906  # else
     907  _GL_CXXALIAS_SYS (getchar, int, (void));
     908  # endif
     909  # if __GLIBC__ >= 2
     910  _GL_CXXALIASWARN (getchar);
     911  # endif
     912  #endif
     913  
     914  #if @GNULIB_GETDELIM@
     915  /* Read input, up to (and including) the next occurrence of DELIMITER, from
     916     STREAM, store it in *LINEPTR (and NUL-terminate it).
     917     *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
     918     bytes of space.  It is realloc'd as necessary.
     919     Return the number of bytes read and stored at *LINEPTR (not including the
     920     NUL terminator), or -1 on error or EOF.  */
     921  # if @REPLACE_GETDELIM@
     922  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     923  #   undef getdelim
     924  #   define getdelim rpl_getdelim
     925  #  endif
     926  _GL_FUNCDECL_RPL (getdelim, ssize_t,
     927                    (char **restrict lineptr, size_t *restrict linesize,
     928                     int delimiter,
     929                     FILE *restrict stream)
     930                    _GL_ARG_NONNULL ((1, 2, 4)));
     931  _GL_CXXALIAS_RPL (getdelim, ssize_t,
     932                    (char **restrict lineptr, size_t *restrict linesize,
     933                     int delimiter,
     934                     FILE *restrict stream));
     935  # else
     936  #  if !@HAVE_DECL_GETDELIM@
     937  _GL_FUNCDECL_SYS (getdelim, ssize_t,
     938                    (char **restrict lineptr, size_t *restrict linesize,
     939                     int delimiter,
     940                     FILE *restrict stream)
     941                    _GL_ARG_NONNULL ((1, 2, 4)));
     942  #  endif
     943  _GL_CXXALIAS_SYS (getdelim, ssize_t,
     944                    (char **restrict lineptr, size_t *restrict linesize,
     945                     int delimiter,
     946                     FILE *restrict stream));
     947  # endif
     948  # if __GLIBC__ >= 2
     949  _GL_CXXALIASWARN (getdelim);
     950  # endif
     951  #elif defined GNULIB_POSIXCHECK
     952  # undef getdelim
     953  # if HAVE_RAW_DECL_GETDELIM
     954  _GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
     955                   "use gnulib module getdelim for portability");
     956  # endif
     957  #endif
     958  
     959  #if @GNULIB_GETLINE@
     960  /* Read a line, up to (and including) the next newline, from STREAM, store it
     961     in *LINEPTR (and NUL-terminate it).
     962     *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
     963     bytes of space.  It is realloc'd as necessary.
     964     Return the number of bytes read and stored at *LINEPTR (not including the
     965     NUL terminator), or -1 on error or EOF.  */
     966  # if @REPLACE_GETLINE@
     967  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
     968  #   undef getline
     969  #   define getline rpl_getline
     970  #  endif
     971  _GL_FUNCDECL_RPL (getline, ssize_t,
     972                    (char **restrict lineptr, size_t *restrict linesize,
     973                     FILE *restrict stream)
     974                    _GL_ARG_NONNULL ((1, 2, 3)));
     975  _GL_CXXALIAS_RPL (getline, ssize_t,
     976                    (char **restrict lineptr, size_t *restrict linesize,
     977                     FILE *restrict stream));
     978  # else
     979  #  if !@HAVE_DECL_GETLINE@
     980  _GL_FUNCDECL_SYS (getline, ssize_t,
     981                    (char **restrict lineptr, size_t *restrict linesize,
     982                     FILE *restrict stream)
     983                    _GL_ARG_NONNULL ((1, 2, 3)));
     984  #  endif
     985  _GL_CXXALIAS_SYS (getline, ssize_t,
     986                    (char **restrict lineptr, size_t *restrict linesize,
     987                     FILE *restrict stream));
     988  # endif
     989  # if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@
     990  _GL_CXXALIASWARN (getline);
     991  # endif
     992  #elif defined GNULIB_POSIXCHECK
     993  # undef getline
     994  # if HAVE_RAW_DECL_GETLINE
     995  _GL_WARN_ON_USE (getline, "getline is unportable - "
     996                   "use gnulib module getline for portability");
     997  # endif
     998  #endif
     999  
    1000  /* It is very rare that the developer ever has full control of stdin,
    1001     so any use of gets warrants an unconditional warning; besides, C11
    1002     removed it.  */
    1003  #undef gets
    1004  #if HAVE_RAW_DECL_GETS && !defined __cplusplus
    1005  _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
    1006  #endif
    1007  
    1008  #if @GNULIB_MDA_GETW@
    1009  /* On native Windows, map 'getw' to '_getw', so that -loldnames is not
    1010     required.  In C++ with GNULIB_NAMESPACE, avoid differences between
    1011     platforms by defining GNULIB_NAMESPACE::getw always.  */
    1012  # if defined _WIN32 && !defined __CYGWIN__
    1013  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1014  #   undef getw
    1015  #   define getw _getw
    1016  #  endif
    1017  _GL_CXXALIAS_MDA (getw, int, (FILE *restrict stream));
    1018  # else
    1019  #  if @HAVE_DECL_GETW@
    1020  #   if defined __APPLE__ && defined __MACH__
    1021  /* The presence of the declaration depends on _POSIX_C_SOURCE.  */
    1022  _GL_FUNCDECL_SYS (getw, int, (FILE *restrict stream));
    1023  #   endif
    1024  _GL_CXXALIAS_SYS (getw, int, (FILE *restrict stream));
    1025  #  endif
    1026  # endif
    1027  # if __GLIBC__ >= 2
    1028  _GL_CXXALIASWARN (getw);
    1029  # endif
    1030  #endif
    1031  
    1032  #if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
    1033  struct obstack;
    1034  /* Grow an obstack with formatted output.  Return the number of
    1035     bytes added to OBS.  No trailing nul byte is added, and the
    1036     object should be closed with obstack_finish before use.  Upon
    1037     memory allocation error, call obstack_alloc_failed_handler.  Upon
    1038     other error, return -1.  */
    1039  # if @REPLACE_OBSTACK_PRINTF@
    1040  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1041  #   define obstack_printf rpl_obstack_printf
    1042  #  endif
    1043  _GL_FUNCDECL_RPL (obstack_printf, int,
    1044                    (struct obstack *obs, const char *format, ...)
    1045                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
    1046                    _GL_ARG_NONNULL ((1, 2)));
    1047  _GL_CXXALIAS_RPL (obstack_printf, int,
    1048                    (struct obstack *obs, const char *format, ...));
    1049  # else
    1050  #  if !@HAVE_DECL_OBSTACK_PRINTF@
    1051  _GL_FUNCDECL_SYS (obstack_printf, int,
    1052                    (struct obstack *obs, const char *format, ...)
    1053                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
    1054                    _GL_ARG_NONNULL ((1, 2)));
    1055  #  endif
    1056  _GL_CXXALIAS_SYS (obstack_printf, int,
    1057                    (struct obstack *obs, const char *format, ...));
    1058  # endif
    1059  _GL_CXXALIASWARN (obstack_printf);
    1060  # if @REPLACE_OBSTACK_PRINTF@
    1061  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1062  #   define obstack_vprintf rpl_obstack_vprintf
    1063  #  endif
    1064  _GL_FUNCDECL_RPL (obstack_vprintf, int,
    1065                    (struct obstack *obs, const char *format, va_list args)
    1066                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1067                    _GL_ARG_NONNULL ((1, 2)));
    1068  _GL_CXXALIAS_RPL (obstack_vprintf, int,
    1069                    (struct obstack *obs, const char *format, va_list args));
    1070  # else
    1071  #  if !@HAVE_DECL_OBSTACK_PRINTF@
    1072  _GL_FUNCDECL_SYS (obstack_vprintf, int,
    1073                    (struct obstack *obs, const char *format, va_list args)
    1074                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1075                    _GL_ARG_NONNULL ((1, 2)));
    1076  #  endif
    1077  _GL_CXXALIAS_SYS (obstack_vprintf, int,
    1078                    (struct obstack *obs, const char *format, va_list args));
    1079  # endif
    1080  _GL_CXXALIASWARN (obstack_vprintf);
    1081  #endif
    1082  
    1083  #if @GNULIB_PCLOSE@
    1084  # if !@HAVE_PCLOSE@
    1085  _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
    1086  # endif
    1087  _GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
    1088  _GL_CXXALIASWARN (pclose);
    1089  #elif defined GNULIB_POSIXCHECK
    1090  # undef pclose
    1091  # if HAVE_RAW_DECL_PCLOSE
    1092  _GL_WARN_ON_USE (pclose, "pclose is unportable - "
    1093                   "use gnulib module pclose for more portability");
    1094  # endif
    1095  #endif
    1096  
    1097  #if @GNULIB_PERROR@
    1098  /* Print a message to standard error, describing the value of ERRNO,
    1099     (if STRING is not NULL and not empty) prefixed with STRING and ": ",
    1100     and terminated with a newline.  */
    1101  # if @REPLACE_PERROR@
    1102  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1103  #   define perror rpl_perror
    1104  #  endif
    1105  _GL_FUNCDECL_RPL (perror, void, (const char *string));
    1106  _GL_CXXALIAS_RPL (perror, void, (const char *string));
    1107  # else
    1108  _GL_CXXALIAS_SYS (perror, void, (const char *string));
    1109  # endif
    1110  # if __GLIBC__ >= 2
    1111  _GL_CXXALIASWARN (perror);
    1112  # endif
    1113  #elif defined GNULIB_POSIXCHECK
    1114  # undef perror
    1115  /* Assume perror is always declared.  */
    1116  _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
    1117                   "use gnulib module perror for portability");
    1118  #endif
    1119  
    1120  #if @GNULIB_POPEN@
    1121  # if @REPLACE_POPEN@
    1122  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1123  #   undef popen
    1124  #   define popen rpl_popen
    1125  #  endif
    1126  _GL_FUNCDECL_RPL (popen, FILE *,
    1127                    (const char *cmd, const char *mode)
    1128                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
    1129                    _GL_ATTRIBUTE_MALLOC);
    1130  _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
    1131  # else
    1132  #  if !@HAVE_POPEN@ || __GNUC__ >= 11
    1133  _GL_FUNCDECL_SYS (popen, FILE *,
    1134                    (const char *cmd, const char *mode)
    1135                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
    1136                    _GL_ATTRIBUTE_MALLOC);
    1137  #  endif
    1138  _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
    1139  # endif
    1140  _GL_CXXALIASWARN (popen);
    1141  #else
    1142  # if @GNULIB_PCLOSE@ && __GNUC__ >= 11 && !defined popen
    1143  /* For -Wmismatched-dealloc: Associate popen with pclose or rpl_pclose.  */
    1144  _GL_FUNCDECL_SYS (popen, FILE *,
    1145                    (const char *cmd, const char *mode)
    1146                    _GL_ARG_NONNULL ((1, 2)) _GL_ATTRIBUTE_DEALLOC (pclose, 1)
    1147                    _GL_ATTRIBUTE_MALLOC);
    1148  # endif
    1149  # if defined GNULIB_POSIXCHECK
    1150  #  undef popen
    1151  #  if HAVE_RAW_DECL_POPEN
    1152  _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
    1153                   "use gnulib module popen or pipe for more portability");
    1154  #  endif
    1155  # endif
    1156  #endif
    1157  
    1158  #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
    1159  # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
    1160       || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
    1161  #  if defined __GNUC__ || defined __clang__
    1162  #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1163  /* Don't break __attribute__((format(printf,M,N))).  */
    1164  #    define printf __printf__
    1165  #   endif
    1166  #   if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
    1167  _GL_FUNCDECL_RPL_1 (__printf__, int,
    1168                      (const char *restrict format, ...)
    1169                      __asm__ (@ASM_SYMBOL_PREFIX@
    1170                               _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
    1171                      _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
    1172                      _GL_ARG_NONNULL ((1)));
    1173  #   else
    1174  _GL_FUNCDECL_RPL_1 (__printf__, int,
    1175                      (const char *restrict format, ...)
    1176                      __asm__ (@ASM_SYMBOL_PREFIX@
    1177                               _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
    1178                      _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
    1179                      _GL_ARG_NONNULL ((1)));
    1180  #   endif
    1181  _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
    1182  #  else
    1183  #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1184  #    define printf rpl_printf
    1185  #   endif
    1186  _GL_FUNCDECL_RPL (printf, int,
    1187                    (const char *restrict format, ...)
    1188                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 2)
    1189                    _GL_ARG_NONNULL ((1)));
    1190  _GL_CXXALIAS_RPL (printf, int, (const char *restrict format, ...));
    1191  #  endif
    1192  #  define GNULIB_overrides_printf 1
    1193  # else
    1194  _GL_CXXALIAS_SYS (printf, int, (const char *restrict format, ...));
    1195  # endif
    1196  # if __GLIBC__ >= 2
    1197  _GL_CXXALIASWARN (printf);
    1198  # endif
    1199  #endif
    1200  #if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
    1201  # if !GNULIB_overrides_printf
    1202  #  undef printf
    1203  # endif
    1204  /* Assume printf is always declared.  */
    1205  _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
    1206                   "use gnulib module printf-posix for portable "
    1207                   "POSIX compliance");
    1208  #endif
    1209  
    1210  #if @GNULIB_PUTC@
    1211  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
    1212  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1213  #   undef putc
    1214  #   define putc rpl_fputc
    1215  #  endif
    1216  _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
    1217  _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
    1218  # else
    1219  _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
    1220  # endif
    1221  # if __GLIBC__ >= 2
    1222  _GL_CXXALIASWARN (putc);
    1223  # endif
    1224  #endif
    1225  
    1226  #if @GNULIB_PUTCHAR@
    1227  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
    1228  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1229  #   undef putchar
    1230  #   define putchar rpl_putchar
    1231  #  endif
    1232  _GL_FUNCDECL_RPL (putchar, int, (int c));
    1233  _GL_CXXALIAS_RPL (putchar, int, (int c));
    1234  # else
    1235  _GL_CXXALIAS_SYS (putchar, int, (int c));
    1236  # endif
    1237  # if __GLIBC__ >= 2
    1238  _GL_CXXALIASWARN (putchar);
    1239  # endif
    1240  #endif
    1241  
    1242  #if @GNULIB_PUTS@
    1243  # if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
    1244  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1245  #   undef puts
    1246  #   define puts rpl_puts
    1247  #  endif
    1248  _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
    1249  _GL_CXXALIAS_RPL (puts, int, (const char *string));
    1250  # else
    1251  _GL_CXXALIAS_SYS (puts, int, (const char *string));
    1252  # endif
    1253  # if __GLIBC__ >= 2
    1254  _GL_CXXALIASWARN (puts);
    1255  # endif
    1256  #endif
    1257  
    1258  #if @GNULIB_MDA_PUTW@
    1259  /* On native Windows, map 'putw' to '_putw', so that -loldnames is not
    1260     required.  In C++ with GNULIB_NAMESPACE, avoid differences between
    1261     platforms by defining GNULIB_NAMESPACE::putw always.  */
    1262  # if defined _WIN32 && !defined __CYGWIN__
    1263  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1264  #   undef putw
    1265  #   define putw _putw
    1266  #  endif
    1267  _GL_CXXALIAS_MDA (putw, int, (int w, FILE *restrict stream));
    1268  # else
    1269  #  if @HAVE_DECL_PUTW@
    1270  #   if defined __APPLE__ && defined __MACH__
    1271  /* The presence of the declaration depends on _POSIX_C_SOURCE.  */
    1272  _GL_FUNCDECL_SYS (putw, int, (int w, FILE *restrict stream));
    1273  #   endif
    1274  _GL_CXXALIAS_SYS (putw, int, (int w, FILE *restrict stream));
    1275  #  endif
    1276  # endif
    1277  # if __GLIBC__ >= 2
    1278  _GL_CXXALIASWARN (putw);
    1279  # endif
    1280  #endif
    1281  
    1282  #if @GNULIB_REMOVE@
    1283  # if @REPLACE_REMOVE@
    1284  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1285  #   undef remove
    1286  #   define remove rpl_remove
    1287  #  endif
    1288  _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
    1289  _GL_CXXALIAS_RPL (remove, int, (const char *name));
    1290  # else
    1291  _GL_CXXALIAS_SYS (remove, int, (const char *name));
    1292  # endif
    1293  # if __GLIBC__ >= 2
    1294  _GL_CXXALIASWARN (remove);
    1295  # endif
    1296  #elif defined GNULIB_POSIXCHECK
    1297  # undef remove
    1298  /* Assume remove is always declared.  */
    1299  _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
    1300                   "use gnulib module remove for more portability");
    1301  #endif
    1302  
    1303  #if @GNULIB_RENAME@
    1304  # if @REPLACE_RENAME@
    1305  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1306  #   undef rename
    1307  #   define rename rpl_rename
    1308  #  endif
    1309  _GL_FUNCDECL_RPL (rename, int,
    1310                    (const char *old_filename, const char *new_filename)
    1311                    _GL_ARG_NONNULL ((1, 2)));
    1312  _GL_CXXALIAS_RPL (rename, int,
    1313                    (const char *old_filename, const char *new_filename));
    1314  # else
    1315  _GL_CXXALIAS_SYS (rename, int,
    1316                    (const char *old_filename, const char *new_filename));
    1317  # endif
    1318  # if __GLIBC__ >= 2
    1319  _GL_CXXALIASWARN (rename);
    1320  # endif
    1321  #elif defined GNULIB_POSIXCHECK
    1322  # undef rename
    1323  /* Assume rename is always declared.  */
    1324  _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
    1325                   "use gnulib module rename for more portability");
    1326  #endif
    1327  
    1328  #if @GNULIB_RENAMEAT@
    1329  # if @REPLACE_RENAMEAT@
    1330  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1331  #   undef renameat
    1332  #   define renameat rpl_renameat
    1333  #  endif
    1334  _GL_FUNCDECL_RPL (renameat, int,
    1335                    (int fd1, char const *file1, int fd2, char const *file2)
    1336                    _GL_ARG_NONNULL ((2, 4)));
    1337  _GL_CXXALIAS_RPL (renameat, int,
    1338                    (int fd1, char const *file1, int fd2, char const *file2));
    1339  # else
    1340  #  if !@HAVE_RENAMEAT@
    1341  _GL_FUNCDECL_SYS (renameat, int,
    1342                    (int fd1, char const *file1, int fd2, char const *file2)
    1343                    _GL_ARG_NONNULL ((2, 4)));
    1344  #  endif
    1345  _GL_CXXALIAS_SYS (renameat, int,
    1346                    (int fd1, char const *file1, int fd2, char const *file2));
    1347  # endif
    1348  _GL_CXXALIASWARN (renameat);
    1349  #elif defined GNULIB_POSIXCHECK
    1350  # undef renameat
    1351  # if HAVE_RAW_DECL_RENAMEAT
    1352  _GL_WARN_ON_USE (renameat, "renameat is not portable - "
    1353                   "use gnulib module renameat for portability");
    1354  # endif
    1355  #endif
    1356  
    1357  #if @GNULIB_SCANF@
    1358  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
    1359  #  if defined __GNUC__ || defined __clang__
    1360  #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1361  #    undef scanf
    1362  /* Don't break __attribute__((format(scanf,M,N))).  */
    1363  #    define scanf __scanf__
    1364  #   endif
    1365  _GL_FUNCDECL_RPL_1 (__scanf__, int,
    1366                      (const char *restrict format, ...)
    1367                      __asm__ (@ASM_SYMBOL_PREFIX@
    1368                               _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
    1369                      _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
    1370                      _GL_ARG_NONNULL ((1)));
    1371  _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *restrict format, ...));
    1372  #  else
    1373  #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1374  #    undef scanf
    1375  #    define scanf rpl_scanf
    1376  #   endif
    1377  _GL_FUNCDECL_RPL (scanf, int, (const char *restrict format, ...)
    1378                                _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
    1379                                _GL_ARG_NONNULL ((1)));
    1380  _GL_CXXALIAS_RPL (scanf, int, (const char *restrict format, ...));
    1381  #  endif
    1382  # else
    1383  _GL_CXXALIAS_SYS (scanf, int, (const char *restrict format, ...));
    1384  # endif
    1385  # if __GLIBC__ >= 2
    1386  _GL_CXXALIASWARN (scanf);
    1387  # endif
    1388  #endif
    1389  
    1390  #if @GNULIB_SNPRINTF@
    1391  # if @REPLACE_SNPRINTF@
    1392  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1393  #   define snprintf rpl_snprintf
    1394  #  endif
    1395  #  define GNULIB_overrides_snprintf 1
    1396  _GL_FUNCDECL_RPL (snprintf, int,
    1397                    (char *restrict str, size_t size,
    1398                     const char *restrict format, ...)
    1399                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
    1400                    _GL_ARG_NONNULL ((3)));
    1401  _GL_CXXALIAS_RPL (snprintf, int,
    1402                    (char *restrict str, size_t size,
    1403                     const char *restrict format, ...));
    1404  # else
    1405  #  if !@HAVE_DECL_SNPRINTF@
    1406  _GL_FUNCDECL_SYS (snprintf, int,
    1407                    (char *restrict str, size_t size,
    1408                     const char *restrict format, ...)
    1409                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 4)
    1410                    _GL_ARG_NONNULL ((3)));
    1411  #  endif
    1412  _GL_CXXALIAS_SYS (snprintf, int,
    1413                    (char *restrict str, size_t size,
    1414                     const char *restrict format, ...));
    1415  # endif
    1416  # if __GLIBC__ >= 2
    1417  _GL_CXXALIASWARN (snprintf);
    1418  # endif
    1419  #elif defined GNULIB_POSIXCHECK
    1420  # undef snprintf
    1421  # if HAVE_RAW_DECL_SNPRINTF
    1422  _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
    1423                   "use gnulib module snprintf for portability");
    1424  # endif
    1425  #endif
    1426  
    1427  /* Some people would argue that all sprintf uses should be warned about
    1428     (for example, OpenBSD issues a link warning for it),
    1429     since it can cause security holes due to buffer overruns.
    1430     However, we believe that sprintf can be used safely, and is more
    1431     efficient than snprintf in those safe cases; and as proof of our
    1432     belief, we use sprintf in several gnulib modules.  So this header
    1433     intentionally avoids adding a warning to sprintf except when
    1434     GNULIB_POSIXCHECK is defined.  */
    1435  
    1436  #if @GNULIB_SPRINTF_POSIX@
    1437  # if @REPLACE_SPRINTF@
    1438  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1439  #   define sprintf rpl_sprintf
    1440  #  endif
    1441  #  define GNULIB_overrides_sprintf 1
    1442  _GL_FUNCDECL_RPL (sprintf, int,
    1443                    (char *restrict str, const char *restrict format, ...)
    1444                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
    1445                    _GL_ARG_NONNULL ((1, 2)));
    1446  _GL_CXXALIAS_RPL (sprintf, int,
    1447                    (char *restrict str, const char *restrict format, ...));
    1448  # else
    1449  _GL_CXXALIAS_SYS (sprintf, int,
    1450                    (char *restrict str, const char *restrict format, ...));
    1451  # endif
    1452  # if __GLIBC__ >= 2
    1453  _GL_CXXALIASWARN (sprintf);
    1454  # endif
    1455  #elif defined GNULIB_POSIXCHECK
    1456  # undef sprintf
    1457  /* Assume sprintf is always declared.  */
    1458  _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
    1459                   "use gnulib module sprintf-posix for portable "
    1460                   "POSIX compliance");
    1461  #endif
    1462  
    1463  #if @GNULIB_MDA_TEMPNAM@
    1464  /* On native Windows, map 'tempnam' to '_tempnam', so that -loldnames is not
    1465     required.  In C++ with GNULIB_NAMESPACE, avoid differences between
    1466     platforms by defining GNULIB_NAMESPACE::tempnam always.  */
    1467  # if defined _WIN32 && !defined __CYGWIN__
    1468  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1469  #   undef tempnam
    1470  #   define tempnam _tempnam
    1471  #  endif
    1472  _GL_CXXALIAS_MDA (tempnam, char *, (const char *dir, const char *prefix));
    1473  # else
    1474  _GL_CXXALIAS_SYS (tempnam, char *, (const char *dir, const char *prefix));
    1475  # endif
    1476  _GL_CXXALIASWARN (tempnam);
    1477  #endif
    1478  
    1479  #if @GNULIB_TMPFILE@
    1480  # if @REPLACE_TMPFILE@
    1481  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1482  #   define tmpfile rpl_tmpfile
    1483  #  endif
    1484  _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)
    1485                                     _GL_ATTRIBUTE_DEALLOC (fclose, 1)
    1486                                     _GL_ATTRIBUTE_MALLOC);
    1487  _GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
    1488  # else
    1489  #  if __GNUC__ >= 11
    1490  /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose.  */
    1491  _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
    1492                                     _GL_ATTRIBUTE_DEALLOC (fclose, 1)
    1493                                     _GL_ATTRIBUTE_MALLOC);
    1494  #  endif
    1495  _GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
    1496  # endif
    1497  # if __GLIBC__ >= 2
    1498  _GL_CXXALIASWARN (tmpfile);
    1499  # endif
    1500  #else
    1501  # if @GNULIB_FCLOSE@ && __GNUC__ >= 11 && !defined tmpfile
    1502  /* For -Wmismatched-dealloc: Associate tmpfile with fclose or rpl_fclose.  */
    1503  _GL_FUNCDECL_SYS (tmpfile, FILE *, (void)
    1504                                     _GL_ATTRIBUTE_DEALLOC (fclose, 1)
    1505                                     _GL_ATTRIBUTE_MALLOC);
    1506  # endif
    1507  # if defined GNULIB_POSIXCHECK
    1508  #  undef tmpfile
    1509  #  if HAVE_RAW_DECL_TMPFILE
    1510  _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
    1511                   "use gnulib module tmpfile for portability");
    1512  #  endif
    1513  # endif
    1514  #endif
    1515  
    1516  #if @GNULIB_VASPRINTF@
    1517  /* Write formatted output to a string dynamically allocated with malloc().
    1518     If the memory allocation succeeds, store the address of the string in
    1519     *RESULT and return the number of resulting bytes, excluding the trailing
    1520     NUL.  Upon memory allocation error, or some other error, return -1.  */
    1521  # if @REPLACE_VASPRINTF@
    1522  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1523  #   define asprintf rpl_asprintf
    1524  #  endif
    1525  #  define GNULIB_overrides_asprintf
    1526  _GL_FUNCDECL_RPL (asprintf, int,
    1527                    (char **result, const char *format, ...)
    1528                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
    1529                    _GL_ARG_NONNULL ((1, 2)));
    1530  _GL_CXXALIAS_RPL (asprintf, int,
    1531                    (char **result, const char *format, ...));
    1532  # else
    1533  #  if !@HAVE_VASPRINTF@
    1534  _GL_FUNCDECL_SYS (asprintf, int,
    1535                    (char **result, const char *format, ...)
    1536                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 3)
    1537                    _GL_ARG_NONNULL ((1, 2)));
    1538  #  endif
    1539  _GL_CXXALIAS_SYS (asprintf, int,
    1540                    (char **result, const char *format, ...));
    1541  # endif
    1542  _GL_CXXALIASWARN (asprintf);
    1543  # if @REPLACE_VASPRINTF@
    1544  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1545  #   define vasprintf rpl_vasprintf
    1546  #  endif
    1547  #  define GNULIB_overrides_vasprintf 1
    1548  _GL_FUNCDECL_RPL (vasprintf, int,
    1549                    (char **result, const char *format, va_list args)
    1550                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1551                    _GL_ARG_NONNULL ((1, 2)));
    1552  _GL_CXXALIAS_RPL (vasprintf, int,
    1553                    (char **result, const char *format, va_list args));
    1554  # else
    1555  #  if !@HAVE_VASPRINTF@
    1556  _GL_FUNCDECL_SYS (vasprintf, int,
    1557                    (char **result, const char *format, va_list args)
    1558                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1559                    _GL_ARG_NONNULL ((1, 2)));
    1560  #  endif
    1561  _GL_CXXALIAS_SYS (vasprintf, int,
    1562                    (char **result, const char *format, va_list args));
    1563  # endif
    1564  _GL_CXXALIASWARN (vasprintf);
    1565  #endif
    1566  
    1567  #if @GNULIB_VDPRINTF@
    1568  # if @REPLACE_VDPRINTF@
    1569  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1570  #   define vdprintf rpl_vdprintf
    1571  #  endif
    1572  _GL_FUNCDECL_RPL (vdprintf, int,
    1573                    (int fd, const char *restrict format, va_list args)
    1574                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1575                    _GL_ARG_NONNULL ((2)));
    1576  _GL_CXXALIAS_RPL (vdprintf, int,
    1577                    (int fd, const char *restrict format, va_list args));
    1578  # else
    1579  #  if !@HAVE_VDPRINTF@
    1580  _GL_FUNCDECL_SYS (vdprintf, int,
    1581                    (int fd, const char *restrict format, va_list args)
    1582                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1583                    _GL_ARG_NONNULL ((2)));
    1584  #  endif
    1585  /* Need to cast, because on Solaris, the third parameter will likely be
    1586                                                      __va_list args.  */
    1587  _GL_CXXALIAS_SYS_CAST (vdprintf, int,
    1588                         (int fd, const char *restrict format, va_list args));
    1589  # endif
    1590  # if __GLIBC__ >= 2
    1591  _GL_CXXALIASWARN (vdprintf);
    1592  # endif
    1593  #elif defined GNULIB_POSIXCHECK
    1594  # undef vdprintf
    1595  # if HAVE_RAW_DECL_VDPRINTF
    1596  _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
    1597                   "use gnulib module vdprintf for portability");
    1598  # endif
    1599  #endif
    1600  
    1601  #if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
    1602  # if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
    1603       || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
    1604  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1605  #   define vfprintf rpl_vfprintf
    1606  #  endif
    1607  #  define GNULIB_overrides_vfprintf 1
    1608  #  if @GNULIB_VFPRINTF_POSIX@
    1609  _GL_FUNCDECL_RPL (vfprintf, int,
    1610                    (FILE *restrict fp,
    1611                     const char *restrict format, va_list args)
    1612                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1613                    _GL_ARG_NONNULL ((1, 2)));
    1614  #  else
    1615  _GL_FUNCDECL_RPL (vfprintf, int,
    1616                    (FILE *restrict fp,
    1617                     const char *restrict format, va_list args)
    1618                    _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
    1619                    _GL_ARG_NONNULL ((1, 2)));
    1620  #  endif
    1621  _GL_CXXALIAS_RPL (vfprintf, int,
    1622                    (FILE *restrict fp,
    1623                     const char *restrict format, va_list args));
    1624  # else
    1625  /* Need to cast, because on Solaris, the third parameter is
    1626                                                        __va_list args
    1627     and GCC's fixincludes did not change this to __gnuc_va_list.  */
    1628  _GL_CXXALIAS_SYS_CAST (vfprintf, int,
    1629                         (FILE *restrict fp,
    1630                          const char *restrict format, va_list args));
    1631  # endif
    1632  # if __GLIBC__ >= 2
    1633  _GL_CXXALIASWARN (vfprintf);
    1634  # endif
    1635  #endif
    1636  #if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
    1637  # if !GNULIB_overrides_vfprintf
    1638  #  undef vfprintf
    1639  # endif
    1640  /* Assume vfprintf is always declared.  */
    1641  _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
    1642                   "use gnulib module vfprintf-posix for portable "
    1643                        "POSIX compliance");
    1644  #endif
    1645  
    1646  #if @GNULIB_VFSCANF@
    1647  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
    1648  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1649  #   undef vfscanf
    1650  #   define vfscanf rpl_vfscanf
    1651  #  endif
    1652  _GL_FUNCDECL_RPL (vfscanf, int,
    1653                    (FILE *restrict stream,
    1654                     const char *restrict format, va_list args)
    1655                    _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
    1656                    _GL_ARG_NONNULL ((1, 2)));
    1657  _GL_CXXALIAS_RPL (vfscanf, int,
    1658                    (FILE *restrict stream,
    1659                     const char *restrict format, va_list args));
    1660  # else
    1661  _GL_CXXALIAS_SYS (vfscanf, int,
    1662                    (FILE *restrict stream,
    1663                     const char *restrict format, va_list args));
    1664  # endif
    1665  # if __GLIBC__ >= 2
    1666  _GL_CXXALIASWARN (vfscanf);
    1667  # endif
    1668  #endif
    1669  
    1670  #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
    1671  # if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
    1672       || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
    1673  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1674  #   define vprintf rpl_vprintf
    1675  #  endif
    1676  #  define GNULIB_overrides_vprintf 1
    1677  #  if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
    1678  _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
    1679                                  _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (1, 0)
    1680                                  _GL_ARG_NONNULL ((1)));
    1681  #  else
    1682  _GL_FUNCDECL_RPL (vprintf, int, (const char *restrict format, va_list args)
    1683                                  _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
    1684                                  _GL_ARG_NONNULL ((1)));
    1685  #  endif
    1686  _GL_CXXALIAS_RPL (vprintf, int, (const char *restrict format, va_list args));
    1687  # else
    1688  /* Need to cast, because on Solaris, the second parameter is
    1689                                                            __va_list args
    1690     and GCC's fixincludes did not change this to __gnuc_va_list.  */
    1691  _GL_CXXALIAS_SYS_CAST (vprintf, int,
    1692                         (const char *restrict format, va_list args));
    1693  # endif
    1694  # if __GLIBC__ >= 2
    1695  _GL_CXXALIASWARN (vprintf);
    1696  # endif
    1697  #endif
    1698  #if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
    1699  # if !GNULIB_overrides_vprintf
    1700  #  undef vprintf
    1701  # endif
    1702  /* Assume vprintf is always declared.  */
    1703  _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
    1704                   "use gnulib module vprintf-posix for portable "
    1705                   "POSIX compliance");
    1706  #endif
    1707  
    1708  #if @GNULIB_VSCANF@
    1709  # if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
    1710  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1711  #   undef vscanf
    1712  #   define vscanf rpl_vscanf
    1713  #  endif
    1714  _GL_FUNCDECL_RPL (vscanf, int, (const char *restrict format, va_list args)
    1715                                 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
    1716                                 _GL_ARG_NONNULL ((1)));
    1717  _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
    1718  # else
    1719  _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
    1720  # endif
    1721  # if __GLIBC__ >= 2
    1722  _GL_CXXALIASWARN (vscanf);
    1723  # endif
    1724  #endif
    1725  
    1726  #if @GNULIB_VSNPRINTF@
    1727  # if @REPLACE_VSNPRINTF@
    1728  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1729  #   define vsnprintf rpl_vsnprintf
    1730  #  endif
    1731  #  define GNULIB_overrides_vsnprintf 1
    1732  _GL_FUNCDECL_RPL (vsnprintf, int,
    1733                    (char *restrict str, size_t size,
    1734                     const char *restrict format, va_list args)
    1735                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
    1736                    _GL_ARG_NONNULL ((3)));
    1737  _GL_CXXALIAS_RPL (vsnprintf, int,
    1738                    (char *restrict str, size_t size,
    1739                     const char *restrict format, va_list args));
    1740  # else
    1741  #  if !@HAVE_DECL_VSNPRINTF@
    1742  _GL_FUNCDECL_SYS (vsnprintf, int,
    1743                    (char *restrict str, size_t size,
    1744                     const char *restrict format, va_list args)
    1745                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (3, 0)
    1746                    _GL_ARG_NONNULL ((3)));
    1747  #  endif
    1748  _GL_CXXALIAS_SYS (vsnprintf, int,
    1749                    (char *restrict str, size_t size,
    1750                     const char *restrict format, va_list args));
    1751  # endif
    1752  # if __GLIBC__ >= 2
    1753  _GL_CXXALIASWARN (vsnprintf);
    1754  # endif
    1755  #elif defined GNULIB_POSIXCHECK
    1756  # undef vsnprintf
    1757  # if HAVE_RAW_DECL_VSNPRINTF
    1758  _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
    1759                   "use gnulib module vsnprintf for portability");
    1760  # endif
    1761  #endif
    1762  
    1763  #if @GNULIB_VSPRINTF_POSIX@
    1764  # if @REPLACE_VSPRINTF@
    1765  #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
    1766  #   define vsprintf rpl_vsprintf
    1767  #  endif
    1768  #  define GNULIB_overrides_vsprintf 1
    1769  _GL_FUNCDECL_RPL (vsprintf, int,
    1770                    (char *restrict str,
    1771                     const char *restrict format, va_list args)
    1772                    _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD (2, 0)
    1773                    _GL_ARG_NONNULL ((1, 2)));
    1774  _GL_CXXALIAS_RPL (vsprintf, int,
    1775                    (char *restrict str,
    1776                     const char *restrict format, va_list args));
    1777  # else
    1778  /* Need to cast, because on Solaris, the third parameter is
    1779                                                         __va_list args
    1780     and GCC's fixincludes did not change this to __gnuc_va_list.  */
    1781  _GL_CXXALIAS_SYS_CAST (vsprintf, int,
    1782                         (char *restrict str,
    1783                          const char *restrict format, va_list args));
    1784  # endif
    1785  # if __GLIBC__ >= 2
    1786  _GL_CXXALIASWARN (vsprintf);
    1787  # endif
    1788  #elif defined GNULIB_POSIXCHECK
    1789  # undef vsprintf
    1790  /* Assume vsprintf is always declared.  */
    1791  _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
    1792                   "use gnulib module vsprintf-posix for portable "
    1793                        "POSIX compliance");
    1794  #endif
    1795  
    1796  #endif /* _@GUARD_PREFIX@_STDIO_H */
    1797  #endif /* _@GUARD_PREFIX@_STDIO_H */
    1798  #endif