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
  [EMAIL PROTECTED]               |  (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

Reply via email to