HAVE_FSEEKO for WIN32

Started by Andrew Dunstanover 17 years ago6 messageshackers
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

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?

cheers

andrew

#2Bruce Momjian
bruce@momjian.us
In reply to: Andrew Dunstan (#1)
Re: HAVE_FSEEKO for WIN32

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?

Well, we are doing something odd here but it might not be what you
think.

We currently use fseeko() only in pg_dump. We define C code in /port
for some Unix platforms that don't support fseeko.

For platforms that don't support fseeko and don't have /port support for
it we just use fseek() in port.h:

#ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek(a, b, c)
#define ftello(a) ftell(a)
#endif

but then for Win32 we #undef fseeko and redefine it:

#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

Clearly this code should be moved into port.h, I think.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Bruce Momjian
bruce@momjian.us
In reply to: Andrew Dunstan (#1)
Re: HAVE_FSEEKO for WIN32

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. +

Attachments:

/rtmp/difftext/x-diffDownload+22-25
#4Magnus Hagander
magnus@hagander.net
In reply to: Bruce Momjian (#3)
Re: HAVE_FSEEKO for WIN32

Bruce Momjian wrote:

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.

Which is what? :-)

It just needs to set HAVE_FSEEKO to 1 in pg_config.h?

//Magnus

#5Andrew Dunstan
andrew@dunslane.net
In reply to: Magnus Hagander (#4)
Re: HAVE_FSEEKO for WIN32

Magnus Hagander wrote:

Bruce Momjian wrote:

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.

Which is what? :-)

It just needs to set HAVE_FSEEKO to 1 in pg_config.h?

Yep. I have fixed it already.

cheers

andrew

#6Magnus Hagander
magnus@hagander.net
In reply to: Andrew Dunstan (#5)
Re: HAVE_FSEEKO for WIN32

Andrew Dunstan wrote:

Magnus Hagander wrote:

Bruce Momjian wrote:

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.

Which is what? :-)

It just needs to set HAVE_FSEEKO to 1 in pg_config.h?

Yep. I have fixed it already.

Ok, thanks!

//Magnus