stdio.in.h 61 KB

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