151ddd709SJohn Marino /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 251ddd709SJohn Marino /* A GNU-like <stdio.h>. 351ddd709SJohn Marino 4*4ce1b016SDaniel Fojt Copyright (C) 2004, 2007-2020 Free Software Foundation, Inc. 551ddd709SJohn Marino 651ddd709SJohn Marino This program is free software; you can redistribute it and/or modify 751ddd709SJohn Marino it under the terms of the GNU General Public License as published by 851ddd709SJohn Marino the Free Software Foundation; either version 3, or (at your option) 951ddd709SJohn Marino any later version. 1051ddd709SJohn Marino 1151ddd709SJohn Marino This program is distributed in the hope that it will be useful, 1251ddd709SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of 1351ddd709SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1451ddd709SJohn Marino GNU General Public License for more details. 1551ddd709SJohn Marino 1651ddd709SJohn Marino You should have received a copy of the GNU General Public License 17*4ce1b016SDaniel Fojt along with this program; if not, see <https://www.gnu.org/licenses/>. */ 1851ddd709SJohn Marino 1951ddd709SJohn Marino #if __GNUC__ >= 3 2051ddd709SJohn Marino #pragma GCC system_header 2151ddd709SJohn Marino #endif 2251ddd709SJohn Marino 2351ddd709SJohn Marino 2451ddd709SJohn Marino #if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H 2551ddd709SJohn Marino /* Special invocation convention: 2651ddd709SJohn Marino - Inside glibc header files. 2751ddd709SJohn Marino - On OSF/1 5.1 we have a sequence of nested includes 2851ddd709SJohn Marino <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> -> 2951ddd709SJohn Marino <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>. 3051ddd709SJohn Marino In this situation, the functions are not yet declared, therefore we cannot 3151ddd709SJohn Marino provide the C++ aliases. */ 3251ddd709SJohn Marino 3351ddd709SJohn Marino #include_next <stdio.h> 3451ddd709SJohn Marino 3551ddd709SJohn Marino #else 3651ddd709SJohn Marino /* Normal invocation convention. */ 3751ddd709SJohn Marino 3851ddd709SJohn Marino #ifndef _GL_STDIO_H 3951ddd709SJohn Marino 4051ddd709SJohn Marino #define _GL_ALREADY_INCLUDING_STDIO_H 4151ddd709SJohn Marino 4251ddd709SJohn Marino /* The include_next requires a split double-inclusion guard. */ 4351ddd709SJohn Marino #include_next <stdio.h> 4451ddd709SJohn Marino 4551ddd709SJohn Marino #undef _GL_ALREADY_INCLUDING_STDIO_H 4651ddd709SJohn Marino 4751ddd709SJohn Marino #ifndef _GL_STDIO_H 4851ddd709SJohn Marino #define _GL_STDIO_H 4951ddd709SJohn Marino 5051ddd709SJohn Marino /* Get va_list. Needed on many systems, including glibc 2.8. */ 5151ddd709SJohn Marino #include <stdarg.h> 5251ddd709SJohn Marino 5351ddd709SJohn Marino #include <stddef.h> 5451ddd709SJohn Marino 5551ddd709SJohn Marino /* Get off_t and ssize_t. Needed on many systems, including glibc 2.8 5651ddd709SJohn Marino and eglibc 2.11.2. 5751ddd709SJohn Marino May also define off_t to a 64-bit type on native Windows. */ 5851ddd709SJohn Marino #include <sys/types.h> 5951ddd709SJohn Marino 6051ddd709SJohn Marino /* The __attribute__ feature is available in gcc versions 2.5 and later. 6151ddd709SJohn Marino The __-protected variants of the attributes 'format' and 'printf' are 6251ddd709SJohn Marino accepted by gcc versions 2.6.4 (effectively 2.7) and later. 6351ddd709SJohn Marino We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because 6451ddd709SJohn Marino gnulib and libintl do '#define printf __printf__' when they override 6551ddd709SJohn Marino the 'printf' function. */ 6651ddd709SJohn Marino #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 6751ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 6851ddd709SJohn Marino #else 6951ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ 7051ddd709SJohn Marino #endif 7151ddd709SJohn Marino 7251ddd709SJohn Marino /* _GL_ATTRIBUTE_FORMAT_PRINTF 7351ddd709SJohn Marino indicates to GCC that the function takes a format string and arguments, 7451ddd709SJohn Marino where the format string directives are the ones standardized by ISO C99 7551ddd709SJohn Marino and POSIX. */ 7651ddd709SJohn Marino #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 7751ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 7851ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument)) 7951ddd709SJohn Marino #else 8051ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 8151ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) 8251ddd709SJohn Marino #endif 8351ddd709SJohn Marino 8451ddd709SJohn Marino /* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF, 8551ddd709SJohn Marino except that it indicates to GCC that the supported format string directives 8651ddd709SJohn Marino are the ones of the system printf(), rather than the ones standardized by 8751ddd709SJohn Marino ISO C99 and POSIX. */ 88cf51209aSJohn Marino #if GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU 89cf51209aSJohn Marino # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ 90cf51209aSJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (formatstring_parameter, first_argument) 91cf51209aSJohn Marino #else 9251ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \ 9351ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument)) 94cf51209aSJohn Marino #endif 9551ddd709SJohn Marino 9651ddd709SJohn Marino /* _GL_ATTRIBUTE_FORMAT_SCANF 9751ddd709SJohn Marino indicates to GCC that the function takes a format string and arguments, 9851ddd709SJohn Marino where the format string directives are the ones standardized by ISO C99 9951ddd709SJohn Marino and POSIX. */ 10051ddd709SJohn Marino #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 10151ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ 10251ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument)) 10351ddd709SJohn Marino #else 10451ddd709SJohn Marino # define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \ 10551ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) 10651ddd709SJohn Marino #endif 10751ddd709SJohn Marino 10851ddd709SJohn Marino /* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF, 10951ddd709SJohn Marino except that it indicates to GCC that the supported format string directives 11051ddd709SJohn Marino are the ones of the system scanf(), rather than the ones standardized by 11151ddd709SJohn Marino ISO C99 and POSIX. */ 11251ddd709SJohn Marino #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ 11351ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) 11451ddd709SJohn Marino 115*4ce1b016SDaniel Fojt /* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>. */ 11651ddd709SJohn Marino /* But in any case avoid namespace pollution on glibc systems. */ 117*4ce1b016SDaniel Fojt #if (0 || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \ 11851ddd709SJohn Marino && ! defined __GLIBC__ 11951ddd709SJohn Marino # include <unistd.h> 12051ddd709SJohn Marino #endif 12151ddd709SJohn Marino 122*4ce1b016SDaniel Fojt /* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>. */ 123*4ce1b016SDaniel Fojt /* But in any case avoid namespace pollution on glibc systems. */ 124*4ce1b016SDaniel Fojt #if (0 || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ 125*4ce1b016SDaniel Fojt && ! defined __GLIBC__ 126*4ce1b016SDaniel Fojt # include <sys/stat.h> 127*4ce1b016SDaniel Fojt #endif 128*4ce1b016SDaniel Fojt 129*4ce1b016SDaniel Fojt /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>. We must include 130*4ce1b016SDaniel Fojt it before we #define perror rpl_perror. */ 131*4ce1b016SDaniel Fojt /* But in any case avoid namespace pollution on glibc systems. */ 132*4ce1b016SDaniel Fojt #if (IN_GREP_GNULIB_TESTS || defined GNULIB_POSIXCHECK) \ 133*4ce1b016SDaniel Fojt && (defined _WIN32 && ! defined __CYGWIN__) \ 134*4ce1b016SDaniel Fojt && ! defined __GLIBC__ 135*4ce1b016SDaniel Fojt # include <stdlib.h> 136*4ce1b016SDaniel Fojt #endif 137*4ce1b016SDaniel Fojt 138*4ce1b016SDaniel Fojt /* MSVC declares 'remove' in <io.h>, not in <stdio.h>. We must include 139*4ce1b016SDaniel Fojt it before we #define remove rpl_remove. */ 140*4ce1b016SDaniel Fojt /* MSVC declares 'rename' in <io.h>, not in <stdio.h>. We must include 141*4ce1b016SDaniel Fojt it before we #define rename rpl_rename. */ 142*4ce1b016SDaniel Fojt /* But in any case avoid namespace pollution on glibc systems. */ 143*4ce1b016SDaniel Fojt #if (0 || 0 || defined GNULIB_POSIXCHECK) \ 144*4ce1b016SDaniel Fojt && (defined _WIN32 && ! defined __CYGWIN__) \ 145*4ce1b016SDaniel Fojt && ! defined __GLIBC__ 146*4ce1b016SDaniel Fojt # include <io.h> 147*4ce1b016SDaniel Fojt #endif 148*4ce1b016SDaniel Fojt 14951ddd709SJohn Marino 15051ddd709SJohn Marino /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 151*4ce1b016SDaniel Fojt /* C++ compatible function declaration macros. 152*4ce1b016SDaniel Fojt Copyright (C) 2010-2020 Free Software Foundation, Inc. 153*4ce1b016SDaniel Fojt 154*4ce1b016SDaniel Fojt This program is free software: you can redistribute it and/or modify it 155*4ce1b016SDaniel Fojt under the terms of the GNU General Public License as published 156*4ce1b016SDaniel Fojt by the Free Software Foundation; either version 3 of the License, or 157*4ce1b016SDaniel Fojt (at your option) any later version. 158*4ce1b016SDaniel Fojt 159*4ce1b016SDaniel Fojt This program is distributed in the hope that it will be useful, 160*4ce1b016SDaniel Fojt but WITHOUT ANY WARRANTY; without even the implied warranty of 161*4ce1b016SDaniel Fojt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 162*4ce1b016SDaniel Fojt General Public License for more details. 163*4ce1b016SDaniel Fojt 164*4ce1b016SDaniel Fojt You should have received a copy of the GNU General Public License 165*4ce1b016SDaniel Fojt along with this program. If not, see <https://www.gnu.org/licenses/>. */ 166*4ce1b016SDaniel Fojt 16751ddd709SJohn Marino #ifndef _GL_CXXDEFS_H 16851ddd709SJohn Marino #define _GL_CXXDEFS_H 16951ddd709SJohn Marino 170*4ce1b016SDaniel Fojt /* Begin/end the GNULIB_NAMESPACE namespace. */ 171*4ce1b016SDaniel Fojt #if defined __cplusplus && defined GNULIB_NAMESPACE 172*4ce1b016SDaniel Fojt # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 173*4ce1b016SDaniel Fojt # define _GL_END_NAMESPACE } 174*4ce1b016SDaniel Fojt #else 175*4ce1b016SDaniel Fojt # define _GL_BEGIN_NAMESPACE 176*4ce1b016SDaniel Fojt # define _GL_END_NAMESPACE 177*4ce1b016SDaniel Fojt #endif 178*4ce1b016SDaniel Fojt 17951ddd709SJohn Marino /* The three most frequent use cases of these macros are: 18051ddd709SJohn Marino 18151ddd709SJohn Marino * For providing a substitute for a function that is missing on some 18251ddd709SJohn Marino platforms, but is declared and works fine on the platforms on which 18351ddd709SJohn Marino it exists: 18451ddd709SJohn Marino 18551ddd709SJohn Marino #if @GNULIB_FOO@ 18651ddd709SJohn Marino # if !@HAVE_FOO@ 18751ddd709SJohn Marino _GL_FUNCDECL_SYS (foo, ...); 18851ddd709SJohn Marino # endif 18951ddd709SJohn Marino _GL_CXXALIAS_SYS (foo, ...); 19051ddd709SJohn Marino _GL_CXXALIASWARN (foo); 19151ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 19251ddd709SJohn Marino ... 19351ddd709SJohn Marino #endif 19451ddd709SJohn Marino 19551ddd709SJohn Marino * For providing a replacement for a function that exists on all platforms, 19651ddd709SJohn Marino but is broken/insufficient and needs to be replaced on some platforms: 19751ddd709SJohn Marino 19851ddd709SJohn Marino #if @GNULIB_FOO@ 19951ddd709SJohn Marino # if @REPLACE_FOO@ 20051ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 20151ddd709SJohn Marino # undef foo 20251ddd709SJohn Marino # define foo rpl_foo 20351ddd709SJohn Marino # endif 20451ddd709SJohn Marino _GL_FUNCDECL_RPL (foo, ...); 20551ddd709SJohn Marino _GL_CXXALIAS_RPL (foo, ...); 20651ddd709SJohn Marino # else 20751ddd709SJohn Marino _GL_CXXALIAS_SYS (foo, ...); 20851ddd709SJohn Marino # endif 20951ddd709SJohn Marino _GL_CXXALIASWARN (foo); 21051ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 21151ddd709SJohn Marino ... 21251ddd709SJohn Marino #endif 21351ddd709SJohn Marino 21451ddd709SJohn Marino * For providing a replacement for a function that exists on some platforms 21551ddd709SJohn Marino but is broken/insufficient and needs to be replaced on some of them and 21651ddd709SJohn Marino is additionally either missing or undeclared on some other platforms: 21751ddd709SJohn Marino 21851ddd709SJohn Marino #if @GNULIB_FOO@ 21951ddd709SJohn Marino # if @REPLACE_FOO@ 22051ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 22151ddd709SJohn Marino # undef foo 22251ddd709SJohn Marino # define foo rpl_foo 22351ddd709SJohn Marino # endif 22451ddd709SJohn Marino _GL_FUNCDECL_RPL (foo, ...); 22551ddd709SJohn Marino _GL_CXXALIAS_RPL (foo, ...); 22651ddd709SJohn Marino # else 22751ddd709SJohn Marino # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 22851ddd709SJohn Marino _GL_FUNCDECL_SYS (foo, ...); 22951ddd709SJohn Marino # endif 23051ddd709SJohn Marino _GL_CXXALIAS_SYS (foo, ...); 23151ddd709SJohn Marino # endif 23251ddd709SJohn Marino _GL_CXXALIASWARN (foo); 23351ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 23451ddd709SJohn Marino ... 23551ddd709SJohn Marino #endif 23651ddd709SJohn Marino */ 23751ddd709SJohn Marino 23851ddd709SJohn Marino /* _GL_EXTERN_C declaration; 23951ddd709SJohn Marino performs the declaration with C linkage. */ 24051ddd709SJohn Marino #if defined __cplusplus 24151ddd709SJohn Marino # define _GL_EXTERN_C extern "C" 24251ddd709SJohn Marino #else 24351ddd709SJohn Marino # define _GL_EXTERN_C extern 24451ddd709SJohn Marino #endif 24551ddd709SJohn Marino 24651ddd709SJohn Marino /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 24751ddd709SJohn Marino declares a replacement function, named rpl_func, with the given prototype, 24851ddd709SJohn Marino consisting of return type, parameters, and attributes. 24951ddd709SJohn Marino Example: 25051ddd709SJohn Marino _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 25151ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 25251ddd709SJohn Marino */ 25351ddd709SJohn Marino #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 25451ddd709SJohn Marino _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 25551ddd709SJohn Marino #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 25651ddd709SJohn Marino _GL_EXTERN_C rettype rpl_func parameters_and_attributes 25751ddd709SJohn Marino 25851ddd709SJohn Marino /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 25951ddd709SJohn Marino declares the system function, named func, with the given prototype, 26051ddd709SJohn Marino consisting of return type, parameters, and attributes. 26151ddd709SJohn Marino Example: 26251ddd709SJohn Marino _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 26351ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 26451ddd709SJohn Marino */ 26551ddd709SJohn Marino #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 26651ddd709SJohn Marino _GL_EXTERN_C rettype func parameters_and_attributes 26751ddd709SJohn Marino 26851ddd709SJohn Marino /* _GL_CXXALIAS_RPL (func, rettype, parameters); 26951ddd709SJohn Marino declares a C++ alias called GNULIB_NAMESPACE::func 27051ddd709SJohn Marino that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 27151ddd709SJohn Marino Example: 27251ddd709SJohn Marino _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 273*4ce1b016SDaniel Fojt 274*4ce1b016SDaniel Fojt Wrapping rpl_func in an object with an inline conversion operator 275*4ce1b016SDaniel Fojt avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 276*4ce1b016SDaniel Fojt actually used in the program. */ 27751ddd709SJohn Marino #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 27851ddd709SJohn Marino _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 27951ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 28051ddd709SJohn Marino # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 28151ddd709SJohn Marino namespace GNULIB_NAMESPACE \ 28251ddd709SJohn Marino { \ 283*4ce1b016SDaniel Fojt static const struct _gl_ ## func ## _wrapper \ 284*4ce1b016SDaniel Fojt { \ 285*4ce1b016SDaniel Fojt typedef rettype (*type) parameters; \ 286*4ce1b016SDaniel Fojt \ 287*4ce1b016SDaniel Fojt inline operator type () const \ 288*4ce1b016SDaniel Fojt { \ 289*4ce1b016SDaniel Fojt return ::rpl_func; \ 290*4ce1b016SDaniel Fojt } \ 291*4ce1b016SDaniel Fojt } func = {}; \ 29251ddd709SJohn Marino } \ 29351ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 29451ddd709SJohn Marino #else 29551ddd709SJohn Marino # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 29651ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 29751ddd709SJohn Marino #endif 29851ddd709SJohn Marino 29951ddd709SJohn Marino /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 30051ddd709SJohn Marino is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 30151ddd709SJohn Marino except that the C function rpl_func may have a slightly different 30251ddd709SJohn Marino declaration. A cast is used to silence the "invalid conversion" error 30351ddd709SJohn Marino that would otherwise occur. */ 30451ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 30551ddd709SJohn Marino # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 30651ddd709SJohn Marino namespace GNULIB_NAMESPACE \ 30751ddd709SJohn Marino { \ 308*4ce1b016SDaniel Fojt static const struct _gl_ ## func ## _wrapper \ 309*4ce1b016SDaniel Fojt { \ 310*4ce1b016SDaniel Fojt typedef rettype (*type) parameters; \ 311*4ce1b016SDaniel Fojt \ 312*4ce1b016SDaniel Fojt inline operator type () const \ 313*4ce1b016SDaniel Fojt { \ 314*4ce1b016SDaniel Fojt return reinterpret_cast<type>(::rpl_func); \ 315*4ce1b016SDaniel Fojt } \ 316*4ce1b016SDaniel Fojt } func = {}; \ 31751ddd709SJohn Marino } \ 31851ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 31951ddd709SJohn Marino #else 32051ddd709SJohn Marino # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 32151ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 32251ddd709SJohn Marino #endif 32351ddd709SJohn Marino 32451ddd709SJohn Marino /* _GL_CXXALIAS_SYS (func, rettype, parameters); 32551ddd709SJohn Marino declares a C++ alias called GNULIB_NAMESPACE::func 32651ddd709SJohn Marino that redirects to the system provided function func, if GNULIB_NAMESPACE 32751ddd709SJohn Marino is defined. 32851ddd709SJohn Marino Example: 32951ddd709SJohn Marino _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 330*4ce1b016SDaniel Fojt 331*4ce1b016SDaniel Fojt Wrapping func in an object with an inline conversion operator 332*4ce1b016SDaniel Fojt avoids a reference to func unless GNULIB_NAMESPACE::func is 333*4ce1b016SDaniel Fojt actually used in the program. */ 33451ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 33551ddd709SJohn Marino # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 33651ddd709SJohn Marino namespace GNULIB_NAMESPACE \ 33751ddd709SJohn Marino { \ 338*4ce1b016SDaniel Fojt static const struct _gl_ ## func ## _wrapper \ 339*4ce1b016SDaniel Fojt { \ 340*4ce1b016SDaniel Fojt typedef rettype (*type) parameters; \ 341*4ce1b016SDaniel Fojt \ 342*4ce1b016SDaniel Fojt inline operator type () const \ 343*4ce1b016SDaniel Fojt { \ 344*4ce1b016SDaniel Fojt return ::func; \ 345*4ce1b016SDaniel Fojt } \ 346*4ce1b016SDaniel Fojt } func = {}; \ 34751ddd709SJohn Marino } \ 34851ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 34951ddd709SJohn Marino #else 35051ddd709SJohn Marino # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 35151ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 35251ddd709SJohn Marino #endif 35351ddd709SJohn Marino 35451ddd709SJohn Marino /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 35551ddd709SJohn Marino is like _GL_CXXALIAS_SYS (func, rettype, parameters); 35651ddd709SJohn Marino except that the C function func may have a slightly different declaration. 35751ddd709SJohn Marino A cast is used to silence the "invalid conversion" error that would 35851ddd709SJohn Marino otherwise occur. */ 35951ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 36051ddd709SJohn Marino # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 36151ddd709SJohn Marino namespace GNULIB_NAMESPACE \ 36251ddd709SJohn Marino { \ 363*4ce1b016SDaniel Fojt static const struct _gl_ ## func ## _wrapper \ 364*4ce1b016SDaniel Fojt { \ 365*4ce1b016SDaniel Fojt typedef rettype (*type) parameters; \ 366*4ce1b016SDaniel Fojt \ 367*4ce1b016SDaniel Fojt inline operator type () const \ 368*4ce1b016SDaniel Fojt { \ 369*4ce1b016SDaniel Fojt return reinterpret_cast<type>(::func); \ 370*4ce1b016SDaniel Fojt } \ 371*4ce1b016SDaniel Fojt } func = {}; \ 37251ddd709SJohn Marino } \ 37351ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 37451ddd709SJohn Marino #else 37551ddd709SJohn Marino # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 37651ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 37751ddd709SJohn Marino #endif 37851ddd709SJohn Marino 37951ddd709SJohn Marino /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 38051ddd709SJohn Marino is like _GL_CXXALIAS_SYS (func, rettype, parameters); 38151ddd709SJohn Marino except that the C function is picked among a set of overloaded functions, 38251ddd709SJohn Marino namely the one with rettype2 and parameters2. Two consecutive casts 38351ddd709SJohn Marino are used to silence the "cannot find a match" and "invalid conversion" 38451ddd709SJohn Marino errors that would otherwise occur. */ 38551ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 38651ddd709SJohn Marino /* The outer cast must be a reinterpret_cast. 38751ddd709SJohn Marino The inner cast: When the function is defined as a set of overloaded 38851ddd709SJohn Marino functions, it works as a static_cast<>, choosing the designated variant. 38951ddd709SJohn Marino When the function is defined as a single variant, it works as a 39051ddd709SJohn Marino reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 39151ddd709SJohn Marino # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 39251ddd709SJohn Marino namespace GNULIB_NAMESPACE \ 39351ddd709SJohn Marino { \ 394*4ce1b016SDaniel Fojt static const struct _gl_ ## func ## _wrapper \ 395*4ce1b016SDaniel Fojt { \ 396*4ce1b016SDaniel Fojt typedef rettype (*type) parameters; \ 397*4ce1b016SDaniel Fojt \ 398*4ce1b016SDaniel Fojt inline operator type () const \ 399*4ce1b016SDaniel Fojt { \ 400*4ce1b016SDaniel Fojt return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 401*4ce1b016SDaniel Fojt } \ 402*4ce1b016SDaniel Fojt } func = {}; \ 40351ddd709SJohn Marino } \ 40451ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 40551ddd709SJohn Marino #else 40651ddd709SJohn Marino # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 40751ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 40851ddd709SJohn Marino #endif 40951ddd709SJohn Marino 41051ddd709SJohn Marino /* _GL_CXXALIASWARN (func); 41151ddd709SJohn Marino causes a warning to be emitted when ::func is used but not when 41251ddd709SJohn Marino GNULIB_NAMESPACE::func is used. func must be defined without overloaded 41351ddd709SJohn Marino variants. */ 41451ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 41551ddd709SJohn Marino # define _GL_CXXALIASWARN(func) \ 41651ddd709SJohn Marino _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 41751ddd709SJohn Marino # define _GL_CXXALIASWARN_1(func,namespace) \ 41851ddd709SJohn Marino _GL_CXXALIASWARN_2 (func, namespace) 419*4ce1b016SDaniel Fojt /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 42051ddd709SJohn Marino we enable the warning only when not optimizing. */ 42151ddd709SJohn Marino # if !__OPTIMIZE__ 42251ddd709SJohn Marino # define _GL_CXXALIASWARN_2(func,namespace) \ 42351ddd709SJohn Marino _GL_WARN_ON_USE (func, \ 42451ddd709SJohn Marino "The symbol ::" #func " refers to the system function. " \ 42551ddd709SJohn Marino "Use " #namespace "::" #func " instead.") 42651ddd709SJohn Marino # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 42751ddd709SJohn Marino # define _GL_CXXALIASWARN_2(func,namespace) \ 42851ddd709SJohn Marino extern __typeof__ (func) func 42951ddd709SJohn Marino # else 43051ddd709SJohn Marino # define _GL_CXXALIASWARN_2(func,namespace) \ 43151ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 43251ddd709SJohn Marino # endif 43351ddd709SJohn Marino #else 43451ddd709SJohn Marino # define _GL_CXXALIASWARN(func) \ 43551ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 43651ddd709SJohn Marino #endif 43751ddd709SJohn Marino 43851ddd709SJohn Marino /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 43951ddd709SJohn Marino causes a warning to be emitted when the given overloaded variant of ::func 44051ddd709SJohn Marino is used but not when GNULIB_NAMESPACE::func is used. */ 44151ddd709SJohn Marino #if defined __cplusplus && defined GNULIB_NAMESPACE 44251ddd709SJohn Marino # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 44351ddd709SJohn Marino _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 44451ddd709SJohn Marino GNULIB_NAMESPACE) 44551ddd709SJohn Marino # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 44651ddd709SJohn Marino _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 447*4ce1b016SDaniel Fojt /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 44851ddd709SJohn Marino we enable the warning only when not optimizing. */ 44951ddd709SJohn Marino # if !__OPTIMIZE__ 45051ddd709SJohn Marino # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 45151ddd709SJohn Marino _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 45251ddd709SJohn Marino "The symbol ::" #func " refers to the system function. " \ 45351ddd709SJohn Marino "Use " #namespace "::" #func " instead.") 45451ddd709SJohn Marino # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 45551ddd709SJohn Marino # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 45651ddd709SJohn Marino extern __typeof__ (func) func 45751ddd709SJohn Marino # else 45851ddd709SJohn Marino # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 45951ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 46051ddd709SJohn Marino # endif 46151ddd709SJohn Marino #else 46251ddd709SJohn Marino # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 46351ddd709SJohn Marino _GL_EXTERN_C int _gl_cxxalias_dummy 46451ddd709SJohn Marino #endif 46551ddd709SJohn Marino 46651ddd709SJohn Marino #endif /* _GL_CXXDEFS_H */ 46751ddd709SJohn Marino 46851ddd709SJohn Marino /* The definition of _GL_ARG_NONNULL is copied here. */ 469*4ce1b016SDaniel Fojt /* A C macro for declaring that specific arguments must not be NULL. 470*4ce1b016SDaniel Fojt Copyright (C) 2009-2020 Free Software Foundation, Inc. 471*4ce1b016SDaniel Fojt 472*4ce1b016SDaniel Fojt This program is free software: you can redistribute it and/or modify it 473*4ce1b016SDaniel Fojt under the terms of the GNU General Public License as published 474*4ce1b016SDaniel Fojt by the Free Software Foundation; either version 3 of the License, or 475*4ce1b016SDaniel Fojt (at your option) any later version. 476*4ce1b016SDaniel Fojt 477*4ce1b016SDaniel Fojt This program is distributed in the hope that it will be useful, 478*4ce1b016SDaniel Fojt but WITHOUT ANY WARRANTY; without even the implied warranty of 479*4ce1b016SDaniel Fojt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 480*4ce1b016SDaniel Fojt General Public License for more details. 481*4ce1b016SDaniel Fojt 482*4ce1b016SDaniel Fojt You should have received a copy of the GNU General Public License 483*4ce1b016SDaniel Fojt along with this program. If not, see <https://www.gnu.org/licenses/>. */ 484*4ce1b016SDaniel Fojt 48551ddd709SJohn Marino /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 48651ddd709SJohn Marino that the values passed as arguments n, ..., m must be non-NULL pointers. 48751ddd709SJohn Marino n = 1 stands for the first argument, n = 2 for the second argument etc. */ 48851ddd709SJohn Marino #ifndef _GL_ARG_NONNULL 48951ddd709SJohn Marino # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 49051ddd709SJohn Marino # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 49151ddd709SJohn Marino # else 49251ddd709SJohn Marino # define _GL_ARG_NONNULL(params) 49351ddd709SJohn Marino # endif 49451ddd709SJohn Marino #endif 49551ddd709SJohn Marino 49651ddd709SJohn Marino /* The definition of _GL_WARN_ON_USE is copied here. */ 497*4ce1b016SDaniel Fojt /* A C macro for emitting warnings if a function is used. 498*4ce1b016SDaniel Fojt Copyright (C) 2010-2020 Free Software Foundation, Inc. 499*4ce1b016SDaniel Fojt 500*4ce1b016SDaniel Fojt This program is free software: you can redistribute it and/or modify it 501*4ce1b016SDaniel Fojt under the terms of the GNU General Public License as published 502*4ce1b016SDaniel Fojt by the Free Software Foundation; either version 3 of the License, or 503*4ce1b016SDaniel Fojt (at your option) any later version. 504*4ce1b016SDaniel Fojt 505*4ce1b016SDaniel Fojt This program is distributed in the hope that it will be useful, 506*4ce1b016SDaniel Fojt but WITHOUT ANY WARRANTY; without even the implied warranty of 507*4ce1b016SDaniel Fojt MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 508*4ce1b016SDaniel Fojt General Public License for more details. 509*4ce1b016SDaniel Fojt 510*4ce1b016SDaniel Fojt You should have received a copy of the GNU General Public License 511*4ce1b016SDaniel Fojt along with this program. If not, see <https://www.gnu.org/licenses/>. */ 512*4ce1b016SDaniel Fojt 513*4ce1b016SDaniel Fojt /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 514*4ce1b016SDaniel Fojt for FUNCTION which will then trigger a compiler warning containing 515*4ce1b016SDaniel Fojt the text of "literal string" anywhere that function is called, if 516*4ce1b016SDaniel Fojt supported by the compiler. If the compiler does not support this 517*4ce1b016SDaniel Fojt feature, the macro expands to an unused extern declaration. 518*4ce1b016SDaniel Fojt 519*4ce1b016SDaniel Fojt _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 520*4ce1b016SDaniel Fojt attribute used in _GL_WARN_ON_USE. If the compiler does not support 521*4ce1b016SDaniel Fojt this feature, it expands to empty. 522*4ce1b016SDaniel Fojt 523*4ce1b016SDaniel Fojt These macros are useful for marking a function as a potential 524*4ce1b016SDaniel Fojt portability trap, with the intent that "literal string" include 525*4ce1b016SDaniel Fojt instructions on the replacement function that should be used 526*4ce1b016SDaniel Fojt instead. 527*4ce1b016SDaniel Fojt _GL_WARN_ON_USE is for functions with 'extern' linkage. 528*4ce1b016SDaniel Fojt _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 529*4ce1b016SDaniel Fojt linkage. 530*4ce1b016SDaniel Fojt 531*4ce1b016SDaniel Fojt However, one of the reasons that a function is a portability trap is 532*4ce1b016SDaniel Fojt if it has the wrong signature. Declaring FUNCTION with a different 533*4ce1b016SDaniel Fojt signature in C is a compilation error, so this macro must use the 534*4ce1b016SDaniel Fojt same type as any existing declaration so that programs that avoid 535*4ce1b016SDaniel Fojt the problematic FUNCTION do not fail to compile merely because they 536*4ce1b016SDaniel Fojt included a header that poisoned the function. But this implies that 537*4ce1b016SDaniel Fojt _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 538*4ce1b016SDaniel Fojt have a declaration. Use of this macro implies that there must not 539*4ce1b016SDaniel Fojt be any other macro hiding the declaration of FUNCTION; but 540*4ce1b016SDaniel Fojt undefining FUNCTION first is part of the poisoning process anyway 541*4ce1b016SDaniel Fojt (although for symbols that are provided only via a macro, the result 542*4ce1b016SDaniel Fojt is a compilation error rather than a warning containing 543*4ce1b016SDaniel Fojt "literal string"). Also note that in C++, it is only safe to use if 544*4ce1b016SDaniel Fojt FUNCTION has no overloads. 545*4ce1b016SDaniel Fojt 546*4ce1b016SDaniel Fojt For an example, it is possible to poison 'getline' by: 547*4ce1b016SDaniel Fojt - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 548*4ce1b016SDaniel Fojt [getline]) in configure.ac, which potentially defines 549*4ce1b016SDaniel Fojt HAVE_RAW_DECL_GETLINE 550*4ce1b016SDaniel Fojt - adding this code to a header that wraps the system <stdio.h>: 551*4ce1b016SDaniel Fojt #undef getline 552*4ce1b016SDaniel Fojt #if HAVE_RAW_DECL_GETLINE 553*4ce1b016SDaniel Fojt _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 554*4ce1b016SDaniel Fojt "not universally present; use the gnulib module getline"); 555*4ce1b016SDaniel Fojt #endif 556*4ce1b016SDaniel Fojt 557*4ce1b016SDaniel Fojt It is not possible to directly poison global variables. But it is 558*4ce1b016SDaniel Fojt possible to write a wrapper accessor function, and poison that 559*4ce1b016SDaniel Fojt (less common usage, like &environ, will cause a compilation error 560*4ce1b016SDaniel Fojt rather than issue the nice warning, but the end result of informing 561*4ce1b016SDaniel Fojt the developer about their portability problem is still achieved): 562*4ce1b016SDaniel Fojt #if HAVE_RAW_DECL_ENVIRON 563*4ce1b016SDaniel Fojt static char *** 564*4ce1b016SDaniel Fojt rpl_environ (void) { return &environ; } 565*4ce1b016SDaniel Fojt _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 566*4ce1b016SDaniel Fojt # undef environ 567*4ce1b016SDaniel Fojt # define environ (*rpl_environ ()) 568*4ce1b016SDaniel Fojt #endif 569*4ce1b016SDaniel Fojt or better (avoiding contradictory use of 'static' and 'extern'): 570*4ce1b016SDaniel Fojt #if HAVE_RAW_DECL_ENVIRON 571*4ce1b016SDaniel Fojt static char *** 572*4ce1b016SDaniel Fojt _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 573*4ce1b016SDaniel Fojt rpl_environ (void) { return &environ; } 574*4ce1b016SDaniel Fojt # undef environ 575*4ce1b016SDaniel Fojt # define environ (*rpl_environ ()) 576*4ce1b016SDaniel Fojt #endif 577*4ce1b016SDaniel Fojt */ 57851ddd709SJohn Marino #ifndef _GL_WARN_ON_USE 57951ddd709SJohn Marino 58051ddd709SJohn Marino # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 58151ddd709SJohn Marino /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 58251ddd709SJohn Marino # define _GL_WARN_ON_USE(function, message) \ 58351ddd709SJohn Marino extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 584*4ce1b016SDaniel Fojt # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 585*4ce1b016SDaniel Fojt __attribute__ ((__warning__ (message))) 58651ddd709SJohn Marino # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 58751ddd709SJohn Marino /* Verify the existence of the function. */ 58851ddd709SJohn Marino # define _GL_WARN_ON_USE(function, message) \ 58951ddd709SJohn Marino extern __typeof__ (function) function 590*4ce1b016SDaniel Fojt # define _GL_WARN_ON_USE_ATTRIBUTE(message) 59151ddd709SJohn Marino # else /* Unsupported. */ 59251ddd709SJohn Marino # define _GL_WARN_ON_USE(function, message) \ 59351ddd709SJohn Marino _GL_WARN_EXTERN_C int _gl_warn_on_use 594*4ce1b016SDaniel Fojt # define _GL_WARN_ON_USE_ATTRIBUTE(message) 59551ddd709SJohn Marino # endif 59651ddd709SJohn Marino #endif 59751ddd709SJohn Marino 59851ddd709SJohn Marino /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 59951ddd709SJohn Marino is like _GL_WARN_ON_USE (function, "string"), except that the function is 60051ddd709SJohn Marino declared with the given prototype, consisting of return type, parameters, 60151ddd709SJohn Marino and attributes. 60251ddd709SJohn Marino This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 60351ddd709SJohn Marino not work in this case. */ 60451ddd709SJohn Marino #ifndef _GL_WARN_ON_USE_CXX 60551ddd709SJohn Marino # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 60651ddd709SJohn Marino # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 60751ddd709SJohn Marino extern rettype function parameters_and_attributes \ 60851ddd709SJohn Marino __attribute__ ((__warning__ (msg))) 60951ddd709SJohn Marino # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 61051ddd709SJohn Marino /* Verify the existence of the function. */ 61151ddd709SJohn Marino # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 61251ddd709SJohn Marino extern rettype function parameters_and_attributes 61351ddd709SJohn Marino # else /* Unsupported. */ 61451ddd709SJohn Marino # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 61551ddd709SJohn Marino _GL_WARN_EXTERN_C int _gl_warn_on_use 61651ddd709SJohn Marino # endif 61751ddd709SJohn Marino #endif 61851ddd709SJohn Marino 61951ddd709SJohn Marino /* _GL_WARN_EXTERN_C declaration; 62051ddd709SJohn Marino performs the declaration with C linkage. */ 62151ddd709SJohn Marino #ifndef _GL_WARN_EXTERN_C 62251ddd709SJohn Marino # if defined __cplusplus 62351ddd709SJohn Marino # define _GL_WARN_EXTERN_C extern "C" 62451ddd709SJohn Marino # else 62551ddd709SJohn Marino # define _GL_WARN_EXTERN_C extern 62651ddd709SJohn Marino # endif 62751ddd709SJohn Marino #endif 62851ddd709SJohn Marino 62951ddd709SJohn Marino /* Macros for stringification. */ 63051ddd709SJohn Marino #define _GL_STDIO_STRINGIZE(token) #token 63151ddd709SJohn Marino #define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) 63251ddd709SJohn Marino 63351ddd709SJohn Marino /* When also using extern inline, suppress the use of static inline in 63451ddd709SJohn Marino standard headers of problematic Apple configurations, as Libc at 63551ddd709SJohn Marino least through Libc-825.26 (2013-04-09) mishandles it; see, e.g., 636*4ce1b016SDaniel Fojt <https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html>. 63751ddd709SJohn Marino Perhaps Apple will fix this some day. */ 63851ddd709SJohn Marino #if (defined _GL_EXTERN_INLINE_IN_USE && defined __APPLE__ \ 63951ddd709SJohn Marino && defined __GNUC__ && defined __STDC__) 64051ddd709SJohn Marino # undef putc_unlocked 64151ddd709SJohn Marino #endif 64251ddd709SJohn Marino 64351ddd709SJohn Marino #if 0 64451ddd709SJohn Marino # if 0 64551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 64651ddd709SJohn Marino # define dprintf rpl_dprintf 64751ddd709SJohn Marino # endif 64851ddd709SJohn Marino _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) 64951ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 65051ddd709SJohn Marino _GL_ARG_NONNULL ((2))); 65151ddd709SJohn Marino _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); 65251ddd709SJohn Marino # else 65351ddd709SJohn Marino # if !1 65451ddd709SJohn Marino _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) 65551ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 65651ddd709SJohn Marino _GL_ARG_NONNULL ((2))); 65751ddd709SJohn Marino # endif 65851ddd709SJohn Marino _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); 65951ddd709SJohn Marino # endif 66051ddd709SJohn Marino _GL_CXXALIASWARN (dprintf); 66151ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 66251ddd709SJohn Marino # undef dprintf 66351ddd709SJohn Marino # if HAVE_RAW_DECL_DPRINTF 66451ddd709SJohn Marino _GL_WARN_ON_USE (dprintf, "dprintf is unportable - " 66551ddd709SJohn Marino "use gnulib module dprintf for portability"); 66651ddd709SJohn Marino # endif 66751ddd709SJohn Marino #endif 66851ddd709SJohn Marino 66951ddd709SJohn Marino #if 0 67051ddd709SJohn Marino /* Close STREAM and its underlying file descriptor. */ 67151ddd709SJohn Marino # if 0 67251ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 67351ddd709SJohn Marino # define fclose rpl_fclose 67451ddd709SJohn Marino # endif 67551ddd709SJohn Marino _GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 67651ddd709SJohn Marino _GL_CXXALIAS_RPL (fclose, int, (FILE *stream)); 67751ddd709SJohn Marino # else 67851ddd709SJohn Marino _GL_CXXALIAS_SYS (fclose, int, (FILE *stream)); 67951ddd709SJohn Marino # endif 680*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 68151ddd709SJohn Marino _GL_CXXALIASWARN (fclose); 682*4ce1b016SDaniel Fojt # endif 68351ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 68451ddd709SJohn Marino # undef fclose 68551ddd709SJohn Marino /* Assume fclose is always declared. */ 68651ddd709SJohn Marino _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - " 68751ddd709SJohn Marino "use gnulib module fclose for portable POSIX compliance"); 68851ddd709SJohn Marino #endif 68951ddd709SJohn Marino 69051ddd709SJohn Marino #if IN_GREP_GNULIB_TESTS 69151ddd709SJohn Marino # if 0 69251ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 69351ddd709SJohn Marino # undef fdopen 69451ddd709SJohn Marino # define fdopen rpl_fdopen 69551ddd709SJohn Marino # endif 69651ddd709SJohn Marino _GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode) 69751ddd709SJohn Marino _GL_ARG_NONNULL ((2))); 69851ddd709SJohn Marino _GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode)); 69951ddd709SJohn Marino # else 70051ddd709SJohn Marino _GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode)); 70151ddd709SJohn Marino # endif 70251ddd709SJohn Marino _GL_CXXALIASWARN (fdopen); 70351ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 70451ddd709SJohn Marino # undef fdopen 70551ddd709SJohn Marino /* Assume fdopen is always declared. */ 70651ddd709SJohn Marino _GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - " 70751ddd709SJohn Marino "use gnulib module fdopen for portability"); 70851ddd709SJohn Marino #endif 70951ddd709SJohn Marino 71051ddd709SJohn Marino #if 0 71151ddd709SJohn Marino /* Flush all pending data on STREAM according to POSIX rules. Both 71251ddd709SJohn Marino output and seekable input streams are supported. 71351ddd709SJohn Marino Note! LOSS OF DATA can occur if fflush is applied on an input stream 71451ddd709SJohn Marino that is _not_seekable_ or on an update stream that is _not_seekable_ 71551ddd709SJohn Marino and in which the most recent operation was input. Seekability can 71651ddd709SJohn Marino be tested with lseek(fileno(fp),0,SEEK_CUR). */ 71751ddd709SJohn Marino # if 0 71851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 71951ddd709SJohn Marino # define fflush rpl_fflush 72051ddd709SJohn Marino # endif 72151ddd709SJohn Marino _GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream)); 72251ddd709SJohn Marino _GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream)); 72351ddd709SJohn Marino # else 72451ddd709SJohn Marino _GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream)); 72551ddd709SJohn Marino # endif 726*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 72751ddd709SJohn Marino _GL_CXXALIASWARN (fflush); 728*4ce1b016SDaniel Fojt # endif 72951ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 73051ddd709SJohn Marino # undef fflush 73151ddd709SJohn Marino /* Assume fflush is always declared. */ 73251ddd709SJohn Marino _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - " 73351ddd709SJohn Marino "use gnulib module fflush for portable POSIX compliance"); 73451ddd709SJohn Marino #endif 73551ddd709SJohn Marino 73651ddd709SJohn Marino #if 1 73751ddd709SJohn Marino # if 0 && 0 73851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 73951ddd709SJohn Marino # undef fgetc 74051ddd709SJohn Marino # define fgetc rpl_fgetc 74151ddd709SJohn Marino # endif 74251ddd709SJohn Marino _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 74351ddd709SJohn Marino _GL_CXXALIAS_RPL (fgetc, int, (FILE *stream)); 74451ddd709SJohn Marino # else 74551ddd709SJohn Marino _GL_CXXALIAS_SYS (fgetc, int, (FILE *stream)); 74651ddd709SJohn Marino # endif 747*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 74851ddd709SJohn Marino _GL_CXXALIASWARN (fgetc); 74951ddd709SJohn Marino # endif 750*4ce1b016SDaniel Fojt #endif 75151ddd709SJohn Marino 75251ddd709SJohn Marino #if 1 75351ddd709SJohn Marino # if 0 && 0 75451ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 75551ddd709SJohn Marino # undef fgets 75651ddd709SJohn Marino # define fgets rpl_fgets 75751ddd709SJohn Marino # endif 75851ddd709SJohn Marino _GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream) 75951ddd709SJohn Marino _GL_ARG_NONNULL ((1, 3))); 76051ddd709SJohn Marino _GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream)); 76151ddd709SJohn Marino # else 76251ddd709SJohn Marino _GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream)); 76351ddd709SJohn Marino # endif 764*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 76551ddd709SJohn Marino _GL_CXXALIASWARN (fgets); 76651ddd709SJohn Marino # endif 767*4ce1b016SDaniel Fojt #endif 76851ddd709SJohn Marino 76951ddd709SJohn Marino #if 0 77051ddd709SJohn Marino # if 0 77151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 77251ddd709SJohn Marino # undef fopen 77351ddd709SJohn Marino # define fopen rpl_fopen 77451ddd709SJohn Marino # endif 77551ddd709SJohn Marino _GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode) 77651ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 77751ddd709SJohn Marino _GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode)); 77851ddd709SJohn Marino # else 77951ddd709SJohn Marino _GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode)); 78051ddd709SJohn Marino # endif 781*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 78251ddd709SJohn Marino _GL_CXXALIASWARN (fopen); 783*4ce1b016SDaniel Fojt # endif 78451ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 78551ddd709SJohn Marino # undef fopen 78651ddd709SJohn Marino /* Assume fopen is always declared. */ 78751ddd709SJohn Marino _GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - " 78851ddd709SJohn Marino "use gnulib module fopen for portability"); 78951ddd709SJohn Marino #endif 79051ddd709SJohn Marino 79151ddd709SJohn Marino #if 0 || 1 79251ddd709SJohn Marino # if (0 && 0) \ 79351ddd709SJohn Marino || (1 && 0 && (0 || 0)) 79451ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 79551ddd709SJohn Marino # define fprintf rpl_fprintf 79651ddd709SJohn Marino # endif 79751ddd709SJohn Marino # define GNULIB_overrides_fprintf 1 79851ddd709SJohn Marino # if 0 || 0 79951ddd709SJohn Marino _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 80051ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 80151ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 80251ddd709SJohn Marino # else 80351ddd709SJohn Marino _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 80451ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3) 80551ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 80651ddd709SJohn Marino # endif 80751ddd709SJohn Marino _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); 80851ddd709SJohn Marino # else 80951ddd709SJohn Marino _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); 81051ddd709SJohn Marino # endif 811*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 81251ddd709SJohn Marino _GL_CXXALIASWARN (fprintf); 81351ddd709SJohn Marino # endif 814*4ce1b016SDaniel Fojt #endif 81551ddd709SJohn Marino #if !0 && defined GNULIB_POSIXCHECK 81651ddd709SJohn Marino # if !GNULIB_overrides_fprintf 81751ddd709SJohn Marino # undef fprintf 81851ddd709SJohn Marino # endif 81951ddd709SJohn Marino /* Assume fprintf is always declared. */ 82051ddd709SJohn Marino _GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - " 82151ddd709SJohn Marino "use gnulib module fprintf-posix for portable " 82251ddd709SJohn Marino "POSIX compliance"); 82351ddd709SJohn Marino #endif 82451ddd709SJohn Marino 82551ddd709SJohn Marino #if 0 82651ddd709SJohn Marino /* Discard all pending buffered I/O data on STREAM. 82751ddd709SJohn Marino STREAM must not be wide-character oriented. 82851ddd709SJohn Marino When discarding pending output, the file position is set back to where it 82951ddd709SJohn Marino was before the write calls. When discarding pending input, the file 83051ddd709SJohn Marino position is advanced to match the end of the previously read input. 83151ddd709SJohn Marino Return 0 if successful. Upon error, return -1 and set errno. */ 83251ddd709SJohn Marino # if 0 83351ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 83451ddd709SJohn Marino # define fpurge rpl_fpurge 83551ddd709SJohn Marino # endif 83651ddd709SJohn Marino _GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 83751ddd709SJohn Marino _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream)); 83851ddd709SJohn Marino # else 83951ddd709SJohn Marino # if !1 84051ddd709SJohn Marino _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1))); 84151ddd709SJohn Marino # endif 84251ddd709SJohn Marino _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream)); 84351ddd709SJohn Marino # endif 84451ddd709SJohn Marino _GL_CXXALIASWARN (fpurge); 84551ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 84651ddd709SJohn Marino # undef fpurge 84751ddd709SJohn Marino # if HAVE_RAW_DECL_FPURGE 84851ddd709SJohn Marino _GL_WARN_ON_USE (fpurge, "fpurge is not always present - " 84951ddd709SJohn Marino "use gnulib module fpurge for portability"); 85051ddd709SJohn Marino # endif 85151ddd709SJohn Marino #endif 85251ddd709SJohn Marino 85351ddd709SJohn Marino #if 1 85451ddd709SJohn Marino # if 0 && (0 || 0) 85551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 85651ddd709SJohn Marino # undef fputc 85751ddd709SJohn Marino # define fputc rpl_fputc 85851ddd709SJohn Marino # endif 85951ddd709SJohn Marino _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 86051ddd709SJohn Marino _GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream)); 86151ddd709SJohn Marino # else 86251ddd709SJohn Marino _GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream)); 86351ddd709SJohn Marino # endif 864*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 86551ddd709SJohn Marino _GL_CXXALIASWARN (fputc); 86651ddd709SJohn Marino # endif 867*4ce1b016SDaniel Fojt #endif 86851ddd709SJohn Marino 86951ddd709SJohn Marino #if 1 87051ddd709SJohn Marino # if 0 && (0 || 0) 87151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 87251ddd709SJohn Marino # undef fputs 87351ddd709SJohn Marino # define fputs rpl_fputs 87451ddd709SJohn Marino # endif 87551ddd709SJohn Marino _GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream) 87651ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 87751ddd709SJohn Marino _GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream)); 87851ddd709SJohn Marino # else 87951ddd709SJohn Marino _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream)); 88051ddd709SJohn Marino # endif 881*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 88251ddd709SJohn Marino _GL_CXXALIASWARN (fputs); 88351ddd709SJohn Marino # endif 884*4ce1b016SDaniel Fojt #endif 88551ddd709SJohn Marino 88651ddd709SJohn Marino #if 1 88751ddd709SJohn Marino # if 0 && 0 88851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 88951ddd709SJohn Marino # undef fread 89051ddd709SJohn Marino # define fread rpl_fread 89151ddd709SJohn Marino # endif 89251ddd709SJohn Marino _GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream) 89351ddd709SJohn Marino _GL_ARG_NONNULL ((4))); 89451ddd709SJohn Marino _GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 89551ddd709SJohn Marino # else 89651ddd709SJohn Marino _GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)); 89751ddd709SJohn Marino # endif 898*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 89951ddd709SJohn Marino _GL_CXXALIASWARN (fread); 90051ddd709SJohn Marino # endif 901*4ce1b016SDaniel Fojt #endif 90251ddd709SJohn Marino 90351ddd709SJohn Marino #if 0 90451ddd709SJohn Marino # if 0 90551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 90651ddd709SJohn Marino # undef freopen 90751ddd709SJohn Marino # define freopen rpl_freopen 90851ddd709SJohn Marino # endif 90951ddd709SJohn Marino _GL_FUNCDECL_RPL (freopen, FILE *, 91051ddd709SJohn Marino (const char *filename, const char *mode, FILE *stream) 91151ddd709SJohn Marino _GL_ARG_NONNULL ((2, 3))); 91251ddd709SJohn Marino _GL_CXXALIAS_RPL (freopen, FILE *, 91351ddd709SJohn Marino (const char *filename, const char *mode, FILE *stream)); 91451ddd709SJohn Marino # else 91551ddd709SJohn Marino _GL_CXXALIAS_SYS (freopen, FILE *, 91651ddd709SJohn Marino (const char *filename, const char *mode, FILE *stream)); 91751ddd709SJohn Marino # endif 918*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 91951ddd709SJohn Marino _GL_CXXALIASWARN (freopen); 920*4ce1b016SDaniel Fojt # endif 92151ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 92251ddd709SJohn Marino # undef freopen 92351ddd709SJohn Marino /* Assume freopen is always declared. */ 92451ddd709SJohn Marino _GL_WARN_ON_USE (freopen, 92551ddd709SJohn Marino "freopen on native Windows platforms is not POSIX compliant - " 92651ddd709SJohn Marino "use gnulib module freopen for portability"); 92751ddd709SJohn Marino #endif 92851ddd709SJohn Marino 92951ddd709SJohn Marino #if 1 93051ddd709SJohn Marino # if 0 && 0 93151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 93251ddd709SJohn Marino # undef fscanf 93351ddd709SJohn Marino # define fscanf rpl_fscanf 93451ddd709SJohn Marino # endif 93551ddd709SJohn Marino _GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...) 93651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3) 93751ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 93851ddd709SJohn Marino _GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...)); 93951ddd709SJohn Marino # else 94051ddd709SJohn Marino _GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...)); 94151ddd709SJohn Marino # endif 942*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 94351ddd709SJohn Marino _GL_CXXALIASWARN (fscanf); 94451ddd709SJohn Marino # endif 945*4ce1b016SDaniel Fojt #endif 94651ddd709SJohn Marino 94751ddd709SJohn Marino 94851ddd709SJohn Marino /* Set up the following warnings, based on which modules are in use. 94951ddd709SJohn Marino GNU Coding Standards discourage the use of fseek, since it imposes 95051ddd709SJohn Marino an arbitrary limitation on some 32-bit hosts. Remember that the 95151ddd709SJohn Marino fseek module depends on the fseeko module, so we only have three 95251ddd709SJohn Marino cases to consider: 95351ddd709SJohn Marino 95451ddd709SJohn Marino 1. The developer is not using either module. Issue a warning under 95551ddd709SJohn Marino GNULIB_POSIXCHECK for both functions, to remind them that both 95651ddd709SJohn Marino functions have bugs on some systems. _GL_NO_LARGE_FILES has no 95751ddd709SJohn Marino impact on this warning. 95851ddd709SJohn Marino 95951ddd709SJohn Marino 2. The developer is using both modules. They may be unaware of the 96051ddd709SJohn Marino arbitrary limitations of fseek, so issue a warning under 96151ddd709SJohn Marino GNULIB_POSIXCHECK. On the other hand, they may be using both 96251ddd709SJohn Marino modules intentionally, so the developer can define 96351ddd709SJohn Marino _GL_NO_LARGE_FILES in the compilation units where the use of fseek 96451ddd709SJohn Marino is safe, to silence the warning. 96551ddd709SJohn Marino 96651ddd709SJohn Marino 3. The developer is using the fseeko module, but not fseek. Gnulib 96751ddd709SJohn Marino guarantees that fseek will still work around platform bugs in that 96851ddd709SJohn Marino case, but we presume that the developer is aware of the pitfalls of 96951ddd709SJohn Marino fseek and was trying to avoid it, so issue a warning even when 97051ddd709SJohn Marino GNULIB_POSIXCHECK is undefined. Again, _GL_NO_LARGE_FILES can be 97151ddd709SJohn Marino defined to silence the warning in particular compilation units. 97251ddd709SJohn Marino In C++ compilations with GNULIB_NAMESPACE, in order to avoid that 97351ddd709SJohn Marino fseek gets defined as a macro, it is recommended that the developer 97451ddd709SJohn Marino uses the fseek module, even if he is not calling the fseek function. 97551ddd709SJohn Marino 97651ddd709SJohn Marino Most gnulib clients that perform stream operations should fall into 97751ddd709SJohn Marino category 3. */ 97851ddd709SJohn Marino 97951ddd709SJohn Marino #if 0 98051ddd709SJohn Marino # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES 98151ddd709SJohn Marino # define _GL_FSEEK_WARN /* Category 2, above. */ 98251ddd709SJohn Marino # undef fseek 98351ddd709SJohn Marino # endif 98451ddd709SJohn Marino # if 0 98551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 98651ddd709SJohn Marino # undef fseek 98751ddd709SJohn Marino # define fseek rpl_fseek 98851ddd709SJohn Marino # endif 98951ddd709SJohn Marino _GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence) 99051ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 99151ddd709SJohn Marino _GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence)); 99251ddd709SJohn Marino # else 99351ddd709SJohn Marino _GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence)); 99451ddd709SJohn Marino # endif 995*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 99651ddd709SJohn Marino _GL_CXXALIASWARN (fseek); 99751ddd709SJohn Marino # endif 998*4ce1b016SDaniel Fojt #endif 99951ddd709SJohn Marino 100051ddd709SJohn Marino #if 0 100151ddd709SJohn Marino # if !0 && !defined _GL_NO_LARGE_FILES 100251ddd709SJohn Marino # define _GL_FSEEK_WARN /* Category 3, above. */ 100351ddd709SJohn Marino # undef fseek 100451ddd709SJohn Marino # endif 100551ddd709SJohn Marino # if 0 100651ddd709SJohn Marino /* Provide an fseeko function that is aware of a preceding fflush(), and which 100751ddd709SJohn Marino detects pipes. */ 100851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 100951ddd709SJohn Marino # undef fseeko 101051ddd709SJohn Marino # define fseeko rpl_fseeko 101151ddd709SJohn Marino # endif 101251ddd709SJohn Marino _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) 101351ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 101451ddd709SJohn Marino _GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); 101551ddd709SJohn Marino # else 101651ddd709SJohn Marino # if ! 1 101751ddd709SJohn Marino _GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) 101851ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 101951ddd709SJohn Marino # endif 102051ddd709SJohn Marino _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); 102151ddd709SJohn Marino # endif 102251ddd709SJohn Marino _GL_CXXALIASWARN (fseeko); 102351ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 102451ddd709SJohn Marino # define _GL_FSEEK_WARN /* Category 1, above. */ 102551ddd709SJohn Marino # undef fseek 102651ddd709SJohn Marino # undef fseeko 102751ddd709SJohn Marino # if HAVE_RAW_DECL_FSEEKO 102851ddd709SJohn Marino _GL_WARN_ON_USE (fseeko, "fseeko is unportable - " 102951ddd709SJohn Marino "use gnulib module fseeko for portability"); 103051ddd709SJohn Marino # endif 103151ddd709SJohn Marino #endif 103251ddd709SJohn Marino 103351ddd709SJohn Marino #ifdef _GL_FSEEK_WARN 103451ddd709SJohn Marino # undef _GL_FSEEK_WARN 103551ddd709SJohn Marino /* Here, either fseek is undefined (but C89 guarantees that it is 103651ddd709SJohn Marino declared), or it is defined as rpl_fseek (declared above). */ 103751ddd709SJohn Marino _GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB " 103851ddd709SJohn Marino "on 32-bit platforms - " 103951ddd709SJohn Marino "use fseeko function for handling of large files"); 104051ddd709SJohn Marino #endif 104151ddd709SJohn Marino 104251ddd709SJohn Marino 104351ddd709SJohn Marino /* ftell, ftello. See the comments on fseek/fseeko. */ 104451ddd709SJohn Marino 104551ddd709SJohn Marino #if 0 104651ddd709SJohn Marino # if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES 104751ddd709SJohn Marino # define _GL_FTELL_WARN /* Category 2, above. */ 104851ddd709SJohn Marino # undef ftell 104951ddd709SJohn Marino # endif 105051ddd709SJohn Marino # if 0 105151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 105251ddd709SJohn Marino # undef ftell 105351ddd709SJohn Marino # define ftell rpl_ftell 105451ddd709SJohn Marino # endif 105551ddd709SJohn Marino _GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1))); 105651ddd709SJohn Marino _GL_CXXALIAS_RPL (ftell, long, (FILE *fp)); 105751ddd709SJohn Marino # else 105851ddd709SJohn Marino _GL_CXXALIAS_SYS (ftell, long, (FILE *fp)); 105951ddd709SJohn Marino # endif 1060*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 106151ddd709SJohn Marino _GL_CXXALIASWARN (ftell); 106251ddd709SJohn Marino # endif 1063*4ce1b016SDaniel Fojt #endif 106451ddd709SJohn Marino 106551ddd709SJohn Marino #if 0 106651ddd709SJohn Marino # if !0 && !defined _GL_NO_LARGE_FILES 106751ddd709SJohn Marino # define _GL_FTELL_WARN /* Category 3, above. */ 106851ddd709SJohn Marino # undef ftell 106951ddd709SJohn Marino # endif 107051ddd709SJohn Marino # if 0 107151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 107251ddd709SJohn Marino # undef ftello 107351ddd709SJohn Marino # define ftello rpl_ftello 107451ddd709SJohn Marino # endif 107551ddd709SJohn Marino _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 107651ddd709SJohn Marino _GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); 107751ddd709SJohn Marino # else 107851ddd709SJohn Marino # if ! 1 107951ddd709SJohn Marino _GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 108051ddd709SJohn Marino # endif 108151ddd709SJohn Marino _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); 108251ddd709SJohn Marino # endif 108351ddd709SJohn Marino _GL_CXXALIASWARN (ftello); 108451ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 108551ddd709SJohn Marino # define _GL_FTELL_WARN /* Category 1, above. */ 108651ddd709SJohn Marino # undef ftell 108751ddd709SJohn Marino # undef ftello 108851ddd709SJohn Marino # if HAVE_RAW_DECL_FTELLO 108951ddd709SJohn Marino _GL_WARN_ON_USE (ftello, "ftello is unportable - " 109051ddd709SJohn Marino "use gnulib module ftello for portability"); 109151ddd709SJohn Marino # endif 109251ddd709SJohn Marino #endif 109351ddd709SJohn Marino 109451ddd709SJohn Marino #ifdef _GL_FTELL_WARN 109551ddd709SJohn Marino # undef _GL_FTELL_WARN 109651ddd709SJohn Marino /* Here, either ftell is undefined (but C89 guarantees that it is 109751ddd709SJohn Marino declared), or it is defined as rpl_ftell (declared above). */ 109851ddd709SJohn Marino _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB " 109951ddd709SJohn Marino "on 32-bit platforms - " 110051ddd709SJohn Marino "use ftello function for handling of large files"); 110151ddd709SJohn Marino #endif 110251ddd709SJohn Marino 110351ddd709SJohn Marino 110451ddd709SJohn Marino #if 1 110551ddd709SJohn Marino # if 0 && (0 || 0) 110651ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 110751ddd709SJohn Marino # undef fwrite 110851ddd709SJohn Marino # define fwrite rpl_fwrite 110951ddd709SJohn Marino # endif 111051ddd709SJohn Marino _GL_FUNCDECL_RPL (fwrite, size_t, 111151ddd709SJohn Marino (const void *ptr, size_t s, size_t n, FILE *stream) 111251ddd709SJohn Marino _GL_ARG_NONNULL ((1, 4))); 111351ddd709SJohn Marino _GL_CXXALIAS_RPL (fwrite, size_t, 111451ddd709SJohn Marino (const void *ptr, size_t s, size_t n, FILE *stream)); 111551ddd709SJohn Marino # else 111651ddd709SJohn Marino _GL_CXXALIAS_SYS (fwrite, size_t, 111751ddd709SJohn Marino (const void *ptr, size_t s, size_t n, FILE *stream)); 111851ddd709SJohn Marino 111951ddd709SJohn Marino /* Work around bug 11959 when fortifying glibc 2.4 through 2.15 1120*4ce1b016SDaniel Fojt <https://sourceware.org/bugzilla/show_bug.cgi?id=11959>, 112151ddd709SJohn Marino which sometimes causes an unwanted diagnostic for fwrite calls. 112251ddd709SJohn Marino This affects only function declaration attributes under certain 112351ddd709SJohn Marino versions of gcc and clang, and is not needed for C++. */ 112451ddd709SJohn Marino # if (0 < __USE_FORTIFY_LEVEL \ 112551ddd709SJohn Marino && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \ 112651ddd709SJohn Marino && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \ 112751ddd709SJohn Marino && !defined __cplusplus) 112851ddd709SJohn Marino # undef fwrite 112951ddd709SJohn Marino # undef fwrite_unlocked 113051ddd709SJohn Marino extern size_t __REDIRECT (rpl_fwrite, 113151ddd709SJohn Marino (const void *__restrict, size_t, size_t, 113251ddd709SJohn Marino FILE *__restrict), 113351ddd709SJohn Marino fwrite); 113451ddd709SJohn Marino extern size_t __REDIRECT (rpl_fwrite_unlocked, 113551ddd709SJohn Marino (const void *__restrict, size_t, size_t, 113651ddd709SJohn Marino FILE *__restrict), 113751ddd709SJohn Marino fwrite_unlocked); 113851ddd709SJohn Marino # define fwrite rpl_fwrite 113951ddd709SJohn Marino # define fwrite_unlocked rpl_fwrite_unlocked 114051ddd709SJohn Marino # endif 114151ddd709SJohn Marino # endif 1142*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 114351ddd709SJohn Marino _GL_CXXALIASWARN (fwrite); 114451ddd709SJohn Marino # endif 1145*4ce1b016SDaniel Fojt #endif 114651ddd709SJohn Marino 114751ddd709SJohn Marino #if 1 114851ddd709SJohn Marino # if 0 && 0 114951ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 115051ddd709SJohn Marino # undef getc 115151ddd709SJohn Marino # define getc rpl_fgetc 115251ddd709SJohn Marino # endif 115351ddd709SJohn Marino _GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 115451ddd709SJohn Marino _GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream)); 115551ddd709SJohn Marino # else 115651ddd709SJohn Marino _GL_CXXALIAS_SYS (getc, int, (FILE *stream)); 115751ddd709SJohn Marino # endif 1158*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 115951ddd709SJohn Marino _GL_CXXALIASWARN (getc); 116051ddd709SJohn Marino # endif 1161*4ce1b016SDaniel Fojt #endif 116251ddd709SJohn Marino 116351ddd709SJohn Marino #if 1 116451ddd709SJohn Marino # if 0 && 0 116551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 116651ddd709SJohn Marino # undef getchar 116751ddd709SJohn Marino # define getchar rpl_getchar 116851ddd709SJohn Marino # endif 116951ddd709SJohn Marino _GL_FUNCDECL_RPL (getchar, int, (void)); 117051ddd709SJohn Marino _GL_CXXALIAS_RPL (getchar, int, (void)); 117151ddd709SJohn Marino # else 117251ddd709SJohn Marino _GL_CXXALIAS_SYS (getchar, int, (void)); 117351ddd709SJohn Marino # endif 1174*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 117551ddd709SJohn Marino _GL_CXXALIASWARN (getchar); 117651ddd709SJohn Marino # endif 1177*4ce1b016SDaniel Fojt #endif 117851ddd709SJohn Marino 117951ddd709SJohn Marino #if 0 118051ddd709SJohn Marino /* Read input, up to (and including) the next occurrence of DELIMITER, from 118151ddd709SJohn Marino STREAM, store it in *LINEPTR (and NUL-terminate it). 118251ddd709SJohn Marino *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE 118351ddd709SJohn Marino bytes of space. It is realloc'd as necessary. 118451ddd709SJohn Marino Return the number of bytes read and stored at *LINEPTR (not including the 118551ddd709SJohn Marino NUL terminator), or -1 on error or EOF. */ 118651ddd709SJohn Marino # if 0 118751ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 118851ddd709SJohn Marino # undef getdelim 118951ddd709SJohn Marino # define getdelim rpl_getdelim 119051ddd709SJohn Marino # endif 119151ddd709SJohn Marino _GL_FUNCDECL_RPL (getdelim, ssize_t, 119251ddd709SJohn Marino (char **lineptr, size_t *linesize, int delimiter, 119351ddd709SJohn Marino FILE *stream) 119451ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2, 4))); 119551ddd709SJohn Marino _GL_CXXALIAS_RPL (getdelim, ssize_t, 119651ddd709SJohn Marino (char **lineptr, size_t *linesize, int delimiter, 119751ddd709SJohn Marino FILE *stream)); 119851ddd709SJohn Marino # else 119951ddd709SJohn Marino # if !1 120051ddd709SJohn Marino _GL_FUNCDECL_SYS (getdelim, ssize_t, 120151ddd709SJohn Marino (char **lineptr, size_t *linesize, int delimiter, 120251ddd709SJohn Marino FILE *stream) 120351ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2, 4))); 120451ddd709SJohn Marino # endif 120551ddd709SJohn Marino _GL_CXXALIAS_SYS (getdelim, ssize_t, 120651ddd709SJohn Marino (char **lineptr, size_t *linesize, int delimiter, 120751ddd709SJohn Marino FILE *stream)); 120851ddd709SJohn Marino # endif 120951ddd709SJohn Marino _GL_CXXALIASWARN (getdelim); 121051ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 121151ddd709SJohn Marino # undef getdelim 121251ddd709SJohn Marino # if HAVE_RAW_DECL_GETDELIM 121351ddd709SJohn Marino _GL_WARN_ON_USE (getdelim, "getdelim is unportable - " 121451ddd709SJohn Marino "use gnulib module getdelim for portability"); 121551ddd709SJohn Marino # endif 121651ddd709SJohn Marino #endif 121751ddd709SJohn Marino 121851ddd709SJohn Marino #if 0 121951ddd709SJohn Marino /* Read a line, up to (and including) the next newline, from STREAM, store it 122051ddd709SJohn Marino in *LINEPTR (and NUL-terminate it). 122151ddd709SJohn Marino *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE 122251ddd709SJohn Marino bytes of space. It is realloc'd as necessary. 122351ddd709SJohn Marino Return the number of bytes read and stored at *LINEPTR (not including the 122451ddd709SJohn Marino NUL terminator), or -1 on error or EOF. */ 122551ddd709SJohn Marino # if 0 122651ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 122751ddd709SJohn Marino # undef getline 122851ddd709SJohn Marino # define getline rpl_getline 122951ddd709SJohn Marino # endif 123051ddd709SJohn Marino _GL_FUNCDECL_RPL (getline, ssize_t, 123151ddd709SJohn Marino (char **lineptr, size_t *linesize, FILE *stream) 123251ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2, 3))); 123351ddd709SJohn Marino _GL_CXXALIAS_RPL (getline, ssize_t, 123451ddd709SJohn Marino (char **lineptr, size_t *linesize, FILE *stream)); 123551ddd709SJohn Marino # else 123651ddd709SJohn Marino # if !1 123751ddd709SJohn Marino _GL_FUNCDECL_SYS (getline, ssize_t, 123851ddd709SJohn Marino (char **lineptr, size_t *linesize, FILE *stream) 123951ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2, 3))); 124051ddd709SJohn Marino # endif 124151ddd709SJohn Marino _GL_CXXALIAS_SYS (getline, ssize_t, 124251ddd709SJohn Marino (char **lineptr, size_t *linesize, FILE *stream)); 124351ddd709SJohn Marino # endif 124451ddd709SJohn Marino # if 1 124551ddd709SJohn Marino _GL_CXXALIASWARN (getline); 124651ddd709SJohn Marino # endif 124751ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 124851ddd709SJohn Marino # undef getline 124951ddd709SJohn Marino # if HAVE_RAW_DECL_GETLINE 125051ddd709SJohn Marino _GL_WARN_ON_USE (getline, "getline is unportable - " 125151ddd709SJohn Marino "use gnulib module getline for portability"); 125251ddd709SJohn Marino # endif 125351ddd709SJohn Marino #endif 125451ddd709SJohn Marino 125551ddd709SJohn Marino /* It is very rare that the developer ever has full control of stdin, 125651ddd709SJohn Marino so any use of gets warrants an unconditional warning; besides, C11 125751ddd709SJohn Marino removed it. */ 125851ddd709SJohn Marino #undef gets 1259cf51209aSJohn Marino #if HAVE_RAW_DECL_GETS && !defined __cplusplus 126051ddd709SJohn Marino _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 126151ddd709SJohn Marino #endif 126251ddd709SJohn Marino 126351ddd709SJohn Marino #if 0 || 0 126451ddd709SJohn Marino struct obstack; 126551ddd709SJohn Marino /* Grow an obstack with formatted output. Return the number of 126651ddd709SJohn Marino bytes added to OBS. No trailing nul byte is added, and the 126751ddd709SJohn Marino object should be closed with obstack_finish before use. Upon 126851ddd709SJohn Marino memory allocation error, call obstack_alloc_failed_handler. Upon 126951ddd709SJohn Marino other error, return -1. */ 127051ddd709SJohn Marino # if 0 127151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 127251ddd709SJohn Marino # define obstack_printf rpl_obstack_printf 127351ddd709SJohn Marino # endif 127451ddd709SJohn Marino _GL_FUNCDECL_RPL (obstack_printf, int, 127551ddd709SJohn Marino (struct obstack *obs, const char *format, ...) 127651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 127751ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 127851ddd709SJohn Marino _GL_CXXALIAS_RPL (obstack_printf, int, 127951ddd709SJohn Marino (struct obstack *obs, const char *format, ...)); 128051ddd709SJohn Marino # else 128151ddd709SJohn Marino # if !1 128251ddd709SJohn Marino _GL_FUNCDECL_SYS (obstack_printf, int, 128351ddd709SJohn Marino (struct obstack *obs, const char *format, ...) 128451ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 128551ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 128651ddd709SJohn Marino # endif 128751ddd709SJohn Marino _GL_CXXALIAS_SYS (obstack_printf, int, 128851ddd709SJohn Marino (struct obstack *obs, const char *format, ...)); 128951ddd709SJohn Marino # endif 129051ddd709SJohn Marino _GL_CXXALIASWARN (obstack_printf); 129151ddd709SJohn Marino # if 0 129251ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 129351ddd709SJohn Marino # define obstack_vprintf rpl_obstack_vprintf 129451ddd709SJohn Marino # endif 129551ddd709SJohn Marino _GL_FUNCDECL_RPL (obstack_vprintf, int, 129651ddd709SJohn Marino (struct obstack *obs, const char *format, va_list args) 129751ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 129851ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 129951ddd709SJohn Marino _GL_CXXALIAS_RPL (obstack_vprintf, int, 130051ddd709SJohn Marino (struct obstack *obs, const char *format, va_list args)); 130151ddd709SJohn Marino # else 130251ddd709SJohn Marino # if !1 130351ddd709SJohn Marino _GL_FUNCDECL_SYS (obstack_vprintf, int, 130451ddd709SJohn Marino (struct obstack *obs, const char *format, va_list args) 130551ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 130651ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 130751ddd709SJohn Marino # endif 130851ddd709SJohn Marino _GL_CXXALIAS_SYS (obstack_vprintf, int, 130951ddd709SJohn Marino (struct obstack *obs, const char *format, va_list args)); 131051ddd709SJohn Marino # endif 131151ddd709SJohn Marino _GL_CXXALIASWARN (obstack_vprintf); 131251ddd709SJohn Marino #endif 131351ddd709SJohn Marino 131451ddd709SJohn Marino #if 0 131551ddd709SJohn Marino # if !1 131651ddd709SJohn Marino _GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1))); 131751ddd709SJohn Marino # endif 131851ddd709SJohn Marino _GL_CXXALIAS_SYS (pclose, int, (FILE *stream)); 131951ddd709SJohn Marino _GL_CXXALIASWARN (pclose); 132051ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 132151ddd709SJohn Marino # undef pclose 132251ddd709SJohn Marino # if HAVE_RAW_DECL_PCLOSE 132351ddd709SJohn Marino _GL_WARN_ON_USE (pclose, "pclose is unportable - " 132451ddd709SJohn Marino "use gnulib module pclose for more portability"); 132551ddd709SJohn Marino # endif 132651ddd709SJohn Marino #endif 132751ddd709SJohn Marino 1328*4ce1b016SDaniel Fojt #if IN_GREP_GNULIB_TESTS 132951ddd709SJohn Marino /* Print a message to standard error, describing the value of ERRNO, 133051ddd709SJohn Marino (if STRING is not NULL and not empty) prefixed with STRING and ": ", 133151ddd709SJohn Marino and terminated with a newline. */ 1332*4ce1b016SDaniel Fojt # if 1 133351ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 133451ddd709SJohn Marino # define perror rpl_perror 133551ddd709SJohn Marino # endif 133651ddd709SJohn Marino _GL_FUNCDECL_RPL (perror, void, (const char *string)); 133751ddd709SJohn Marino _GL_CXXALIAS_RPL (perror, void, (const char *string)); 133851ddd709SJohn Marino # else 133951ddd709SJohn Marino _GL_CXXALIAS_SYS (perror, void, (const char *string)); 134051ddd709SJohn Marino # endif 1341*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 134251ddd709SJohn Marino _GL_CXXALIASWARN (perror); 1343*4ce1b016SDaniel Fojt # endif 134451ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 134551ddd709SJohn Marino # undef perror 134651ddd709SJohn Marino /* Assume perror is always declared. */ 134751ddd709SJohn Marino _GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - " 134851ddd709SJohn Marino "use gnulib module perror for portability"); 134951ddd709SJohn Marino #endif 135051ddd709SJohn Marino 135151ddd709SJohn Marino #if 0 135251ddd709SJohn Marino # if 0 135351ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 135451ddd709SJohn Marino # undef popen 135551ddd709SJohn Marino # define popen rpl_popen 135651ddd709SJohn Marino # endif 135751ddd709SJohn Marino _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode) 135851ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 135951ddd709SJohn Marino _GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 136051ddd709SJohn Marino # else 136151ddd709SJohn Marino # if !1 136251ddd709SJohn Marino _GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode) 136351ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 136451ddd709SJohn Marino # endif 136551ddd709SJohn Marino _GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 136651ddd709SJohn Marino # endif 136751ddd709SJohn Marino _GL_CXXALIASWARN (popen); 136851ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 136951ddd709SJohn Marino # undef popen 137051ddd709SJohn Marino # if HAVE_RAW_DECL_POPEN 137151ddd709SJohn Marino _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " 137251ddd709SJohn Marino "use gnulib module popen or pipe for more portability"); 137351ddd709SJohn Marino # endif 137451ddd709SJohn Marino #endif 137551ddd709SJohn Marino 137651ddd709SJohn Marino #if 0 || 1 137751ddd709SJohn Marino # if (0 && 0) \ 137851ddd709SJohn Marino || (1 && 0 && (0 || 0)) 137951ddd709SJohn Marino # if defined __GNUC__ 138051ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 138151ddd709SJohn Marino /* Don't break __attribute__((format(printf,M,N))). */ 138251ddd709SJohn Marino # define printf __printf__ 138351ddd709SJohn Marino # endif 138451ddd709SJohn Marino # if 0 || 0 138551ddd709SJohn Marino _GL_FUNCDECL_RPL_1 (__printf__, int, 138651ddd709SJohn Marino (const char *format, ...) 138751ddd709SJohn Marino __asm__ ( 138851ddd709SJohn Marino _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 138951ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 139051ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 139151ddd709SJohn Marino # else 139251ddd709SJohn Marino _GL_FUNCDECL_RPL_1 (__printf__, int, 139351ddd709SJohn Marino (const char *format, ...) 139451ddd709SJohn Marino __asm__ ( 139551ddd709SJohn Marino _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 139651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2) 139751ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 139851ddd709SJohn Marino # endif 139951ddd709SJohn Marino _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); 140051ddd709SJohn Marino # else 140151ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 140251ddd709SJohn Marino # define printf rpl_printf 140351ddd709SJohn Marino # endif 140451ddd709SJohn Marino _GL_FUNCDECL_RPL (printf, int, 140551ddd709SJohn Marino (const char *format, ...) 140651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2) 140751ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 140851ddd709SJohn Marino _GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); 140951ddd709SJohn Marino # endif 141051ddd709SJohn Marino # define GNULIB_overrides_printf 1 141151ddd709SJohn Marino # else 141251ddd709SJohn Marino _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); 141351ddd709SJohn Marino # endif 1414*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 141551ddd709SJohn Marino _GL_CXXALIASWARN (printf); 141651ddd709SJohn Marino # endif 1417*4ce1b016SDaniel Fojt #endif 141851ddd709SJohn Marino #if !0 && defined GNULIB_POSIXCHECK 141951ddd709SJohn Marino # if !GNULIB_overrides_printf 142051ddd709SJohn Marino # undef printf 142151ddd709SJohn Marino # endif 142251ddd709SJohn Marino /* Assume printf is always declared. */ 142351ddd709SJohn Marino _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - " 142451ddd709SJohn Marino "use gnulib module printf-posix for portable " 142551ddd709SJohn Marino "POSIX compliance"); 142651ddd709SJohn Marino #endif 142751ddd709SJohn Marino 142851ddd709SJohn Marino #if 1 142951ddd709SJohn Marino # if 0 && (0 || 0) 143051ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 143151ddd709SJohn Marino # undef putc 143251ddd709SJohn Marino # define putc rpl_fputc 143351ddd709SJohn Marino # endif 143451ddd709SJohn Marino _GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2))); 143551ddd709SJohn Marino _GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream)); 143651ddd709SJohn Marino # else 143751ddd709SJohn Marino _GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream)); 143851ddd709SJohn Marino # endif 1439*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 144051ddd709SJohn Marino _GL_CXXALIASWARN (putc); 144151ddd709SJohn Marino # endif 1442*4ce1b016SDaniel Fojt #endif 144351ddd709SJohn Marino 144451ddd709SJohn Marino #if 1 144551ddd709SJohn Marino # if 0 && (0 || 0) 144651ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 144751ddd709SJohn Marino # undef putchar 144851ddd709SJohn Marino # define putchar rpl_putchar 144951ddd709SJohn Marino # endif 145051ddd709SJohn Marino _GL_FUNCDECL_RPL (putchar, int, (int c)); 145151ddd709SJohn Marino _GL_CXXALIAS_RPL (putchar, int, (int c)); 145251ddd709SJohn Marino # else 145351ddd709SJohn Marino _GL_CXXALIAS_SYS (putchar, int, (int c)); 145451ddd709SJohn Marino # endif 1455*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 145651ddd709SJohn Marino _GL_CXXALIASWARN (putchar); 145751ddd709SJohn Marino # endif 1458*4ce1b016SDaniel Fojt #endif 145951ddd709SJohn Marino 146051ddd709SJohn Marino #if 1 146151ddd709SJohn Marino # if 0 && (0 || 0) 146251ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 146351ddd709SJohn Marino # undef puts 146451ddd709SJohn Marino # define puts rpl_puts 146551ddd709SJohn Marino # endif 146651ddd709SJohn Marino _GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1))); 146751ddd709SJohn Marino _GL_CXXALIAS_RPL (puts, int, (const char *string)); 146851ddd709SJohn Marino # else 146951ddd709SJohn Marino _GL_CXXALIAS_SYS (puts, int, (const char *string)); 147051ddd709SJohn Marino # endif 1471*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 147251ddd709SJohn Marino _GL_CXXALIASWARN (puts); 147351ddd709SJohn Marino # endif 1474*4ce1b016SDaniel Fojt #endif 147551ddd709SJohn Marino 147651ddd709SJohn Marino #if 0 147751ddd709SJohn Marino # if 0 147851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 147951ddd709SJohn Marino # undef remove 148051ddd709SJohn Marino # define remove rpl_remove 148151ddd709SJohn Marino # endif 148251ddd709SJohn Marino _GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1))); 148351ddd709SJohn Marino _GL_CXXALIAS_RPL (remove, int, (const char *name)); 148451ddd709SJohn Marino # else 148551ddd709SJohn Marino _GL_CXXALIAS_SYS (remove, int, (const char *name)); 148651ddd709SJohn Marino # endif 1487*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 148851ddd709SJohn Marino _GL_CXXALIASWARN (remove); 1489*4ce1b016SDaniel Fojt # endif 149051ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 149151ddd709SJohn Marino # undef remove 149251ddd709SJohn Marino /* Assume remove is always declared. */ 149351ddd709SJohn Marino _GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - " 149451ddd709SJohn Marino "use gnulib module remove for more portability"); 149551ddd709SJohn Marino #endif 149651ddd709SJohn Marino 149751ddd709SJohn Marino #if 0 149851ddd709SJohn Marino # if 0 149951ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 150051ddd709SJohn Marino # undef rename 150151ddd709SJohn Marino # define rename rpl_rename 150251ddd709SJohn Marino # endif 150351ddd709SJohn Marino _GL_FUNCDECL_RPL (rename, int, 150451ddd709SJohn Marino (const char *old_filename, const char *new_filename) 150551ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 150651ddd709SJohn Marino _GL_CXXALIAS_RPL (rename, int, 150751ddd709SJohn Marino (const char *old_filename, const char *new_filename)); 150851ddd709SJohn Marino # else 150951ddd709SJohn Marino _GL_CXXALIAS_SYS (rename, int, 151051ddd709SJohn Marino (const char *old_filename, const char *new_filename)); 151151ddd709SJohn Marino # endif 1512*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 151351ddd709SJohn Marino _GL_CXXALIASWARN (rename); 1514*4ce1b016SDaniel Fojt # endif 151551ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 151651ddd709SJohn Marino # undef rename 151751ddd709SJohn Marino /* Assume rename is always declared. */ 151851ddd709SJohn Marino _GL_WARN_ON_USE (rename, "rename is buggy on some platforms - " 151951ddd709SJohn Marino "use gnulib module rename for more portability"); 152051ddd709SJohn Marino #endif 152151ddd709SJohn Marino 152251ddd709SJohn Marino #if 0 152351ddd709SJohn Marino # if 0 152451ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 152551ddd709SJohn Marino # undef renameat 152651ddd709SJohn Marino # define renameat rpl_renameat 152751ddd709SJohn Marino # endif 152851ddd709SJohn Marino _GL_FUNCDECL_RPL (renameat, int, 152951ddd709SJohn Marino (int fd1, char const *file1, int fd2, char const *file2) 153051ddd709SJohn Marino _GL_ARG_NONNULL ((2, 4))); 153151ddd709SJohn Marino _GL_CXXALIAS_RPL (renameat, int, 153251ddd709SJohn Marino (int fd1, char const *file1, int fd2, char const *file2)); 153351ddd709SJohn Marino # else 153451ddd709SJohn Marino # if !1 153551ddd709SJohn Marino _GL_FUNCDECL_SYS (renameat, int, 153651ddd709SJohn Marino (int fd1, char const *file1, int fd2, char const *file2) 153751ddd709SJohn Marino _GL_ARG_NONNULL ((2, 4))); 153851ddd709SJohn Marino # endif 153951ddd709SJohn Marino _GL_CXXALIAS_SYS (renameat, int, 154051ddd709SJohn Marino (int fd1, char const *file1, int fd2, char const *file2)); 154151ddd709SJohn Marino # endif 154251ddd709SJohn Marino _GL_CXXALIASWARN (renameat); 154351ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 154451ddd709SJohn Marino # undef renameat 154551ddd709SJohn Marino # if HAVE_RAW_DECL_RENAMEAT 154651ddd709SJohn Marino _GL_WARN_ON_USE (renameat, "renameat is not portable - " 154751ddd709SJohn Marino "use gnulib module renameat for portability"); 154851ddd709SJohn Marino # endif 154951ddd709SJohn Marino #endif 155051ddd709SJohn Marino 155151ddd709SJohn Marino #if 1 155251ddd709SJohn Marino # if 0 && 0 155351ddd709SJohn Marino # if defined __GNUC__ 155451ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 155551ddd709SJohn Marino # undef scanf 155651ddd709SJohn Marino /* Don't break __attribute__((format(scanf,M,N))). */ 155751ddd709SJohn Marino # define scanf __scanf__ 155851ddd709SJohn Marino # endif 155951ddd709SJohn Marino _GL_FUNCDECL_RPL_1 (__scanf__, int, 156051ddd709SJohn Marino (const char *format, ...) 156151ddd709SJohn Marino __asm__ ( 156251ddd709SJohn Marino _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf)) 156351ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 156451ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 156551ddd709SJohn Marino _GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...)); 156651ddd709SJohn Marino # else 156751ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 156851ddd709SJohn Marino # undef scanf 156951ddd709SJohn Marino # define scanf rpl_scanf 157051ddd709SJohn Marino # endif 157151ddd709SJohn Marino _GL_FUNCDECL_RPL (scanf, int, (const char *format, ...) 157251ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2) 157351ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 157451ddd709SJohn Marino _GL_CXXALIAS_RPL (scanf, int, (const char *format, ...)); 157551ddd709SJohn Marino # endif 157651ddd709SJohn Marino # else 157751ddd709SJohn Marino _GL_CXXALIAS_SYS (scanf, int, (const char *format, ...)); 157851ddd709SJohn Marino # endif 1579*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 158051ddd709SJohn Marino _GL_CXXALIASWARN (scanf); 158151ddd709SJohn Marino # endif 1582*4ce1b016SDaniel Fojt #endif 158351ddd709SJohn Marino 158451ddd709SJohn Marino #if IN_GREP_GNULIB_TESTS 158551ddd709SJohn Marino # if 0 158651ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 158751ddd709SJohn Marino # define snprintf rpl_snprintf 158851ddd709SJohn Marino # endif 158951ddd709SJohn Marino _GL_FUNCDECL_RPL (snprintf, int, 159051ddd709SJohn Marino (char *str, size_t size, const char *format, ...) 159151ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 159251ddd709SJohn Marino _GL_ARG_NONNULL ((3))); 159351ddd709SJohn Marino _GL_CXXALIAS_RPL (snprintf, int, 159451ddd709SJohn Marino (char *str, size_t size, const char *format, ...)); 159551ddd709SJohn Marino # else 159651ddd709SJohn Marino # if !1 159751ddd709SJohn Marino _GL_FUNCDECL_SYS (snprintf, int, 159851ddd709SJohn Marino (char *str, size_t size, const char *format, ...) 159951ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4) 160051ddd709SJohn Marino _GL_ARG_NONNULL ((3))); 160151ddd709SJohn Marino # endif 160251ddd709SJohn Marino _GL_CXXALIAS_SYS (snprintf, int, 160351ddd709SJohn Marino (char *str, size_t size, const char *format, ...)); 160451ddd709SJohn Marino # endif 160551ddd709SJohn Marino _GL_CXXALIASWARN (snprintf); 160651ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 160751ddd709SJohn Marino # undef snprintf 160851ddd709SJohn Marino # if HAVE_RAW_DECL_SNPRINTF 160951ddd709SJohn Marino _GL_WARN_ON_USE (snprintf, "snprintf is unportable - " 161051ddd709SJohn Marino "use gnulib module snprintf for portability"); 161151ddd709SJohn Marino # endif 161251ddd709SJohn Marino #endif 161351ddd709SJohn Marino 161451ddd709SJohn Marino /* Some people would argue that all sprintf uses should be warned about 161551ddd709SJohn Marino (for example, OpenBSD issues a link warning for it), 161651ddd709SJohn Marino since it can cause security holes due to buffer overruns. 161751ddd709SJohn Marino However, we believe that sprintf can be used safely, and is more 161851ddd709SJohn Marino efficient than snprintf in those safe cases; and as proof of our 161951ddd709SJohn Marino belief, we use sprintf in several gnulib modules. So this header 162051ddd709SJohn Marino intentionally avoids adding a warning to sprintf except when 162151ddd709SJohn Marino GNULIB_POSIXCHECK is defined. */ 162251ddd709SJohn Marino 162351ddd709SJohn Marino #if 0 162451ddd709SJohn Marino # if 0 162551ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 162651ddd709SJohn Marino # define sprintf rpl_sprintf 162751ddd709SJohn Marino # endif 162851ddd709SJohn Marino _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) 162951ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 163051ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 163151ddd709SJohn Marino _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); 163251ddd709SJohn Marino # else 163351ddd709SJohn Marino _GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...)); 163451ddd709SJohn Marino # endif 1635*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 163651ddd709SJohn Marino _GL_CXXALIASWARN (sprintf); 1637*4ce1b016SDaniel Fojt # endif 163851ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 163951ddd709SJohn Marino # undef sprintf 164051ddd709SJohn Marino /* Assume sprintf is always declared. */ 164151ddd709SJohn Marino _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " 164251ddd709SJohn Marino "use gnulib module sprintf-posix for portable " 164351ddd709SJohn Marino "POSIX compliance"); 164451ddd709SJohn Marino #endif 164551ddd709SJohn Marino 164651ddd709SJohn Marino #if 0 164751ddd709SJohn Marino # if 0 164851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 164951ddd709SJohn Marino # define tmpfile rpl_tmpfile 165051ddd709SJohn Marino # endif 165151ddd709SJohn Marino _GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); 165251ddd709SJohn Marino _GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); 165351ddd709SJohn Marino # else 165451ddd709SJohn Marino _GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); 165551ddd709SJohn Marino # endif 1656*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 165751ddd709SJohn Marino _GL_CXXALIASWARN (tmpfile); 1658*4ce1b016SDaniel Fojt # endif 165951ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 166051ddd709SJohn Marino # undef tmpfile 166151ddd709SJohn Marino # if HAVE_RAW_DECL_TMPFILE 166251ddd709SJohn Marino _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " 166351ddd709SJohn Marino "use gnulib module tmpfile for portability"); 166451ddd709SJohn Marino # endif 166551ddd709SJohn Marino #endif 166651ddd709SJohn Marino 166751ddd709SJohn Marino #if 0 166851ddd709SJohn Marino /* Write formatted output to a string dynamically allocated with malloc(). 166951ddd709SJohn Marino If the memory allocation succeeds, store the address of the string in 167051ddd709SJohn Marino *RESULT and return the number of resulting bytes, excluding the trailing 167151ddd709SJohn Marino NUL. Upon memory allocation error, or some other error, return -1. */ 167251ddd709SJohn Marino # if 0 167351ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 167451ddd709SJohn Marino # define asprintf rpl_asprintf 167551ddd709SJohn Marino # endif 167651ddd709SJohn Marino _GL_FUNCDECL_RPL (asprintf, int, 167751ddd709SJohn Marino (char **result, const char *format, ...) 167851ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 167951ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 168051ddd709SJohn Marino _GL_CXXALIAS_RPL (asprintf, int, 168151ddd709SJohn Marino (char **result, const char *format, ...)); 168251ddd709SJohn Marino # else 168351ddd709SJohn Marino # if !1 168451ddd709SJohn Marino _GL_FUNCDECL_SYS (asprintf, int, 168551ddd709SJohn Marino (char **result, const char *format, ...) 168651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3) 168751ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 168851ddd709SJohn Marino # endif 168951ddd709SJohn Marino _GL_CXXALIAS_SYS (asprintf, int, 169051ddd709SJohn Marino (char **result, const char *format, ...)); 169151ddd709SJohn Marino # endif 169251ddd709SJohn Marino _GL_CXXALIASWARN (asprintf); 169351ddd709SJohn Marino # if 0 169451ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 169551ddd709SJohn Marino # define vasprintf rpl_vasprintf 169651ddd709SJohn Marino # endif 169751ddd709SJohn Marino _GL_FUNCDECL_RPL (vasprintf, int, 169851ddd709SJohn Marino (char **result, const char *format, va_list args) 169951ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 170051ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 170151ddd709SJohn Marino _GL_CXXALIAS_RPL (vasprintf, int, 170251ddd709SJohn Marino (char **result, const char *format, va_list args)); 170351ddd709SJohn Marino # else 170451ddd709SJohn Marino # if !1 170551ddd709SJohn Marino _GL_FUNCDECL_SYS (vasprintf, int, 170651ddd709SJohn Marino (char **result, const char *format, va_list args) 170751ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 170851ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 170951ddd709SJohn Marino # endif 171051ddd709SJohn Marino _GL_CXXALIAS_SYS (vasprintf, int, 171151ddd709SJohn Marino (char **result, const char *format, va_list args)); 171251ddd709SJohn Marino # endif 171351ddd709SJohn Marino _GL_CXXALIASWARN (vasprintf); 171451ddd709SJohn Marino #endif 171551ddd709SJohn Marino 171651ddd709SJohn Marino #if 0 171751ddd709SJohn Marino # if 0 171851ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 171951ddd709SJohn Marino # define vdprintf rpl_vdprintf 172051ddd709SJohn Marino # endif 172151ddd709SJohn Marino _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) 172251ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 172351ddd709SJohn Marino _GL_ARG_NONNULL ((2))); 172451ddd709SJohn Marino _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); 172551ddd709SJohn Marino # else 172651ddd709SJohn Marino # if !1 172751ddd709SJohn Marino _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) 172851ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 172951ddd709SJohn Marino _GL_ARG_NONNULL ((2))); 173051ddd709SJohn Marino # endif 173151ddd709SJohn Marino /* Need to cast, because on Solaris, the third parameter will likely be 173251ddd709SJohn Marino __va_list args. */ 173351ddd709SJohn Marino _GL_CXXALIAS_SYS_CAST (vdprintf, int, 173451ddd709SJohn Marino (int fd, const char *format, va_list args)); 173551ddd709SJohn Marino # endif 1736*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 173751ddd709SJohn Marino _GL_CXXALIASWARN (vdprintf); 1738*4ce1b016SDaniel Fojt # endif 173951ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 174051ddd709SJohn Marino # undef vdprintf 174151ddd709SJohn Marino # if HAVE_RAW_DECL_VDPRINTF 174251ddd709SJohn Marino _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - " 174351ddd709SJohn Marino "use gnulib module vdprintf for portability"); 174451ddd709SJohn Marino # endif 174551ddd709SJohn Marino #endif 174651ddd709SJohn Marino 174751ddd709SJohn Marino #if 0 || 1 174851ddd709SJohn Marino # if (0 && 0) \ 174951ddd709SJohn Marino || (1 && 0 && (0 || 0)) 175051ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 175151ddd709SJohn Marino # define vfprintf rpl_vfprintf 175251ddd709SJohn Marino # endif 175351ddd709SJohn Marino # define GNULIB_overrides_vfprintf 1 175451ddd709SJohn Marino # if 0 175551ddd709SJohn Marino _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 175651ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 175751ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 175851ddd709SJohn Marino # else 175951ddd709SJohn Marino _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 176051ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0) 176151ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 176251ddd709SJohn Marino # endif 176351ddd709SJohn Marino _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); 176451ddd709SJohn Marino # else 176551ddd709SJohn Marino /* Need to cast, because on Solaris, the third parameter is 176651ddd709SJohn Marino __va_list args 176751ddd709SJohn Marino and GCC's fixincludes did not change this to __gnuc_va_list. */ 176851ddd709SJohn Marino _GL_CXXALIAS_SYS_CAST (vfprintf, int, 176951ddd709SJohn Marino (FILE *fp, const char *format, va_list args)); 177051ddd709SJohn Marino # endif 1771*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 177251ddd709SJohn Marino _GL_CXXALIASWARN (vfprintf); 177351ddd709SJohn Marino # endif 1774*4ce1b016SDaniel Fojt #endif 177551ddd709SJohn Marino #if !0 && defined GNULIB_POSIXCHECK 177651ddd709SJohn Marino # if !GNULIB_overrides_vfprintf 177751ddd709SJohn Marino # undef vfprintf 177851ddd709SJohn Marino # endif 177951ddd709SJohn Marino /* Assume vfprintf is always declared. */ 178051ddd709SJohn Marino _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - " 178151ddd709SJohn Marino "use gnulib module vfprintf-posix for portable " 178251ddd709SJohn Marino "POSIX compliance"); 178351ddd709SJohn Marino #endif 178451ddd709SJohn Marino 178551ddd709SJohn Marino #if 0 178651ddd709SJohn Marino # if 0 && 0 178751ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 178851ddd709SJohn Marino # undef vfscanf 178951ddd709SJohn Marino # define vfscanf rpl_vfscanf 179051ddd709SJohn Marino # endif 179151ddd709SJohn Marino _GL_FUNCDECL_RPL (vfscanf, int, 179251ddd709SJohn Marino (FILE *stream, const char *format, va_list args) 179351ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0) 179451ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 179551ddd709SJohn Marino _GL_CXXALIAS_RPL (vfscanf, int, 179651ddd709SJohn Marino (FILE *stream, const char *format, va_list args)); 179751ddd709SJohn Marino # else 179851ddd709SJohn Marino _GL_CXXALIAS_SYS (vfscanf, int, 179951ddd709SJohn Marino (FILE *stream, const char *format, va_list args)); 180051ddd709SJohn Marino # endif 180151ddd709SJohn Marino _GL_CXXALIASWARN (vfscanf); 180251ddd709SJohn Marino #endif 180351ddd709SJohn Marino 180451ddd709SJohn Marino #if 0 || 1 180551ddd709SJohn Marino # if (0 && 0) \ 180651ddd709SJohn Marino || (1 && 0 && (0 || 0)) 180751ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 180851ddd709SJohn Marino # define vprintf rpl_vprintf 180951ddd709SJohn Marino # endif 181051ddd709SJohn Marino # define GNULIB_overrides_vprintf 1 181151ddd709SJohn Marino # if 0 || 0 181251ddd709SJohn Marino _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 181351ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0) 181451ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 181551ddd709SJohn Marino # else 181651ddd709SJohn Marino _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 181751ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0) 181851ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 181951ddd709SJohn Marino # endif 182051ddd709SJohn Marino _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); 182151ddd709SJohn Marino # else 182251ddd709SJohn Marino /* Need to cast, because on Solaris, the second parameter is 182351ddd709SJohn Marino __va_list args 182451ddd709SJohn Marino and GCC's fixincludes did not change this to __gnuc_va_list. */ 182551ddd709SJohn Marino _GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); 182651ddd709SJohn Marino # endif 1827*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 182851ddd709SJohn Marino _GL_CXXALIASWARN (vprintf); 182951ddd709SJohn Marino # endif 1830*4ce1b016SDaniel Fojt #endif 183151ddd709SJohn Marino #if !0 && defined GNULIB_POSIXCHECK 183251ddd709SJohn Marino # if !GNULIB_overrides_vprintf 183351ddd709SJohn Marino # undef vprintf 183451ddd709SJohn Marino # endif 183551ddd709SJohn Marino /* Assume vprintf is always declared. */ 183651ddd709SJohn Marino _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - " 183751ddd709SJohn Marino "use gnulib module vprintf-posix for portable " 183851ddd709SJohn Marino "POSIX compliance"); 183951ddd709SJohn Marino #endif 184051ddd709SJohn Marino 184151ddd709SJohn Marino #if 0 184251ddd709SJohn Marino # if 0 && 0 184351ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 184451ddd709SJohn Marino # undef vscanf 184551ddd709SJohn Marino # define vscanf rpl_vscanf 184651ddd709SJohn Marino # endif 184751ddd709SJohn Marino _GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args) 184851ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0) 184951ddd709SJohn Marino _GL_ARG_NONNULL ((1))); 185051ddd709SJohn Marino _GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args)); 185151ddd709SJohn Marino # else 185251ddd709SJohn Marino _GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args)); 185351ddd709SJohn Marino # endif 185451ddd709SJohn Marino _GL_CXXALIASWARN (vscanf); 185551ddd709SJohn Marino #endif 185651ddd709SJohn Marino 185751ddd709SJohn Marino #if 0 185851ddd709SJohn Marino # if 0 185951ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 186051ddd709SJohn Marino # define vsnprintf rpl_vsnprintf 186151ddd709SJohn Marino # endif 186251ddd709SJohn Marino _GL_FUNCDECL_RPL (vsnprintf, int, 186351ddd709SJohn Marino (char *str, size_t size, const char *format, va_list args) 186451ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 186551ddd709SJohn Marino _GL_ARG_NONNULL ((3))); 186651ddd709SJohn Marino _GL_CXXALIAS_RPL (vsnprintf, int, 186751ddd709SJohn Marino (char *str, size_t size, const char *format, va_list args)); 186851ddd709SJohn Marino # else 186951ddd709SJohn Marino # if !1 187051ddd709SJohn Marino _GL_FUNCDECL_SYS (vsnprintf, int, 187151ddd709SJohn Marino (char *str, size_t size, const char *format, va_list args) 187251ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) 187351ddd709SJohn Marino _GL_ARG_NONNULL ((3))); 187451ddd709SJohn Marino # endif 187551ddd709SJohn Marino _GL_CXXALIAS_SYS (vsnprintf, int, 187651ddd709SJohn Marino (char *str, size_t size, const char *format, va_list args)); 187751ddd709SJohn Marino # endif 187851ddd709SJohn Marino _GL_CXXALIASWARN (vsnprintf); 187951ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 188051ddd709SJohn Marino # undef vsnprintf 188151ddd709SJohn Marino # if HAVE_RAW_DECL_VSNPRINTF 188251ddd709SJohn Marino _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - " 188351ddd709SJohn Marino "use gnulib module vsnprintf for portability"); 188451ddd709SJohn Marino # endif 188551ddd709SJohn Marino #endif 188651ddd709SJohn Marino 188751ddd709SJohn Marino #if 0 188851ddd709SJohn Marino # if 0 188951ddd709SJohn Marino # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 189051ddd709SJohn Marino # define vsprintf rpl_vsprintf 189151ddd709SJohn Marino # endif 189251ddd709SJohn Marino _GL_FUNCDECL_RPL (vsprintf, int, 189351ddd709SJohn Marino (char *str, const char *format, va_list args) 189451ddd709SJohn Marino _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0) 189551ddd709SJohn Marino _GL_ARG_NONNULL ((1, 2))); 189651ddd709SJohn Marino _GL_CXXALIAS_RPL (vsprintf, int, 189751ddd709SJohn Marino (char *str, const char *format, va_list args)); 189851ddd709SJohn Marino # else 189951ddd709SJohn Marino /* Need to cast, because on Solaris, the third parameter is 190051ddd709SJohn Marino __va_list args 190151ddd709SJohn Marino and GCC's fixincludes did not change this to __gnuc_va_list. */ 190251ddd709SJohn Marino _GL_CXXALIAS_SYS_CAST (vsprintf, int, 190351ddd709SJohn Marino (char *str, const char *format, va_list args)); 190451ddd709SJohn Marino # endif 1905*4ce1b016SDaniel Fojt # if __GLIBC__ >= 2 190651ddd709SJohn Marino _GL_CXXALIASWARN (vsprintf); 1907*4ce1b016SDaniel Fojt # endif 190851ddd709SJohn Marino #elif defined GNULIB_POSIXCHECK 190951ddd709SJohn Marino # undef vsprintf 191051ddd709SJohn Marino /* Assume vsprintf is always declared. */ 191151ddd709SJohn Marino _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - " 191251ddd709SJohn Marino "use gnulib module vsprintf-posix for portable " 191351ddd709SJohn Marino "POSIX compliance"); 191451ddd709SJohn Marino #endif 191551ddd709SJohn Marino 191651ddd709SJohn Marino #endif /* _GL_STDIO_H */ 191751ddd709SJohn Marino #endif /* _GL_STDIO_H */ 191851ddd709SJohn Marino #endif 1919