diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-31 17:44:55 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-10-31 17:44:55 +0000 |
commit | d68c9dadbe2c8fda2039b574af7201427c09a77e (patch) | |
tree | 203369273dd14a7ee74aea51ee6f81faf1d82050 /gcc/ada/sysdep.c | |
parent | e26ebbeea9b05be79828e144c7db6445fc6378bc (diff) | |
download | gcc-d68c9dadbe2c8fda2039b574af7201427c09a77e.tar.gz |
2006-10-31 Hristian Kirtchev <kirtchev@adacore.com>
Jose Ruiz <ruiz@adacore.com>
* a-calend-vms.adb (Leap_Sec_Ops): Temp body for package in private
part of Ada.Calendar: all subprogram raise Unimplemented.
(Split_W_Offset): Temp function body, raising Unimplemented
* a-calend.ads, a-calend-vms.ads:
Add imported variable Invalid_TZ_Offset used to designate targets unable
to support time zones.
(Unimplemented): Temporary function raised by the body of new
subprograms below.
(Leap_Sec_Ops): New package in the private part of Ada.Calendar. This
unit provides handling of leap seconds and is used by the new Ada 2005
packages Ada.Calendar.Arithmetic and Ada.Calendar.Formatting.
(Split_W_Offset): Identical spec to that of Ada.Calendar.Split. This
version returns an extra value which is the offset to UTC.
* a-calend.adb (Split_W_Offset): Add call to localtime_tzoff.
(Leap_Sec_Ops): New body for package in private part of Ada.Calendar.
(Split_W_Offset): New function body.
(Time_Of): When a date is close to UNIX epoch, compute the time for
that date plus one day (that amount is later substracted after
executing mktime) so there are no problems with time zone adjustments.
* a-calend-mingw.adb: Remove Windows specific version no longer needed.
* a-calari.ads, a-calari.adb, a-calfor.ads, a-calfor.adb,
a-catizo.ads, a-catizo.adb: New files.
* impunit.adb: Add new Ada 2005 entries
* sysdep.c: Add external variable __gnat_invalid_tz_offset.
Rename all occurences of "__gnat_localtime_r" to
"__gnat_localtime_tzoff".
(__gnat_localtime_tzoff for Windows): Add logic to retrieve the time
zone data and calculate the GMT offset.
(__gnat_localtime_tzoff for Darwin, Free BSD, Linux, Lynx and Tru64):
Use the field "tm_gmtoff" to extract the GMT offset.
(__gnat_localtime_tzoff for AIX, HPUX, SGI Irix and Sun Solaris): Use
the external variable "timezone" to calculate the GMT offset.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118234 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sysdep.c')
-rw-r--r-- | gcc/ada/sysdep.c | 83 |
1 files changed, 69 insertions, 14 deletions
diff --git a/gcc/ada/sysdep.c b/gcc/ada/sysdep.c index 055c99f1ad8..0562766a9e5 100644 --- a/gcc/ada/sysdep.c +++ b/gcc/ada/sysdep.c @@ -44,7 +44,6 @@ #include "tsystem.h" #include <fcntl.h> #include <sys/stat.h> -#include <time.h> #ifdef VMS #include <unixio.h> #endif @@ -53,6 +52,14 @@ #include "system.h" #endif +#include <time.h> + +#if defined (sun) && defined (__SVR4) && !defined (__vxworks) +/* The declaration is present in <time.h> but conditionalized + on a couple of macros we don't define. */ +extern struct tm *localtime_r(const time_t *, struct tm *); +#endif + #include "adaint.h" /* @@ -664,8 +671,6 @@ rts_get_nShowCmd (void) /* This gets around a problem with using the old threads library on VMS 7.0. */ -#include <time.h> - extern long get_gmtoff (void); long @@ -680,27 +685,57 @@ get_gmtoff (void) } #endif +/* This value is returned as the time zone offset when a valid value + cannot be determined. It is simply a bizarre value that will never + occur. It is 3 days plus 73 seconds (offset is in seconds. */ + +long __gnat_invalid_tzoff = 259273; + /* Definition of __gnat_locatime_r used by a-calend.adb */ -#if defined (__EMX__) +#if defined (__EMX__) || defined (__MINGW32__) + +#ifdef CERT + +/* For the Cert run times on native Windows we use dummy functions + for locking and unlocking tasks since we do not support multiple + threads on this configuration (Cert run time on native Windows). */ + +void dummy (void) {} + +void (*Lock_Task) () = &dummy; +void (*Unlock_Task) () = &dummy; + +#else + #define Lock_Task system__soft_links__lock_task extern void (*Lock_Task) (void); #define Unlock_Task system__soft_links__unlock_task extern void (*Unlock_Task) (void); -/* Provide reentrant version of localtime on OS/2. */ +#endif + +/* Reentrant localtime for Windows and OS/2. */ -extern struct tm *__gnat_localtime_r (const time_t *, struct tm *); +extern struct tm * +__gnat_localtime_tzoff (const time_t *, struct tm *, long *); struct tm * -__gnat_localtime_r (const time_t *timer, struct tm *tp) +__gnat_localtime_tzoff (const time_t *timer, struct tm *tp, long *off) { + DWORD dwRet; struct tm *tmp; + TIME_ZONE_INFORMATION tzi; (*Lock_Task) (); tmp = localtime (timer); memcpy (tp, tmp, sizeof (struct tm)); + dwRet = GetTimeZoneInformation (&tzi); + *off = tzi.Bias; + if (tp->tm_isdst > 0) + *off = *off + tzi.DaylightBias; + *off = *off * -60; (*Unlock_Task) (); return tp; } @@ -714,31 +749,51 @@ __gnat_localtime_r (const time_t *timer, struct tm *tp) spec is required. Only use when ___THREADS_POSIX4ad4__ is defined, the Lynx convention when building against the legacy API. */ -extern struct tm *__gnat_localtime_r (const time_t *, struct tm *); +extern struct tm * +__gnat_localtime_tzoff (const time_t *, struct tm *, long *); struct tm * -__gnat_localtime_r (const time_t *timer, struct tm *tp) +__gnat_localtime_tzoff (const time_t *timer, struct tm *tp, long *off) { localtime_r (tp, timer); + *off = __gnat_invalid_tzoff; return NULL; } #else -#if defined (VMS) || defined (__MINGW32__) +#if defined (VMS) -/* __gnat_localtime_r is not needed on NT and VMS */ +/* __gnat_localtime_tzoff is not needed on VMS */ #else /* All other targets provide a standard localtime_r */ -extern struct tm *__gnat_localtime_r (const time_t *, struct tm *); +extern struct tm * +__gnat_localtime_tzoff (const time_t *, struct tm *, long *); struct tm * -__gnat_localtime_r (const time_t *timer, struct tm *tp) +__gnat_localtime_tzoff (const time_t *timer, struct tm *tp, long *off) { - return (struct tm *) localtime_r (timer, tp); + localtime_r (timer, tp); + +/* AIX, HPUX, SGI Irix, Sun Solaris */ +#if defined (_AIX) || defined (__hpux__) || defined (sgi) || defined (sun) + *off = (long) -timezone; + if (tp->tm_isdst > 0) + *off = *off + 3600; + +/* Lynx, VXWorks */ +#elif defined (__Lynx__) || defined (__vxworks) + *off = __gnat_invalid_tzoff; + +/* Darwin, Free BSD, Linux, Tru64 */ +#else + *off = tp->tm_gmtoff; +#endif + return NULL; } + #endif #endif #endif |