Re: HAVE_FSEEKO for WIN32 - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: HAVE_FSEEKO for WIN32 |
Date | |
Msg-id | 200901070339.n073dBd03442@momjian.us Whole thread Raw |
In response to | HAVE_FSEEKO for WIN32 (Andrew Dunstan <andrew@dunslane.net>) |
Responses |
Re: HAVE_FSEEKO for WIN32
|
List | pgsql-hackers |
Andrew Dunstan wrote: > > Cleaning up the parallel restore patch I came across a question I might > have asked before, but one which in any case I worked around: > > Why do we carefully define fseeko() for WIN32 but then not define > HAVE_FSEEKO, which makes doing the former pretty much pointless? With Andrew, I have developed and applied the attached patch so MinGW handles fseeko() translation similar to Unix. Someone will need to update MSVC to have similar behavior. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Index: configure =================================================================== RCS file: /cvsroot/pgsql/configure,v retrieving revision 1.623 diff -c -c -r1.623 configure *** configure 6 Jan 2009 17:27:05 -0000 1.623 --- configure 7 Jan 2009 03:31:03 -0000 *************** *** 18999,19005 **** case $host_os in # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos ! bsdi*|netbsd*) cat >>confdefs.h <<\_ACEOF #define HAVE_FSEEKO 1 --- 18999,19006 ---- case $host_os in # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos ! # Mingw uses macros to access Win32 API calls ! bsdi*|netbsd*|mingw*) cat >>confdefs.h <<\_ACEOF #define HAVE_FSEEKO 1 Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.582 diff -c -c -r1.582 configure.in *** configure.in 6 Jan 2009 17:27:06 -0000 1.582 --- configure.in 7 Jan 2009 03:31:03 -0000 *************** *** 1319,1325 **** AC_REPLACE_FUNCS(fseeko) case $host_os in # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos ! bsdi*|netbsd*) AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.]) ac_cv_func_fseeko=yes;; *) --- 1319,1326 ---- AC_REPLACE_FUNCS(fseeko) case $host_os in # BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos ! # Mingw uses macros to access Win32 API calls ! bsdi*|netbsd*|mingw*) AC_DEFINE(HAVE_FSEEKO, 1, [Define to 1 because replacement version used.]) ac_cv_func_fseeko=yes;; *) Index: src/bin/pg_dump/pg_dump.h =================================================================== RCS file: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.h,v retrieving revision 1.145 diff -c -c -r1.145 pg_dump.h *** src/bin/pg_dump/pg_dump.h 1 Jan 2009 17:23:54 -0000 1.145 --- src/bin/pg_dump/pg_dump.h 7 Jan 2009 03:31:08 -0000 *************** *** 17,41 **** #include "postgres_fe.h" /* - * WIN32 does not provide 64-bit off_t, but does provide the functions operating - * with 64-bit offsets. - */ - #ifdef WIN32 - #define pgoff_t __int64 - #undef fseeko - #undef ftello - #ifdef WIN32_ONLY_COMPILER - #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin) - #define ftello(stream) _ftelli64(stream) - #else - #define fseeko(stream, offset, origin) fseeko64(stream, offset, origin) - #define ftello(stream) ftello64(stream) - #endif - #else - #define pgoff_t off_t - #endif - - /* * pg_dump uses two different mechanisms for identifying database objects: * * CatalogId represents an object by the tableoid and oid of its defining --- 17,22 ---- Index: src/include/port.h =================================================================== RCS file: /cvsroot/pgsql/src/include/port.h,v retrieving revision 1.123 diff -c -c -r1.123 port.h *** src/include/port.h 1 Jan 2009 17:23:55 -0000 1.123 --- src/include/port.h 7 Jan 2009 03:31:08 -0000 *************** *** 341,350 **** --- 341,354 ---- extern char *crypt(const char *key, const char *setting); #endif + /* WIN32 handled in port/win32.h */ + #ifndef WIN32 + #define pgoff_t off_t #if defined(bsdi) || defined(netbsd) extern int fseeko(FILE *stream, off_t offset, int whence); extern off_t ftello(FILE *stream); #endif + #endif #ifndef HAVE_FSEEKO #define fseeko(a, b, c) fseek(a, b, c) Index: src/include/port/win32.h =================================================================== RCS file: /cvsroot/pgsql/src/include/port/win32.h,v retrieving revision 1.84 diff -c -c -r1.84 win32.h *** src/include/port/win32.h 17 Feb 2008 02:09:31 -0000 1.84 --- src/include/port/win32.h 7 Jan 2009 03:31:09 -0000 *************** *** 190,195 **** --- 190,207 ---- int setitimer(int which, const struct itimerval * value, struct itimerval * ovalue); + /* + * WIN32 does not provide 64-bit off_t, but does provide the functions operating + * with 64-bit offsets. + */ + #define pgoff_t __int64 + #ifdef WIN32_ONLY_COMPILER + #define fseeko(stream, offset, origin) _fseeki64(stream, offset, origin) + #define ftello(stream) _ftelli64(stream) + #else + #define fseeko(stream, offset, origin) fseeko64(stream, offset, origin) + #define ftello(stream) ftello64(stream) + #endif /* * Supplement to <sys/types.h>.
pgsql-hackers by date: