[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>
* 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:
-- 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))
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
Expand_Ctrl_Function_Call (N);
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
#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
prototype to the C library function localtime_r from the POSIX.4
@ -828,18 +831,24 @@ __gnat_localtime_tzoff (const time_t *, long *);
void
__gnat_localtime_tzoff (const time_t *timer, long *off)
{
/* Treat all time values in GMT */
*off = 0;
}
#else
/* VMS does not need __gnat_locatime_tzoff */
#if defined (VMS)
/* __gnat_localtime_tzoff is not needed on VMS */
/* Other targets except Lynx, VMS and Windows provide a standard locatime_r */
#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
__gnat_localtime_tzoff (const time_t *, long *);
@ -847,25 +856,33 @@ __gnat_localtime_tzoff (const time_t *, long *);
void
__gnat_localtime_tzoff (const time_t *timer, long *off)
{
struct tm tp;
localtime_r (timer, &tp);
struct tm 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;
{
(*Lock_Task) ();
/* Lynx - Treat all time values in GMT */
#elif defined (__Lynx__)
*off = 0;
localtime_r (timer, &tp);
*off = (long) -timezone;
(*Unlock_Task) ();
if (tp.tm_isdst > 0)
*off = *off + 3600;
}
/* VxWorks */
#elif defined (__vxworks)
#include <stdlib.h>
{
(*Lock_Task) ();
localtime_r (timer, &tp);
/* 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. */
char *tz_str = getenv ("TIMEZONE");
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
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. */
tz_start = index (tz_str, ':') + 2;
tz_end = index (tz_start, ':');
tz_end = '\0';
/* The Ada layer expects an offset in seconds */
*off = atol (tz_start) * 60;
}
(*Unlock_Task) ();
}
/* Darwin, Free BSD, Linux, Tru64, where component tm_gmtoff is present in
struct tm */
#elif defined (__APPLE__) || defined (__FreeBSD__) || defined (linux) ||\
(defined (__alpha__) && defined (__osf__)) || defined (__GLIBC__)
{
localtime_r (timer, &tp);
*off = tp.tm_gmtoff;
}
/* Default: treat all time values in GMT */
/* All other platforms: Treat all time values in GMT */
#else
*off = 0;
#endif
}