1 /* A GNU-like <stdio.h>.
3 Copyright (C) 2004, 2007 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 #if defined __need_FILE || defined __need___FILE
20 /* Special invocation convention inside glibc header files. */
22 #if @HAVE_INCLUDE_NEXT@
23 # include_next <stdio.h>
25 # include @ABSOLUTE_STDIO_H@
29 /* Normal invocation convention. */
31 #if @HAVE_INCLUDE_NEXT@
32 # include_next <stdio.h>
38 #if ! @HAVE_INCLUDE_NEXT@
39 # include @ABSOLUTE_STDIO_H@
45 #if (@GNULIB_FFLUSH@ && @REPLACE_FFLUSH@) \
46 || (@GNULIB_FSEEKO@ && (!@HAVE_FSEEKO@ || @REPLACE_FSEEKO@)) \
47 || (@GNULIB_FTELLO@ && (!@HAVE_FTELLO@ || @REPLACE_FTELLO@))
49 # include <sys/types.h>
53 /* This feature is available in gcc versions 2.5 and later. */
54 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
55 # define __attribute__(Spec) /* empty */
57 /* The __-protected variants of `format' and `printf' attributes
58 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
59 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
60 # define __format__ format
61 # define __printf__ printf
66 /* The definition of GL_LINK_WARNING is copied here. */
74 #if @GNULIB_FPRINTF_POSIX@
75 # if @REPLACE_FPRINTF@
76 # define fprintf rpl_fprintf
77 extern int fprintf (FILE *fp, const char *format, ...)
78 __attribute__ ((__format__ (__printf__, 2, 3)));
80 #elif defined GNULIB_POSIXCHECK
83 (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
84 "use gnulib module fprintf-posix for portable " \
85 "POSIX compliance"), \
89 #if @GNULIB_VFPRINTF_POSIX@
90 # if @REPLACE_VFPRINTF@
91 # define vfprintf rpl_vfprintf
92 extern int vfprintf (FILE *fp, const char *format, va_list args)
93 __attribute__ ((__format__ (__printf__, 2, 0)));
95 #elif defined GNULIB_POSIXCHECK
97 # define vfprintf(s,f,a) \
98 (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
99 "use gnulib module vfprintf-posix for portable " \
100 "POSIX compliance"), \
104 #if @GNULIB_PRINTF_POSIX@
105 # if @REPLACE_PRINTF@
106 /* Don't break __attribute__((format(printf,M,N))). */
107 # define printf __printf__
108 extern int printf (const char *format, ...)
109 __attribute__ ((__format__ (__printf__, 1, 2)));
111 #elif defined GNULIB_POSIXCHECK
114 (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
115 "use gnulib module printf-posix for portable " \
116 "POSIX compliance"), \
118 /* Don't break __attribute__((format(printf,M,N))). */
119 # define format(kind,m,n) format (__##kind##__, m, n)
120 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
121 # define ____printf____ __printf__
122 # define ____scanf____ __scanf__
123 # define ____strftime____ __strftime__
124 # define ____strfmon____ __strfmon__
127 #if @GNULIB_VPRINTF_POSIX@
128 # if @REPLACE_VPRINTF@
129 # define vprintf rpl_vprintf
130 extern int vprintf (const char *format, va_list args)
131 __attribute__ ((__format__ (__printf__, 1, 0)));
133 #elif defined GNULIB_POSIXCHECK
135 # define vprintf(f,a) \
136 (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
137 "use gnulib module vprintf-posix for portable " \
138 "POSIX compliance"), \
142 #if @GNULIB_SNPRINTF@
143 # if @REPLACE_SNPRINTF@
144 # define snprintf rpl_snprintf
146 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
147 extern int snprintf (char *str, size_t size, const char *format, ...)
148 __attribute__ ((__format__ (__printf__, 3, 4)));
150 #elif defined GNULIB_POSIXCHECK
153 (GL_LINK_WARNING ("snprintf is unportable - " \
154 "use gnulib module snprintf for portability"), \
158 #if @GNULIB_VSNPRINTF@
159 # if @REPLACE_VSNPRINTF@
160 # define vsnprintf rpl_vsnprintf
162 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
163 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
164 __attribute__ ((__format__ (__printf__, 3, 0)));
166 #elif defined GNULIB_POSIXCHECK
168 # define vsnprintf(b,s,f,a) \
169 (GL_LINK_WARNING ("vsnprintf is unportable - " \
170 "use gnulib module vsnprintf for portability"), \
171 vsnprintf (b, s, f, a))
174 #if @GNULIB_SPRINTF_POSIX@
175 # if @REPLACE_SPRINTF@
176 # define sprintf rpl_sprintf
177 extern int sprintf (char *str, const char *format, ...)
178 __attribute__ ((__format__ (__printf__, 2, 3)));
180 #elif defined GNULIB_POSIXCHECK
183 (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
184 "use gnulib module sprintf-posix for portable " \
185 "POSIX compliance"), \
189 #if @GNULIB_VSPRINTF_POSIX@
190 # if @REPLACE_VSPRINTF@
191 # define vsprintf rpl_vsprintf
192 extern int vsprintf (char *str, const char *format, va_list args)
193 __attribute__ ((__format__ (__printf__, 2, 0)));
195 #elif defined GNULIB_POSIXCHECK
197 # define vsprintf(b,f,a) \
198 (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
199 "use gnulib module vsprintf-posix for portable " \
200 "POSIX compliance"), \
204 #if @GNULIB_VASPRINTF@
205 # if @REPLACE_VASPRINTF@
206 # define asprintf rpl_asprintf
207 # define vasprintf rpl_vasprintf
209 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
210 /* Write formatted output to a string dynamically allocated with malloc().
211 If the memory allocation succeeds, store the address of the string in
212 *RESULT and return the number of resulting bytes, excluding the trailing
213 NUL. Upon memory allocation error, or some other error, return -1. */
214 extern int asprintf (char **result, const char *format, ...)
215 __attribute__ ((__format__ (__printf__, 2, 3)));
216 extern int vasprintf (char **result, const char *format, va_list args)
217 __attribute__ ((__format__ (__printf__, 2, 0)));
221 #if (@GNULIB_FFLUSH@ && @REPLACE_FFLUSH@) || (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@)
222 /* Provide fseek, fseeko functions that are aware of a preceding fflush(). */
223 # define fseeko rpl_fseeko
224 extern int fseeko (FILE *fp, off_t offset, int whence);
225 # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
226 #elif @GNULIB_FSEEKO@
228 /* Assume 'off_t' is the same type as 'long'. */
229 typedef int verify_fseeko_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
230 # define fseeko fseek
232 #elif defined GNULIB_POSIXCHECK
234 # define fseeko(f,o,w) \
235 (GL_LINK_WARNING ("fseeko is unportable - " \
236 "use gnulib module fseeko for portability"), \
240 #if defined GNULIB_POSIXCHECK
242 # define fseek(f,o,w) \
243 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
244 "on 32-bit platforms - " \
245 "use fseeko function for handling of large files"), \
252 /* Assume 'off_t' is the same type as 'long'. */
253 typedef int verify_ftello_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
254 # define ftello ftell
255 # elif @REPLACE_FTELLO@
256 # define ftello rpl_ftello
257 extern off_t ftello (FILE *fp);
259 #elif defined GNULIB_POSIXCHECK
262 (GL_LINK_WARNING ("ftello is unportable - " \
263 "use gnulib module ftello for portability"), \
267 #if defined GNULIB_POSIXCHECK
270 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
271 "on 32-bit platforms - " \
272 "use ftello function for handling of large files"), \
278 # if @REPLACE_FFLUSH@
279 # define fflush rpl_fflush
280 /* Flush all pending data on STREAM according to POSIX rules. Both
281 output and seekable input streams are supported. */
282 extern int fflush (FILE *gl_stream);
284 #elif defined GNULIB_POSIXCHECK
287 (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
288 "use gnulib module fflush for portable " \
289 "POSIX compliance"), \
297 #endif /* _GL_STDIO_H */