X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2Fcbits%2Ftimezone.h;h=f84c241fff19b9c649feb58751ebded2c675e043;hb=787e7d83405af4644612284a00a61626c2c27864;hp=2bfe281522cfbd69d9040d9adbfeea8494b8ecd3;hpb=438596897ebbe25a07e1c82085cfbc5bdb00f09e;p=ghc-hetmet.git diff --git a/ghc/lib/std/cbits/timezone.h b/ghc/lib/std/cbits/timezone.h index 2bfe281..f84c241 100644 --- a/ghc/lib/std/cbits/timezone.h +++ b/ghc/lib/std/cbits/timezone.h @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: timezone.h,v 1.3 1998/12/02 13:28:01 simonm Exp $ + * $Id: timezone.h,v 1.10 2000/07/17 15:27:15 rrt Exp $ * * Time-zone support header */ @@ -26,6 +26,25 @@ */ # undef HAVE_TM_ZONE # define HAVE_TZNAME 1 + +/* Double sigh. The timezone variable is only available under Linux + * when we're compiling NON_POSIX_SOURCE (or _GNU_SOURCE or whatever), + * but to make that work we have to make sure NON_POSIX_SOURCE is + * defined before anything from /usr/include is included. To avoid + * infecting too much source with NON_POSIX_SOURCE, we frob it + * below... + */ +#undef HAVE_TIMEZONE + +/* The correct solution to this problem would appear to be to ditch + * the standard GNU configure tests for the time stuff, and hack up + * our own that test for POSIX-compliant time support first, then + * BSD-style time stuff. + */ +#endif + +#ifdef solaris2_TARGET_OS +#undef HAVE_TIMEZONE #endif #if TIME_WITH_SYS_TIME @@ -44,11 +63,14 @@ #define SETZONE(x,z) (((struct tm *)x)->tm_zone = z) #define GMTOFF(x) (((struct tm *)x)->tm_gmtoff) #else /* ! HAVE_TM_ZONE */ -# if HAVE_TZNAME || cygwin32_TARGET_OS -#if cygwin32_TARGET_OS -#define tzname _tzname -#endif +# if HAVE_TZNAME || _WIN32 +# if cygwin32_TARGET_OS +# define tzname _tzname +# endif +# ifndef mingw32_TARGET_OS extern char *tzname[2]; +# endif + # define ZONE(x) (((struct tm *)x)->tm_isdst ? tzname[1] : tzname[0]) # define SETZONE(x,z) # else /* ! HAVE_TZNAME */ @@ -57,14 +79,20 @@ extern char *tzname[2]; # endif /* ! HAVE_TZNAME */ /* Get the offset in secs from UTC, if (struct tm) doesn't supply it. */ +#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) +#define timezone _timezone +#endif + +#if !defined(HAVE_TIMEZONE) && !defined(mingw32_TARGET_OS) extern TYPE_TIMEZONE timezone; +#endif # if HAVE_ALTZONE extern time_t altzone; -# define GMTOFF(x) (((struct tm *)x)->tm_isdst ? altzone : timezone) +# define GMTOFF(x) (((struct tm *)x)->tm_isdst ? altzone : timezone ) # else /* ! HAVE_ALTZONE */ /* Assume that DST offset is 1 hour ... */ -# define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone) +# define GMTOFF(x) (((struct tm *)x)->tm_isdst ? (timezone - 3600) : timezone ) # endif /* ! HAVE_ALTZONE */ #endif /* ! HAVE_TM_ZONE */