Re: [HACKERS] xlog.c.patch for cygwin port. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] xlog.c.patch for cygwin port.
Date
Msg-id 23176.952477276@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] xlog.c.patch for cygwin port.  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [HACKERS] xlog.c.patch for cygwin port.
Re: [HACKERS] xlog.c.patch for cygwin port.
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> This looks interesting.  We could remove some of our ifwin cruft.

I have been thinking for quite some time that most of the CYGWIN32
ifdefs represent very poor programming.  Instead of zillions of

#ifndef __CYGWIN32__fd = open(filename, O_RDONLY, 0666);
#elsefd = open(filename, O_RDONLY | O_BINARY, 0666);
#endif

we should have in one include file something like

#ifndef __CYGWIN32__
#define  OPEN_FLAGS_READ   O_RDONLY
#define  OPEN_FLAGS_WRITE  O_WRONLY
// etc for the combinations we need
#else
#define  OPEN_FLAGS_READ   (O_RDONLY | O_BINARY)
#define  OPEN_FLAGS_WRITE  (O_WRONLY | O_BINARY)
// etc
#endif

and then the body of the code would have
fd = open(filename, OPEN_FLAGS_READ, 0666);

and no ifdef.  This would also provide a single place to tweak open()
flags for other platforms, whereas the existing method is exactly zero
help for any non-CYGWIN platform that wants to add O_BINARY ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] DROP TABLE inside a transaction block
Next
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] sqgfault on initdb with current CVS