HAVE_TIMEZONE and cygwin

Billinghurst, David (CRTS) David.Billinghurst@riotinto.com
Wed May 1 22:29:00 GMT 2002


Here is an untested patch for configure.in (trunk).  I have autoconf version
problems, so this will have to do at present.  The code fragments do the right 
thing.

Compiling this fails
#include <time.h>
void i(){long z2 = 2*timezone;}

but this is OK
#include <time.h>
long z2 = _timezone;

2002-05-02  David Billinghurst <David.Billinghurst@riotinto.com>

	* configure.in: Adjust test for HAVE_TIMEZONE so it fails
	on cygwin.  Add test HAVE_UNDERSCORE_TIMEZONE.

Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.129
diff -u -r1.129 configure.in
--- configure.in        21 Apr 2002 09:37:48 -0000      1.129
+++ configure.in        2 May 2002 05:19:36 -0000
@@ -852,10 +852,17 @@
    dnl FIXME: we don't want a link check here because that won't work
    dnl when cross-compiling.  So instead we make an assumption that
    dnl the header file will mention timezone if it exists.
-   AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
+   dnl Don't find the win32 function timezone
+   AC_TRY_COMPILE([#include <time.h>], [void i(){long z2 = 2*timezone;}],
      [AC_DEFINE(HAVE_TIMEZONE)
       AC_MSG_RESULT(yes)],
-     [AC_MSG_RESULT(no)])])
+     [AC_MSG_RESULT(no)
+       AC_MSG_CHECKING([for global _timezone variable])
+       dnl FIXME: As above, don't want link check
+       AC_TRY_COMPILE([#include <time.h>], [long z2 = _timezone;],
+         [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE)
+          AC_MSG_RESULT(yes)],
+          [AC_MSG_RESULT(no)])])])

 AC_FUNC_ALLOCA

-----Original Message-----
From: Billinghurst, David (CRTS) 
Sent: Thursday, 2 May 2002 2:18 
To: java@gcc.gnu.org
Subject: HAVE_TIMEZONE and cygwin


The cygwin patch for natSystem.cc
(http://gcc.gnu.org/ml/java-patches/2002-q2/msg00252.html) 
probably should read something like

#elif HAVE_UNDERSCORE_TIMEZONE
   tzoffset = _timezone;
#elif HAVE_TIMEZONE
   // timezone is secs WEST of UTC.
   tzoffset = timezone;	
#else
   // FIXME: there must be another global if neither
tm_gmtoff nor timezone
   // is available, esp. if tzname is valid.


To do this we need to add to libjava/configure.in 
a test something like

   AC_TRY_COMPILE([#include <time.h>], [long z2 = _timezone;],
     [AC_DEFINE(HAVE_UNDERSCORE_TIMEZONE)
      AC_MSG_RESULT(yes)],
     [AC_MSG_RESULT(no)])])

and preferably get the existing test    

   AC_TRY_COMPILE([#include <time.h>], [long z2 = timezone;],
     [AC_DEFINE(HAVE_TIMEZONE)
      AC_MSG_RESULT(yes)],
     [AC_MSG_RESULT(no)])])

to fail for the cygwin <time.h> which has
  char *_EXFUN(timezone, (void));



More information about the Java mailing list