From ad0d71b531e7d06b96e1b3675ba99845f43f766d Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Sun, 13 Oct 2013 18:21:32 +0200 Subject: [PATCH] [multiple changes] 2013-10-13 Thomas Quinot * scos.ads: Minor documentation clarification. 2013-10-13 Thomas Quinot * s-oscons-tmplt.c (CLOCK_RT_Ada): Set to CLOCK_MONOTONIC when building on AIX 5.3 or later, and to CLOCK_REALTIME on older versions of AIX. * init.c (pthread_condattr_setclock): Remove now useless weak symbol. * thread.c(__gnat_pthread_condattr_setup): Remove bogus AIX 5.2 compatibility shim. * s-osinte-aix.ads(clock_id_t): Fix C mapping (this is a 64-bit type). (clock_gettime): Import from C runtime library. * s-osinte-aix.adb (clock_gettime): Remove bogus emulation body, this routine is provided by the system in current supported versions of AIX. 2013-10-13 Robert Dewar * sem_ch3.adb: Minor reformatting. 2013-10-13 Ed Schonberg * freeze.adb (Freeze_Entity): For a function whose return type is incomplete, do not replace the type with the full view if the type is a limited view. In that case the full view appears in a different unit, and the back-end will retrieve it at the proper elaboration point. 2013-10-13 Yannick Moy * exp_spark.adb (Expand_SPARK_Call): Do not introduce temporaries for actuals. From-SVN: r203503 --- gcc/ada/ChangeLog | 36 ++++++++++++++++++++++++++++++++ gcc/ada/exp_spark.adb | 16 ++------------- gcc/ada/freeze.adb | 8 +++++++- gcc/ada/init.c | 13 ------------ gcc/ada/s-oscons-tmplt.c | 12 +++++++---- gcc/ada/s-osinte-aix.adb | 44 +--------------------------------------- gcc/ada/s-osinte-aix.ads | 7 +++++-- gcc/ada/scos.ads | 13 ++++++------ gcc/ada/sem_ch3.adb | 2 +- gcc/ada/thread.c | 19 ----------------- 10 files changed, 67 insertions(+), 103 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index b8483d48e00..6afa9022280 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,39 @@ +2013-10-13 Thomas Quinot + + * scos.ads: Minor documentation clarification. + +2013-10-13 Thomas Quinot + + * s-oscons-tmplt.c (CLOCK_RT_Ada): Set to CLOCK_MONOTONIC when + building on AIX 5.3 or later, and to CLOCK_REALTIME on older + versions of AIX. + * init.c (pthread_condattr_setclock): Remove now useless weak symbol. + * thread.c(__gnat_pthread_condattr_setup): Remove bogus AIX 5.2 + compatibility shim. + * s-osinte-aix.ads(clock_id_t): Fix C mapping (this is a 64-bit + type). + (clock_gettime): Import from C runtime library. + * s-osinte-aix.adb (clock_gettime): Remove bogus emulation body, + this routine is provided by the system in current supported + versions of AIX. + +2013-10-13 Robert Dewar + + * sem_ch3.adb: Minor reformatting. + +2013-10-13 Ed Schonberg + + * freeze.adb (Freeze_Entity): For a function whose return type + is incomplete, do not replace the type with the full view if the + type is a limited view. In that case the full view appears in a + different unit, and the back-end will retrieve it at the proper + elaboration point. + +2013-10-13 Yannick Moy + + * exp_spark.adb (Expand_SPARK_Call): Do not introduce temporaries for + actuals. + 2013-10-13 Ed Schonberg * sem_ch3.adb: in Ada 2012 access_to_function types can have diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb index bd8932ecb60..7851f0999cf 100644 --- a/gcc/ada/exp_spark.adb +++ b/gcc/ada/exp_spark.adb @@ -26,7 +26,6 @@ with Atree; use Atree; with Einfo; use Einfo; with Exp_Ch4; use Exp_Ch4; -with Exp_Ch6; use Exp_Ch6; with Exp_Dbug; use Exp_Dbug; with Exp_Util; use Exp_Util; with Sem_Aux; use Sem_Aux; @@ -43,9 +42,7 @@ package body Exp_SPARK is procedure Expand_SPARK_Call (N : Node_Id); -- This procedure contains common processing for function and procedure - -- calls: - -- * expansion of actuals to introduce necessary temporaries - -- * replacement of renaming by subprogram renamed + -- calls: replacement of renaming by subprogram renamed procedure Expand_SPARK_N_Object_Renaming_Declaration (N : Node_Id); -- Perform name evaluation for a renamed object @@ -106,7 +103,6 @@ package body Exp_SPARK is procedure Expand_SPARK_Call (N : Node_Id) is Call_Node : constant Node_Id := N; Parent_Subp : Entity_Id; - Subp : Entity_Id; begin -- Ignore if previous error @@ -120,14 +116,12 @@ package body Exp_SPARK is -- Call using access to subprogram with explicit dereference if Nkind (Name (Call_Node)) = N_Explicit_Dereference then - Subp := Etype (Name (Call_Node)); Parent_Subp := Empty; -- Case of call to simple entry, where the Name is a selected component -- whose prefix is the task, and whose selector name is the entry name elsif Nkind (Name (Call_Node)) = N_Selected_Component then - Subp := Entity (Selector_Name (Name (Call_Node))); Parent_Subp := Empty; -- Case of call to member of entry family, where Name is an indexed @@ -135,20 +129,14 @@ package body Exp_SPARK is -- task and entry family name, and the index being the entry index. elsif Nkind (Name (Call_Node)) = N_Indexed_Component then - Subp := Entity (Selector_Name (Prefix (Name (Call_Node)))); Parent_Subp := Empty; -- Normal case else - Subp := Entity (Name (Call_Node)); - Parent_Subp := Alias (Subp); + Parent_Subp := Alias (Entity (Name (Call_Node))); end if; - -- Various expansion activities for actuals are carried out - - Expand_Actuals (N, Subp); - -- If the subprogram is a renaming, replace it in the call with the name -- of the actual subprogram being called. diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 67f203de559..8c9ceb0c917 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2956,6 +2956,7 @@ package body Freeze is if Is_Incomplete_Type (F_Type) and then Present (Full_View (F_Type)) + and then not From_With_Type (F_Type) then F_Type := Full_View (F_Type); Set_Etype (Formal, F_Type); @@ -3134,10 +3135,15 @@ package body Freeze is R_Type := Etype (E); -- AI05-0151: the return type may have been incomplete - -- at the point of declaration. + -- at the point of declaration. Replace it with the full + -- view, unless the current type is a limited view. In + -- that case the full view is in a different unit, and + -- gigi finds the non-limited view after the other unit + -- is elaborated. if Ekind (R_Type) = E_Incomplete_Type and then Present (Full_View (R_Type)) + and then not From_With_Type (R_Type) then R_Type := Full_View (R_Type); Set_Etype (E, R_Type); diff --git a/gcc/ada/init.c b/gcc/ada/init.c index 1b2e188ab51..c8de26b6498 100644 --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -226,19 +226,6 @@ nanosleep (struct timestruc_t *Rqtp, struct timestruc_t *Rmtp) #endif /* _AIXVERSION_430 */ -/* Version of AIX before 5.3 don't have pthread_condattr_setclock: - * supply it as a weak symbol here so that if linking on a 5.3 or newer - * machine, we get the real one. - */ - -#ifndef _AIXVERSION_530 -#pragma weak pthread_condattr_setclock -int -pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t cl) { - return 0; -} -#endif - static void __gnat_error_handler (int sig, siginfo_t *si ATTRIBUTE_UNUSED, diff --git a/gcc/ada/s-oscons-tmplt.c b/gcc/ada/s-oscons-tmplt.c index 6f018f8ea7a..2357d61d699 100644 --- a/gcc/ada/s-oscons-tmplt.c +++ b/gcc/ada/s-oscons-tmplt.c @@ -1407,11 +1407,15 @@ CND(CLOCK_FASTEST, "Fastest clock") #endif CND(CLOCK_THREAD_CPUTIME_ID, "Thread CPU clock") - -#if defined(__FreeBSD__) || defined(_AIX) +#if defined(__FreeBSD__) || (defined(_AIX) && defined(_AIXVERSION_530)) /** On these platforms use system provided monotonic clock instead of - ** the default CLOCK_REALTIME. Note: We then need to set up cond var - ** attributes appropriately (see thread.c). + ** the default CLOCK_REALTIME. We then need to set up cond var attributes + ** appropriately (see thread.c). + ** + ** Note that AIX 5.2 does not support CLOCK_MONOTONIC timestamps for + ** pthread_cond_timedwait (and does not have pthread_condattr_setclock), + ** hence the conditionalization on AIX version above). _AIXVERSION_530 + ** is defined in AIX 5.3 and more recent versions. **/ # define CLOCK_RT_Ada "CLOCK_MONOTONIC" diff --git a/gcc/ada/s-osinte-aix.adb b/gcc/ada/s-osinte-aix.adb index bfe03a637b2..2d5f160ca5f 100644 --- a/gcc/ada/s-osinte-aix.adb +++ b/gcc/ada/s-osinte-aix.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1997-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 1997-2013, Free Software Foundation, Inc. -- -- -- -- GNARL 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- -- @@ -99,48 +99,6 @@ package body System.OS_Interface is tv_nsec => long (Long_Long_Integer (F * 10#1#E9))); end To_Timespec; - ------------------- - -- clock_gettime -- - ------------------- - - function clock_gettime - (clock_id : clockid_t; - tp : access timespec) - return int - is - pragma Unreferenced (clock_id); - - -- Older AIX don't have clock_gettime, so use gettimeofday - - use Interfaces; - - type timeval is array (1 .. 2) of C.long; - - procedure timeval_to_duration - (T : not null access timeval; - sec : not null access C.long; - usec : not null access C.long); - pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration"); - - Micro : constant := 10**6; - sec : aliased C.long; - usec : aliased C.long; - TV : aliased timeval; - Result : int; - - function gettimeofday - (Tv : access timeval; - Tz : System.Address := System.Null_Address) return int; - pragma Import (C, gettimeofday, "gettimeofday"); - - begin - Result := gettimeofday (TV'Access, System.Null_Address); - pragma Assert (Result = 0); - timeval_to_duration (TV'Access, sec'Access, usec'Access); - tp.all := To_Timespec (Duration (sec) + Duration (usec) / Micro); - return Result; - end clock_gettime; - ----------------- -- sched_yield -- ----------------- diff --git a/gcc/ada/s-osinte-aix.ads b/gcc/ada/s-osinte-aix.ads index c89e7296e14..6fce65ffd23 100644 --- a/gcc/ada/s-osinte-aix.ads +++ b/gcc/ada/s-osinte-aix.ads @@ -7,7 +7,7 @@ -- S p e c -- -- -- -- Copyright (C) 1991-1994, Florida State University -- --- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1995-2013, 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- -- @@ -41,6 +41,7 @@ with Ada.Unchecked_Conversion; with Interfaces.C; +with Interfaces.C.Extensions; package System.OS_Interface is pragma Preelaborate; @@ -55,6 +56,7 @@ package System.OS_Interface is subtype int is Interfaces.C.int; subtype short is Interfaces.C.short; subtype long is Interfaces.C.long; + subtype long_long is Interfaces.C.Extensions.long_long; subtype unsigned is Interfaces.C.unsigned; subtype unsigned_short is Interfaces.C.unsigned_short; subtype unsigned_long is Interfaces.C.unsigned_long; @@ -197,11 +199,12 @@ package System.OS_Interface is type timespec is private; - type clockid_t is new int; + type clockid_t is new long_long; function clock_gettime (clock_id : clockid_t; tp : access timespec) return int; + pragma Import (C, clock_gettime, "clock_gettime"); function To_Duration (TS : timespec) return Duration; pragma Inline (To_Duration); diff --git a/gcc/ada/scos.ads b/gcc/ada/scos.ads index dc4248e12d9..6efc5cebcc9 100644 --- a/gcc/ada/scos.ads +++ b/gcc/ada/scos.ads @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2009-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2009-2013, 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- -- @@ -367,11 +367,12 @@ package SCOs is Last : Boolean := False; Pragma_Sloc : Source_Ptr := No_Location; - -- For the statement SCO for a pragma, or for any expression SCO nested - -- in a pragma Debug/Assert/PPC, location of PRAGMA token (used for - -- control of SCO output, value not recorded in ALI file). For the - -- decision SCO for an aspect, or for any expression SCO nested in an - -- aspect, location of aspect identifier token (likewise). + -- For the decision SCO of a pragma, or for the decision SCO of any + -- expression nested in a pragma Debug/Assert/PPC, location of PRAGMA + -- token (used for control of SCO output, value not recorded in ALI + -- file). Similarly, for the decision SCO of an aspect, or for the + -- decision SCO of any expression nested in an aspect, location of + -- aspect identifier token. Pragma_Aspect_Name : Name_Id := No_Name; -- For the SCO for a pragma/aspect, gives the pragma/apsect name diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 6b2e0a66b81..77805d1d45f 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -4052,7 +4052,7 @@ package body Sem_Ch3 is -- type with constraints. In this case the entity has been introduced -- in the private declaration. - -- Finally this happens in some complex cases when validity checks are + -- Finally this happens in some complex cases when validity checks are -- enabled, where the same subtype declaration may be analyzed twice. -- This can happen if the subtype is created by the pre-analysis of -- an attribute tht gives the range of a loop statement, and the loop diff --git a/gcc/ada/thread.c b/gcc/ada/thread.c index 237cfaf79e4..31309e05b6e 100644 --- a/gcc/ada/thread.c +++ b/gcc/ada/thread.c @@ -40,27 +40,8 @@ # include # include -#ifndef _AIXVERSION_530 -/* We use the same runtime library for AIX 5.2 and 5.3, but pthread_condattr_ - * setclock exists only on the latter, so for the former provide a dummy - * implementation (declared below, weak symbol defined in init.c). - * - * Note: this means that under AIX 5.2 we'll be using CLOCK_MONOTONIC - * timestamps from clock_gettime() as arguments to pthread_cond_timedwait, - * which expects a CLOCK_REALTIME value, which is technically wrong, but - * inocuous in practice on that particular platform since both clocks happen - * to use close epochs. - */ - -extern int pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t cl); -#endif - int __gnat_pthread_condattr_setup(pthread_condattr_t *attr) { -/* - * If using a clock other than CLOCK_REALTIME for the Ada Monotonic_Clock, - * the corresponding clock id must be set for condition variables. - */ return pthread_condattr_setclock (attr, CLOCK_RT_Ada); } -- 2.30.2