Thread: Win32 defines

Win32 defines

From
Bruce Momjian
Date:
This adds some Win32 defines to cygwin defines --- this isn't all of
them, but it is most.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: contrib/pgbench/pgbench.c
===================================================================
RCS file: /cvsroot/pgsql-server/contrib/pgbench/pgbench.c,v
retrieving revision 1.22
diff -c -c -r1.22 pgbench.c
*** contrib/pgbench/pgbench.c    20 Oct 2002 19:38:10 -0000    1.22
--- contrib/pgbench/pgbench.c    3 Apr 2003 06:09:21 -0000
***************
*** 695,701 ****
      int            nsocks;            /* return from select(2) */
      int            maxsock;        /* max socket number to be waited */

! #ifndef __CYGWIN__
      struct rlimit rlim;
  #endif

--- 695,701 ----
      int            nsocks;            /* return from select(2) */
      int            maxsock;        /* max socket number to be waited */

! #if !defined(__CYGWIN__) && !defined(WIN32)
      struct rlimit rlim;
  #endif

***************
*** 737,743 ****
                      fprintf(stderr, "invalid number of clients: %d\n", nclients);
                      exit(1);
                  }
! #ifndef __CYGWIN__
  #ifdef RLIMIT_NOFILE            /* most platform uses RLIMIT_NOFILE */
                  if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
                  {
--- 737,743 ----
                      fprintf(stderr, "invalid number of clients: %d\n", nclients);
                      exit(1);
                  }
! #if !defined(__CYGWIN__) && !defined(WIN32)
  #ifdef RLIMIT_NOFILE            /* most platform uses RLIMIT_NOFILE */
                  if (getrlimit(RLIMIT_NOFILE, &rlim) == -1)
                  {
***************
*** 754,760 ****
                      fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
                      exit(1);
                  }
! #endif   /* #ifndef __CYGWIN__ */
                  break;
              case 'C':
                  is_connect = 1;
--- 754,760 ----
                      fprintf(stderr, "Use limit/ulimt to increase the limit before using pgbench.\n");
                      exit(1);
                  }
! #endif
                  break;
              case 'C':
                  is_connect = 1;
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);
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
***************
*** 300,307 ****
  {
      char        path[MAXPGPATH];
      FILE       *fp;
!
! #ifndef __CYGWIN__
      struct stat stat_buf;
  #endif

--- 300,307 ----
  {
      char        path[MAXPGPATH];
      FILE       *fp;
!
! #if !defined(__CYGWIN__) && !defined(WIN32)
      struct stat stat_buf;
  #endif

***************
*** 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)
***************
*** 337,343 ****
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif   /* !__CYGWIN__ */

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
--- 336,342 ----
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
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
***************
*** 678,684 ****
   * ----------------------------------------------------------------
   */

! #ifdef __CYGWIN__
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
--- 678,684 ----
   * ----------------------------------------------------------------
   */

! #if defined(__CYGWIN__) || defined(WIN32)
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
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
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
***************
*** 216,222 ****
  #endif

  /* Global variable holding time zone information. */
! #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
  #define TIMEZONE_GLOBAL _timezone
  #else
  #define TIMEZONE_GLOBAL timezone
--- 216,222 ----
  #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
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)

Re: Win32 defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> This adds some Win32 defines to cygwin defines --- this isn't all of
> them, but it is most.

You got at least some of these backwards, eg

> ! #ifndef __CYGWIN__

> ! #if defined(__CYGWIN__) || defined(WIN32)

Also, are you sure that it's really appropriate to handle the native
port like Cygwin in each of these cases?  Maybe so, I didn't look...

            regards, tom lane


Re: Win32 defines

From
Peter Eisentraut
Date:
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@gmx.net


Re: Win32 defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > This adds some Win32 defines to cygwin defines --- this isn't all of
> > them, but it is most.
>
> You got at least some of these backwards, eg
>
> > ! #ifndef __CYGWIN__
>
> > ! #if defined(__CYGWIN__) || defined(WIN32)

Thanks.  Fixed.  I reviewed them all, but hacked at this one after
checking.

> Also, are you sure that it's really appropriate to handle the native
> port like Cygwin in each of these cases?  Maybe so, I didn't look...

I am goiing to back off some of these until it is compiled on Win32 ---
I am not positive if some of these are cygwin-specific changes and which
are Win32 also.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Neil Conway
Date:
On Fri, 2003-04-04 at 15:48, Bruce Momjian wrote:
> I am goiing to back off some of these until it is compiled on Win32 ---
> I am not positive if some of these are cygwin-specific changes and which
> are Win32 also.

If we finish the native Win32 port, is there any need to keep the cygwin
stuff around?

Cheers,

Neil


Re: Win32 defines

From
Bruce Momjian
Date:
Neil Conway wrote:
> On Fri, 2003-04-04 at 15:48, Bruce Momjian wrote:
> > I am goiing to back off some of these until it is compiled on Win32 ---
> > I am not positive if some of these are cygwin-specific changes and which
> > are Win32 also.
>
> If we finish the native Win32 port, is there any need to keep the cygwin
> stuff around?

They do ship PostgreSQL with cygwin, so we may need to keep it around,
at least for a few releases, and it isn't that big a port.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Alvaro Herrera
Date:
On Sat, Apr 05, 2003 at 12:38:51PM -0500, Bruce Momjian wrote:
> Neil Conway wrote:
>
> > If we finish the native Win32 port, is there any need to keep the cygwin
> > stuff around?
>
> They do ship PostgreSQL with cygwin, so we may need to keep it around,
> at least for a few releases, and it isn't that big a port.

Surely there's no need for a less performant, less reliable Cygwin port
when a native Win32 one is available?  If they ship it now, they
probably won't need to later when the Win32 port is finished.  Cygwin is
already said to be "experimental" or non-commercial quality, AFAIR.

Not that I care though...

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Y una voz del caos me hablo y me dijo
"Sonrie y se feliz, podria ser peor".
Y sonrei. Y fui feliz.
Y fue peor.


Re: Win32 defines

From
Bruce Momjian
Date:
Alvaro Herrera wrote:
> On Sat, Apr 05, 2003 at 12:38:51PM -0500, Bruce Momjian wrote:
> > Neil Conway wrote:
> >
> > > If we finish the native Win32 port, is there any need to keep the cygwin
> > > stuff around?
> >
> > They do ship PostgreSQL with cygwin, so we may need to keep it around,
> > at least for a few releases, and it isn't that big a port.
>
> Surely there's no need for a less performant, less reliable Cygwin port
> when a native Win32 one is available?  If they ship it now, they
> probably won't need to later when the Win32 port is finished.  Cygwin is
> already said to be "experimental" or non-commercial quality, AFAIR.
>
> Not that I care though...

I can remove it anytime people want it removed --- maybe once we have
Win32 stabalized and working 100%, we can remove it.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Rod Taylor
Date:
On Sat, 2003-04-05 at 12:53, Bruce Momjian wrote:
> Alvaro Herrera wrote:
> > On Sat, Apr 05, 2003 at 12:38:51PM -0500, Bruce Momjian wrote:
> > > Neil Conway wrote:
> > >
> > > > If we finish the native Win32 port, is there any need to keep the cygwin
> > > > stuff around?
> > >
> > > They do ship PostgreSQL with cygwin, so we may need to keep it around,
> > > at least for a few releases, and it isn't that big a port.
> >
> > Surely there's no need for a less performant, less reliable Cygwin port
> > when a native Win32 one is available?  If they ship it now, they
> > probably won't need to later when the Win32 port is finished.  Cygwin is
> > already said to be "experimental" or non-commercial quality, AFAIR.
> >
> > Not that I care though...
>
> I can remove it anytime people want it removed --- maybe once we have
> Win32 stabalized and working 100%, we can remove it.

Even wine has the occasional update to ensure it works on Cygwin -- so
I'm sure there are a number of good reasons that we just don't know yet.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Attachment

Re: Win32 defines

From
Peter Eisentraut
Date:
Neil Conway writes:

> If we finish the native Win32 port, is there any need to keep the cygwin
> stuff around?

Yes, because some people use it.

Why, you ask?  For the same reason they are using Cygwin in the first
place.

--
Peter Eisentraut   peter_e@gmx.net


Re: Win32 defines

From
Bruce Momjian
Date:
OK, I have modified the patch to match your suggestions. I also removed
the N_PLAT_NLM define because I think that just got in when we were
thinking about the Novell port that we cancelled.  Is that correct?

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> 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@gmx.net
>
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
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    16 Apr 2003 03:59:39 -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 HAVE_LINK
      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);
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.310
diff -c -c -r1.310 postmaster.c
*** src/backend/postmaster/postmaster.c    6 Apr 2003 22:45:22 -0000    1.310
--- src/backend/postmaster/postmaster.c    16 Apr 2003 03:59:45 -0000
***************
*** 300,306 ****
      char        path[MAXPGPATH];
      FILE       *fp;

! #ifndef __CYGWIN__
      struct stat stat_buf;
  #endif

--- 300,306 ----
      char        path[MAXPGPATH];
      FILE       *fp;

! #if !defined(__CYGWIN__) && !defined(WIN32)
      struct stat stat_buf;
  #endif

***************
*** 322,329 ****
       * 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)
--- 322,328 ----
       * 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)
***************
*** 336,342 ****
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif   /* !__CYGWIN__ */

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
--- 335,341 ----
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
Index: src/backend/utils/adt/datetime.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/datetime.c,v
retrieving revision 1.103
diff -c -c -r1.103 datetime.c
*** src/backend/utils/adt/datetime.c    4 Apr 2003 04:50:44 -0000    1.103
--- src/backend/utils/adt/datetime.c    16 Apr 2003 03:59:49 -0000
***************
*** 1533,1539 ****
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
--- 1533,1539 ----
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (timezone - 3600) : timezone);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
Index: src/backend/utils/adt/nabstime.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/nabstime.c,v
retrieving revision 1.106
diff -c -c -r1.106 nabstime.c
*** src/backend/utils/adt/nabstime.c    4 Apr 2003 04:50:44 -0000    1.106
--- src/backend/utils/adt/nabstime.c    16 Apr 2003 03:59:50 -0000
***************
*** 261,267 ****
          }
          else
          {
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);

              if (tzn != NULL)
              {
--- 261,267 ----
          }
          else
          {
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);

              if (tzn != NULL)
              {
Index: src/backend/utils/adt/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/timestamp.c,v
retrieving revision 1.83
diff -c -c -r1.83 timestamp.c
*** src/backend/utils/adt/timestamp.c    7 Apr 2003 15:04:03 -0000    1.83
--- src/backend/utils/adt/timestamp.c    16 Apr 2003 03:59:52 -0000
***************
*** 899,905 ****
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
--- 899,905 ----
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.137
diff -c -c -r1.137 c.h
*** src/include/c.h    6 Apr 2003 22:45:23 -0000    1.137
--- src/include/c.h    16 Apr 2003 03:59:54 -0000
***************
*** 65,74 ****
  #endif
  #include <sys/types.h>

- #ifdef __CYGWIN__
  #include <errno.h>
  #include <sys/fcntl.h>            /* ensure O_BINARY is available */
- #endif
  #ifdef HAVE_SUPPORTDEFS_H
  #include <SupportDefs.h>
  #endif
--- 65,72 ----
***************
*** 680,686 ****
   * ----------------------------------------------------------------
   */

! #ifdef __CYGWIN__
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
--- 678,684 ----
   * ----------------------------------------------------------------
   */

! #if defined(__CYGWIN__) || defined(WIN32)
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
Index: src/include/pg_config_manual.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config_manual.h,v
retrieving revision 1.1
diff -c -c -r1.1 pg_config_manual.h
*** src/include/pg_config_manual.h    6 Apr 2003 22:45:23 -0000    1.1
--- src/include/pg_config_manual.h    16 Apr 2003 03:59:55 -0000
***************
*** 135,140 ****
--- 135,148 ----
  #endif

  /*
+  * Define this if your operating system supports link()
+  */
+ #if !defined(__QNX__) && !defined(__BEOS__) && \
+     !defined(__CYGWIN__) && !defined(WIN32)
+ # define HAVE_LINK 1
+ #endif
+
+ /*
   * This is the default directory in which AF_UNIX socket files are
   * placed.  Caution: changing this risks breaking your existing client
   * applications, which are likely to continue to look in the old
Index: src/include/port/cygwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/cygwin.h,v
retrieving revision 1.1
diff -c -c -r1.1 cygwin.h
*** src/include/port/cygwin.h    21 Mar 2003 17:18:34 -0000    1.1
--- src/include/port/cygwin.h    16 Apr 2003 03:59:55 -0000
***************
*** 24,26 ****
--- 24,28 ----
  #else
  #define DLLIMPORT __declspec (dllimport)
  #endif
+
+ #define timezone _timezone
Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/win32.h,v
retrieving revision 1.6
diff -c -c -r1.6 win32.h
*** src/include/port/win32.h    22 Jan 2002 19:02:40 -0000    1.6
--- src/include/port/win32.h    16 Apr 2003 03:59:55 -0000
***************
*** 27,29 ****
--- 27,31 ----
  #define DLLIMPORT

  #endif
+
+ #define timezone _timezone
Index: src/include/utils/datetime.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/datetime.h,v
retrieving revision 1.37
diff -c -c -r1.37 datetime.h
*** src/include/utils/datetime.h    4 Apr 2003 04:50:44 -0000    1.37
--- src/include/utils/datetime.h    16 Apr 2003 03:59:56 -0000
***************
*** 216,228 ****
  } while(0)
  #endif

- /* Global variable holding time zone information. */
- #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
- #define TIMEZONE_GLOBAL _timezone
- #else
- #define TIMEZONE_GLOBAL timezone
- #endif
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 216,221 ----
Index: src/interfaces/ecpg/include/sqlca.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/include/sqlca.h,v
retrieving revision 1.22
diff -c -c -r1.22 sqlca.h
*** src/interfaces/ecpg/include/sqlca.h    10 Mar 2003 22:28:21 -0000    1.22
--- src/interfaces/ecpg/include/sqlca.h    16 Apr 2003 03:59:56 -0000
***************
*** 2,8 ****
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #ifdef __CYGWIN__
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
--- 2,8 ----
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #if defined(__CYGWIN__) || defined(WIN32)
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
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    16 Apr 2003 03:59:56 -0000
***************
*** 215,227 ****
  } while(0)
  #endif

- /* Global variable holding time zone information. */
- #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
- #define TIMEZONE_GLOBAL _timezone
- #else
- #define TIMEZONE_GLOBAL timezone
- #endif
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 215,220 ----
Index: src/interfaces/ecpg/pgtypeslib/dt_common.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt_common.c,v
retrieving revision 1.3
diff -c -c -r1.3 dt_common.c
*** src/interfaces/ecpg/pgtypeslib/dt_common.c    1 Apr 2003 14:37:25 -0000    1.3
--- src/interfaces/ecpg/pgtypeslib/dt_common.c    16 Apr 2003 04:00:05 -0000
***************
*** 1167,1173 ****
  #elif defined(HAVE_INT_TIMEZONE)
      if (tzp != NULL)
      {
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);

              if (tzn != NULL)
              {
--- 1167,1173 ----
  #elif defined(HAVE_INT_TIMEZONE)
      if (tzp != NULL)
      {
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);

              if (tzn != NULL)
              {
***************
*** 1252,1258 ****
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
--- 1252,1258 ----
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (timezone - 3600) : timezone);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
Index: src/interfaces/ecpg/pgtypeslib/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/timestamp.c,v
retrieving revision 1.5
diff -c -c -r1.5 timestamp.c
*** src/interfaces/ecpg/pgtypeslib/timestamp.c    1 Apr 2003 14:37:25 -0000    1.5
--- src/interfaces/ecpg/pgtypeslib/timestamp.c    16 Apr 2003 04:00:05 -0000
***************
*** 214,220 ****
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
--- 214,220 ----
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
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    16 Apr 2003 04:00:05 -0000
***************
*** 12,17 ****
--- 12,19 ----
  #include <stdlib.h>
  #include <string.h>

+ #include "../include/c.h"
+
  #define NUL                '\0'

  #ifndef TRUE
***************
*** 94,104 ****
              in_file = stdin;
          else
          {
! #ifndef __CYGWIN__
!             if ((in_file = fopen(*argv, "r")) == NULL)
! #else
!             if ((in_file = fopen(*argv, "rb")) == NULL)
! #endif
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }
--- 96,102 ----
              in_file = stdin;
          else
          {
!             if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }

Re: Win32 defines

From
Tom Lane
Date:
Why is this removing the use of the TIMEZONE_GLOBAL macro?

            regards, tom lane


Re: Win32 defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Why is this removing the use of the TIMEZONE_GLOBAL macro?

It was Peter's suggestion.  Once we had a port-specific define, we
should use timezone directly, no?

---------------------------------------------------------------------------

> 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


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Tom Lane wrote:
>> Why is this removing the use of the TIMEZONE_GLOBAL macro?

> It was Peter's suggestion.  Once we had a port-specific define, we
> should use timezone directly, no?

> #define timezone _timezone

Oh, I missed that part.  A bit risky IMHO --- the macro might expand in
places you didn't expect/want.  TIMEZONE_GLOBAL is unlikely to cause
any such conflict ...

            regards, tom lane


Re: Win32 defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Why is this removing the use of the TIMEZONE_GLOBAL macro?
>
> > It was Peter's suggestion.  Once we had a port-specific define, we
> > should use timezone directly, no?
>
> > #define timezone _timezone
>
> Oh, I missed that part.  A bit risky IMHO --- the macro might expand in
> places you didn't expect/want.  TIMEZONE_GLOBAL is unlikely to cause
> any such conflict ...

Agreed.  A 'timezone' macro will expand as a structure member, while a
timezone variable will not.  Here is a new version that defines a
variable timezone to equal _timezone.  This seems cleaner, and removes
the need for TIMEZONE_GLOBAL.

I am still researching the stat() handling in postmaster.c.  SRA has a
porting document that I translated from Japanese (via Babelfish) which
looks very helpful.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
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    16 Apr 2003 17:49:45 -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 HAVE_LINK
      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);
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.310
diff -c -c -r1.310 postmaster.c
*** src/backend/postmaster/postmaster.c    6 Apr 2003 22:45:22 -0000    1.310
--- src/backend/postmaster/postmaster.c    16 Apr 2003 17:49:48 -0000
***************
*** 300,306 ****
      char        path[MAXPGPATH];
      FILE       *fp;

! #ifndef __CYGWIN__
      struct stat stat_buf;
  #endif

--- 300,306 ----
      char        path[MAXPGPATH];
      FILE       *fp;

! #if !defined(__CYGWIN__) && !defined(WIN32)
      struct stat stat_buf;
  #endif

***************
*** 322,329 ****
       * 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)
--- 322,328 ----
       * 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)
***************
*** 336,342 ****
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif   /* !__CYGWIN__ */

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
--- 335,341 ----
      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
Index: src/backend/utils/adt/datetime.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/datetime.c,v
retrieving revision 1.103
diff -c -c -r1.103 datetime.c
*** src/backend/utils/adt/datetime.c    4 Apr 2003 04:50:44 -0000    1.103
--- src/backend/utils/adt/datetime.c    16 Apr 2003 17:49:51 -0000
***************
*** 1533,1539 ****
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
--- 1533,1539 ----
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (timezone - 3600) : timezone);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
Index: src/backend/utils/adt/nabstime.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/nabstime.c,v
retrieving revision 1.106
diff -c -c -r1.106 nabstime.c
*** src/backend/utils/adt/nabstime.c    4 Apr 2003 04:50:44 -0000    1.106
--- src/backend/utils/adt/nabstime.c    16 Apr 2003 17:49:52 -0000
***************
*** 261,267 ****
          }
          else
          {
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);

              if (tzn != NULL)
              {
--- 261,267 ----
          }
          else
          {
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);

              if (tzn != NULL)
              {
Index: src/backend/utils/adt/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/timestamp.c,v
retrieving revision 1.83
diff -c -c -r1.83 timestamp.c
*** src/backend/utils/adt/timestamp.c    7 Apr 2003 15:04:03 -0000    1.83
--- src/backend/utils/adt/timestamp.c    16 Apr 2003 17:49:53 -0000
***************
*** 899,905 ****
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
--- 899,905 ----
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.137
diff -c -c -r1.137 c.h
*** src/include/c.h    6 Apr 2003 22:45:23 -0000    1.137
--- src/include/c.h    16 Apr 2003 17:49:55 -0000
***************
*** 51,57 ****
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"
  #include "pg_config_os.h"
  #include "postgres_ext.h"

--- 51,57 ----
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"    /* must be after pg_config.h */
  #include "pg_config_os.h"
  #include "postgres_ext.h"

***************
*** 65,74 ****
  #endif
  #include <sys/types.h>

- #ifdef __CYGWIN__
  #include <errno.h>
  #include <sys/fcntl.h>            /* ensure O_BINARY is available */
- #endif
  #ifdef HAVE_SUPPORTDEFS_H
  #include <SupportDefs.h>
  #endif
--- 65,72 ----
***************
*** 680,686 ****
   * ----------------------------------------------------------------
   */

! #ifdef __CYGWIN__
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
--- 678,684 ----
   * ----------------------------------------------------------------
   */

! #if defined(__CYGWIN__) || defined(WIN32)
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
Index: src/include/pg_config_manual.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config_manual.h,v
retrieving revision 1.1
diff -c -c -r1.1 pg_config_manual.h
*** src/include/pg_config_manual.h    6 Apr 2003 22:45:23 -0000    1.1
--- src/include/pg_config_manual.h    16 Apr 2003 17:49:56 -0000
***************
*** 135,140 ****
--- 135,156 ----
  #endif

  /*
+  * Define this if your operating system supports link()
+  */
+ #if !defined(__QNX__) && !defined(__BEOS__) && \
+     !defined(__CYGWIN__) && !defined(WIN32)
+ # define HAVE_LINK 1
+ #endif
+
+ /*
+  * Define this if your operating system has _timezone rather than timezone
+  */
+ #if defined(__CYGWIN__) || defined(WIN32)
+ # define HAVE_INT_TIMEZONE        /* has int _timezone */
+ # define HAVE_UNDERSCORE_TIMEZONE 1
+ #endif
+
+ /*
   * This is the default directory in which AF_UNIX socket files are
   * placed.  Caution: changing this risks breaking your existing client
   * applications, which are likely to continue to look in the old
Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/win32.h,v
retrieving revision 1.6
diff -c -c -r1.6 win32.h
*** src/include/port/win32.h    22 Jan 2002 19:02:40 -0000    1.6
--- src/include/port/win32.h    16 Apr 2003 17:49:56 -0000
***************
*** 1,6 ****
--- 1,9 ----
  #define USES_WINSOCK
  #define NOFILE          100

+ #define tzname _tzname            /* should be in time.h? */
+ #define HAVE_INT_TIMEZONE        /* has int _timezone */
+
  /* defines for dynamic linking on Win32 platform */
  #ifdef __CYGWIN__

Index: src/include/utils/datetime.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/datetime.h,v
retrieving revision 1.37
diff -c -c -r1.37 datetime.h
*** src/include/utils/datetime.h    4 Apr 2003 04:50:44 -0000    1.37
--- src/include/utils/datetime.h    16 Apr 2003 17:49:57 -0000
***************
*** 216,226 ****
  } while(0)
  #endif

! /* Global variable holding time zone information. */
! #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
! #define TIMEZONE_GLOBAL _timezone
! #else
! #define TIMEZONE_GLOBAL timezone
  #endif

  /*
--- 216,224 ----
  } while(0)
  #endif

! #ifdef HAVE_UNDERSCORE_TIMEZONE
! short timezone = _timezone;
! char *tzname = _tzname;
  #endif

  /*
Index: src/interfaces/ecpg/include/sqlca.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/include/sqlca.h,v
retrieving revision 1.22
diff -c -c -r1.22 sqlca.h
*** src/interfaces/ecpg/include/sqlca.h    10 Mar 2003 22:28:21 -0000    1.22
--- src/interfaces/ecpg/include/sqlca.h    16 Apr 2003 17:49:57 -0000
***************
*** 2,8 ****
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #ifdef __CYGWIN__
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
--- 2,8 ----
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #if defined(__CYGWIN__) || defined(WIN32)
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
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    16 Apr 2003 17:49:57 -0000
***************
*** 215,227 ****
  } while(0)
  #endif

- /* Global variable holding time zone information. */
- #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
- #define TIMEZONE_GLOBAL _timezone
- #else
- #define TIMEZONE_GLOBAL timezone
- #endif
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 215,220 ----
Index: src/interfaces/ecpg/pgtypeslib/dt_common.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt_common.c,v
retrieving revision 1.3
diff -c -c -r1.3 dt_common.c
*** src/interfaces/ecpg/pgtypeslib/dt_common.c    1 Apr 2003 14:37:25 -0000    1.3
--- src/interfaces/ecpg/pgtypeslib/dt_common.c    16 Apr 2003 17:49:59 -0000
***************
*** 9,14 ****
--- 9,19 ----
  #include "dt.h"
  #include "extern.h"

+ #ifdef HAVE_UNDERSCORE_TIMEZONE
+ short timezone = _timezone;
+ char *tzname = _tzname;
+ #endif
+
  static int day_tab[2][13] = {
              {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0},
          {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}};
***************
*** 1167,1173 ****
  #elif defined(HAVE_INT_TIMEZONE)
      if (tzp != NULL)
      {
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);

              if (tzn != NULL)
              {
--- 1172,1178 ----
  #elif defined(HAVE_INT_TIMEZONE)
      if (tzp != NULL)
      {
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);

              if (tzn != NULL)
              {
***************
*** 1252,1258 ****
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
--- 1257,1263 ----
              /* tm_gmtoff is Sun/DEC-ism */
              tz = -(tmp->tm_gmtoff);
  #elif defined(HAVE_INT_TIMEZONE)
!             tz = ((tmp->tm_isdst > 0) ? (timezone - 3600) : timezone);
  #endif   /* HAVE_INT_TIMEZONE */
          }
          else
Index: src/interfaces/ecpg/pgtypeslib/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/timestamp.c,v
retrieving revision 1.5
diff -c -c -r1.5 timestamp.c
*** src/interfaces/ecpg/pgtypeslib/timestamp.c    1 Apr 2003 14:37:25 -0000    1.5
--- src/interfaces/ecpg/pgtypeslib/timestamp.c    16 Apr 2003 17:50:00 -0000
***************
*** 214,220 ****
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
--- 214,220 ----
              if (tzn != NULL)
                  *tzn = (char *) tm->tm_zone;
  #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
              if (tzn != NULL)
                  *tzn = tzname[(tm->tm_isdst > 0)];
  #endif
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    16 Apr 2003 17:50:01 -0000
***************
*** 12,17 ****
--- 12,19 ----
  #include <stdlib.h>
  #include <string.h>

+ #include "../include/c.h"
+
  #define NUL                '\0'

  #ifndef TRUE
***************
*** 94,104 ****
              in_file = stdin;
          else
          {
! #ifndef __CYGWIN__
!             if ((in_file = fopen(*argv, "r")) == NULL)
! #else
!             if ((in_file = fopen(*argv, "rb")) == NULL)
! #endif
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }
--- 96,102 ----
              in_file = stdin;
          else
          {
!             if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }

Re: Win32 defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Here is a new version that defines a
> variable timezone to equal _timezone.

Surely that will not work.  It won't even compile, let alone track
run-time changes in _timezone.

            regards, tom lane


Re: Win32 defines

From
Bruce Momjian
Date:
OK, here is the newest version of the patch, with a new file for Win32
macros.

---------------------------------------------------------------------------

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Tom Lane wrote:
> >> Why is this removing the use of the TIMEZONE_GLOBAL macro?
>
> > It was Peter's suggestion.  Once we had a port-specific define, we
> > should use timezone directly, no?
>
> > #define timezone _timezone
>
> Oh, I missed that part.  A bit risky IMHO --- the macro might expand in
> places you didn't expect/want.  TIMEZONE_GLOBAL is unlikely to cause
> any such conflict ...
>
>             regards, tom lane
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
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    17 Apr 2003 02:48:24 -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 HAVE_LINK
      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);
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.310
diff -c -c -r1.310 postmaster.c
*** src/backend/postmaster/postmaster.c    6 Apr 2003 22:45:22 -0000    1.310
--- src/backend/postmaster/postmaster.c    17 Apr 2003 02:48:27 -0000
***************
*** 300,308 ****
      char        path[MAXPGPATH];
      FILE       *fp;

- #ifndef __CYGWIN__
      struct stat stat_buf;
- #endif

      if (checkdir == NULL)
      {
--- 300,306 ----
***************
*** 315,329 ****
          ExitPostmaster(2);
      }

-     /*
-      * Check if the directory has group or world access.  If so, reject.
-      *
-      * XXX temporarily suppress check when on Windows, because there may not
-      * 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)
--- 313,318 ----
***************
*** 333,342 ****
                   checkdir);
      }

      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif   /* !__CYGWIN__ */

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
--- 322,339 ----
                   checkdir);
      }

+     /*
+      * Check if the directory has group or world access.  If so, reject.
+      *
+      * XXX temporarily suppress check when on Windows, because there may not
+      * 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_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.137
diff -c -c -r1.137 c.h
*** src/include/c.h    6 Apr 2003 22:45:23 -0000    1.137
--- src/include/c.h    17 Apr 2003 02:48:36 -0000
***************
*** 51,57 ****
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"
  #include "pg_config_os.h"
  #include "postgres_ext.h"

--- 51,57 ----
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"    /* must be after pg_config.h */
  #include "pg_config_os.h"
  #include "postgres_ext.h"

***************
*** 65,74 ****
  #endif
  #include <sys/types.h>

- #ifdef __CYGWIN__
  #include <errno.h>
  #include <sys/fcntl.h>            /* ensure O_BINARY is available */
- #endif
  #ifdef HAVE_SUPPORTDEFS_H
  #include <SupportDefs.h>
  #endif
--- 65,72 ----
***************
*** 321,326 ****
--- 319,332 ----
  #define HAVE_INT64_TIMESTAMP
  #endif

+ /* Global variable holding time zone information. */
+ #ifndef HAVE_UNDERSCORE_TIMEZONE
+ #define TIMEZONE_GLOBAL timezone
+ #else
+ #define TIMEZONE_GLOBAL _timezone
+ #define tzname _tzname            /* should be in time.h? */
+ #endif
+
  /* sig_atomic_t is required by ANSI C, but may be missing on old platforms */
  #ifndef HAVE_SIG_ATOMIC_T
  typedef int sig_atomic_t;
***************
*** 680,686 ****
   * ----------------------------------------------------------------
   */

! #ifdef __CYGWIN__
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
--- 686,692 ----
   * ----------------------------------------------------------------
   */

! #if defined(__CYGWIN__) || defined(WIN32)
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
Index: src/include/pg_config_manual.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config_manual.h,v
retrieving revision 1.1
diff -c -c -r1.1 pg_config_manual.h
*** src/include/pg_config_manual.h    6 Apr 2003 22:45:23 -0000    1.1
--- src/include/pg_config_manual.h    17 Apr 2003 02:48:36 -0000
***************
*** 135,140 ****
--- 135,156 ----
  #endif

  /*
+  * Define this if your operating system supports link()
+  */
+ #if !defined(__QNX__) && !defined(__BEOS__) && \
+     !defined(__CYGWIN__) && !defined(WIN32)
+ # define HAVE_LINK 1
+ #endif
+
+ /*
+  * Define this if your operating system has _timezone rather than timezone
+  */
+ #if defined(__CYGWIN__) || defined(WIN32)
+ # define HAVE_INT_TIMEZONE        /* has int _timezone */
+ # define HAVE_UNDERSCORE_TIMEZONE 1
+ #endif
+
+ /*
   * This is the default directory in which AF_UNIX socket files are
   * placed.  Caution: changing this risks breaking your existing client
   * applications, which are likely to continue to look in the old
Index: src/include/port/cygwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/cygwin.h,v
retrieving revision 1.1
diff -c -c -r1.1 cygwin.h
*** src/include/port/cygwin.h    21 Mar 2003 17:18:34 -0000    1.1
--- src/include/port/cygwin.h    17 Apr 2003 02:48:37 -0000
***************
*** 1,10 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */

  #define HAS_TEST_AND_SET
  typedef unsigned char slock_t;
-
- #define tzname _tzname            /* should be in time.h? */
- #define HAVE_INT_TIMEZONE        /* has int _timezone */

  #include <cygwin/version.h>

--- 1,9 ----
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */

+ #include <port/win32defs.h>
+
  #define HAS_TEST_AND_SET
  typedef unsigned char slock_t;

  #include <cygwin/version.h>

Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/win32.h,v
retrieving revision 1.6
diff -c -c -r1.6 win32.h
*** src/include/port/win32.h    22 Jan 2002 19:02:40 -0000    1.6
--- src/include/port/win32.h    17 Apr 2003 02:48:37 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */
+
+ #include <port/win32defs.h>
+
  #define USES_WINSOCK
  #define NOFILE          100

Index: src/include/utils/datetime.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/datetime.h,v
retrieving revision 1.37
diff -c -c -r1.37 datetime.h
*** src/include/utils/datetime.h    4 Apr 2003 04:50:44 -0000    1.37
--- src/include/utils/datetime.h    17 Apr 2003 02:48:37 -0000
***************
*** 216,228 ****
  } while(0)
  #endif

- /* Global variable holding time zone information. */
- #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
- #define TIMEZONE_GLOBAL _timezone
- #else
- #define TIMEZONE_GLOBAL timezone
- #endif
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 216,221 ----
Index: src/interfaces/ecpg/include/sqlca.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/include/sqlca.h,v
retrieving revision 1.22
diff -c -c -r1.22 sqlca.h
*** src/interfaces/ecpg/include/sqlca.h    10 Mar 2003 22:28:21 -0000    1.22
--- src/interfaces/ecpg/include/sqlca.h    17 Apr 2003 02:48:37 -0000
***************
*** 2,8 ****
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #ifdef __CYGWIN__
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
--- 2,8 ----
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #if defined(__CYGWIN__) || defined(WIN32)
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
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    17 Apr 2003 02:48:37 -0000
***************
*** 216,225 ****
  #endif

  /* Global variable holding time zone information. */
! #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
! #define TIMEZONE_GLOBAL _timezone
! #else
  #define TIMEZONE_GLOBAL timezone
  #endif

  /*
--- 216,226 ----
  #endif

  /* Global variable holding time zone information. */
! #if !defined(__CYGWIN__) && !defined(WIN32)
  #define TIMEZONE_GLOBAL timezone
+ #else
+ #define TIMEZONE_GLOBAL _timezone
+ #define tzname _tzname            /* should be in time.h? */
  #endif

  /*
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    17 Apr 2003 02:48:44 -0000
***************
*** 12,17 ****
--- 12,19 ----
  #include <stdlib.h>
  #include <string.h>

+ #include "../include/c.h"
+
  #define NUL                '\0'

  #ifndef TRUE
***************
*** 94,104 ****
              in_file = stdin;
          else
          {
! #ifndef __CYGWIN__
!             if ((in_file = fopen(*argv, "r")) == NULL)
! #else
!             if ((in_file = fopen(*argv, "rb")) == NULL)
! #endif
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }
--- 96,102 ----
              in_file = stdin;
          else
          {
!             if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }
/*
 * Supplement to <sys/types.h>.
 */
#define uid_t int
#define gid_t int
#define pid_t unsigned long
#define ssize_t int
#define mode_t int
#define key_t long
#define ushort unsigned short

/*
 * Supplement to <sys/stat.h>.
 */
#define lstat slat

#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)

#define S_IRUSR _S_IREAD
#define S_IWUSR _S_IWRITE
#define S_IXUSR _S_IEXEC
#define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)

/*
 * Supplement to <errno.h>.
 */
#include <errno.h>
#undef EAGAIN
#undef EINTR
#define EINTR WSAEINTR
#define EAGAIN WSAEWOULDBLOCK
#define EMSGSIZE WSAEMSGSIZE
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ECONNRESET WSAECONNRESET
#define EINPROGRESS WSAEINPROGRESS

/*
 * Supplement to <math.h>.
 */
#define isnan _isnan
#define finite _finite
extern double rint(double x);

/*
 * Supplement to <stdio.h>.
 */
#define snprintf _snprintf
#define vsnprintf _vsnprintf

/*
 * Fake strerror().
 */
#ifdef POWERGRES_EXPORTS
#include <string.h>
extern char *mystrerror(int errnum);
#define strerror mystrerror
#endif

Re: Win32 defines

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> [ patch removes #ifndef CYGWIN around permissions checks ]

Has Windows' filesystem gotten better since we put those #ifdefs in
there?  IIRC, they're there because PG refused to boot on Windows
without 'em.

            regards, tom lane


Re: Win32 defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > [ patch removes #ifndef CYGWIN around permissions checks ]
>
> Has Windows' filesystem gotten better since we put those #ifdefs in
> there?  IIRC, they're there because PG refused to boot on Windows
> without 'em.

Is this the check you are asking about:

+ #if !defined(__CYGWIN__) && !defined(WIN32)
        if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
                elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
                         checkdir);
! #endif

The check is still there, but it does the stat() and checks the return
code first, then skips the group/other checks.


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Bruce Momjian
Date:
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > [ patch removes #ifndef CYGWIN around permissions checks ]
>
> Has Windows' filesystem gotten better since we put those #ifdefs in
> there?  IIRC, they're there because PG refused to boot on Windows
> without 'em.

Actually, it would compile with the new win32defs.h file, but it would
be useless, so I skip it.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Peter Eisentraut
Date:
Bruce Momjian writes:

> OK, I have modified the patch to match your suggestions. I also removed
> the N_PLAT_NLM define because I think that just got in when we were
> thinking about the Novell port that we cancelled.  Is that correct?

Could you use HAVE_WORKING_LINK instead of HAVE_LINK?  The symbol names
containing _WORKING_ are sort of standard for cases where the function
exists but doesn't really work well.

--
Peter Eisentraut   peter_e@gmx.net


Re: Win32 defines

From
Peter Eisentraut
Date:
Bruce Momjian writes:

> OK, here is the newest version of the patch, with a new file for Win32
> macros.

Surely that file should go into src/include/port/win.h?  And what's
POWERGRES_EXPORTS?

--
Peter Eisentraut   peter_e@gmx.net


Re: Win32 defines

From
Bruce Momjian
Date:
Thanks. Done.

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > OK, I have modified the patch to match your suggestions. I also removed
> > the N_PLAT_NLM define because I think that just got in when we were
> > thinking about the Novell port that we cancelled.  Is that correct?
>
> Could you use HAVE_WORKING_LINK instead of HAVE_LINK?  The symbol names
> containing _WORKING_ are sort of standard for cases where the function
> exists but doesn't really work well.
>
> --
> Peter Eisentraut   peter_e@gmx.net
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Bruce Momjian
Date:
Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > OK, here is the newest version of the patch, with a new file for Win32
> > macros.
>

> Surely that file should go into src/include/port/win.h?  And what's

I was confused by win.h.  It looks similar to win32.h and cygwin.h in
that it defines DLIMPORT stuff, but not much else.  What is that file
for?  I am looking for something that cygwin and win32 can both use,
though actually maybe are better just leaving cygwin alone and do just
win32.  Let me do that, unless you have another suggestion.

> POWERGRES_EXPORTS?

Sorry, I didn't mean to add those lines.  Thanks.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073


Re: Win32 defines

From
Bruce Momjian
Date:
OK, patch attached and applied.

---------------------------------------------------------------------------

Peter Eisentraut wrote:
> Bruce Momjian writes:
>
> > OK, I have modified the patch to match your suggestions. I also removed
> > the N_PLAT_NLM define because I think that just got in when we were
> > thinking about the Novell port that we cancelled.  Is that correct?
>
> Could you use HAVE_WORKING_LINK instead of HAVE_LINK?  The symbol names
> containing _WORKING_ are sort of standard for cases where the function
> exists but doesn't really work well.
>
> --
> Peter Eisentraut   peter_e@gmx.net
>
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
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    18 Apr 2003 00:48:32 -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 HAVE_WORKING_LINK
      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);
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.311
diff -c -c -r1.311 postmaster.c
*** src/backend/postmaster/postmaster.c    17 Apr 2003 22:26:01 -0000    1.311
--- src/backend/postmaster/postmaster.c    18 Apr 2003 00:48:36 -0000
***************
*** 299,307 ****
      char        path[MAXPGPATH];
      FILE       *fp;

- #ifndef __CYGWIN__
      struct stat stat_buf;
- #endif

      if (checkdir == NULL)
      {
--- 299,305 ----
***************
*** 314,328 ****
          ExitPostmaster(2);
      }

-     /*
-      * Check if the directory has group or world access.  If so, reject.
-      *
-      * XXX temporarily suppress check when on Windows, because there may not
-      * 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)
--- 312,317 ----
***************
*** 332,341 ****
                   checkdir);
      }

      if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif   /* !__CYGWIN__ */

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
--- 321,338 ----
                   checkdir);
      }

+     /*
+      * Check if the directory has group or world access.  If so, reject.
+      *
+      * XXX temporarily suppress check when on Windows, because there may not
+      * 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_buf.st_mode & (S_IRWXG | S_IRWXO))
          elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
               checkdir);
! #endif

      /* Look for PG_VERSION before looking for pg_control */
      ValidatePgVersion(checkdir);
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.137
diff -c -c -r1.137 c.h
*** src/include/c.h    6 Apr 2003 22:45:23 -0000    1.137
--- src/include/c.h    18 Apr 2003 00:48:37 -0000
***************
*** 51,57 ****
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"
  #include "pg_config_os.h"
  #include "postgres_ext.h"

--- 51,57 ----
   */

  #include "pg_config.h"
! #include "pg_config_manual.h"    /* must be after pg_config.h */
  #include "pg_config_os.h"
  #include "postgres_ext.h"

***************
*** 65,74 ****
  #endif
  #include <sys/types.h>

- #ifdef __CYGWIN__
  #include <errno.h>
  #include <sys/fcntl.h>            /* ensure O_BINARY is available */
- #endif
  #ifdef HAVE_SUPPORTDEFS_H
  #include <SupportDefs.h>
  #endif
--- 65,72 ----
***************
*** 321,326 ****
--- 319,332 ----
  #define HAVE_INT64_TIMESTAMP
  #endif

+ /* Global variable holding time zone information. */
+ #ifndef HAVE_UNDERSCORE_TIMEZONE
+ #define TIMEZONE_GLOBAL timezone
+ #else
+ #define TIMEZONE_GLOBAL _timezone
+ #define tzname _tzname            /* should be in time.h? */
+ #endif
+
  /* sig_atomic_t is required by ANSI C, but may be missing on old platforms */
  #ifndef HAVE_SIG_ATOMIC_T
  typedef int sig_atomic_t;
***************
*** 680,686 ****
   * ----------------------------------------------------------------
   */

! #ifdef __CYGWIN__
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
--- 686,692 ----
   * ----------------------------------------------------------------
   */

! #if defined(__CYGWIN__) || defined(WIN32)
  #define PG_BINARY    O_BINARY
  #define PG_BINARY_R "rb"
  #define PG_BINARY_W "wb"
Index: src/include/pg_config_manual.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/pg_config_manual.h,v
retrieving revision 1.1
diff -c -c -r1.1 pg_config_manual.h
*** src/include/pg_config_manual.h    6 Apr 2003 22:45:23 -0000    1.1
--- src/include/pg_config_manual.h    18 Apr 2003 00:48:38 -0000
***************
*** 135,140 ****
--- 135,156 ----
  #endif

  /*
+  * Define this if your operating system supports link()
+  */
+ #if !defined(__QNX__) && !defined(__BEOS__) && \
+     !defined(__CYGWIN__) && !defined(WIN32)
+ # define HAVE_WORKING_LINK 1
+ #endif
+
+ /*
+  * Define this if your operating system has _timezone rather than timezone
+  */
+ #if defined(__CYGWIN__) || defined(WIN32)
+ # define HAVE_INT_TIMEZONE        /* has int _timezone */
+ # define HAVE_UNDERSCORE_TIMEZONE 1
+ #endif
+
+ /*
   * This is the default directory in which AF_UNIX socket files are
   * placed.  Caution: changing this risks breaking your existing client
   * applications, which are likely to continue to look in the old
Index: src/include/port/cygwin.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/cygwin.h,v
retrieving revision 1.1
diff -c -c -r1.1 cygwin.h
*** src/include/port/cygwin.h    21 Mar 2003 17:18:34 -0000    1.1
--- src/include/port/cygwin.h    18 Apr 2003 00:48:38 -0000
***************
*** 1,10 ****
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */

  #define HAS_TEST_AND_SET
  typedef unsigned char slock_t;
-
- #define tzname _tzname            /* should be in time.h? */
- #define HAVE_INT_TIMEZONE        /* has int _timezone */

  #include <cygwin/version.h>

--- 1,9 ----
  /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */

+ #include <port/win32defs.h>
+
  #define HAS_TEST_AND_SET
  typedef unsigned char slock_t;

  #include <cygwin/version.h>

Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port/win32.h,v
retrieving revision 1.6
diff -c -c -r1.6 win32.h
*** src/include/port/win32.h    22 Jan 2002 19:02:40 -0000    1.6
--- src/include/port/win32.h    18 Apr 2003 00:48:38 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ /* $Header: /cvsroot/pgsql-server/src/include/port/cygwin.h,v 1.1 2003/03/21 17:18:34 petere Exp $ */
+
+ #include <port/win32defs.h>
+
  #define USES_WINSOCK
  #define NOFILE          100

***************
*** 27,29 ****
--- 31,86 ----
  #define DLLIMPORT

  #endif
+
+ /*
+  * Supplement to <sys/types.h>.
+  */
+ #define uid_t int
+ #define gid_t int
+ #define pid_t unsigned long
+ #define ssize_t int
+ #define mode_t int
+ #define key_t long
+ #define ushort unsigned short
+
+ /*
+  * Supplement to <sys/stat.h>.
+  */
+ #define lstat slat
+
+ #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+ #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+
+ #define S_IRUSR _S_IREAD
+ #define S_IWUSR _S_IWRITE
+ #define S_IXUSR _S_IEXEC
+ #define S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
+
+ /*
+  * Supplement to <errno.h>.
+  */
+ #include <errno.h>
+ #undef EAGAIN
+ #undef EINTR
+ #define EINTR WSAEINTR
+ #define EAGAIN WSAEWOULDBLOCK
+ #define EMSGSIZE WSAEMSGSIZE
+ #define EAFNOSUPPORT WSAEAFNOSUPPORT
+ #define EWOULDBLOCK WSAEWOULDBLOCK
+ #define ECONNRESET WSAECONNRESET
+ #define EINPROGRESS WSAEINPROGRESS
+
+ /*
+  * Supplement to <math.h>.
+  */
+ #define isnan _isnan
+ #define finite _finite
+ extern double rint(double x);
+
+ /*
+  * Supplement to <stdio.h>.
+  */
+ #define snprintf _snprintf
+ #define vsnprintf _vsnprintf
+
+
Index: src/include/utils/datetime.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/datetime.h,v
retrieving revision 1.37
diff -c -c -r1.37 datetime.h
*** src/include/utils/datetime.h    4 Apr 2003 04:50:44 -0000    1.37
--- src/include/utils/datetime.h    18 Apr 2003 00:48:38 -0000
***************
*** 216,228 ****
  } while(0)
  #endif

- /* Global variable holding time zone information. */
- #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
- #define TIMEZONE_GLOBAL _timezone
- #else
- #define TIMEZONE_GLOBAL timezone
- #endif
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 216,221 ----
Index: src/interfaces/ecpg/include/sqlca.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/include/sqlca.h,v
retrieving revision 1.22
diff -c -c -r1.22 sqlca.h
*** src/interfaces/ecpg/include/sqlca.h    10 Mar 2003 22:28:21 -0000    1.22
--- src/interfaces/ecpg/include/sqlca.h    18 Apr 2003 00:48:39 -0000
***************
*** 2,8 ****
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #ifdef __CYGWIN__
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
--- 2,8 ----
  #define POSTGRES_SQLCA_H

  #ifndef DLLIMPORT
! #if defined(__CYGWIN__) || defined(WIN32)
  #define DLLIMPORT __declspec (dllimport)
  #else
  #define DLLIMPORT
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    18 Apr 2003 00:48:39 -0000
***************
*** 216,225 ****
  #endif

  /* Global variable holding time zone information. */
! #if defined(__CYGWIN__) || defined(N_PLAT_NLM)
! #define TIMEZONE_GLOBAL _timezone
! #else
  #define TIMEZONE_GLOBAL timezone
  #endif

  /*
--- 216,226 ----
  #endif

  /* Global variable holding time zone information. */
! #if !defined(__CYGWIN__) && !defined(WIN32)
  #define TIMEZONE_GLOBAL timezone
+ #else
+ #define TIMEZONE_GLOBAL _timezone
+ #define tzname _tzname            /* should be in time.h? */
  #endif

  /*
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    18 Apr 2003 00:48:40 -0000
***************
*** 12,17 ****
--- 12,19 ----
  #include <stdlib.h>
  #include <string.h>

+ #include "../include/c.h"
+
  #define NUL                '\0'

  #ifndef TRUE
***************
*** 94,104 ****
              in_file = stdin;
          else
          {
! #ifndef __CYGWIN__
!             if ((in_file = fopen(*argv, "r")) == NULL)
! #else
!             if ((in_file = fopen(*argv, "rb")) == NULL)
! #endif
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }
--- 96,102 ----
              in_file = stdin;
          else
          {
!             if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
                  halt("PERROR:  Can not open file %s\n", argv[0]);
              argv++;
          }

Re: Win32 defines

From
Peter Eisentraut
Date:
Bruce Momjian writes:

> I was confused by win.h.  It looks similar to win32.h and cygwin.h in
> that it defines DLIMPORT stuff, but not much else.  What is that file
> for?  I am looking for something that cygwin and win32 can both use,
> though actually maybe are better just leaving cygwin alone and do just
> win32.  Let me do that, unless you have another suggestion.

cygwin.h is for the Cygwin port and win.h is for the Windows port.  There
will be occasional similiarities, but it's not useful to try to keep them
the same.  (win32.h is for the existing client-side Windows compilation
path.  Eventually, it should be removed and users be directed to use the
real Windows port. -- To be determined; don't worry about it now.)

--
Peter Eisentraut   peter_e@gmx.net