Thread: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c, timezone/pgtz.c

cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c, timezone/pgtz.c

From
Reini Urban
Date:
Attached patches are required for cygwin:

2004-08-24 21:23:53 rurban@x-ray.at
    * (postmaster/syslogger.c) struct timeval is
           declared in sys/time.h, not in time.h

2004-08-24 20:20:54 rurban:
    * (port/dirmod.c) cygwin needs different header locations,
           and unlink is a macro. There are no pgport_palloc
           versions yet


timezone/pgtz.c:
Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
PGAC_VAR_INT_TIMEZONE

In the meantime I've hacked it with a cast from time_t to (int) in
timezone/pgtz.c: get_timezone_offset

but timezone really is of time_t, not int. I don't know what you are
trying to do here.


There's on remaining issue for the cygwin build:
../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
reference to `__imp__CurrentMemoryContext'
../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
reference to `__imp__CurrentMemoryContext'

which explains the pgport_palloc problem.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

2004-08-24 20:20:54 rurban:
    * cygwin needs different header locations, and unlink is a macro
     * There are no pgport_palloc versions yet

--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
@@ -33,16 +33,28 @@


 #include "miscadmin.h"
+
+#ifdef __CYGWIN__
+#include <windows.h>
+#include <w32api/winioctl.h>
+#else
 #include <winioctl.h>
+#undef unlink
+#endif

 #undef rename
-#undef unlink

+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
+#if 0
 #ifndef FRONTEND
+#undef palloc
+#undef pstrdup
+#undef pfree
 #define palloc(sz)    pgport_palloc(sz)
 #define pstrdup(str)    pgport_pstrdup(str)
 #define pfree(pointer)    pgport_pfree(pointer)
 #endif
+#endif


 /*
2004-08-24 21:23:53 rurban@x-ray.at
    * struct timeval is declared in sys/time.h, not in time.h

--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <time.h>
 #include <unistd.h>
+#include <sys/time.h>
 #include <sys/stat.h>

 #include "libpq/pqsignal.h"
--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
@@ -97,9 +97,9 @@
     return tm->tm_gmtoff;
 #elif defined(HAVE_INT_TIMEZONE)
 #ifdef HAVE_UNDERSCORE_TIMEZONE
-    return -_timezone;
+    return -(int)_timezone;
 #else
-    return -timezone;
+    return -(int)timezone;
 #endif
 #else
 #error No way to determine TZ? Can this happen?

Re: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c, timezone/pgtz.c

From
Jason Tishler
Date:
On Tue, Aug 24, 2004 at 09:49:51PM +0200, Reini Urban wrote:
> There's on remaining issue for the cygwin build:
> ../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
> reference to `__imp__CurrentMemoryContext'
> ../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
> reference to `__imp__CurrentMemoryContext'

Note I have no experience with 8.0 so the following is a WAG...
The above is likely caused by not linking against an import library
(i.e., libpostgres.a).

HTH,
Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

From
Bruce Momjian
Date:
Your patch highlighted several bugs in our code.  First, I wasn't
testing for CYGWIN in the backend pgport_palloc code.  Second, I added
an #undef to prevent compiler warnings.  Third I added your Cygwin
includes with an #ifdef.  These will appear in beta2.

On the timezone issue, I see this in dt.h:

    /* 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

so are you saying your _timezone is time_t and not an int?  Sometimes it
is just a short because it is only minutes west of GMT, not an actually
seconds since 1970 or anything.  Making it time_t actually sounds like
overkill, but we can work around that in dt.h if indeed that is how your
OS defines it.  The easiest fix would probably be to add the cast to int
right in dt.h and only for Cygwin:

    #define TIMEZONE_GLOBAL ((int)_timezone)

Does that work for you?

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

Reini Urban wrote:
> Attached patches are required for cygwin:
>
> 2004-08-24 21:23:53 rurban@x-ray.at
>     * (postmaster/syslogger.c) struct timeval is
>            declared in sys/time.h, not in time.h
>
> 2004-08-24 20:20:54 rurban:
>     * (port/dirmod.c) cygwin needs different header locations,
>            and unlink is a macro. There are no pgport_palloc
>            versions yet
>
>
> timezone/pgtz.c:
> Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
> PGAC_VAR_INT_TIMEZONE
>
> In the meantime I've hacked it with a cast from time_t to (int) in
> timezone/pgtz.c: get_timezone_offset
>
> but timezone really is of time_t, not int. I don't know what you are
> trying to do here.
>
>
> There's on remaining issue for the cygwin build:
> ../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
> reference to `__imp__CurrentMemoryContext'
> ../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
> reference to `__imp__CurrentMemoryContext'
>
> which explains the pgport_palloc problem.
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/
>

> 2004-08-24 20:20:54 rurban:
>     * cygwin needs different header locations, and unlink is a macro
>      * There are no pgport_palloc versions yet
>
> --- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
> +++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
> @@ -33,16 +33,28 @@
>
>
>  #include "miscadmin.h"
> +
> +#ifdef __CYGWIN__
> +#include <windows.h>
> +#include <w32api/winioctl.h>
> +#else
>  #include <winioctl.h>
> +#undef unlink
> +#endif
>
>  #undef rename
> -#undef unlink
>
> +/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
> +#if 0
>  #ifndef FRONTEND
> +#undef palloc
> +#undef pstrdup
> +#undef pfree
>  #define palloc(sz)    pgport_palloc(sz)
>  #define pstrdup(str)    pgport_pstrdup(str)
>  #define pfree(pointer)    pgport_pfree(pointer)
>  #endif
> +#endif
>
>
>  /*

> 2004-08-24 21:23:53 rurban@x-ray.at
>     * struct timeval is declared in sys/time.h, not in time.h
>
> --- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
> +++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
> @@ -28,6 +28,7 @@
>  #include <signal.h>
>  #include <time.h>
>  #include <unistd.h>
> +#include <sys/time.h>
>  #include <sys/stat.h>
>
>  #include "libpq/pqsignal.h"

> --- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
> +++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
> @@ -97,9 +97,9 @@
>      return tm->tm_gmtoff;
>  #elif defined(HAVE_INT_TIMEZONE)
>  #ifdef HAVE_UNDERSCORE_TIMEZONE
> -    return -_timezone;
> +    return -(int)_timezone;
>  #else
> -    return -timezone;
> +    return -(int)timezone;
>  #endif
>  #else
>  #error No way to determine TZ? Can this happen?

>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
>       joining column's datatypes do not match

--
  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/utils/mmgr/mcxt.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
retrieving revision 1.47
diff -c -c -r1.47 mcxt.c
*** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
--- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
***************
*** 631,637 ****
  }


! #ifdef WIN32
  /*
   *    Memory support routines for libpgport on Win32
   *
--- 631,637 ----
  }


! #if defined(WIN32) || defined(__CYGWIN__)
  /*
   *    Memory support routines for libpgport on Win32
   *
***************
*** 649,654 ****
--- 649,655 ----
      return palloc(sz);
  }

+
  char *
  pgport_pstrdup(const char *str)
  {
Index: src/port/dirmod.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
retrieving revision 1.19
diff -c -c -r1.19 dirmod.c
*** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
--- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
***************
*** 31,48 ****

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

-
  #include "miscadmin.h"
- #include <winioctl.h>

  #undef rename
  #undef unlink

  #ifndef FRONTEND
  /*
   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
   *    because of DLLIMPORT.
   */
  #define palloc(sz)        pgport_palloc(sz)
  #define pstrdup(str)    pgport_pstrdup(str)
  #define pfree(pointer)    pgport_pfree(pointer)
--- 31,57 ----

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

  #include "miscadmin.h"

  #undef rename
  #undef unlink

+ #ifdef __WIN32__
+ #include <winioctl.h>
+ #else
+ /* __CYGWIN__ */
+ #include <windows.h>
+ #include <w32api/winioctl.h>
+ #endif
+
  #ifndef FRONTEND
  /*
   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
   *    because of DLLIMPORT.
   */
+ #undef palloc
+ #undef pstrdup
+ #undef pfree
  #define palloc(sz)        pgport_palloc(sz)
  #define pstrdup(str)    pgport_pstrdup(str)
  #define pfree(pointer)    pgport_pfree(pointer)

Re: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

From
Reini Urban
Date:
Bruce Momjian schrieb:
> Your patch highlighted several bugs in our code.  First, I wasn't
> testing for CYGWIN in the backend pgport_palloc code.  Second, I added
> an #undef to prevent compiler warnings.  Third I added your Cygwin
> includes with an #ifdef.  These will appear in beta2.
>
> On the timezone issue, I see this in dt.h:
>
>     /* 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
>
> so are you saying your _timezone is time_t and not an int?  Sometimes it
> is just a short because it is only minutes west of GMT, not an actually
> seconds since 1970 or anything.  Making it time_t actually sounds like
> overkill, but we can work around that in dt.h if indeed that is how your
> OS defines it.  The easiest fix would probably be to add the cast to int
> right in dt.h and only for Cygwin:
>
>     #define TIMEZONE_GLOBAL ((int)_timezone)
>
> Does that work for you?

yes, that's better.

FYI /usr/include/time.h:
/* defines for the opengroup specifications Derived from Issue 1 of the
SVID.  */
extern __IMPORT time_t _timezone;
...

BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but
configure didn't check for that.
I'll come with better patches after beta2.


> ---------------------------------------------------------------------------
>
> Reini Urban wrote:
>
>>Attached patches are required for cygwin:
>>
>>2004-08-24 21:23:53 rurban@x-ray.at
>>    * (postmaster/syslogger.c) struct timeval is
>>           declared in sys/time.h, not in time.h
>>
>>2004-08-24 20:20:54 rurban:
>>    * (port/dirmod.c) cygwin needs different header locations,
>>           and unlink is a macro. There are no pgport_palloc
>>           versions yet
>>
>>
>>timezone/pgtz.c:
>>Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
>>PGAC_VAR_INT_TIMEZONE
>>
>>In the meantime I've hacked it with a cast from time_t to (int) in
>>timezone/pgtz.c: get_timezone_offset
>>
>>but timezone really is of time_t, not int. I don't know what you are
>>trying to do here.
>>
>>
>>There's on remaining issue for the cygwin build:
>>../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
>>reference to `__imp__CurrentMemoryContext'
>>../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
>>reference to `__imp__CurrentMemoryContext'
>>
>>which explains the pgport_palloc problem.
>>--
>>Reini Urban
>>http://xarch.tu-graz.ac.at/home/rurban/
>>
>
>
>>2004-08-24 20:20:54 rurban:
>>    * cygwin needs different header locations, and unlink is a macro
>>     * There are no pgport_palloc versions yet
>>
>>--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
>>+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
>>@@ -33,16 +33,28 @@
>>
>>
>> #include "miscadmin.h"
>>+
>>+#ifdef __CYGWIN__
>>+#include <windows.h>
>>+#include <w32api/winioctl.h>
>>+#else
>> #include <winioctl.h>
>>+#undef unlink
>>+#endif
>>
>> #undef rename
>>-#undef unlink
>>
>>+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
>>+#if 0
>> #ifndef FRONTEND
>>+#undef palloc
>>+#undef pstrdup
>>+#undef pfree
>> #define palloc(sz)    pgport_palloc(sz)
>> #define pstrdup(str)    pgport_pstrdup(str)
>> #define pfree(pointer)    pgport_pfree(pointer)
>> #endif
>>+#endif
>>
>>
>> /*
>
>
>>2004-08-24 21:23:53 rurban@x-ray.at
>>    * struct timeval is declared in sys/time.h, not in time.h
>>
>>--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
>>+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
>>@@ -28,6 +28,7 @@
>> #include <signal.h>
>> #include <time.h>
>> #include <unistd.h>
>>+#include <sys/time.h>
>> #include <sys/stat.h>
>>
>> #include "libpq/pqsignal.h"
>
>
>>--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
>>+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
>>@@ -97,9 +97,9 @@
>>     return tm->tm_gmtoff;
>> #elif defined(HAVE_INT_TIMEZONE)
>> #ifdef HAVE_UNDERSCORE_TIMEZONE
>>-    return -_timezone;
>>+    return -(int)_timezone;
>> #else
>>-    return -timezone;
>>+    return -(int)timezone;
>> #endif
>> #else
>> #error No way to determine TZ? Can this happen?
>
>
>>---------------------------(end of broadcast)---------------------------
>>TIP 9: the planner will ignore your desire to choose an index scan if your
>>      joining column's datatypes do not match
>
>
>
> ------------------------------------------------------------------------
>
> Index: src/backend/utils/mmgr/mcxt.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
> retrieving revision 1.47
> diff -c -c -r1.47 mcxt.c
> *** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
> --- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
> ***************
> *** 631,637 ****
>   }
>
>
> ! #ifdef WIN32
>   /*
>    *    Memory support routines for libpgport on Win32
>    *
> --- 631,637 ----
>   }
>
>
> ! #if defined(WIN32) || defined(__CYGWIN__)
>   /*
>    *    Memory support routines for libpgport on Win32
>    *
> ***************
> *** 649,654 ****
> --- 649,655 ----
>       return palloc(sz);
>   }
>
> +
>   char *
>   pgport_pstrdup(const char *str)
>   {
> Index: src/port/dirmod.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
> retrieving revision 1.19
> diff -c -c -r1.19 dirmod.c
> *** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
> --- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
> ***************
> *** 31,48 ****
>
>   #if defined(WIN32) || defined(__CYGWIN__)
>
> -
>   #include "miscadmin.h"
> - #include <winioctl.h>
>
>   #undef rename
>   #undef unlink
>
>   #ifndef FRONTEND
>   /*
>    *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>    *    because of DLLIMPORT.
>    */
>   #define palloc(sz)        pgport_palloc(sz)
>   #define pstrdup(str)    pgport_pstrdup(str)
>   #define pfree(pointer)    pgport_pfree(pointer)
> --- 31,57 ----
>
>   #if defined(WIN32) || defined(__CYGWIN__)
>
>   #include "miscadmin.h"
>
>   #undef rename
>   #undef unlink
>
> + #ifdef __WIN32__
> + #include <winioctl.h>
> + #else
> + /* __CYGWIN__ */
> + #include <windows.h>
> + #include <w32api/winioctl.h>
> + #endif
> +
>   #ifndef FRONTEND
>   /*
>    *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>    *    because of DLLIMPORT.
>    */
> + #undef palloc
> + #undef pstrdup
> + #undef pfree
>   #define palloc(sz)        pgport_palloc(sz)
>   #define pstrdup(str)    pgport_pstrdup(str)
>   #define pfree(pointer)    pgport_pfree(pointer)


--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

From
Bruce Momjian
Date:
Should I apply this change?

     #define TIMEZONE_GLOBAL ((int)_timezone)


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

Reini Urban wrote:
> Bruce Momjian schrieb:
> > Your patch highlighted several bugs in our code.  First, I wasn't
> > testing for CYGWIN in the backend pgport_palloc code.  Second, I added
> > an #undef to prevent compiler warnings.  Third I added your Cygwin
> > includes with an #ifdef.  These will appear in beta2.
> >
> > On the timezone issue, I see this in dt.h:
> >
> >     /* 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
> >
> > so are you saying your _timezone is time_t and not an int?  Sometimes it
> > is just a short because it is only minutes west of GMT, not an actually
> > seconds since 1970 or anything.  Making it time_t actually sounds like
> > overkill, but we can work around that in dt.h if indeed that is how your
> > OS defines it.  The easiest fix would probably be to add the cast to int
> > right in dt.h and only for Cygwin:
> >
> >     #define TIMEZONE_GLOBAL ((int)_timezone)
> >
> > Does that work for you?
>
> yes, that's better.
>
> FYI /usr/include/time.h:
> /* defines for the opengroup specifications Derived from Issue 1 of the
> SVID.  */
> extern __IMPORT time_t _timezone;
> ...
>
> BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but
> configure didn't check for that.
> I'll come with better patches after beta2.
>
>
> > ---------------------------------------------------------------------------
> >
> > Reini Urban wrote:
> >
> >>Attached patches are required for cygwin:
> >>
> >>2004-08-24 21:23:53 rurban@x-ray.at
> >>    * (postmaster/syslogger.c) struct timeval is
> >>           declared in sys/time.h, not in time.h
> >>
> >>2004-08-24 20:20:54 rurban:
> >>    * (port/dirmod.c) cygwin needs different header locations,
> >>           and unlink is a macro. There are no pgport_palloc
> >>           versions yet
> >>
> >>
> >>timezone/pgtz.c:
> >>Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
> >>PGAC_VAR_INT_TIMEZONE
> >>
> >>In the meantime I've hacked it with a cast from time_t to (int) in
> >>timezone/pgtz.c: get_timezone_offset
> >>
> >>but timezone really is of time_t, not int. I don't know what you are
> >>trying to do here.
> >>
> >>
> >>There's on remaining issue for the cygwin build:
> >>../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
> >>reference to `__imp__CurrentMemoryContext'
> >>../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
> >>reference to `__imp__CurrentMemoryContext'
> >>
> >>which explains the pgport_palloc problem.
> >>--
> >>Reini Urban
> >>http://xarch.tu-graz.ac.at/home/rurban/
> >>
> >
> >
> >>2004-08-24 20:20:54 rurban:
> >>    * cygwin needs different header locations, and unlink is a macro
> >>     * There are no pgport_palloc versions yet
> >>
> >>--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
> >>+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
> >>@@ -33,16 +33,28 @@
> >>
> >>
> >> #include "miscadmin.h"
> >>+
> >>+#ifdef __CYGWIN__
> >>+#include <windows.h>
> >>+#include <w32api/winioctl.h>
> >>+#else
> >> #include <winioctl.h>
> >>+#undef unlink
> >>+#endif
> >>
> >> #undef rename
> >>-#undef unlink
> >>
> >>+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
> >>+#if 0
> >> #ifndef FRONTEND
> >>+#undef palloc
> >>+#undef pstrdup
> >>+#undef pfree
> >> #define palloc(sz)    pgport_palloc(sz)
> >> #define pstrdup(str)    pgport_pstrdup(str)
> >> #define pfree(pointer)    pgport_pfree(pointer)
> >> #endif
> >>+#endif
> >>
> >>
> >> /*
> >
> >
> >>2004-08-24 21:23:53 rurban@x-ray.at
> >>    * struct timeval is declared in sys/time.h, not in time.h
> >>
> >>--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
> >>+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
> >>@@ -28,6 +28,7 @@
> >> #include <signal.h>
> >> #include <time.h>
> >> #include <unistd.h>
> >>+#include <sys/time.h>
> >> #include <sys/stat.h>
> >>
> >> #include "libpq/pqsignal.h"
> >
> >
> >>--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
> >>+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
> >>@@ -97,9 +97,9 @@
> >>     return tm->tm_gmtoff;
> >> #elif defined(HAVE_INT_TIMEZONE)
> >> #ifdef HAVE_UNDERSCORE_TIMEZONE
> >>-    return -_timezone;
> >>+    return -(int)_timezone;
> >> #else
> >>-    return -timezone;
> >>+    return -(int)timezone;
> >> #endif
> >> #else
> >> #error No way to determine TZ? Can this happen?
> >
> >
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 9: the planner will ignore your desire to choose an index scan if your
> >>      joining column's datatypes do not match
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index: src/backend/utils/mmgr/mcxt.c
> > ===================================================================
> > RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
> > retrieving revision 1.47
> > diff -c -c -r1.47 mcxt.c
> > *** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
> > --- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
> > ***************
> > *** 631,637 ****
> >   }
> >
> >
> > ! #ifdef WIN32
> >   /*
> >    *    Memory support routines for libpgport on Win32
> >    *
> > --- 631,637 ----
> >   }
> >
> >
> > ! #if defined(WIN32) || defined(__CYGWIN__)
> >   /*
> >    *    Memory support routines for libpgport on Win32
> >    *
> > ***************
> > *** 649,654 ****
> > --- 649,655 ----
> >       return palloc(sz);
> >   }
> >
> > +
> >   char *
> >   pgport_pstrdup(const char *str)
> >   {
> > Index: src/port/dirmod.c
> > ===================================================================
> > RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
> > retrieving revision 1.19
> > diff -c -c -r1.19 dirmod.c
> > *** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
> > --- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
> > ***************
> > *** 31,48 ****
> >
> >   #if defined(WIN32) || defined(__CYGWIN__)
> >
> > -
> >   #include "miscadmin.h"
> > - #include <winioctl.h>
> >
> >   #undef rename
> >   #undef unlink
> >
> >   #ifndef FRONTEND
> >   /*
> >    *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
> >    *    because of DLLIMPORT.
> >    */
> >   #define palloc(sz)        pgport_palloc(sz)
> >   #define pstrdup(str)    pgport_pstrdup(str)
> >   #define pfree(pointer)    pgport_pfree(pointer)
> > --- 31,57 ----
> >
> >   #if defined(WIN32) || defined(__CYGWIN__)
> >
> >   #include "miscadmin.h"
> >
> >   #undef rename
> >   #undef unlink
> >
> > + #ifdef __WIN32__
> > + #include <winioctl.h>
> > + #else
> > + /* __CYGWIN__ */
> > + #include <windows.h>
> > + #include <w32api/winioctl.h>
> > + #endif
> > +
> >   #ifndef FRONTEND
> >   /*
> >    *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
> >    *    because of DLLIMPORT.
> >    */
> > + #undef palloc
> > + #undef pstrdup
> > + #undef pfree
> >   #define palloc(sz)        pgport_palloc(sz)
> >   #define pstrdup(str)    pgport_pstrdup(str)
> >   #define pfree(pointer)    pgport_pfree(pointer)
>
>
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
  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: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

From
Reini Urban
Date:
Bruce Momjian schrieb:
> Should I apply this change?
>
>      #define TIMEZONE_GLOBAL ((int)_timezone)

yes, please.
I have no time yet, to come up with the better patch. It's already  monday.

> ---------------------------------------------------------------------------
>
> Reini Urban wrote:
>
>>Bruce Momjian schrieb:
>>
>>>Your patch highlighted several bugs in our code.  First, I wasn't
>>>testing for CYGWIN in the backend pgport_palloc code.  Second, I added
>>>an #undef to prevent compiler warnings.  Third I added your Cygwin
>>>includes with an #ifdef.  These will appear in beta2.
>>>
>>>On the timezone issue, I see this in dt.h:
>>>
>>>    /* 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
>>>
>>>so are you saying your _timezone is time_t and not an int?  Sometimes it
>>>is just a short because it is only minutes west of GMT, not an actually
>>>seconds since 1970 or anything.  Making it time_t actually sounds like
>>>overkill, but we can work around that in dt.h if indeed that is how your
>>>OS defines it.  The easiest fix would probably be to add the cast to int
>>>right in dt.h and only for Cygwin:
>>>
>>>    #define TIMEZONE_GLOBAL ((int)_timezone)
>>>
>>>Does that work for you?
>>
>>yes, that's better.
>>
>>FYI /usr/include/time.h:
>>/* defines for the opengroup specifications Derived from Issue 1 of the
>>SVID.  */
>>extern __IMPORT time_t _timezone;
>>...
>>
>>BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but
>>configure didn't check for that.
>>I'll come with better patches after beta2.
>>
>>
>>
>>>---------------------------------------------------------------------------
>>>
>>>Reini Urban wrote:
>>>
>>>
>>>>Attached patches are required for cygwin:
>>>>
>>>>2004-08-24 21:23:53 rurban@x-ray.at
>>>>    * (postmaster/syslogger.c) struct timeval is
>>>>          declared in sys/time.h, not in time.h
>>>>
>>>>2004-08-24 20:20:54 rurban:
>>>>    * (port/dirmod.c) cygwin needs different header locations,
>>>>          and unlink is a macro. There are no pgport_palloc
>>>>          versions yet
>>>>
>>>>
>>>>timezone/pgtz.c:
>>>>Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
>>>>PGAC_VAR_INT_TIMEZONE
>>>>
>>>>In the meantime I've hacked it with a cast from time_t to (int) in
>>>>timezone/pgtz.c: get_timezone_offset
>>>>
>>>>but timezone really is of time_t, not int. I don't know what you are
>>>>trying to do here.
>>>>
>>>>
>>>>There's on remaining issue for the cygwin build:
>>>>../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
>>>>reference to `__imp__CurrentMemoryContext'
>>>>../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
>>>>reference to `__imp__CurrentMemoryContext'
>>>>
>>>>which explains the pgport_palloc problem.
>>>>--
>>>>Reini Urban
>>>>http://xarch.tu-graz.ac.at/home/rurban/
>>>>
>>>
>>>
>>>>2004-08-24 20:20:54 rurban:
>>>>    * cygwin needs different header locations, and unlink is a macro
>>>>    * There are no pgport_palloc versions yet
>>>>
>>>>--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
>>>>+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
>>>>@@ -33,16 +33,28 @@
>>>>
>>>>
>>>>#include "miscadmin.h"
>>>>+
>>>>+#ifdef __CYGWIN__
>>>>+#include <windows.h>
>>>>+#include <w32api/winioctl.h>
>>>>+#else
>>>>#include <winioctl.h>
>>>>+#undef unlink
>>>>+#endif
>>>>
>>>>#undef rename
>>>>-#undef unlink
>>>>
>>>>+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
>>>>+#if 0
>>>>#ifndef FRONTEND
>>>>+#undef palloc
>>>>+#undef pstrdup
>>>>+#undef pfree
>>>>#define palloc(sz)    pgport_palloc(sz)
>>>>#define pstrdup(str)    pgport_pstrdup(str)
>>>>#define pfree(pointer)    pgport_pfree(pointer)
>>>>#endif
>>>>+#endif
>>>>
>>>>
>>>>/*
>>>
>>>
>>>>2004-08-24 21:23:53 rurban@x-ray.at
>>>>    * struct timeval is declared in sys/time.h, not in time.h
>>>>
>>>>--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
>>>>+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
>>>>@@ -28,6 +28,7 @@
>>>>#include <signal.h>
>>>>#include <time.h>
>>>>#include <unistd.h>
>>>>+#include <sys/time.h>
>>>>#include <sys/stat.h>
>>>>
>>>>#include "libpq/pqsignal.h"
>>>
>>>
>>>>--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
>>>>+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
>>>>@@ -97,9 +97,9 @@
>>>>    return tm->tm_gmtoff;
>>>>#elif defined(HAVE_INT_TIMEZONE)
>>>>#ifdef HAVE_UNDERSCORE_TIMEZONE
>>>>-    return -_timezone;
>>>>+    return -(int)_timezone;
>>>>#else
>>>>-    return -timezone;
>>>>+    return -(int)timezone;
>>>>#endif
>>>>#else
>>>>#error No way to determine TZ? Can this happen?
>>>
>>>
>>>>---------------------------(end of broadcast)---------------------------
>>>>TIP 9: the planner will ignore your desire to choose an index scan if your
>>>>     joining column's datatypes do not match
>>>
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>Index: src/backend/utils/mmgr/mcxt.c
>>>===================================================================
>>>RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
>>>retrieving revision 1.47
>>>diff -c -c -r1.47 mcxt.c
>>>*** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
>>>--- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
>>>***************
>>>*** 631,637 ****
>>>  }
>>>
>>>
>>>! #ifdef WIN32
>>>  /*
>>>   *    Memory support routines for libpgport on Win32
>>>   *
>>>--- 631,637 ----
>>>  }
>>>
>>>
>>>! #if defined(WIN32) || defined(__CYGWIN__)
>>>  /*
>>>   *    Memory support routines for libpgport on Win32
>>>   *
>>>***************
>>>*** 649,654 ****
>>>--- 649,655 ----
>>>      return palloc(sz);
>>>  }
>>>
>>>+
>>>  char *
>>>  pgport_pstrdup(const char *str)
>>>  {
>>>Index: src/port/dirmod.c
>>>===================================================================
>>>RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
>>>retrieving revision 1.19
>>>diff -c -c -r1.19 dirmod.c
>>>*** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
>>>--- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
>>>***************
>>>*** 31,48 ****
>>>
>>>  #if defined(WIN32) || defined(__CYGWIN__)
>>>
>>>-
>>>  #include "miscadmin.h"
>>>- #include <winioctl.h>
>>>
>>>  #undef rename
>>>  #undef unlink
>>>
>>>  #ifndef FRONTEND
>>>  /*
>>>   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>>>   *    because of DLLIMPORT.
>>>   */
>>>  #define palloc(sz)        pgport_palloc(sz)
>>>  #define pstrdup(str)    pgport_pstrdup(str)
>>>  #define pfree(pointer)    pgport_pfree(pointer)
>>>--- 31,57 ----
>>>
>>>  #if defined(WIN32) || defined(__CYGWIN__)
>>>
>>>  #include "miscadmin.h"
>>>
>>>  #undef rename
>>>  #undef unlink
>>>
>>>+ #ifdef __WIN32__
>>>+ #include <winioctl.h>
>>>+ #else
>>>+ /* __CYGWIN__ */
>>>+ #include <windows.h>
>>>+ #include <w32api/winioctl.h>
>>>+ #endif
>>>+
>>>  #ifndef FRONTEND
>>>  /*
>>>   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>>>   *    because of DLLIMPORT.
>>>   */
>>>+ #undef palloc
>>>+ #undef pstrdup
>>>+ #undef pfree
>>>  #define palloc(sz)        pgport_palloc(sz)
>>>  #define pstrdup(str)    pgport_pstrdup(str)
>>>  #define pfree(pointer)    pgport_pfree(pointer)
>>
>>
>>--
>>Reini Urban
>>http://xarch.tu-graz.ac.at/home/rurban/
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 4: Don't 'kill -9' the postmaster
>>
>
>


--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: cygwin 8.0.0beta1 postmaster/syslogger.c, port/dirmod.c,

From
Bruce Momjian
Date:
OK, patch attached and applied that casts _timezone to (int) on Cygwin.

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

Reini Urban wrote:
> Bruce Momjian schrieb:
> > Should I apply this change?
> >
> >      #define TIMEZONE_GLOBAL ((int)_timezone)
>
> yes, please.
> I have no time yet, to come up with the better patch. It's already  monday.
>
> > ---------------------------------------------------------------------------
> >
> > Reini Urban wrote:
> >
> >>Bruce Momjian schrieb:
> >>
> >>>Your patch highlighted several bugs in our code.  First, I wasn't
> >>>testing for CYGWIN in the backend pgport_palloc code.  Second, I added
> >>>an #undef to prevent compiler warnings.  Third I added your Cygwin
> >>>includes with an #ifdef.  These will appear in beta2.
> >>>
> >>>On the timezone issue, I see this in dt.h:
> >>>
> >>>    /* 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
> >>>
> >>>so are you saying your _timezone is time_t and not an int?  Sometimes it
> >>>is just a short because it is only minutes west of GMT, not an actually
> >>>seconds since 1970 or anything.  Making it time_t actually sounds like
> >>>overkill, but we can work around that in dt.h if indeed that is how your
> >>>OS defines it.  The easiest fix would probably be to add the cast to int
> >>>right in dt.h and only for Cygwin:
> >>>
> >>>    #define TIMEZONE_GLOBAL ((int)_timezone)
> >>>
> >>>Does that work for you?
> >>
> >>yes, that's better.
> >>
> >>FYI /usr/include/time.h:
> >>/* defines for the opengroup specifications Derived from Issue 1 of the
> >>SVID.  */
> >>extern __IMPORT time_t _timezone;
> >>...
> >>
> >>BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but
> >>configure didn't check for that.
> >>I'll come with better patches after beta2.
> >>
> >>
> >>
> >>>---------------------------------------------------------------------------
> >>>
> >>>Reini Urban wrote:
> >>>
> >>>
> >>>>Attached patches are required for cygwin:
> >>>>
> >>>>2004-08-24 21:23:53 rurban@x-ray.at
> >>>>    * (postmaster/syslogger.c) struct timeval is
> >>>>          declared in sys/time.h, not in time.h
> >>>>
> >>>>2004-08-24 20:20:54 rurban:
> >>>>    * (port/dirmod.c) cygwin needs different header locations,
> >>>>          and unlink is a macro. There are no pgport_palloc
> >>>>          versions yet
> >>>>
> >>>>
> >>>>timezone/pgtz.c:
> >>>>Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
> >>>>PGAC_VAR_INT_TIMEZONE
> >>>>
> >>>>In the meantime I've hacked it with a cast from time_t to (int) in
> >>>>timezone/pgtz.c: get_timezone_offset
> >>>>
> >>>>but timezone really is of time_t, not int. I don't know what you are
> >>>>trying to do here.
> >>>>
> >>>>
> >>>>There's on remaining issue for the cygwin build:
> >>>>../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
> >>>>reference to `__imp__CurrentMemoryContext'
> >>>>../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
> >>>>reference to `__imp__CurrentMemoryContext'
> >>>>
> >>>>which explains the pgport_palloc problem.
> >>>>--
> >>>>Reini Urban
> >>>>http://xarch.tu-graz.ac.at/home/rurban/
> >>>>
> >>>
> >>>
> >>>>2004-08-24 20:20:54 rurban:
> >>>>    * cygwin needs different header locations, and unlink is a macro
> >>>>    * There are no pgport_palloc versions yet
> >>>>
> >>>>--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
> >>>>+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
> >>>>@@ -33,16 +33,28 @@
> >>>>
> >>>>
> >>>>#include "miscadmin.h"
> >>>>+
> >>>>+#ifdef __CYGWIN__
> >>>>+#include <windows.h>
> >>>>+#include <w32api/winioctl.h>
> >>>>+#else
> >>>>#include <winioctl.h>
> >>>>+#undef unlink
> >>>>+#endif
> >>>>
> >>>>#undef rename
> >>>>-#undef unlink
> >>>>
> >>>>+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
> >>>>+#if 0
> >>>>#ifndef FRONTEND
> >>>>+#undef palloc
> >>>>+#undef pstrdup
> >>>>+#undef pfree
> >>>>#define palloc(sz)    pgport_palloc(sz)
> >>>>#define pstrdup(str)    pgport_pstrdup(str)
> >>>>#define pfree(pointer)    pgport_pfree(pointer)
> >>>>#endif
> >>>>+#endif
> >>>>
> >>>>
> >>>>/*
> >>>
> >>>
> >>>>2004-08-24 21:23:53 rurban@x-ray.at
> >>>>    * struct timeval is declared in sys/time.h, not in time.h
> >>>>
> >>>>--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
> >>>>+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
> >>>>@@ -28,6 +28,7 @@
> >>>>#include <signal.h>
> >>>>#include <time.h>
> >>>>#include <unistd.h>
> >>>>+#include <sys/time.h>
> >>>>#include <sys/stat.h>
> >>>>
> >>>>#include "libpq/pqsignal.h"
> >>>
> >>>
> >>>>--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
> >>>>+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
> >>>>@@ -97,9 +97,9 @@
> >>>>    return tm->tm_gmtoff;
> >>>>#elif defined(HAVE_INT_TIMEZONE)
> >>>>#ifdef HAVE_UNDERSCORE_TIMEZONE
> >>>>-    return -_timezone;
> >>>>+    return -(int)_timezone;
> >>>>#else
> >>>>-    return -timezone;
> >>>>+    return -(int)timezone;
> >>>>#endif
> >>>>#else
> >>>>#error No way to determine TZ? Can this happen?
> >>>
> >>>
> >>>>---------------------------(end of broadcast)---------------------------
> >>>>TIP 9: the planner will ignore your desire to choose an index scan if your
> >>>>     joining column's datatypes do not match
> >>>
> >>>
> >>>
> >>>------------------------------------------------------------------------
> >>>
> >>>Index: src/backend/utils/mmgr/mcxt.c
> >>>===================================================================
> >>>RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
> >>>retrieving revision 1.47
> >>>diff -c -c -r1.47 mcxt.c
> >>>*** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
> >>>--- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
> >>>***************
> >>>*** 631,637 ****
> >>>  }
> >>>
> >>>
> >>>! #ifdef WIN32
> >>>  /*
> >>>   *    Memory support routines for libpgport on Win32
> >>>   *
> >>>--- 631,637 ----
> >>>  }
> >>>
> >>>
> >>>! #if defined(WIN32) || defined(__CYGWIN__)
> >>>  /*
> >>>   *    Memory support routines for libpgport on Win32
> >>>   *
> >>>***************
> >>>*** 649,654 ****
> >>>--- 649,655 ----
> >>>      return palloc(sz);
> >>>  }
> >>>
> >>>+
> >>>  char *
> >>>  pgport_pstrdup(const char *str)
> >>>  {
> >>>Index: src/port/dirmod.c
> >>>===================================================================
> >>>RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
> >>>retrieving revision 1.19
> >>>diff -c -c -r1.19 dirmod.c
> >>>*** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
> >>>--- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
> >>>***************
> >>>*** 31,48 ****
> >>>
> >>>  #if defined(WIN32) || defined(__CYGWIN__)
> >>>
> >>>-
> >>>  #include "miscadmin.h"
> >>>- #include <winioctl.h>
> >>>
> >>>  #undef rename
> >>>  #undef unlink
> >>>
> >>>  #ifndef FRONTEND
> >>>  /*
> >>>   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
> >>>   *    because of DLLIMPORT.
> >>>   */
> >>>  #define palloc(sz)        pgport_palloc(sz)
> >>>  #define pstrdup(str)    pgport_pstrdup(str)
> >>>  #define pfree(pointer)    pgport_pfree(pointer)
> >>>--- 31,57 ----
> >>>
> >>>  #if defined(WIN32) || defined(__CYGWIN__)
> >>>
> >>>  #include "miscadmin.h"
> >>>
> >>>  #undef rename
> >>>  #undef unlink
> >>>
> >>>+ #ifdef __WIN32__
> >>>+ #include <winioctl.h>
> >>>+ #else
> >>>+ /* __CYGWIN__ */
> >>>+ #include <windows.h>
> >>>+ #include <w32api/winioctl.h>
> >>>+ #endif
> >>>+
> >>>  #ifndef FRONTEND
> >>>  /*
> >>>   *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
> >>>   *    because of DLLIMPORT.
> >>>   */
> >>>+ #undef palloc
> >>>+ #undef pstrdup
> >>>+ #undef pfree
> >>>  #define palloc(sz)        pgport_palloc(sz)
> >>>  #define pstrdup(str)    pgport_pstrdup(str)
> >>>  #define pfree(pointer)    pgport_pfree(pointer)
> >>
> >>
> >>--
> >>Reini Urban
> >>http://xarch.tu-graz.ac.at/home/rurban/
> >>
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 4: Don't 'kill -9' the postmaster
> >>
> >
> >
>
>
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>

--
  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/interfaces/ecpg/pgtypeslib/dt.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt.h,v
retrieving revision 1.17
diff -c -c -r1.17 dt.h
*** src/interfaces/ecpg/pgtypeslib/dt.h    19 Jan 2004 19:04:40 -0000    1.17
--- src/interfaces/ecpg/pgtypeslib/dt.h    1 Sep 2004 04:00:49 -0000
***************
*** 220,226 ****
--- 220,230 ----
  #if !defined(__CYGWIN__) && !defined(WIN32)
  #define TIMEZONE_GLOBAL timezone
  #else
+ #if defined(WIN32)
  #define TIMEZONE_GLOBAL _timezone
+ #else
+ #define TIMEZONE_GLOBAL ((int)_timezone)    /* time_t on Cywgin */
+ #endif
  #define tzname _tzname            /* should be in time.h? */
  #endif


Re: time_t timezone

From
Reini Urban
Date:
Now I've found time to test beta2 and came up
with the attached better patch:

Added configure time_t timezone check for the SUSV definition.
Not only cygwin, all newlib installations without struct tm timezone.
Casted to (int) timezone.

(configure should really be re-created by autoconf. I patched it just
for completeness in the forthcoming cygwin package.)


Bruce Momjian schrieb:
> OK, patch attached and applied that casts _timezone to (int) on Cygwin.
> ---------------------------------------------------------------------------
>
> Reini Urban wrote:
>>Bruce Momjian schrieb:
>>
>>>Should I apply this change?
>>>
>>>     #define TIMEZONE_GLOBAL ((int)_timezone)
>>
>>yes, please.
>>I have no time yet, to come up with the better patch. It's already  monday.
>>
>>
>>>---------------------------------------------------------------------------
>>>
>>>Reini Urban wrote:
>>>
>>>
>>>>Bruce Momjian schrieb:
>>>>
>>>>
>>>>>Your patch highlighted several bugs in our code.  First, I wasn't
>>>>>testing for CYGWIN in the backend pgport_palloc code.  Second, I added
>>>>>an #undef to prevent compiler warnings.  Third I added your Cygwin
>>>>>includes with an #ifdef.  These will appear in beta2.
>>>>>
>>>>>On the timezone issue, I see this in dt.h:
>>>>>
>>>>>    /* 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
>>>>>
>>>>>so are you saying your _timezone is time_t and not an int?  Sometimes it
>>>>>is just a short because it is only minutes west of GMT, not an actually
>>>>>seconds since 1970 or anything.  Making it time_t actually sounds like
>>>>>overkill, but we can work around that in dt.h if indeed that is how your
>>>>>OS defines it.  The easiest fix would probably be to add the cast to int
>>>>>right in dt.h and only for Cygwin:
>>>>>
>>>>>    #define TIMEZONE_GLOBAL ((int)_timezone)
>>>>>
>>>>>Does that work for you?
>>>>
>>>>yes, that's better.
>>>>
>>>>FYI /usr/include/time.h:
>>>>/* defines for the opengroup specifications Derived from Issue 1 of the
>>>>SVID.  */
>>>>extern __IMPORT time_t _timezone;
>>>>...
>>>>
>>>>BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but
>>>>configure didn't check for that.
>>>>I'll come with better patches after beta2.
>>>>
>>>>
>>>>
>>>>
>>>>>---------------------------------------------------------------------------
>>>>>
>>>>>Reini Urban wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Attached patches are required for cygwin:
>>>>>>
>>>>>>2004-08-24 21:23:53 rurban@x-ray.at
>>>>>>    * (postmaster/syslogger.c) struct timeval is
>>>>>>         declared in sys/time.h, not in time.h
>>>>>>
>>>>>>2004-08-24 20:20:54 rurban:
>>>>>>    * (port/dirmod.c) cygwin needs different header locations,
>>>>>>         and unlink is a macro. There are no pgport_palloc
>>>>>>         versions yet
>>>>>>
>>>>>>
>>>>>>timezone/pgtz.c:
>>>>>>Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
>>>>>>PGAC_VAR_INT_TIMEZONE
>>>>>>
>>>>>>In the meantime I've hacked it with a cast from time_t to (int) in
>>>>>>timezone/pgtz.c: get_timezone_offset
>>>>>>
>>>>>>but timezone really is of time_t, not int. I don't know what you are
>>>>>>trying to do here.
>>>>>>
>>>>>>
>>>>>>There's on remaining issue for the cygwin build:
>>>>>>../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined
>>>>>>reference to `__imp__CurrentMemoryContext'
>>>>>>../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined
>>>>>>reference to `__imp__CurrentMemoryContext'
>>>>>>
>>>>>>which explains the pgport_palloc problem.
>>>>>>--
>>>>>>Reini Urban
>>>>>>http://xarch.tu-graz.ac.at/home/rurban/
>>>>>>
>>>>>
>>>>>
>>>>>>2004-08-24 20:20:54 rurban:
>>>>>>    * cygwin needs different header locations, and unlink is a macro
>>>>>>    * There are no pgport_palloc versions yet
>>>>>>
>>>>>>--- postgresql-8.0.0beta1/src/port/dirmod.c.orig    2004-08-08 07:44:36.000000000 +0100
>>>>>>+++ postgresql-8.0.0beta1/src/port/dirmod.c    2004-08-24 19:20:56.557435000 +0100
>>>>>>@@ -33,16 +33,28 @@
>>>>>>
>>>>>>
>>>>>>#include "miscadmin.h"
>>>>>>+
>>>>>>+#ifdef __CYGWIN__
>>>>>>+#include <windows.h>
>>>>>>+#include <w32api/winioctl.h>
>>>>>>+#else
>>>>>>#include <winioctl.h>
>>>>>>+#undef unlink
>>>>>>+#endif
>>>>>>
>>>>>>#undef rename
>>>>>>-#undef unlink
>>>>>>
>>>>>>+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
>>>>>>+#if 0
>>>>>>#ifndef FRONTEND
>>>>>>+#undef palloc
>>>>>>+#undef pstrdup
>>>>>>+#undef pfree
>>>>>>#define palloc(sz)    pgport_palloc(sz)
>>>>>>#define pstrdup(str)    pgport_pstrdup(str)
>>>>>>#define pfree(pointer)    pgport_pfree(pointer)
>>>>>>#endif
>>>>>>+#endif
>>>>>>
>>>>>>
>>>>>>/*
>>>>>
>>>>>
>>>>>>2004-08-24 21:23:53 rurban@x-ray.at
>>>>>>    * struct timeval is declared in sys/time.h, not in time.h
>>>>>>
>>>>>>--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig    2004-08-06 20:17:31.000000000 +0100
>>>>>>+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c    2004-08-24 20:21:26.057851800 +0100
>>>>>>@@ -28,6 +28,7 @@
>>>>>>#include <signal.h>
>>>>>>#include <time.h>
>>>>>>#include <unistd.h>
>>>>>>+#include <sys/time.h>
>>>>>>#include <sys/stat.h>
>>>>>>
>>>>>>#include "libpq/pqsignal.h"
>>>>>
>>>>>
>>>>>>--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig    2004-07-31 20:12:15.000000000 +0100
>>>>>>+++ postgresql-8.0.0beta1/src/timezone/pgtz.c    2004-08-24 19:56:30.686367800 +0100
>>>>>>@@ -97,9 +97,9 @@
>>>>>>    return tm->tm_gmtoff;
>>>>>>#elif defined(HAVE_INT_TIMEZONE)
>>>>>>#ifdef HAVE_UNDERSCORE_TIMEZONE
>>>>>>-    return -_timezone;
>>>>>>+    return -(int)_timezone;
>>>>>>#else
>>>>>>-    return -timezone;
>>>>>>+    return -(int)timezone;
>>>>>>#endif
>>>>>>#else
>>>>>>#error No way to determine TZ? Can this happen?
>>>>>
>>>>>
>>>>>>---------------------------(end of broadcast)---------------------------
>>>>>>TIP 9: the planner will ignore your desire to choose an index scan if your
>>>>>>    joining column's datatypes do not match
>>>>>
>>>>>
>>>>>
>>>>>------------------------------------------------------------------------
>>>>>
>>>>>Index: src/backend/utils/mmgr/mcxt.c
>>>>>===================================================================
>>>>>RCS file: /cvsroot/pgsql-server/src/backend/utils/mmgr/mcxt.c,v
>>>>>retrieving revision 1.47
>>>>>diff -c -c -r1.47 mcxt.c
>>>>>*** src/backend/utils/mmgr/mcxt.c    8 Aug 2004 06:44:32 -0000    1.47
>>>>>--- src/backend/utils/mmgr/mcxt.c    29 Aug 2004 02:50:25 -0000
>>>>>***************
>>>>>*** 631,637 ****
>>>>> }
>>>>>
>>>>>
>>>>>! #ifdef WIN32
>>>>> /*
>>>>>  *    Memory support routines for libpgport on Win32
>>>>>  *
>>>>>--- 631,637 ----
>>>>> }
>>>>>
>>>>>
>>>>>! #if defined(WIN32) || defined(__CYGWIN__)
>>>>> /*
>>>>>  *    Memory support routines for libpgport on Win32
>>>>>  *
>>>>>***************
>>>>>*** 649,654 ****
>>>>>--- 649,655 ----
>>>>>     return palloc(sz);
>>>>> }
>>>>>
>>>>>+
>>>>> char *
>>>>> pgport_pstrdup(const char *str)
>>>>> {
>>>>>Index: src/port/dirmod.c
>>>>>===================================================================
>>>>>RCS file: /cvsroot/pgsql-server/src/port/dirmod.c,v
>>>>>retrieving revision 1.19
>>>>>diff -c -c -r1.19 dirmod.c
>>>>>*** src/port/dirmod.c    29 Aug 2004 01:44:02 -0000    1.19
>>>>>--- src/port/dirmod.c    29 Aug 2004 02:50:28 -0000
>>>>>***************
>>>>>*** 31,48 ****
>>>>>
>>>>> #if defined(WIN32) || defined(__CYGWIN__)
>>>>>
>>>>>-
>>>>> #include "miscadmin.h"
>>>>>- #include <winioctl.h>
>>>>>
>>>>> #undef rename
>>>>> #undef unlink
>>>>>
>>>>> #ifndef FRONTEND
>>>>> /*
>>>>>  *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>>>>>  *    because of DLLIMPORT.
>>>>>  */
>>>>> #define palloc(sz)        pgport_palloc(sz)
>>>>> #define pstrdup(str)    pgport_pstrdup(str)
>>>>> #define pfree(pointer)    pgport_pfree(pointer)
>>>>>--- 31,57 ----
>>>>>
>>>>> #if defined(WIN32) || defined(__CYGWIN__)
>>>>>
>>>>> #include "miscadmin.h"
>>>>>
>>>>> #undef rename
>>>>> #undef unlink
>>>>>
>>>>>+ #ifdef __WIN32__
>>>>>+ #include <winioctl.h>
>>>>>+ #else
>>>>>+ /* __CYGWIN__ */
>>>>>+ #include <windows.h>
>>>>>+ #include <w32api/winioctl.h>
>>>>>+ #endif
>>>>>+
>>>>> #ifndef FRONTEND
>>>>> /*
>>>>>  *    Call non-macro versions of palloc, can't reference CurrentMemoryContext
>>>>>  *    because of DLLIMPORT.
>>>>>  */
>>>>>+ #undef palloc
>>>>>+ #undef pstrdup
>>>>>+ #undef pfree
>>>>> #define palloc(sz)        pgport_palloc(sz)
>>>>> #define pstrdup(str)    pgport_pstrdup(str)
>>>>> #define pfree(pointer)    pgport_pfree(pointer)
>>>>
>>>>
>>>>--
>>>>Reini Urban
>>>>http://xarch.tu-graz.ac.at/home/rurban/
>>>>
>>>>---------------------------(end of broadcast)---------------------------
>>>>TIP 4: Don't 'kill -9' the postmaster
>>>>
>>>
>>>
>>
>>--
>>Reini Urban
>>http://xarch.tu-graz.ac.at/home/rurban/
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 8: explain analyze is your friend
>>
>
>
>
> ------------------------------------------------------------------------
>
> Index: src/interfaces/ecpg/pgtypeslib/dt.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt.h,v
> retrieving revision 1.17
> diff -c -c -r1.17 dt.h
> *** src/interfaces/ecpg/pgtypeslib/dt.h    19 Jan 2004 19:04:40 -0000    1.17
> --- src/interfaces/ecpg/pgtypeslib/dt.h    1 Sep 2004 04:00:49 -0000
> ***************
> *** 220,226 ****
> --- 220,230 ----
>   #if !defined(__CYGWIN__) && !defined(WIN32)
>   #define TIMEZONE_GLOBAL timezone
>   #else
> + #if defined(WIN32)
>   #define TIMEZONE_GLOBAL _timezone
> + #else
> + #define TIMEZONE_GLOBAL ((int)_timezone)    /* time_t on Cywgin */
> + #endif
>   #define tzname _tzname            /* should be in time.h? */
>   #endif
>


--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
--- config/c-library.m4.orig    2004-06-07 23:39:44.000000000 +0100
+++ config/c-library.m4    2004-09-01 01:52:49.685665700 +0100
@@ -17,7 +17,22 @@
   AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global variable 'int timezone'.])
 fi])# PGAC_VAR_INT_TIMEZONE

+# PGAC_VAR_TIME_T_TIMEZONE
+# ---------------------
+# Check if the global variable `time_t timezone' exists. If so, define
+# HAVE_TIME_T_TIMEZONE.
+AC_DEFUN([PGAC_VAR_TIME_T_TIMEZONE],
+[AC_CACHE_CHECK(for time_t timezone, pgac_cv_var_time_t_timezone,
+[AC_TRY_LINK([#include <time.h>
+int res;],
+  [res = (int) timezone / 60;],
+  [pgac_cv_var_time_t_timezone=yes],
+  [pgac_cv_var_time_t_timezone=no])])
+if test x"$pgac_cv_var_time_t_timezone" = xyes ; then
+  AC_DEFINE(HAVE_TIME_T_TIMEZONE,, [Define to 1 if you have the global variable 'time_t timezone'.])
+fi])# PGAC_VAR_TIME_T_TIMEZONE
+

 # PGAC_STRUCT_TIMEZONE
 # ------------------
--- src/timezone/pgtz.c.orig    2004-08-30 03:54:42.000000000 +0100
+++ src/timezone/pgtz.c    2004-09-01 01:55:46.011533700 +0100
@@ -96,14 +96,20 @@
 #if defined(HAVE_STRUCT_TM_TM_ZONE)
     return tm->tm_gmtoff;
 #elif defined(HAVE_INT_TIMEZONE)
-#ifdef HAVE_UNDERSCORE_TIMEZONE
+#  ifdef HAVE_UNDERSCORE_TIMEZONE
     return -_timezone;
-#else
+#  else
     return -timezone;
-#endif
+#  endif
+#elif defined(HAVE_TIME_T_TIMEZONE)
+#  ifdef HAVE_UNDERSCORE_TIMEZONE
+    return -(int) _timezone;
+#  else
+    return -(int) timezone;
+#  endif
 #else
-#error No way to determine TZ? Can this happen?
+#  error No way to determine TZ? Can this happen?
 #endif
 }

--- configure.in.orig    2004-08-31 05:08:33.000000000 +0100
+++ configure.in    2004-09-01 01:54:24.450077700 +0100
@@ -804,7 +804,8 @@
 ##

 PGAC_VAR_INT_TIMEZONE
+PGAC_VAR_TIME_T_TIMEZONE
 AC_FUNC_ACCEPT_ARGTYPES
 PGAC_FUNC_GETTIMEOFDAY_1ARG

--- configure.orig    2004-08-31 05:08:32.000000000 +0100
+++ configure    2004-09-01 02:00:16.758068100 +0100
@@ -12905,7 +12905,69 @@
 _ACEOF

 fi
+echo "$as_me:$LINENO: checking for time_t timezone" >&5
+echo $ECHO_N "checking for time_t timezone... $ECHO_C" >&6
+if test "${pgac_cv_var_time_t_timezone+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <time.h>
+int res;
+int
+main ()
+{
+res = (int)timezone / 60;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+     { ac_try='test -z "$ac_c_werror_flag"
+             || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+     { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  pgac_cv_var_time_t_timezone=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+pgac_cv_var_time_t_timezone=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $pgac_cv_var_time_t_timezone" >&5
+echo "${ECHO_T}$pgac_cv_var_time_t_timezone" >&6
+if test x"$pgac_cv_var_time_t_timezone" = xyes ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_TIME_T_TIMEZONE
+_ACEOF
+
+fi
 echo "$as_me:$LINENO: checking types of arguments for accept()" >&5
 echo $ECHO_N "checking types of arguments for accept()... $ECHO_C" >&6
  if test "${ac_cv_func_accept_return+set}" = set; then
--- src/include/pg_config.h.orig    2004-09-01 01:24:36.472964100 +0100
+++ src/include/pg_config.h    2004-09-01 02:10:22.562813700 +0100
@@ -177,7 +177,10 @@
 /* Define to 1 if you have the global variable 'int timezone'. */
 /* #undef HAVE_INT_TIMEZONE */

+/* Define to 1 if you have the global variable 'time_t timezone'. */
+#define HAVE_TIME_T_TIMEZONE 1
+
 /* Define to 1 if you have support for IPv6. */
 /* #undef HAVE_IPV6 */

--- src/include/pg_config.h.in.orig    2004-07-14 18:55:10.000000000 +0100
+++ src/include/pg_config.h.in    2004-09-01 02:11:49.389827300 +0100
@@ -176,7 +176,10 @@
 /* Define to 1 if you have the global variable 'int timezone'. */
 #undef HAVE_INT_TIMEZONE

+/* Define to 1 if you have the global variable 'time_t timezone'. */
+#undef HAVE_TIME_T_TIMEZONE
+
 /* Define to 1 if you have support for IPv6. */
 #undef HAVE_IPV6


Re: time_t timezone

From
Tom Lane
Date:
Reini Urban <rurban@x-ray.at> writes:
> Added configure time_t timezone check for the SUSV definition.

Kindly do not claim that this is per SUS spec.

http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html

            regards, tom lane

Re: time_t timezone

From
Reini Urban
Date:
Tom Lane schrieb:
> Reini Urban <rurban@x-ray.at> writes:
>>Added configure time_t timezone check for the SUSV definition.
>
> Kindly do not claim that this is per SUS spec.
>
> http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html

oops! sorry :(

--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Bruce Momjian
Date:
I am inclined to leave the #ifdef Cygwin test in the code rather than
add a configure check.

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

Reini Urban wrote:
> Tom Lane schrieb:
> > Reini Urban <rurban@x-ray.at> writes:
> >>Added configure time_t timezone check for the SUSV definition.
> >
> > Kindly do not claim that this is per SUS spec.
> >
> > http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
>
> oops! sorry :(
>
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>

--
  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: time_t timezone

From
Reini Urban
Date:
Bruce Momjian schrieb:
> I am inclined to leave the #ifdef Cygwin test in the code rather than
> add a configure check.

No,
There are a lot of other systems with time_t timezone!

newlib explains it like this:
/* defines for the opengroup specifications Derived from Issue 1 of the
SVID.  */
extern __IMPORT time_t _timezone;
extern __IMPORT int _daylight;
extern __IMPORT char *_tzname[2];

SVID (System V Interface Definition) seems to be an interesting spec,
which I found here:
   http://www.caldera.com/developers/devspecs/vol1a.pdf
   (nothing about the type of timezone though)

But the time_t timezone issue is here:
   "XSHd7 Aardvark Change Request Report"
   http://www.opengroup.org/austin/docs/austin_97.txt
(ERN 20 Accept as marked, page 1177)

SUSV2 only defines it as long int
   http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html

Caldera, redhat and IRIX 6.2 at least use time_t
   http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html

http://www.opensource.apple.com/darwinsource/10.0.4/tcl-3.1/tcl/unix/tcl.m4

Please google for "time_t timezone" and the accompanying autoconf .m4
files. tcl.m4 could be quite useful, if you don't like my hack.
php also uses time_t and not long int.

PS: For compatibility newlib has:
#ifdef __CYGWIN__
#ifdef timezonevar
#ifndef timezone
#define timezone ((long int) _timezone)
#endif
#endif

Looks like we only have to define timezonevar in our hint,
eh Makefile.port, but then the other platforms will loose.

> ---------------------------------------------------------------------------
>
> Reini Urban wrote:
>>Tom Lane schrieb:
>>>Reini Urban <rurban@x-ray.at> writes:
>>>
>>>>Added configure time_t timezone check for the SUSV definition.
>>>
>>>Kindly do not claim that this is per SUS spec.
>>>http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
>>
>>oops! sorry :(
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Tom Lane
Date:
Reini Urban <rurban@x-ray.at> writes:
> But the time_t timezone issue is here:
>    "XSHd7 Aardvark Change Request Report"
>    http://www.opengroup.org/austin/docs/austin_97.txt
> (ERN 20 Accept as marked, page 1177)

There is nothing whatever on that page about the datatype of the
timezone variable.

> Caldera, redhat and IRIX 6.2 at least use time_t
>    http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html

Red Hat certainly does not:

[tgl@rh1 include]$ grep timezone /usr/include/*h
/usr/include/time.h:   of *TIMER in the local timezone.  */
/usr/include/time.h:extern char *__tzname[2];   /* Current timezone names.  */
/usr/include/time.h:extern long int __timezone; /* Seconds west of UTC.  */
/usr/include/time.h:extern long int timezone;
[tgl@rh1 include]$

But what may be more to the point is that AFAICS we make no assumption
about the exact datatype of the timezone variable.  So long as it is
some signed integer type (which surely it must be), the code will work.
I see no reason to add a configure test to test something we do not care
about.

            regards, tom lane

Re: time_t timezone

From
Reini Urban
Date:
Tom Lane schrieb:
> Reini Urban <rurban@x-ray.at> writes:
>
>>But the time_t timezone issue is here:
>>   "XSHd7 Aardvark Change Request Report"
>>   http://www.opengroup.org/austin/docs/austin_97.txt
>>(ERN 20 Accept as marked, page 1177)
>
> There is nothing whatever on that page about the datatype of the
> timezone variable.

"1) in POSIX, the time_t value is always related to local time by
     the "seconds since the Epoch" expression and the timezone
     information."

Yes, they are talking about the localtime return value,
but nevertheless the newlib folks refer to that. Their fault.

Should I discuss that with them? I will not do that.
newlib is happening in the real world, standards just a general
consensus, how it should happen.
If some other platforms use newlib, you are lost with the make abort.

>>Caldera, redhat and IRIX 6.2 at least use time_t
>>   http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html
>
> Red Hat certainly does not:
>
> [tgl@rh1 include]$ grep timezone /usr/include/*h
> /usr/include/time.h:   of *TIMER in the local timezone.  */
> /usr/include/time.h:extern char *__tzname[2];   /* Current timezone names.  */
> /usr/include/time.h:extern long int __timezone; /* Seconds west of UTC.  */
> /usr/include/time.h:extern long int timezone;
> [tgl@rh1 include]$

dertainly depends which redhat. I have no redhat around and newlib is
quite new. This pgtz timezone code is also quite new.

> But what may be more to the point is that AFAICS we make no assumption
> about the exact datatype of the timezone variable.  So long as it is
> some signed integer type (which surely it must be), the code will work.
> I see no reason to add a configure test to test something we do not care
> about.

Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib
(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c

Fact is: src/timezone/pgtz.c does not compile on cygwin,
and will not compile on any other similar platform, as I saw from
googling around, unless it is checked in configure.in or
- the dirty way - casted away in src/timezone/pgtz.c and the .m4 macro.

Since the current configure check does not define HAVE_INT_TIMEZONE (not
casted there, so it fails), the whole pgtz #ifdef branch will abort.


http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/timezone/pgtz.c?rev=HEAD;content-type=text%2Fx-cvsweb-markup
and

http://developer.postgresql.org/cvsweb.cgi/pgsql-server/config/c-library.m4?rev=HEAD;content-type=text%2Fx-cvsweb-markup
are wrong without the cast.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Tom Lane
Date:
Reini Urban <rurban@x-ray.at> writes:
> Yes, they are talking about the localtime return value,
> but nevertheless the newlib folks refer to that. Their fault.

> Should I discuss that with them?

Probably.  They have a gratuitous variation from the Single Unix Spec.

>> But what may be more to the point is that AFAICS we make no assumption
>> about the exact datatype of the timezone variable.

> Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib
> (src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c

Per my recent post in pghackers, I think that the datatype has nothing
to do with it anyway.  The real problem is the loss of this code that
was in pg_config_manual.h in 7.4 and before:

/*
 * 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

I'm inclined to just put it back, rather than adding a configure test
that we never needed before.

            regards, tom lane

Re: time_t timezone

From
Reini Urban
Date:
Tom Lane schrieb:
> Reini Urban <rurban@x-ray.at> writes:
>>Yes, they are talking about the localtime return value,
>>but nevertheless the newlib folks refer to that. Their fault.
>
>>Should I discuss that with them?
>
> Probably.  They have a gratuitous variation from the Single Unix Spec.
>
>>>But what may be more to the point is that AFAICS we make no assumption
>>>about the exact datatype of the timezone variable.
>
>>Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib
>>(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c


> Per my recent post in pghackers, I think that the datatype has nothing
> to do with it anyway.  The real problem is the loss of this code that
> was in pg_config_manual.h in 7.4 and before:
>
> /*
>  * 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
>
> I'm inclined to just put it back, rather than adding a configure test
> that we never needed before.

Fine with me. I'm just doing the cygwin packaging.
And I can apply my cast to the pgtz.c code by myself also.
But upstream would be better.

I just wanted that you are aware of that. The configure test was more
general and similar to other packages (tcl, php).
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Bruce Momjian
Date:
Tom Lane wrote:
> Reini Urban <rurban@x-ray.at> writes:
> > Yes, they are talking about the localtime return value,
> > but nevertheless the newlib folks refer to that. Their fault.
>
> > Should I discuss that with them?
>
> Probably.  They have a gratuitous variation from the Single Unix Spec.
>
> >> But what may be more to the point is that AFAICS we make no assumption
> >> about the exact datatype of the timezone variable.
>
> > Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib
> > (src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c
>
> Per my recent post in pghackers, I think that the datatype has nothing
> to do with it anyway.  The real problem is the loss of this code that
> was in pg_config_manual.h in 7.4 and before:
>
> /*
>  * 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
>
> I'm inclined to just put it back, rather than adding a configure test
> that we never needed before.

OK, I backed out the int cast I had made for dt.h.  I agree time_t
should cast to int naturally.  I noticed that HAVE_INT_TIMEZONE is
already a configure test.  Is that test not working on Cygwin?  Seems it
is working on MinGW.  The test is this:

    # PGAC_VAR_INT_TIMEZONE
    # ---------------------
    # Check if the global variable `timezone' exists. If so, define
    # HAVE_INT_TIMEZONE.
    AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
    [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
    [AC_TRY_LINK([#include <time.h>
    int res;],
      [res = timezone / 60;],
      [pgac_cv_var_int_timezone=yes],
      [pgac_cv_var_int_timezone=no])])
    if test x"$pgac_cv_var_int_timezone" = xyes ; then
      AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
    variable 'int timezone'.])
    fi])# PGAC_VAR_INT_TIMEZONE

You can look in include/pg_config.h to see how it is defined.

--
  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: time_t timezone

From
Reini Urban
Date:
Bruce Momjian schrieb:
> Tom Lane wrote:
>>Reini Urban <rurban@x-ray.at> writes:
>>
>>>Yes, they are talking about the localtime return value,
>>>but nevertheless the newlib folks refer to that. Their fault.
>>
>>>Should I discuss that with them?
>>
>>Probably.  They have a gratuitous variation from the Single Unix Spec.
>>
>>>>But what may be more to the point is that AFAICS we make no assumption
>>>>about the exact datatype of the timezone variable.
>>
>>>Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib
>>>(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c
>>
>>Per my recent post in pghackers, I think that the datatype has nothing
>>to do with it anyway.  The real problem is the loss of this code that
>>was in pg_config_manual.h in 7.4 and before:
>>
>>/*
>> * 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
>>
>>I'm inclined to just put it back, rather than adding a configure test
>>that we never needed before.
>
> OK, I backed out the int cast I had made for dt.h.  I agree time_t
> should cast to int naturally.  I noticed that HAVE_INT_TIMEZONE is
> already a configure test.  Is that test not working on Cygwin?  Seems it
> is working on MinGW.  The test is this:
>
>     # PGAC_VAR_INT_TIMEZONE
>     # ---------------------
>     # Check if the global variable `timezone' exists. If so, define
>     # HAVE_INT_TIMEZONE.
>     AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
>     [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
>     [AC_TRY_LINK([#include <time.h>
>     int res;],
>       [res = timezone / 60;],
>       [pgac_cv_var_int_timezone=yes],
>       [pgac_cv_var_int_timezone=no])])
>     if test x"$pgac_cv_var_int_timezone" = xyes ; then
>       AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
>     variable 'int timezone'.])
>     fi])# PGAC_VAR_INT_TIMEZONE
>
> You can look in include/pg_config.h to see how it is defined.

This test fails, because you cannot do arithmetic with time_t.
cygwin has/had a special workaround in pg_config_manual.h
See Tom above.

All other platforms with time_t timezone should manually enable their
HAVE_INT_TIMEZONE and manually add the (int) timezone in
src/timezone/pgtz.c.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Tom Lane
Date:
Reini Urban <rurban@x-ray.at> writes:
> This test fails, because you cannot do arithmetic with time_t.

You apparently speak some different flavor of C than the rest of us.

            regards, tom lane

Re: time_t timezone

From
Bruce Momjian
Date:
Reini Urban wrote:
> >     # PGAC_VAR_INT_TIMEZONE
> >     # ---------------------
> >     # Check if the global variable `timezone' exists. If so, define
> >     # HAVE_INT_TIMEZONE.
> >     AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
> >     [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
> >     [AC_TRY_LINK([#include <time.h>
> >     int res;],
> >       [res = timezone / 60;],
> >       [pgac_cv_var_int_timezone=yes],
> >       [pgac_cv_var_int_timezone=no])])
> >     if test x"$pgac_cv_var_int_timezone" = xyes ; then
> >       AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
> >     variable 'int timezone'.])
> >     fi])# PGAC_VAR_INT_TIMEZONE
> >
> > You can look in include/pg_config.h to see how it is defined.
>
> This test fails, because you cannot do arithmetic with time_t.
> cygwin has/had a special workaround in pg_config_manual.h
> See Tom above.
>
> All other platforms with time_t timezone should manually enable their
> HAVE_INT_TIMEZONE and manually add the (int) timezone in
> src/timezone/pgtz.c.

OK, let's get some facts.  How is your timezone variable defined in your
headers?  Is it _timezone?  How is time_t defined?  If you take the
program above and compile it alone, how does it fail?

Also, look at your config.log output to see why it fails or email it to
my privately.

--
  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: time_t timezone

From
Reini Urban
Date:
Bruce Momjian schrieb:

> Reini Urban wrote:
>
>>>    # PGAC_VAR_INT_TIMEZONE
>>>    # ---------------------
>>>    # Check if the global variable `timezone' exists. If so, define
>>>    # HAVE_INT_TIMEZONE.
>>>    AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
>>>    [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
>>>    [AC_TRY_LINK([#include <time.h>
>>>    int res;],
>>>      [res = timezone / 60;],
>>>      [pgac_cv_var_int_timezone=yes],
>>>      [pgac_cv_var_int_timezone=no])])
>>>    if test x"$pgac_cv_var_int_timezone" = xyes ; then
>>>      AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
>>>    variable 'int timezone'.])
>>>    fi])# PGAC_VAR_INT_TIMEZONE
>>>
>>>You can look in include/pg_config.h to see how it is defined.
>>
>>This test fails, because you cannot do arithmetic with time_t.
>>cygwin has/had a special workaround in pg_config_manual.h
>>See Tom above.

sorry, my mistake. you can do arithmetic with time_t.

>>All other platforms with time_t timezone should manually enable their
>>HAVE_INT_TIMEZONE and manually add the (int) timezone in
>>src/timezone/pgtz.c.
>
> OK, let's get some facts.  How is your timezone variable defined in your
> headers?  Is it _timezone?  How is time_t defined?  If you take the
> program above and compile it alone, how does it fail?

yes, it's only _timezone.

already sent to this list. here it is:

/usr/include/time.h from newlib.
...
/* defines for the opengroup specifications Derived from Issue 1 of the
SVID.  */
extern __IMPORT time_t _timezone;
extern __IMPORT int _daylight;
extern __IMPORT char *_tzname[2];

which resolves to (gcc -E):
# 98 "/usr/include/time.h" 3 4
extern __attribute__((dllimport)) time_t _timezone;
extern __attribute__((dllimport)) int _daylight;
extern __attribute__((dllimport)) char *_tzname[2];

time_t is a typedef from sys/types.h:
#ifndef __time_t_defined
typedef _TIME_T_ time_t;
#define __time_t_defined

_TIME_T_ is a macro from machine/types.h:
define _TIME_T_        long

> Also, look at your config.log output to see why it fails or email it to
> my privately.
...
configure:12843: checking for int timezone
configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall
-Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing
-L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt
-lresolv -lm  >&5
conftest.c: In function `main':
conftest.c:67: error: invalid operands to binary /
configure:12871: $? = 1
configure: failed program was:
...

#include <time.h>
int res;
int
main ()
{
res = timezone / 60;
   ;
   return 0;
}

so my patch and my whole point is wrong.
just the underscore is needed for cygwin in pg_config_manual.h
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

Re: time_t timezone

From
Bruce Momjian
Date:
OK, I have applied the following patch to fix the Cygwin _timezone
issue.  I moved the TIMEZONE_GLOBAL up into port.h and change pgtz.c to
use that instead.  I also changed the configure test for INT_TIMEZONE to
test for _timezone on Cygwin.  This should fix all those problems.

You found a few problems in dirmod.c but have run out of time and will
deal with them in a few days.

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

Reini Urban wrote:
> Bruce Momjian schrieb:
>
> > Reini Urban wrote:
> >
> >>>    # PGAC_VAR_INT_TIMEZONE
> >>>    # ---------------------
> >>>    # Check if the global variable `timezone' exists. If so, define
> >>>    # HAVE_INT_TIMEZONE.
> >>>    AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
> >>>    [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
> >>>    [AC_TRY_LINK([#include <time.h>
> >>>    int res;],
> >>>      [res = timezone / 60;],
> >>>      [pgac_cv_var_int_timezone=yes],
> >>>      [pgac_cv_var_int_timezone=no])])
> >>>    if test x"$pgac_cv_var_int_timezone" = xyes ; then
> >>>      AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
> >>>    variable 'int timezone'.])
> >>>    fi])# PGAC_VAR_INT_TIMEZONE
> >>>
> >>>You can look in include/pg_config.h to see how it is defined.
> >>
> >>This test fails, because you cannot do arithmetic with time_t.
> >>cygwin has/had a special workaround in pg_config_manual.h
> >>See Tom above.
>
> sorry, my mistake. you can do arithmetic with time_t.
>
> >>All other platforms with time_t timezone should manually enable their
> >>HAVE_INT_TIMEZONE and manually add the (int) timezone in
> >>src/timezone/pgtz.c.
> >
> > OK, let's get some facts.  How is your timezone variable defined in your
> > headers?  Is it _timezone?  How is time_t defined?  If you take the
> > program above and compile it alone, how does it fail?
>
> yes, it's only _timezone.
>
> already sent to this list. here it is:
>
> /usr/include/time.h from newlib.
> ...
> /* defines for the opengroup specifications Derived from Issue 1 of the
> SVID.  */
> extern __IMPORT time_t _timezone;
> extern __IMPORT int _daylight;
> extern __IMPORT char *_tzname[2];
>
> which resolves to (gcc -E):
> # 98 "/usr/include/time.h" 3 4
> extern __attribute__((dllimport)) time_t _timezone;
> extern __attribute__((dllimport)) int _daylight;
> extern __attribute__((dllimport)) char *_tzname[2];
>
> time_t is a typedef from sys/types.h:
> #ifndef __time_t_defined
> typedef _TIME_T_ time_t;
> #define __time_t_defined
>
> _TIME_T_ is a macro from machine/types.h:
> define _TIME_T_        long
>
> > Also, look at your config.log output to see why it fails or email it to
> > my privately.
> ...
> configure:12843: checking for int timezone
> configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall
> -Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing
> -L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt
> -lresolv -lm  >&5
> conftest.c: In function `main':
> conftest.c:67: error: invalid operands to binary /
> configure:12871: $? = 1
> configure: failed program was:
> ...
>
> #include <time.h>
> int res;
> int
> main ()
> {
> res = timezone / 60;
>    ;
>    return 0;
> }
>
> so my patch and my whole point is wrong.
> just the underscore is needed for cygwin in pg_config_manual.h
> --
> Reini Urban
> http://xarch.tu-graz.ac.at/home/rurban/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

--
  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: configure
===================================================================
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.389
diff -c -c -r1.389 configure
*** configure    2 Sep 2004 20:39:57 -0000    1.389
--- configure    8 Sep 2004 19:36:18 -0000
***************
*** 10725,10731 ****
--- 10725,10735 ----
  int
  main ()
  {
+ #ifndef __CYGWIN__
  res = timezone / 60;
+ #else
+ res = _timezone / 60;
+ #endif
    ;
    return 0;
  }
Index: config/c-library.m4
===================================================================
RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
retrieving revision 1.26
diff -c -c -r1.26 c-library.m4
*** config/c-library.m4    7 Jun 2004 22:39:44 -0000    1.26
--- config/c-library.m4    8 Sep 2004 19:36:19 -0000
***************
*** 10,16 ****
  [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
  [AC_TRY_LINK([#include <time.h>
  int res;],
!   [res = timezone / 60;],
    [pgac_cv_var_int_timezone=yes],
    [pgac_cv_var_int_timezone=no])])
  if test x"$pgac_cv_var_int_timezone" = xyes ; then
--- 10,20 ----
  [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
  [AC_TRY_LINK([#include <time.h>
  int res;],
!   [#ifndef __CYGWIN__
! res = timezone / 60;
! #else
! res = _timezone / 60;
! #endif],
    [pgac_cv_var_int_timezone=yes],
    [pgac_cv_var_int_timezone=no])])
  if test x"$pgac_cv_var_int_timezone" = xyes ; then
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port.h,v
retrieving revision 1.57
diff -c -c -r1.57 port.h
*** src/include/port.h    29 Aug 2004 21:08:48 -0000    1.57
--- src/include/port.h    8 Sep 2004 19:36:26 -0000
***************
*** 180,185 ****
--- 180,193 ----
  #define pclose(a) _pclose(a)
  #endif

+ /* Global variable holding time zone information. */
+ #if !defined(__CYGWIN__)
+ #define TIMEZONE_GLOBAL timezone
+ #else
+ #define TIMEZONE_GLOBAL _timezone
+ #define tzname _tzname            /* should be in time.h? */
+ #endif
+
  extern int    copydir(char *fromdir, char *todir);

  /* Missing rand functions */
Index: src/interfaces/ecpg/pgtypeslib/dt.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt.h,v
retrieving revision 1.19
diff -c -c -r1.19 dt.h
*** src/interfaces/ecpg/pgtypeslib/dt.h    1 Sep 2004 18:59:35 -0000    1.19
--- src/interfaces/ecpg/pgtypeslib/dt.h    8 Sep 2004 19:36:28 -0000
***************
*** 216,229 ****
  } while(0)
  #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
-
  /*
   * Date/time validation
   * Include check for leap year.
--- 216,221 ----
Index: src/timezone/pgtz.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/timezone/pgtz.c,v
retrieving revision 1.27
diff -c -c -r1.27 pgtz.c
*** src/timezone/pgtz.c    2 Sep 2004 01:15:06 -0000    1.27
--- src/timezone/pgtz.c    8 Sep 2004 19:36:33 -0000
***************
*** 96,106 ****
  #if defined(HAVE_STRUCT_TM_TM_ZONE)
      return tm->tm_gmtoff;
  #elif defined(HAVE_INT_TIMEZONE)
! #ifdef HAVE_UNDERSCORE_TIMEZONE
!     return -_timezone;
! #else
!     return -timezone;
! #endif
  #else
  #error No way to determine TZ? Can this happen?
  #endif
--- 96,102 ----
  #if defined(HAVE_STRUCT_TM_TM_ZONE)
      return tm->tm_gmtoff;
  #elif defined(HAVE_INT_TIMEZONE)
!     return -TIMEZONE_GLOBAL;
  #else
  #error No way to determine TZ? Can this happen?
  #endif

Re: time_t timezone

From
Bruce Momjian
Date:
I have done the same cleanup for _tzname for clarity and because some
files were using tzname as local variable names (pgtz.c).

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

Bruce Momjian wrote:
>
> OK, I have applied the following patch to fix the Cygwin _timezone
> issue.  I moved the TIMEZONE_GLOBAL up into port.h and change pgtz.c to
> use that instead.  I also changed the configure test for INT_TIMEZONE to
> test for _timezone on Cygwin.  This should fix all those problems.
>
> You found a few problems in dirmod.c but have run out of time and will
> deal with them in a few days.
>
> ---------------------------------------------------------------------------
>
> Reini Urban wrote:
> > Bruce Momjian schrieb:
> >
> > > Reini Urban wrote:
> > >
> > >>>    # PGAC_VAR_INT_TIMEZONE
> > >>>    # ---------------------
> > >>>    # Check if the global variable `timezone' exists. If so, define
> > >>>    # HAVE_INT_TIMEZONE.
> > >>>    AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
> > >>>    [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
> > >>>    [AC_TRY_LINK([#include <time.h>
> > >>>    int res;],
> > >>>      [res = timezone / 60;],
> > >>>      [pgac_cv_var_int_timezone=yes],
> > >>>      [pgac_cv_var_int_timezone=no])])
> > >>>    if test x"$pgac_cv_var_int_timezone" = xyes ; then
> > >>>      AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
> > >>>    variable 'int timezone'.])
> > >>>    fi])# PGAC_VAR_INT_TIMEZONE
> > >>>
> > >>>You can look in include/pg_config.h to see how it is defined.
> > >>
> > >>This test fails, because you cannot do arithmetic with time_t.
> > >>cygwin has/had a special workaround in pg_config_manual.h
> > >>See Tom above.
> >
> > sorry, my mistake. you can do arithmetic with time_t.
> >
> > >>All other platforms with time_t timezone should manually enable their
> > >>HAVE_INT_TIMEZONE and manually add the (int) timezone in
> > >>src/timezone/pgtz.c.
> > >
> > > OK, let's get some facts.  How is your timezone variable defined in your
> > > headers?  Is it _timezone?  How is time_t defined?  If you take the
> > > program above and compile it alone, how does it fail?
> >
> > yes, it's only _timezone.
> >
> > already sent to this list. here it is:
> >
> > /usr/include/time.h from newlib.
> > ...
> > /* defines for the opengroup specifications Derived from Issue 1 of the
> > SVID.  */
> > extern __IMPORT time_t _timezone;
> > extern __IMPORT int _daylight;
> > extern __IMPORT char *_tzname[2];
> >
> > which resolves to (gcc -E):
> > # 98 "/usr/include/time.h" 3 4
> > extern __attribute__((dllimport)) time_t _timezone;
> > extern __attribute__((dllimport)) int _daylight;
> > extern __attribute__((dllimport)) char *_tzname[2];
> >
> > time_t is a typedef from sys/types.h:
> > #ifndef __time_t_defined
> > typedef _TIME_T_ time_t;
> > #define __time_t_defined
> >
> > _TIME_T_ is a macro from machine/types.h:
> > define _TIME_T_        long
> >
> > > Also, look at your config.log output to see why it fails or email it to
> > > my privately.
> > ...
> > configure:12843: checking for int timezone
> > configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall
> > -Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing
> > -L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt
> > -lresolv -lm  >&5
> > conftest.c: In function `main':
> > conftest.c:67: error: invalid operands to binary /
> > configure:12871: $? = 1
> > configure: failed program was:
> > ...
> >
> > #include <time.h>
> > int res;
> > int
> > main ()
> > {
> > res = timezone / 60;
> >    ;
> >    return 0;
> > }
> >
> > so my patch and my whole point is wrong.
> > just the underscore is needed for cygwin in pg_config_manual.h
> > --
> > Reini Urban
> > http://xarch.tu-graz.ac.at/home/rurban/
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 7: don't forget to increase your free space map settings
> >
>
> --
>   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: configure
> ===================================================================
> RCS file: /cvsroot/pgsql-server/configure,v
> retrieving revision 1.389
> diff -c -c -r1.389 configure
> *** configure    2 Sep 2004 20:39:57 -0000    1.389
> --- configure    8 Sep 2004 19:36:18 -0000
> ***************
> *** 10725,10731 ****
> --- 10725,10735 ----
>   int
>   main ()
>   {
> + #ifndef __CYGWIN__
>   res = timezone / 60;
> + #else
> + res = _timezone / 60;
> + #endif
>     ;
>     return 0;
>   }
> Index: config/c-library.m4
> ===================================================================
> RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
> retrieving revision 1.26
> diff -c -c -r1.26 c-library.m4
> *** config/c-library.m4    7 Jun 2004 22:39:44 -0000    1.26
> --- config/c-library.m4    8 Sep 2004 19:36:19 -0000
> ***************
> *** 10,16 ****
>   [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
>   [AC_TRY_LINK([#include <time.h>
>   int res;],
> !   [res = timezone / 60;],
>     [pgac_cv_var_int_timezone=yes],
>     [pgac_cv_var_int_timezone=no])])
>   if test x"$pgac_cv_var_int_timezone" = xyes ; then
> --- 10,20 ----
>   [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
>   [AC_TRY_LINK([#include <time.h>
>   int res;],
> !   [#ifndef __CYGWIN__
> ! res = timezone / 60;
> ! #else
> ! res = _timezone / 60;
> ! #endif],
>     [pgac_cv_var_int_timezone=yes],
>     [pgac_cv_var_int_timezone=no])])
>   if test x"$pgac_cv_var_int_timezone" = xyes ; then
> Index: src/include/port.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/include/port.h,v
> retrieving revision 1.57
> diff -c -c -r1.57 port.h
> *** src/include/port.h    29 Aug 2004 21:08:48 -0000    1.57
> --- src/include/port.h    8 Sep 2004 19:36:26 -0000
> ***************
> *** 180,185 ****
> --- 180,193 ----
>   #define pclose(a) _pclose(a)
>   #endif
>
> + /* Global variable holding time zone information. */
> + #if !defined(__CYGWIN__)
> + #define TIMEZONE_GLOBAL timezone
> + #else
> + #define TIMEZONE_GLOBAL _timezone
> + #define tzname _tzname            /* should be in time.h? */
> + #endif
> +
>   extern int    copydir(char *fromdir, char *todir);
>
>   /* Missing rand functions */
> Index: src/interfaces/ecpg/pgtypeslib/dt.h
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt.h,v
> retrieving revision 1.19
> diff -c -c -r1.19 dt.h
> *** src/interfaces/ecpg/pgtypeslib/dt.h    1 Sep 2004 18:59:35 -0000    1.19
> --- src/interfaces/ecpg/pgtypeslib/dt.h    8 Sep 2004 19:36:28 -0000
> ***************
> *** 216,229 ****
>   } while(0)
>   #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
> -
>   /*
>    * Date/time validation
>    * Include check for leap year.
> --- 216,221 ----
> Index: src/timezone/pgtz.c
> ===================================================================
> RCS file: /cvsroot/pgsql-server/src/timezone/pgtz.c,v
> retrieving revision 1.27
> diff -c -c -r1.27 pgtz.c
> *** src/timezone/pgtz.c    2 Sep 2004 01:15:06 -0000    1.27
> --- src/timezone/pgtz.c    8 Sep 2004 19:36:33 -0000
> ***************
> *** 96,106 ****
>   #if defined(HAVE_STRUCT_TM_TM_ZONE)
>       return tm->tm_gmtoff;
>   #elif defined(HAVE_INT_TIMEZONE)
> ! #ifdef HAVE_UNDERSCORE_TIMEZONE
> !     return -_timezone;
> ! #else
> !     return -timezone;
> ! #endif
>   #else
>   #error No way to determine TZ? Can this happen?
>   #endif
> --- 96,102 ----
>   #if defined(HAVE_STRUCT_TM_TM_ZONE)
>       return tm->tm_gmtoff;
>   #elif defined(HAVE_INT_TIMEZONE)
> !     return -TIMEZONE_GLOBAL;
>   #else
>   #error No way to determine TZ? Can this happen?
>   #endif

>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

--
  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/include/port.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port.h,v
retrieving revision 1.58
diff -c -c -r1.58 port.h
*** src/include/port.h    8 Sep 2004 19:43:07 -0000    1.58
--- src/include/port.h    9 Sep 2004 00:08:19 -0000
***************
*** 183,191 ****
  /* Global variable holding time zone information. */
  #if !defined(__CYGWIN__)
  #define TIMEZONE_GLOBAL timezone
  #else
  #define TIMEZONE_GLOBAL _timezone
! #define tzname _tzname            /* should be in time.h? */
  #endif

  extern int    copydir(char *fromdir, char *todir);
--- 183,192 ----
  /* Global variable holding time zone information. */
  #if !defined(__CYGWIN__)
  #define TIMEZONE_GLOBAL timezone
+ #define TZNAME_GLOBAL tzname
  #else
  #define TIMEZONE_GLOBAL _timezone
! #define TZNAME_GLOBAL _tzname
  #endif

  extern int    copydir(char *fromdir, char *todir);
Index: src/interfaces/ecpg/pgtypeslib/dt_common.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/dt_common.c,v
retrieving revision 1.18
diff -c -c -r1.18 dt_common.c
*** src/interfaces/ecpg/pgtypeslib/dt_common.c    30 Aug 2004 02:54:41 -0000    1.18
--- src/interfaces/ecpg/pgtypeslib/dt_common.c    9 Sep 2004 00:08:25 -0000
***************
*** 1065,1072 ****
               * case it contains an error message, which doesn't fit in the
               * buffer
               */
!             StrNCpy(*tzn, tzname[tm->tm_isdst], MAXTZLEN + 1);
!             if (strlen(tzname[tm->tm_isdst]) > MAXTZLEN)
                  tm->tm_isdst = -1;
          }
      }
--- 1065,1072 ----
               * case it contains an error message, which doesn't fit in the
               * buffer
               */
!             StrNCpy(*tzn, TZNAME_GLOBAL[tm->tm_isdst], MAXTZLEN + 1);
!             if (strlen(TZNAME_GLOBAL[tm->tm_isdst]) > MAXTZLEN)
                  tm->tm_isdst = -1;
          }
      }
Index: src/interfaces/ecpg/pgtypeslib/timestamp.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/ecpg/pgtypeslib/timestamp.c,v
retrieving revision 1.21
diff -c -c -r1.21 timestamp.c
*** src/interfaces/ecpg/pgtypeslib/timestamp.c    30 Aug 2004 02:54:41 -0000    1.21
--- src/interfaces/ecpg/pgtypeslib/timestamp.c    9 Sep 2004 00:08:27 -0000
***************
*** 223,229 ****
  #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

  #else                            /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */
--- 223,229 ----
  #elif defined(HAVE_INT_TIMEZONE)
              *tzp = ((tm->tm_isdst > 0) ? (TIMEZONE_GLOBAL - 3600) : TIMEZONE_GLOBAL);
              if (tzn != NULL)
!                 *tzn = TZNAME_GLOBAL[(tm->tm_isdst > 0)];
  #endif

  #else                            /* not (HAVE_TM_ZONE || HAVE_INT_TIMEZONE) */