stdio.in.h 61 KB

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