aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sysdep.c
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-23 08:51:38 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-01-23 08:51:38 +0000
commitf65e883c18c6dd5c84ab21ddff0ca25253b91290 (patch)
treeca1029610d8618cd4042b4926c54ebe6c3185af8 /gcc/ada/sysdep.c
parent6d852e2b4b1c3e5096e8da093ec5a01267071047 (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183413 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sysdep.c')
-rw-r--r--gcc/ada/sysdep.c131
1 files changed, 77 insertions, 54 deletions
diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c
index fbb4a00809a..bfe7bce3278 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;