Re: HAVE_FSEEKO for WIN32 - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: HAVE_FSEEKO for WIN32
Date
Msg-id 200812222236.mBMMage03114@momjian.us
Whole thread Raw
In response to HAVE_FSEEKO for WIN32  (Andrew Dunstan <andrew@dunslane.net>)
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?

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


pgsql-hackers by date:

Previous
From: Grzegorz Jaskiewicz
Date:
Subject: Re: affected rows count
Next
From: "Alex Hunsaker"
Date:
Subject: Re: contrib/pg_stat_statements 1212