Re: Win32 defines

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Win32 defines
Дата
Msg-id Pine.LNX.4.44.0304031545400.2215-100000@peter.localdomain
обсуждение исходный текст
Ответ на Win32 defines  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: Win32 defines  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-patches
Bruce Momjian writes:

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

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

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

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

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

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

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

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

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

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

#define timezone _timezone

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

(same here)

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

This should use the macros defined in c.h.

--
Peter Eisentraut   peter_e@gmx.net


В списке pgsql-patches по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Win32 path patch
Следующее
От: Andrew Sullivan
Дата:
Сообщение: pglog-rotator