stdio.in.h 58 KB

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