Re: HAVE_FSEEKO for WIN32

Lists: pgsql-hackers
From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: HAVE_FSEEKO for WIN32
Date: 2008-12-22 21:22:14
Message-ID: 49500506.4010006@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HAVE_FSEEKO for WIN32
Date: 2008-12-22 22:36:42
Message-ID: 200812222236.mBMMage03114@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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?

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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: HAVE_FSEEKO for WIN32
Date: 2009-01-07 03:39:11
Message-ID: 200901070339.n073dBd03442@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: 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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

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

Attachment Content-Type Size
/rtmp/diff text/x-diff 4.2 KB

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HAVE_FSEEKO for WIN32
Date: 2009-01-07 10:11:26
Message-ID: 49647FCE.6010204@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HAVE_FSEEKO for WIN32
Date: 2009-01-07 13:52:10
Message-ID: 4964B38A.6050201@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: HAVE_FSEEKO for WIN32
Date: 2009-01-07 13:56:14
Message-ID: 4964B47E.40106@hagander.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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