From 27afe3a4abea797790659f7ce2302a6105f9d475 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 5 Mar 2014 12:45:49 +0000 Subject: [PATCH] * localtime.cc: Define TM_GMTOFF and TM_ZONE based on __TM_GMTOFF and __TM_ZONE being defined. Throughout, write to these struct tm members only if CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS is true. * libc/strptime.cc: Ditto. * include/cygwin/version.h (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS): Define. (CYGWIN_VERSION_API_MINOR): Bump to 272. --- winsup/cygwin/ChangeLog | 10 +++++++++ winsup/cygwin/include/cygwin/version.h | 6 +++++- winsup/cygwin/libc/strptime.cc | 19 ++++++++++++---- winsup/cygwin/localtime.cc | 30 ++++++++++++++++++-------- 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 74cfc9653..69d15d6fd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2014-03-05 Corinna Vinschen + + * localtime.cc: Define TM_GMTOFF and TM_ZONE based on __TM_GMTOFF and + __TM_ZONE being defined. Throughout, write to these struct tm members + only if CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS is true. + * libc/strptime.cc: Ditto. + * include/cygwin/version.h (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS): + Define. + (CYGWIN_VERSION_API_MINOR): Bump to 272. + 2014-03-04 Corinna Vinschen * exception.h (exception::handler_installed): Remove. diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 03e9b55bb..e77e7104a 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -104,6 +104,9 @@ details. */ #define CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL(u) \ (CYGWIN_VERSION_PER_PROCESS_API_VERSION_COMBINED (u) >= 227) +#define CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS \ + (CYGWIN_VERSION_USER_API_VERSION_COMBINED >= 272) + #define CYGWIN_VERSION_CYGWIN_CONV 181 /* API_MAJOR 0.0: Initial version. API_MINOR changes: @@ -442,12 +445,13 @@ details. */ 270: Redefine mtget.mt_resid field to contain current partition as well as number of partitions on tape. 271: Export posix_spawn, posix_spawnp, and helper functions. + 272: Export tm_gmtoff and tm_zone members. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 271 +#define CYGWIN_VERSION_API_MINOR 272 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc index eeaab831c..1f14818a2 100644 --- a/winsup/cygwin/libc/strptime.cc +++ b/winsup/cygwin/libc/strptime.cc @@ -48,6 +48,13 @@ __RCSID("$NetBSD: strptime.c,v 1.28 2008/04/28 20:23:01 martin Exp $"); #include #include "../locale/timelocal.h" +#ifdef __TM_GMTOFF +# define TM_GMTOFF __TM_GMTOFF +#endif +#ifdef __TM_ZONE +# define TM_ZONE __TM_ZONE +#endif + #ifdef __weak_alias __weak_alias(strptime,_strptime) #endif @@ -653,10 +660,12 @@ literal: if (strncmp((const char *)bp, gmt, 3) == 0) { tm->tm_isdst = 0; #ifdef TM_GMTOFF - tm->TM_GMTOFF = 0; + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tm->TM_GMTOFF = 0; #endif #ifdef TM_ZONE - tm->TM_ZONE = gmt; + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tm->TM_ZONE = gmt; #endif bp += 3; } else { @@ -668,10 +677,12 @@ literal: if (ep != NULL) { tm->tm_isdst = i; #ifdef TM_GMTOFF - tm->TM_GMTOFF = -(timezone); + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tm->TM_GMTOFF = -(timezone); #endif #ifdef TM_ZONE - tm->TM_ZONE = tzname[i]; + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tm->TM_ZONE = tzname[i]; #endif } bp = ep; diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc index a5307101e..29371703e 100644 --- a/winsup/cygwin/localtime.cc +++ b/winsup/cygwin/localtime.cc @@ -344,6 +344,13 @@ struct tzhead { #include "fcntl.h" +#ifdef __TM_GMTOFF +# define TM_GMTOFF __TM_GMTOFF +#endif +#ifdef __TM_ZONE +# define TM_ZONE __TM_ZONE +#endif + /* ** SunOS 4.1.1 headers lack O_BINARY. */ @@ -1740,7 +1747,8 @@ localsub(const timezone_t sp, const time_t * const timep, const long offset, if (sp == lclptr) tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind]; #ifdef TM_ZONE - tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind]; #endif /* defined TM_ZONE */ return result; } @@ -1793,13 +1801,16 @@ gmtsub(const timezone_t sp, const time_t *const timep, const long offset, ** "UTC+xxxx" or "UTC-xxxx" if offset is non-zero, ** but this is no time for a treasure hunt. */ - if (offset != 0) - tmp->TM_ZONE = wildabbr; - else { - if (gmtptr == NULL) - tmp->TM_ZONE = gmt; - else tmp->TM_ZONE = gmtptr->chars; - } + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + { + if (offset != 0) + tmp->TM_ZONE = wildabbr; + else { + if (gmtptr == NULL) + tmp->TM_ZONE = gmt; + else tmp->TM_ZONE = gmtptr->chars; + } + } #endif /* defined TM_ZONE */ return result; } @@ -1978,7 +1989,8 @@ timesub(const timezone_t sp, const time_t *const timep, const long offset, tmp->tm_mday = (int) (idays + 1); tmp->tm_isdst = 0; #ifdef TM_GMTOFF - tmp->TM_GMTOFF = offset; + if (CYGWIN_VERSION_CHECK_FOR_EXTRA_TM_MEMBERS) + tmp->TM_GMTOFF = offset; #endif /* defined TM_GMTOFF */ return tmp; }