Re: Win32 defines

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Win32 defines
Date: 2003-04-03 15:08:00
Message-ID: Pine.LNX.4.44.0304031545400.2215-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Bruce Momjian writes:

> This adds some Win32 defines to cygwin defines --- this isn't all of
> them, but it is most.

> Index: src/backend/access/transam/xlog.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/backend/access/transam/xlog.c,v
> retrieving revision 1.112
> diff -c -c -r1.112 xlog.c
> *** src/backend/access/transam/xlog.c 21 Feb 2003 00:06:22 -0000 1.112
> --- src/backend/access/transam/xlog.c 3 Apr 2003 06:09:26 -0000
> ***************
> *** 1507,1513 ****
> * overwrite an existing logfile. However, there shouldn't be one, so
> * rename() is an acceptable substitute except for the truly paranoid.
> */
> ! #if !defined(__BEOS__) && !defined(N_PLAT_NLM) && !defined(__CYGWIN__)
> if (link(tmppath, path) < 0)
> elog(PANIC, "link from %s to %s (initialization of log file %u, segment %u) failed: %m",
> tmppath, path, log, seg);
> --- 1507,1513 ----
> * overwrite an existing logfile. However, there shouldn't be one, so
> * rename() is an acceptable substitute except for the truly paranoid.
> */
> ! #if !defined(__BEOS__) && !defined(N_PLAT_NLM) && !defined(__CYGWIN__) && !defined(WIN32)
> if (link(tmppath, path) < 0)
> elog(PANIC, "link from %s to %s (initialization of log file %u, segment %u) failed: %m",
> tmppath, path, log, seg);

That list is getting pretty long. This should be replaced by something
like HAVE_WORKING_LINK and be handled liked HAVE_UNIX_SOCKETS.

> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.309
> diff -c -c -r1.309 postmaster.c
> *** src/backend/postmaster/postmaster.c 24 Mar 2003 22:40:14 -0000 1.309
> --- src/backend/postmaster/postmaster.c 3 Apr 2003 06:09:32 -0000

> ***************
> *** 323,330 ****
> * be proper support for Unix-y file permissions. Need to think of a
> * reasonable check to apply on Windows.
> */
> ! #ifndef __CYGWIN__
> !
> if (stat(checkdir, &stat_buf) == -1)
> {
> if (errno == ENOENT)
> --- 323,329 ----
> * be proper support for Unix-y file permissions. Need to think of a
> * reasonable check to apply on Windows.
> */
> ! #if !defined(__CYGWIN__) && !defined(WIN32)
> if (stat(checkdir, &stat_buf) == -1)
> {
> if (errno == ENOENT)

The comment tells the tale. What is a reasonable check to apply to
Windows here?

> Index: src/include/c.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/include/c.h,v
> retrieving revision 1.135
> diff -c -c -r1.135 c.h
> *** src/include/c.h 9 Jan 2003 18:00:24 -0000 1.135
> --- src/include/c.h 3 Apr 2003 06:09:40 -0000
> ***************
> *** 63,69 ****
> #endif
> #include <sys/types.h>
>
> ! #ifdef __CYGWIN__
> #include <errno.h>
> #include <sys/fcntl.h> /* ensure O_BINARY is available */
> #endif
> --- 63,69 ----
> #endif
> #include <sys/types.h>
>
> ! #if defined(__CYGWIN__) || defined(WIN32)
> #include <errno.h>
> #include <sys/fcntl.h> /* ensure O_BINARY is available */
> #endif

I think this should be killed and <errno.h> and <fcntl.h> always included.

> Index: src/include/utils/datetime.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/include/utils/datetime.h,v
> retrieving revision 1.36
> diff -c -c -r1.36 datetime.h
> *** src/include/utils/datetime.h 20 Feb 2003 05:24:55 -0000 1.36
> --- src/include/utils/datetime.h 3 Apr 2003 06:09:41 -0000
> ***************
> *** 217,223 ****
> #endif
>
> /* Global variable holding time zone information. */
> ! #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
> #define TIMEZONE_GLOBAL _timezone
> #else
> #define TIMEZONE_GLOBAL timezone
> --- 217,223 ----
> #endif
>
> /* Global variable holding time zone information. */
> ! #if defined(__CYGWIN__) || defined(WIN32) || defined(N_PLAT_NLM)
> #define TIMEZONE_GLOBAL _timezone
> #else
> #define TIMEZONE_GLOBAL timezone

We should move that to the port-specific include files, like

#define timezone _timezone

> Index: src/interfaces/ecpg/pgtypeslib/dt.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt.h,v
> retrieving revision 1.3
> diff -c -c -r1.3 dt.h
> *** src/interfaces/ecpg/pgtypeslib/dt.h 1 Apr 2003 14:37:25 -0000 1.3
> --- src/interfaces/ecpg/pgtypeslib/dt.h 3 Apr 2003 06:09:41 -0000

(same here)

> Index: src/tools/entab/entab.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/tools/entab/entab.c,v
> retrieving revision 1.11
> diff -c -c -r1.11 entab.c
> *** src/tools/entab/entab.c 9 Jan 2002 18:21:46 -0000 1.11
> --- src/tools/entab/entab.c 3 Apr 2003 06:09:44 -0000
> ***************
> *** 94,100 ****
> in_file = stdin;
> else
> {
> ! #ifndef __CYGWIN__
> if ((in_file = fopen(*argv, "r")) == NULL)
> #else
> if ((in_file = fopen(*argv, "rb")) == NULL)
> --- 94,100 ----
> in_file = stdin;
> else
> {
> ! #if defined(__CYGWIN__) || defined(WIN32)
> if ((in_file = fopen(*argv, "r")) == NULL)
> #else
> if ((in_file = fopen(*argv, "rb")) == NULL)

This should use the macros defined in c.h.

--
Peter Eisentraut peter_e(at)gmx(dot)net

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Sullivan 2003-04-03 21:10:11 pglog-rotator
Previous Message Peter Eisentraut 2003-04-03 15:07:43 Re: Win32 path patch