Re: HAVE_FSEEKO for WIN32

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alex Hunsaker 2008-12-23 03:33:01 Re: contrib/pg_stat_statements 1212
Previous Message Grzegorz Jaskiewicz 2008-12-22 21:38:37 Re: affected rows count