From patchwork Tue May 2 08:47:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 757471 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wHFL5605Tz9s0Z for ; Tue, 2 May 2017 18:47:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bRQ/QtFA"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=QV0189VcEwbyHM+drT3Zrj76NcubBljAQ7nuWJUC4OxA3w+X+x A6a4YrcXDAOLtFYNz3ff6U68YbeCptdRyEEjJko5nsYNieYFiDDP2C4x/0XctpjV tP8Og0Y6g87RWh7p9IPMGn+ONyaEQdR7v32OdYcAbU5tAy8WF8YWy44/A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=Cw+0zs56+ErKBUD8wuKvG0f2hX8=; b=bRQ/QtFA4IiaX96ExV2m EitBeYoEZN4BCcEiFpYz/qDE4ADlEtH0Eok+zqzmW7u9JK2l5lBP+YkskKEVOSYa 09Saby/dgmJJTRFnH6DOmFKBzUPDsvCxSDIvUB13qBsRk5z+C7GZa2rm1L48+tsF OSEiO1wUegwNU3+oubsoND4= Received: (qmail 11807 invoked by alias); 2 May 2017 08:47:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 11794 invoked by uid 89); 2 May 2017 08:47:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=duration, vanished, 4637, Duration X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 08:47:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 073CE9EC6; Tue, 2 May 2017 04:47:39 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mxzx5d0YIevv; Tue, 2 May 2017 04:47:38 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E8C943DC6; Tue, 2 May 2017 04:47:38 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id E4CCD4FF; Tue, 2 May 2017 04:47:38 -0400 (EDT) Date: Tue, 2 May 2017 04:47:38 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Bob Duff Subject: [Ada] Ceiling priorities off by one on Linux Message-ID: <20170502084738.GA99521@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This patch fixes a bug in which ceiling priorities were off by one, so that Program_Error is raised for a ceiling violation when a task calls a protected operation and the priority of the task is equal to the ceiling priority of the protected object. Program_Error should be raised only if the priority of the task is greater, not greater or equal. No test available; too nondeterministic, and requires root privileges. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-05-02 Bob Duff * s-taprop-linux.adb (Prio_To_Linux_Prio): New function to correctly compute the linux priority from the Ada priority. Call this everywhere required. In particular, the previous version was not doing this computation when setting the ceiling priority in various places. It was just converting to C.int, which results in a ceiling that is off by 1. Index: s-taprop-linux.adb =================================================================== --- s-taprop-linux.adb (revision 247472) +++ s-taprop-linux.adb (working copy) @@ -38,7 +38,7 @@ -- Turn off polling, we do not want ATC polling to take place during tasking -- operations. It causes infinite loops and other problems. -with Interfaces.C; +with Interfaces.C; use Interfaces; use type Interfaces.C.int; with System.Task_Info; with System.Tasking.Debug; @@ -60,7 +60,6 @@ use System.Tasking.Debug; use System.Tasking; - use Interfaces.C; use System.OS_Interface; use System.Parameters; use System.OS_Primitives; @@ -111,14 +110,6 @@ -- Constant to indicate that the thread identifier has not yet been -- initialized. - function geteuid return Integer; - pragma Import (C, geteuid, "geteuid"); - pragma Warnings (Off, "non-static call not allowed in preelaborated unit"); - Superuser : constant Boolean := geteuid = 0; - pragma Warnings (On, "non-static call not allowed in preelaborated unit"); - -- True if we are running as 'root'. On Linux, ceiling priorities work only - -- in that case, so if this is False, we ignore Locking_Policy = 'C'. - -------------------- -- Local Packages -- -------------------- @@ -170,17 +161,52 @@ procedure Abort_Handler (signo : Signal); function GNAT_pthread_condattr_setup - (attr : access pthread_condattr_t) return int; - pragma Import (C, - GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); + (attr : access pthread_condattr_t) return C.int; + pragma Import + (C, GNAT_pthread_condattr_setup, "__gnat_pthread_condattr_setup"); + function Prio_To_Linux_Prio (Prio : Any_Priority) return C.int is + (C.int (Prio) + 1); + -- Convert Ada priority to Linux priority. Priorities are 1 .. 99 on + -- GNU/Linux, so we map 0 .. 98 to 1 .. 99. + + function Get_Ceiling_Support return Boolean; + -- Get the value of the Ceiling_Support constant (see below). + -- ???For now, we're returning True only if running as superuser, + -- and ignore capabilities. + + function Get_Ceiling_Support return Boolean is + Ceiling_Support : Boolean := False; + begin + if Locking_Policy = 'C' then + declare + function geteuid return Integer; + pragma Import (C, geteuid, "geteuid"); + Superuser : constant Boolean := geteuid = 0; + begin + if Superuser then + Ceiling_Support := True; + end if; + end; + end if; + + return Ceiling_Support; + end Get_Ceiling_Support; + + pragma Warnings (Off, "non-static call not allowed in preelaborated unit"); + Ceiling_Support : constant Boolean := Get_Ceiling_Support; + pragma Warnings (On, "non-static call not allowed in preelaborated unit"); + -- True if the locking policy is Ceiling_Locking, and the current process + -- has permission to use this policy. The process has permission if it is + -- running as 'root', or if the capability was set by the setcap command, + -- as in "sudo /sbin/setcap cap_sys_nice=ep exe_file". If it doesn't have + -- permission, then a request for Ceiling_Locking is ignored. + type RTS_Lock_Ptr is not null access all RTS_Lock; - function Init_Mutex - (L : RTS_Lock_Ptr; Prio : Any_Priority) - return Interfaces.C.int; - -- Initialize the mutex L. If the locking policy is Ceiling_Locking, then - -- set the ceiling to Prio. + function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int; + -- Initialize the mutex L. If Ceiling_Support is True, then set the ceiling + -- to Prio. Returns 0 for success, or ENOMEM for out-of-memory. ------------------- -- Abort_Handler -- @@ -190,7 +216,7 @@ pragma Unreferenced (signo); Self_Id : constant Task_Id := Self; - Result : Interfaces.C.int; + Result : C.int; Old_Set : aliased sigset_t; begin @@ -272,30 +298,26 @@ -- Init_Mutex -- ---------------- - function Init_Mutex - (L : RTS_Lock_Ptr; Prio : Any_Priority) - return Interfaces.C.int - is + function Init_Mutex (L : RTS_Lock_Ptr; Prio : Any_Priority) return C.int is Mutex_Attr : aliased pthread_mutexattr_t; - Result : Interfaces.C.int; + Result, Result_2 : C.int; + begin Result := pthread_mutexattr_init (Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result = ENOMEM then - return ENOMEM; + return Result; end if; - if Locking_Policy = 'C' then - if Superuser then - Result := pthread_mutexattr_setprotocol - (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); - pragma Assert (Result = 0); + if Ceiling_Support then + Result := pthread_mutexattr_setprotocol + (Mutex_Attr'Access, PTHREAD_PRIO_PROTECT); + pragma Assert (Result = 0); - Result := pthread_mutexattr_setprioceiling - (Mutex_Attr'Access, Interfaces.C.int (Prio)); - pragma Assert (Result = 0); - end if; + Result := pthread_mutexattr_setprioceiling + (Mutex_Attr'Access, Prio_To_Linux_Prio (Prio)); + pragma Assert (Result = 0); elsif Locking_Policy = 'I' then Result := pthread_mutexattr_setprotocol @@ -304,16 +326,11 @@ end if; Result := pthread_mutex_init (L, Mutex_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); - if Result = ENOMEM then - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - return ENOMEM; - end if; - - Result := pthread_mutexattr_destroy (Mutex_Attr'Access); - pragma Assert (Result = 0); - return 0; + Result_2 := pthread_mutexattr_destroy (Mutex_Attr'Access); + pragma Assert (Result_2 = 0); + return Result; -- of pthread_mutex_init, not pthread_mutexattr_destroy end Init_Mutex; --------------------- @@ -327,14 +344,14 @@ -- routines should be able to be handled safely. procedure Initialize_Lock - (Prio : System.Any_Priority; + (Prio : Any_Priority; L : not null access Lock) is begin if Locking_Policy = 'R' then declare RWlock_Attr : aliased pthread_rwlockattr_t; - Result : Interfaces.C.int; + Result : C.int; begin -- Set the rwlock to prefer writer to avoid writers starvation @@ -349,7 +366,7 @@ Result := pthread_rwlock_init (L.RW'Access, RWlock_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result = ENOMEM then raise Storage_Error with "Failed to allocate a lock"; @@ -378,7 +395,7 @@ ------------------- procedure Finalize_Lock (L : not null access Lock) is - Result : Interfaces.C.int; + Result : C.int; begin if Locking_Policy = 'R' then Result := pthread_rwlock_destroy (L.RW'Access); @@ -389,7 +406,7 @@ end Finalize_Lock; procedure Finalize_Lock (L : not null access RTS_Lock) is - Result : Interfaces.C.int; + Result : C.int; begin Result := pthread_mutex_destroy (L); pragma Assert (Result = 0); @@ -403,7 +420,7 @@ (L : not null access Lock; Ceiling_Violation : out Boolean) is - Result : Interfaces.C.int; + Result : C.int; begin if Locking_Policy = 'R' then Result := pthread_rwlock_wrlock (L.RW'Access); @@ -413,15 +430,15 @@ -- The cause of EINVAL is a priority ceiling violation + pragma Assert (Result in 0 | EINVAL); Ceiling_Violation := Result = EINVAL; - pragma Assert (Result = 0 or else Ceiling_Violation); end Write_Lock; procedure Write_Lock (L : not null access RTS_Lock; Global_Lock : Boolean := False) is - Result : Interfaces.C.int; + Result : C.int; begin if not Single_Lock or else Global_Lock then Result := pthread_mutex_lock (L); @@ -430,7 +447,7 @@ end Write_Lock; procedure Write_Lock (T : Task_Id) is - Result : Interfaces.C.int; + Result : C.int; begin if not Single_Lock then Result := pthread_mutex_lock (T.Common.LL.L'Access); @@ -446,7 +463,7 @@ (L : not null access Lock; Ceiling_Violation : out Boolean) is - Result : Interfaces.C.int; + Result : C.int; begin if Locking_Policy = 'R' then Result := pthread_rwlock_rdlock (L.RW'Access); @@ -456,8 +473,8 @@ -- The cause of EINVAL is a priority ceiling violation + pragma Assert (Result in 0 | EINVAL); Ceiling_Violation := Result = EINVAL; - pragma Assert (Result = 0 or else Ceiling_Violation); end Read_Lock; ------------ @@ -465,7 +482,7 @@ ------------ procedure Unlock (L : not null access Lock) is - Result : Interfaces.C.int; + Result : C.int; begin if Locking_Policy = 'R' then Result := pthread_rwlock_unlock (L.RW'Access); @@ -479,7 +496,7 @@ (L : not null access RTS_Lock; Global_Lock : Boolean := False) is - Result : Interfaces.C.int; + Result : C.int; begin if not Single_Lock or else Global_Lock then Result := pthread_mutex_unlock (L); @@ -488,7 +505,7 @@ end Unlock; procedure Unlock (T : Task_Id) is - Result : Interfaces.C.int; + Result : C.int; begin if not Single_Lock then Result := pthread_mutex_unlock (T.Common.LL.L'Access); @@ -504,7 +521,7 @@ procedure Set_Ceiling (L : not null access Lock; - Prio : System.Any_Priority) + Prio : Any_Priority) is pragma Unreferenced (L, Prio); begin @@ -521,7 +538,7 @@ is pragma Unreferenced (Reason); - Result : Interfaces.C.int; + Result : C.int; begin pragma Assert (Self_ID = Self); @@ -535,7 +552,7 @@ -- EINTR is not considered a failure - pragma Assert (Result = 0 or else Result = EINTR); + pragma Assert (Result in 0 | EINTR); end Sleep; ----------------- @@ -560,7 +577,7 @@ Check_Time : Duration := Base_Time; Abs_Time : Duration; Request : aliased timespec; - Result : Interfaces.C.int; + Result : C.int; begin Timedout := True; @@ -588,7 +605,7 @@ Check_Time := Monotonic_Clock; exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - if Result = 0 or else Result = EINTR then + if Result in 0 | EINTR then -- Somebody may have called Wakeup for us @@ -618,7 +635,7 @@ Abs_Time : Duration; Request : aliased timespec; - Result : Interfaces.C.int; + Result : C.int; pragma Warnings (Off, Result); begin @@ -651,9 +668,7 @@ Check_Time := Monotonic_Clock; exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - pragma Assert (Result = 0 or else - Result = ETIMEDOUT or else - Result = EINTR); + pragma Assert (Result in 0 | ETIMEDOUT | EINTR); end loop; Self_ID.Common.State := Runnable; @@ -674,7 +689,7 @@ function Monotonic_Clock return Duration is TS : aliased timespec; - Result : int; + Result : C.int; begin Result := clock_gettime (clock_id => OSC.CLOCK_RT_Ada, tp => TS'Unchecked_Access); @@ -689,7 +704,7 @@ function RT_Resolution return Duration is TS : aliased timespec; - Result : int; + Result : C.int; begin Result := clock_getres (OSC.CLOCK_REALTIME, TS'Unchecked_Access); @@ -704,7 +719,7 @@ procedure Wakeup (T : Task_Id; Reason : System.Tasking.Task_States) is pragma Unreferenced (Reason); - Result : Interfaces.C.int; + Result : C.int; begin Result := pthread_cond_signal (T.Common.LL.CV'Access); pragma Assert (Result = 0); @@ -715,7 +730,7 @@ ----------- procedure Yield (Do_Yield : Boolean := True) is - Result : Interfaces.C.int; + Result : C.int; pragma Unreferenced (Result); begin if Do_Yield then @@ -729,15 +744,15 @@ procedure Set_Priority (T : Task_Id; - Prio : System.Any_Priority; + Prio : Any_Priority; Loss_Of_Inheritance : Boolean := False) is pragma Unreferenced (Loss_Of_Inheritance); - Result : Interfaces.C.int; + Result : C.int; Param : aliased struct_sched_param; - function Get_Policy (Prio : System.Any_Priority) return Character; + function Get_Policy (Prio : Any_Priority) return Character; pragma Import (C, Get_Policy, "__gnat_get_specific_dispatching"); -- Get priority specific dispatching policy @@ -748,10 +763,8 @@ begin T.Common.Current_Priority := Prio; - -- Priorities are 1 .. 99 on GNU/Linux, so we map 0 .. 98 to 1 .. 99 + Param.sched_priority := Prio_To_Linux_Prio (Prio); - Param.sched_priority := Interfaces.C.int (Prio) + 1; - if Dispatching_Policy = 'R' or else Priority_Specific_Policy = 'R' or else Time_Slice_Val > 0 @@ -776,14 +789,14 @@ SCHED_OTHER, Param'Access); end if; - pragma Assert (Result = 0 or else Result = EPERM); + pragma Assert (Result in 0 | EPERM | EINVAL); end Set_Priority; ------------------ -- Get_Priority -- ------------------ - function Get_Priority (T : Task_Id) return System.Any_Priority is + function Get_Priority (T : Task_Id) return Any_Priority is begin return T.Common.Current_Priority; end Get_Priority; @@ -817,7 +830,7 @@ Len : Natural := 0; -- Length of the task name contained in Task_Name - Result : int; + Result : C.int; -- Result from the prctl call begin Result := prctl (PR_GET_NAME, unsigned_long (Thread_Name'Address)); @@ -849,7 +862,7 @@ elsif Self_ID.Common.Task_Image_Len > 0 then declare Task_Name : String (1 .. Parameters.Max_Task_Image_Length + 1); - Result : int; + Result : C.int; begin Task_Name (1 .. Self_ID.Common.Task_Image_Len) := @@ -868,7 +881,7 @@ then declare Stack : aliased stack_t; - Result : Interfaces.C.int; + Result : C.int; begin Stack.ss_sp := Self_ID.Common.Task_Alternate_Stack; Stack.ss_size := Alternate_Stack_Size; @@ -903,7 +916,7 @@ -------------------- procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is - Result : Interfaces.C.int; + Result : C.int; Cond_Attr : aliased pthread_condattr_t; begin @@ -917,7 +930,7 @@ if not Single_Lock then if Init_Mutex - (Self_ID.Common.LL.L'Access, System.Any_Priority'Last) /= 0 + (Self_ID.Common.LL.L'Access, Any_Priority'Last) /= 0 then Succeeded := False; return; @@ -925,7 +938,7 @@ end if; Result := pthread_condattr_init (Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result = 0 then Result := GNAT_pthread_condattr_setup (Cond_Attr'Access); @@ -934,7 +947,7 @@ Result := pthread_cond_init (Self_ID.Common.LL.CV'Access, Cond_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); end if; if Result = 0 then @@ -960,14 +973,14 @@ (T : Task_Id; Wrapper : System.Address; Stack_Size : System.Parameters.Size_Type; - Priority : System.Any_Priority; + Priority : Any_Priority; Succeeded : out Boolean) is Thread_Attr : aliased pthread_attr_t; - Adjusted_Stack_Size : Interfaces.C.size_t; - Result : Interfaces.C.int; + Adjusted_Stack_Size : C.size_t; + Result : C.int; - use type System.Multiprocessors.CPU_Range; + use type Multiprocessors.CPU_Range, Interfaces.C.size_t; begin -- Check whether both Dispatching_Domain and CPU are specified for @@ -975,7 +988,7 @@ -- processors for the domain. if T.Common.Domain /= null - and then T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU + and then T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU and then (T.Common.Base_CPU not in T.Common.Domain'Range or else not T.Common.Domain (T.Common.Base_CPU)) @@ -984,11 +997,10 @@ return; end if; - Adjusted_Stack_Size := - Interfaces.C.size_t (Stack_Size + Alternate_Stack_Size); + Adjusted_Stack_Size := C.size_t (Stack_Size + Alternate_Stack_Size); Result := pthread_attr_init (Thread_Attr'Access); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result /= 0 then Succeeded := False; @@ -1013,16 +1025,15 @@ -- Do nothing if required support not provided by the operating system - if pthread_attr_setaffinity_np'Address = System.Null_Address then + if pthread_attr_setaffinity_np'Address = Null_Address then null; -- Support is available - elsif T.Common.Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU then + elsif T.Common.Base_CPU /= Multiprocessors.Not_A_Specific_CPU then declare CPUs : constant size_t := - Interfaces.C.size_t - (System.Multiprocessors.Number_Of_CPUs); + C.size_t (Multiprocessors.Number_Of_CPUs); CPU_Set : constant cpu_set_t_ptr := CPU_ALLOC (CPUs); Size : constant size_t := CPU_ALLOC_SIZE (CPUs); @@ -1061,8 +1072,7 @@ then declare CPUs : constant size_t := - Interfaces.C.size_t - (System.Multiprocessors.Number_Of_CPUs); + C.size_t (Multiprocessors.Number_Of_CPUs); CPU_Set : constant cpu_set_t_ptr := CPU_ALLOC (CPUs); Size : constant size_t := CPU_ALLOC_SIZE (CPUs); @@ -1103,8 +1113,7 @@ Thread_Body_Access (Wrapper), To_Address (T)); - pragma Assert - (Result = 0 or else Result = EAGAIN or else Result = ENOMEM); + pragma Assert (Result in 0 | EAGAIN | ENOMEM); if Result /= 0 then Succeeded := False; @@ -1126,7 +1135,7 @@ ------------------ procedure Finalize_TCB (T : Task_Id) is - Result : Interfaces.C.int; + Result : C.int; begin if not Single_Lock then @@ -1158,7 +1167,7 @@ ---------------- procedure Abort_Task (T : Task_Id) is - Result : Interfaces.C.int; + Result : C.int; ESRCH : constant := 3; -- No such process -- It can happen that T has already vanished, in which case pthread_kill @@ -1170,7 +1179,7 @@ pthread_kill (T.Common.LL.Thread, Signal (System.Interrupt_Management.Abort_Task_Interrupt)); - pragma Assert (Result = 0 or else Result = ESRCH); + pragma Assert (Result in 0 | ESRCH); end if; end Abort_Task; @@ -1179,7 +1188,7 @@ ---------------- procedure Initialize (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : C.int; begin -- Initialize internal state (always to False (RM D.10(6))) @@ -1191,7 +1200,7 @@ Result := pthread_mutex_init (S.L'Access, null); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result = ENOMEM then raise Storage_Error; @@ -1201,7 +1210,7 @@ Result := pthread_cond_init (S.CV'Access, null); - pragma Assert (Result = 0 or else Result = ENOMEM); + pragma Assert (Result in 0 | ENOMEM); if Result /= 0 then Result := pthread_mutex_destroy (S.L'Access); @@ -1218,7 +1227,7 @@ -------------- procedure Finalize (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : C.int; begin -- Destroy internal mutex @@ -1249,7 +1258,7 @@ --------------- procedure Set_False (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : C.int; begin SSL.Abort_Defer.all; @@ -1270,7 +1279,7 @@ -------------- procedure Set_True (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : C.int; begin SSL.Abort_Defer.all; @@ -1305,7 +1314,7 @@ ------------------------ procedure Suspend_Until_True (S : in out Suspension_Object) is - Result : Interfaces.C.int; + Result : C.int; begin SSL.Abort_Defer.all; @@ -1343,7 +1352,7 @@ -- POSIX does not guarantee it so this may change in future. Result := pthread_cond_wait (S.CV'Access, S.L'Access); - pragma Assert (Result = 0 or else Result = EINTR); + pragma Assert (Result in 0 | EINTR); exit when not S.Waiting; end loop; @@ -1456,7 +1465,7 @@ act : aliased struct_sigaction; old_act : aliased struct_sigaction; Tmp_Set : aliased sigset_t; - Result : Interfaces.C.int; + Result : C.int; -- Whether to use an alternate signal stack for stack overflows function State @@ -1538,7 +1547,7 @@ ----------------------- procedure Set_Task_Affinity (T : ST.Task_Id) is - use type System.Multiprocessors.CPU_Range; + use type Multiprocessors.CPU_Range; begin -- Do nothing if there is no support for setting affinities or the @@ -1546,17 +1555,16 @@ -- yet been created then the proper affinity will be set during its -- creation. - if pthread_setaffinity_np'Address /= System.Null_Address + if pthread_setaffinity_np'Address /= Null_Address and then T.Common.LL.Thread /= Null_Thread_Id then declare CPUs : constant size_t := - Interfaces.C.size_t - (System.Multiprocessors.Number_Of_CPUs); + C.size_t (Multiprocessors.Number_Of_CPUs); CPU_Set : cpu_set_t_ptr := null; Size : constant size_t := CPU_ALLOC_SIZE (CPUs); - Result : Interfaces.C.int; + Result : C.int; begin -- We look at the specific CPU (Base_CPU) first, then at the