diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-01-23 09:51:38 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2012-01-23 09:51:38 +0100 |
commit | 3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085 (patch) | |
tree | ca1029610d8618cd4042b4926c54ebe6c3185af8 /gcc/ada/sysdep.c | |
parent | ce20f35b8f111d13784ac796abbf7dcc7720e9ae (diff) | |
download | gcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.zip gcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.tar.gz gcc-3ffd18f16ccb5256aaf5d8e6a55fc8ad2d521085.tar.bz2 |
[multiple changes]
2012-01-23 Robert Dewar <dewar@adacore.com>
* sprint.ads, sprint.adb (Sprint_Node_List): Add New_Lines parameter
(pg,po,ps): Make sure each entry starts on new line.
2012-01-23 Hristian Kirtchev <kirtchev@adacore.com>
* a-calend.ads, a-calend.adb: Define types int and int_Pointer. Update
the parameter profile of procedure localtime_tzoff and its associated
comment.
(Day_Of_Week): Do not treat the input date as historical
with respect to time zones.
(Split): Do not treat the input
date as historical with respect to time zones. (Time_Of): Do
not treat the input constituents as forming a historical date
with respect to time zones.
(UTC_Time_Offset): Add new formal
parameter Is_Historic. Add local variable Flag. Update the call
to localtime_tzoff.
* a-catizo.ads, a-catizo.adb (UTC_Time_Offset): New routine.
(UTC_Time_Offset (Time)): Update the call to
Time_Zone_Operations.UTC_Time_Offset.
* sysdep.c (__gnat_localtime_tzoff): Update parameter
profile. Split the processing of offsets on Windows into two - one
part of historic time stamps and the other for the current time.
From-SVN: r183413
Diffstat (limited to 'gcc/ada/sysdep.c')
-rw-r--r-- | gcc/ada/sysdep.c | 131 |
1 files changed, 77 insertions, 54 deletions
diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index fbb4a00..bfe7bce 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -6,7 +6,7 @@ * * * C Implementation File * * * - * Copyright (C) 1992-2011, Free Software Foundation, Inc. * + * Copyright (C) 1992-2012, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -644,71 +644,94 @@ extern void (*Unlock_Task) (void); /* Reentrant localtime for Windows. */ extern void -__gnat_localtime_tzoff (const time_t *, long *); +__gnat_localtime_tzoff (const time_t *, const int *, long *); static const unsigned long long w32_epoch_offset = 11644473600ULL; void -__gnat_localtime_tzoff (const time_t *timer, long *off) +__gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off) { - union - { - FILETIME ft_time; - unsigned long long ull_time; - } utc_time, local_time; - - SYSTEMTIME utc_sys_time, local_sys_time; TIME_ZONE_INFORMATION tzi; - BOOL status = 1; + BOOL rtx_active; DWORD tzi_status; - (*Lock_Task) (); - #ifdef RTX + rtx_active = 1; +#else + rtx_active = 0; +#endif + + (*Lock_Task) (); tzi_status = GetTimeZoneInformation (&tzi); - *off = tzi.Bias; - if (tzi_status == TIME_ZONE_ID_STANDARD) - /* The system is operating in the range covered by the StandardDate - member. */ - *off = *off + tzi.StandardBias; - else if (tzi_status == TIME_ZONE_ID_DAYLIGHT) - /* The system is operating in the range covered by the DaylightDate - member. */ - *off = *off + tzi.DaylightBias; - *off = *off * -60; -#else + /* Processing for RTX targets or cases where we simply want to extract the + offset of the current time zone, regardless of the date. */ - /* First convert unix time_t structure to windows FILETIME format. */ - utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset) - * 10000000ULL; + if (rtx_active || !is_historic) { + *off = tzi.Bias; - tzi_status = GetTimeZoneInformation (&tzi); + /* The system is operating in the range covered by the StandardDate + member. */ + if (tzi_status == TIME_ZONE_ID_STANDARD) { + *off = *off + tzi.StandardBias; + } - /* If GetTimeZoneInformation does not return a value between 0 and 2 then - it means that we were not able to retrieve timezone informations. - Note that we cannot use here FileTimeToLocalFileTime as Windows will use - in always in this case the current timezone setting. As suggested on - MSDN we use the following three system calls to get the right information. - Note also that starting with Windows Vista new functions are provided to - get timezone settings that depend on the year. We cannot use them as we - still support Windows XP and Windows 2003. */ - status = (tzi_status >= 0 && tzi_status <= 2) - && FileTimeToSystemTime (&utc_time.ft_time, &utc_sys_time) - && SystemTimeToTzSpecificLocalTime (&tzi, &utc_sys_time, &local_sys_time) - && SystemTimeToFileTime (&local_sys_time, &local_time.ft_time); - - if (!status) - /* An error occurs so return invalid_tzoff. */ - *off = __gnat_invalid_tzoff; - else - if (local_time.ull_time > utc_time.ull_time) - *off = (long) ((local_time.ull_time - utc_time.ull_time) / 10000000ULL); - else - *off = - (long) ((utc_time.ull_time - local_time.ull_time) / 10000000ULL); + /* The system is operating in the range covered by the DaylightDate + member. */ + else if (tzi_status == TIME_ZONE_ID_DAYLIGHT) { + *off = *off + tzi.DaylightBias; + } -#endif + *off = *off * -60; + } + + /* Time zone offset calculations for a historic or future date */ + + else { + union + { + FILETIME ft_time; + unsigned long long ull_time; + } utc_time, local_time; + + SYSTEMTIME utc_sys_time, local_sys_time; + BOOL status; + + /* First convert unix time_t structure to windows FILETIME format. */ + utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset) + * 10000000ULL; + + /* If GetTimeZoneInformation does not return a value between 0 and 2 then + it means that we were not able to retrieve timezone informations. Note + that we cannot use here FileTimeToLocalFileTime as Windows will use in + always in this case the current timezone setting. As suggested on MSDN + we use the following three system calls to get the right information. + Note also that starting with Windows Vista new functions are provided + to get timezone settings that depend on the year. We cannot use them as + we still support Windows XP and Windows 2003. */ + + status = (tzi_status >= 0 && tzi_status <= 2) + && FileTimeToSystemTime (&utc_time.ft_time, &utc_sys_time) + && SystemTimeToTzSpecificLocalTime (&tzi, &utc_sys_time, &local_sys_time) + && SystemTimeToFileTime (&local_sys_time, &local_time.ft_time); + + /* An error has occured, return invalid_tzoff */ + + if (!status) { + *off = __gnat_invalid_tzoff; + } + else { + if (local_time.ull_time > utc_time.ull_time) { + *off = (long) ((local_time.ull_time - utc_time.ull_time) + / 10000000ULL); + } + else { + *off = - (long) ((utc_time.ull_time - local_time.ull_time) + / 10000000ULL); + } + } + } (*Unlock_Task) (); } @@ -726,10 +749,10 @@ __gnat_localtime_tzoff (const time_t *timer, long *off) the Lynx convention when building against the legacy API. */ extern void -__gnat_localtime_tzoff (const time_t *, long *); +__gnat_localtime_tzoff (const time_t *, const int *, long *); void -__gnat_localtime_tzoff (const time_t *timer, long *off) +__gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off) { *off = 0; } @@ -751,10 +774,10 @@ extern void (*Lock_Task) (void); extern void (*Unlock_Task) (void); extern void -__gnat_localtime_tzoff (const time_t *, long *); +__gnat_localtime_tzoff (const time_t *, const int *, long *); void -__gnat_localtime_tzoff (const time_t *timer, long *off) +__gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off) { struct tm tp; |