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