[multiple changes]

2009-07-15  Robert Dewar  <dewar@adacore.com>

	* sem_ch10.adb: Minor reformatting throughout
	Minor code reorganization (put nested subprograms in alpha order)

2009-07-15  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch6.adb (Expand_Call): Prevent double attachment of the result
	when compiling a call to a protected function that returns a controlled
	object.

2009-07-15  Hristian Kirtchev  <kirtchev@adacore.com>

	* sysdep.c (__gnat_localtime_tzoff): Consolidate the Lynx cases into
	one. Add task locking and unlocking around the critical region which
	mentions localtime_r and global variable timezone for various targets.
	Comment reformatting.

From-SVN: r149686
This commit is contained in:
Arnaud Charlet 2009-07-15 14:57:06 +02:00
parent 3eb532e6aa
commit 6eab5a9575
4 changed files with 420 additions and 381 deletions

View File

@ -1,3 +1,21 @@
2009-07-15 Robert Dewar <dewar@adacore.com>
* sem_ch10.adb: Minor reformatting throughout
Minor code reorganization (put nested subprograms in alpha order)
2009-07-15 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb (Expand_Call): Prevent double attachment of the result
when compiling a call to a protected function that returns a controlled
object.
2009-07-15 Hristian Kirtchev <kirtchev@adacore.com>
* sysdep.c (__gnat_localtime_tzoff): Consolidate the Lynx cases into
one. Add task locking and unlocking around the critical region which
mentions localtime_r and global variable timezone for various targets.
Comment reformatting.
2009-07-15 Robert Dewar <dewar@adacore.com> 2009-07-15 Robert Dewar <dewar@adacore.com>
* gnat_rm.texi: Document s-ststop.ads * gnat_rm.texi: Document s-ststop.ads

View File

@ -3097,10 +3097,17 @@ package body Exp_Ch6 is
-- Functions returning controlled objects need special attention: -- Functions returning controlled objects need special attention:
-- if the return type is limited, the context is an initialization -- if the return type is limited, the context is an initialization
-- and different processing applies. -- and different processing applies. If the call is to a protected
-- function, the expansion above will call Expand_Call recusively.
-- To prevent a double attachment, check that the current call is
-- not a rewriting of a protected function call.
if Needs_Finalization (Etype (Subp)) if Needs_Finalization (Etype (Subp))
and then not Is_Inherently_Limited_Type (Etype (Subp)) and then not Is_Inherently_Limited_Type (Etype (Subp))
and then
(No (First_Formal (Subp))
or else
not Is_Concurrent_Record_Type (Etype (First_Formal (Subp))))
then then
Expand_Ctrl_Function_Call (N); Expand_Ctrl_Function_Call (N);
end if; end if;

File diff suppressed because it is too large Load Diff

View File

@ -814,7 +814,10 @@ __gnat_localtime_tzoff (const time_t *timer, long *off)
} }
#else #else
#if defined (__Lynx__) && defined (___THREADS_POSIX4ad4__)
/* On Lynx, all time values are treated in GMT */
#if defined (__Lynx__)
/* As of LynxOS 3.1.0a patch level 040, LynuxWorks changes the /* As of LynxOS 3.1.0a patch level 040, LynuxWorks changes the
prototype to the C library function localtime_r from the POSIX.4 prototype to the C library function localtime_r from the POSIX.4
@ -828,18 +831,24 @@ __gnat_localtime_tzoff (const time_t *, long *);
void void
__gnat_localtime_tzoff (const time_t *timer, long *off) __gnat_localtime_tzoff (const time_t *timer, long *off)
{ {
/* Treat all time values in GMT */
*off = 0; *off = 0;
} }
#else #else
/* VMS does not need __gnat_locatime_tzoff */
#if defined (VMS) #if defined (VMS)
/* __gnat_localtime_tzoff is not needed on VMS */ /* Other targets except Lynx, VMS and Windows provide a standard locatime_r */
#else #else
/* All other targets provide a standard localtime_r */ #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);
extern void extern void
__gnat_localtime_tzoff (const time_t *, long *); __gnat_localtime_tzoff (const time_t *, long *);
@ -847,25 +856,33 @@ __gnat_localtime_tzoff (const time_t *, long *);
void void
__gnat_localtime_tzoff (const time_t *timer, long *off) __gnat_localtime_tzoff (const time_t *timer, long *off)
{ {
struct tm tp; struct tm tp;
localtime_r (timer, &tp);
/* AIX, HPUX, SGI Irix, Sun Solaris */ /* AIX, HPUX, SGI Irix, Sun Solaris */
#if defined (_AIX) || defined (__hpux__) || defined (sgi) || defined (sun) #if defined (_AIX) || defined (__hpux__) || defined (sgi) || defined (sun)
*off = (long) -timezone; {
if (tp.tm_isdst > 0) (*Lock_Task) ();
*off = *off + 3600;
/* Lynx - Treat all time values in GMT */ localtime_r (timer, &tp);
#elif defined (__Lynx__) *off = (long) -timezone;
*off = 0;
(*Unlock_Task) ();
if (tp.tm_isdst > 0)
*off = *off + 3600;
}
/* VxWorks */ /* VxWorks */
#elif defined (__vxworks) #elif defined (__vxworks)
#include <stdlib.h> #include <stdlib.h>
{ {
(*Lock_Task) ();
localtime_r (timer, &tp);
/* Try to read the environment variable TIMEZONE. The variable may not have /* Try to read the environment variable TIMEZONE. The variable may not have
been initialize, in that case return an offset of zero (0) for UTC. */ been initialize, in that case return an offset of zero (0) for UTC. */
char *tz_str = getenv ("TIMEZONE"); char *tz_str = getenv ("TIMEZONE");
if ((tz_str == NULL) || (*tz_str == '\0')) if ((tz_str == NULL) || (*tz_str == '\0'))
@ -880,24 +897,34 @@ __gnat_localtime_tzoff (const time_t *timer, long *off)
the value of U involves setting two pointers, one at the beginning and the value of U involves setting two pointers, one at the beginning and
one at the end of the value. The end pointer is then set to null in one at the end of the value. The end pointer is then set to null in
order to delimit a string slice for atol to process. */ order to delimit a string slice for atol to process. */
tz_start = index (tz_str, ':') + 2; tz_start = index (tz_str, ':') + 2;
tz_end = index (tz_start, ':'); tz_end = index (tz_start, ':');
tz_end = '\0'; tz_end = '\0';
/* The Ada layer expects an offset in seconds */ /* The Ada layer expects an offset in seconds */
*off = atol (tz_start) * 60; *off = atol (tz_start) * 60;
} }
(*Unlock_Task) ();
} }
/* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in /* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in
struct tm */ struct tm */
#elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\ #elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\
(defined (__alpha__) && defined (__osf__)) || defined (__GLIBC__) (defined (__alpha__) && defined (__osf__)) || defined (__GLIBC__)
{
localtime_r (timer, &tp);
*off = tp.tm_gmtoff; *off = tp.tm_gmtoff;
}
/* Default: treat all time values in GMT */
/* All other platforms: Treat all time values in GMT */
#else #else
*off = 0; *off = 0;
#endif #endif
} }