]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/stdio.h
1 #ifndef _SQUID_COMPAT_STDIO_H
2 #define _SQUID_COMPAT_STDIO_H
4 /** 64-bit broken <cstdio>
6 * <stdio.h> provides fgetpos64, fopen64 if __USE_FILE_OFFSET64 is defined.
7 * It then checks whether a gcc-specific __REDIRECT macro is available
8 * (defined in <sys/cdefs.h>, depending on __GNUC__ begin available).
9 * If it is not available, it does a preprocessor #define.
10 * Which <cstdio> undefines, with this comment:
11 * "// Get rid of those macros defined in <stdio.h> in lieu of real functions.".
12 * When it does a namespace redirection ("namespace std { using ::fgetpos; }") it goes blam, as
13 * fgetpos64 is available, while fgetpos is not.
16 // Import the stdio.h definitions first to do the state setup
21 // Check for the buggy case
22 #if defined(__USE_FILE_OFFSET64) && !defined(__REDIRECT)
24 // Define the problem functions as needed
27 inline int fgetpos(FILE *f
, fpos64_t
*p
) { return fgetpos64(f
,p
); }
31 inline FILE * fopen(const char *f
, const char *m
) { return fopen64(f
,m
); }
35 inline FILE * freopen(const char *f
, const char *m
, FILE *s
) { return freopen64(f
,m
,s
); }
39 inline int fsetpos(FILE *f
, fpos64_t
*p
) { return fsetpos64(f
,p
); }
43 inline FILE * tmpfile(void) { return tmpfile64(); }
46 #endif /* __USE_FILE_OFFSET64 && !__REDIRECT */
48 // Finally import the <cstdio> stuff we actually use
49 #if defined(__cplusplus)
54 #define MAXPATHLEN SQUID_MAXPATHLEN
57 #endif /* _SQUID_COMPAT_STDIO_H */