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@) || (@GNULIB_FSEEKO@ && !@HAVE_FSEEKO@) || (@GNULIB_FTELLO@ && !@HAVE_FTELLO@)
47 # include <sys/types.h>
51 /* This feature is available in gcc versions 2.5 and later. */
52 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
53 # define __attribute__(Spec) /* empty */
55 /* The __-protected variants of `format' and `printf' attributes
56 are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
57 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
58 # define __format__ format
59 # define __printf__ printf
64 /* The definition of GL_LINK_WARNING is copied here. */
72 #if @GNULIB_FPRINTF_POSIX@
73 # if @REPLACE_FPRINTF@
74 # define fprintf rpl_fprintf
75 extern int fprintf (FILE *fp, const char *format, ...)
76 __attribute__ ((__format__ (__printf__, 2, 3)));
78 #elif defined GNULIB_POSIXCHECK
81 (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
82 "use gnulib module fprintf-posix for portable " \
83 "POSIX compliance"), \
87 #if @GNULIB_VFPRINTF_POSIX@
88 # if @REPLACE_VFPRINTF@
89 # define vfprintf rpl_vfprintf
90 extern int vfprintf (FILE *fp, const char *format, va_list args)
91 __attribute__ ((__format__ (__printf__, 2, 0)));
93 #elif defined GNULIB_POSIXCHECK
95 # define vfprintf(s,f,a) \
96 (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
97 "use gnulib module vfprintf-posix for portable " \
98 "POSIX compliance"), \
102 #if @GNULIB_PRINTF_POSIX@
103 # if @REPLACE_PRINTF@
104 /* Don't break __attribute__((format(printf,M,N))). */
105 # define printf __printf__
106 extern int printf (const char *format, ...)
107 __attribute__ ((__format__ (__printf__, 1, 2)));
109 #elif defined GNULIB_POSIXCHECK
112 (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
113 "use gnulib module printf-posix for portable " \
114 "POSIX compliance"), \
116 /* Don't break __attribute__((format(printf,M,N))). */
117 # define format(kind,m,n) format (__##kind##__, m, n)
118 # define __format__(kind,m,n) __format__ (__##kind##__, m, n)
119 # define ____printf____ __printf__
120 # define ____scanf____ __scanf__
121 # define ____strftime____ __strftime__
122 # define ____strfmon____ __strfmon__
125 #if @GNULIB_VPRINTF_POSIX@
126 # if @REPLACE_VPRINTF@
127 # define vprintf rpl_vprintf
128 extern int vprintf (const char *format, va_list args)
129 __attribute__ ((__format__ (__printf__, 1, 0)));
131 #elif defined GNULIB_POSIXCHECK
133 # define vprintf(f,a) \
134 (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
135 "use gnulib module vprintf-posix for portable " \
136 "POSIX compliance"), \
140 #if @GNULIB_SNPRINTF@
141 # if @REPLACE_SNPRINTF@
142 # define snprintf rpl_snprintf
144 # if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
145 extern int snprintf (char *str, size_t size, const char *format, ...)
146 __attribute__ ((__format__ (__printf__, 3, 4)));
148 #elif defined GNULIB_POSIXCHECK
151 (GL_LINK_WARNING ("snprintf is unportable - " \
152 "use gnulib module snprintf for portability"), \
156 #if @GNULIB_VSNPRINTF@
157 # if @REPLACE_VSNPRINTF@
158 # define vsnprintf rpl_vsnprintf
160 # if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
161 extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
162 __attribute__ ((__format__ (__printf__, 3, 0)));
164 #elif defined GNULIB_POSIXCHECK
166 # define vsnprintf(b,s,f,a) \
167 (GL_LINK_WARNING ("vsnprintf is unportable - " \
168 "use gnulib module vsnprintf for portability"), \
169 vsnprintf (b, s, f, a))
172 #if @GNULIB_SPRINTF_POSIX@
173 # if @REPLACE_SPRINTF@
174 # define sprintf rpl_sprintf
175 extern int sprintf (char *str, const char *format, ...)
176 __attribute__ ((__format__ (__printf__, 2, 3)));
178 #elif defined GNULIB_POSIXCHECK
181 (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
182 "use gnulib module sprintf-posix for portable " \
183 "POSIX compliance"), \
187 #if @GNULIB_VSPRINTF_POSIX@
188 # if @REPLACE_VSPRINTF@
189 # define vsprintf rpl_vsprintf
190 extern int vsprintf (char *str, const char *format, va_list args)
191 __attribute__ ((__format__ (__printf__, 2, 0)));
193 #elif defined GNULIB_POSIXCHECK
195 # define vsprintf(b,f,a) \
196 (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
197 "use gnulib module vsprintf-posix for portable " \
198 "POSIX compliance"), \
202 #if @GNULIB_VASPRINTF@
203 # if @REPLACE_VASPRINTF@
204 # define asprintf rpl_asprintf
205 # define vasprintf rpl_vasprintf
207 # if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
208 /* Write formatted output to a string dynamically allocated with malloc().
209 If the memory allocation succeeds, store the address of the string in
210 *RESULT and return the number of resulting bytes, excluding the trailing
211 NUL. Upon memory allocation error, or some other error, return -1. */
212 extern int asprintf (char **result, const char *format, ...)
213 __attribute__ ((__format__ (__printf__, 2, 3)));
214 extern int vasprintf (char **result, const char *format, va_list args)
215 __attribute__ ((__format__ (__printf__, 2, 0)));
219 #if @GNULIB_FFLUSH@ && @REPLACE_FFLUSH@
220 /* Provide fseek, fseeko functions that are aware of a preceding fflush(). */
221 # define fseeko rpl_fseeko
222 extern int fseeko (FILE *fp, off_t offset, int whence);
223 # define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
224 #elif @GNULIB_FSEEKO@
226 /* Assume 'off_t' is the same type as 'long'. */
227 typedef int verify_fseeko_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
228 # define fseeko fseek
230 #elif defined GNULIB_POSIXCHECK
232 # define fseeko(f,o,w) \
233 (GL_LINK_WARNING ("fseeko is unportable - " \
234 "use gnulib module fseeko for portability"), \
238 #if defined GNULIB_POSIXCHECK
240 # define fseek(f,o,w) \
241 (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
242 "on 32-bit platforms - " \
243 "use fseeko function for handling of large files"), \
250 /* Assume 'off_t' is the same type as 'long'. */
251 typedef int verify_ftello_types[2 * (sizeof (off_t) == sizeof (long)) - 1];
252 # define ftello ftell
254 #elif defined GNULIB_POSIXCHECK
257 (GL_LINK_WARNING ("ftello is unportable - " \
258 "use gnulib module ftello for portability"), \
262 #if defined GNULIB_POSIXCHECK
265 (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
266 "on 32-bit platforms - " \
267 "use ftello function for handling of large files"), \
273 # if @REPLACE_FFLUSH@
274 # define fflush rpl_fflush
275 /* Flush all pending data on STREAM according to POSIX rules. Both
276 output and seekable input streams are supported. */
277 extern int fflush (FILE *gl_stream);
279 #elif defined GNULIB_POSIXCHECK
282 (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
283 "use gnulib module fflush for portable " \
284 "POSIX compliance"), \
292 #endif /* _GL_STDIO_H */