]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/stdio.h
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef _SQUID_COMPAT_STDIO_H
10 #define _SQUID_COMPAT_STDIO_H
12 /** 64-bit broken <cstdio>
14 * <stdio.h> provides fgetpos64, fopen64 if __USE_FILE_OFFSET64 is defined.
15 * It then checks whether a gcc-specific __REDIRECT macro is available
16 * (defined in <sys/cdefs.h>, depending on __GNUC__ begin available).
17 * If it is not available, it does a preprocessor #define.
18 * Which <cstdio> undefines, with this comment:
19 * "// Get rid of those macros defined in <stdio.h> in lieu of real functions.".
20 * When it does a namespace redirection ("namespace std { using ::fgetpos; }") it goes blam, as
21 * fgetpos64 is available, while fgetpos is not.
24 // Import the stdio.h definitions first to do the state setup
29 // Check for the buggy case
30 #if defined(__USE_FILE_OFFSET64) && !defined(__REDIRECT)
32 // Define the problem functions as needed
35 inline int fgetpos(FILE *f
, fpos64_t
*p
) { return fgetpos64(f
,p
); }
39 inline FILE * fopen(const char *f
, const char *m
) { return fopen64(f
,m
); }
43 inline FILE * freopen(const char *f
, const char *m
, FILE *s
) { return freopen64(f
,m
,s
); }
47 inline int fsetpos(FILE *f
, fpos64_t
*p
) { return fsetpos64(f
,p
); }
51 inline FILE * tmpfile(void) { return tmpfile64(); }
54 #endif /* __USE_FILE_OFFSET64 && !__REDIRECT */
56 // Finally import the <cstdio> stuff we actually use
57 #if defined(__cplusplus)
62 #define MAXPATHLEN SQUID_MAXPATHLEN
65 #endif /* _SQUID_COMPAT_STDIO_H */