From patchwork Fri May 25 09:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 920336 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-478494-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qTf8vOSy"; dkim-atps=neutral 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 40sgPh1pKQz9s19 for ; Fri, 25 May 2018 19:07:36 +1000 (AEST) 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=Hy56vTSz+VCC1cYSnbqBowwtMAypoEF9cVZBN4joj8UgC+kyJT 7bSCN0uV+kySOY95u4EAjBME66j99j7KKY8/k/Mr6nylqXzKvrnVG5qrEtXm15dd 6qx/xb+xMbwHd6MYsz72VcxgBDSAKzZgAlbOeulwous/QXRzqB4fG7cG8= 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=RxDHAqQwPItcZR6uk+cIDfgI2jU=; b=qTf8vOSy3rMChX42o7KY MJvrHrxb95ylagwYoZct/0MPbwPskb4Wkoobc6IewdL0co7oX1fciC+IzC6yV722 U3qWkfWKIJtKHN2PG7hHdfhZfvUhA+86V9P+aIQGDk1zprbsETbcoOCOHi6x9SRQ n3T2Cm3nabaBhYcvONg1t1U= Received: (qmail 602 invoked by alias); 25 May 2018 09:07:19 -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 505 invoked by uid 89); 25 May 2018 09:07:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 spammy=Soft, york, York, compensate 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; Fri, 25 May 2018 09:07:14 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id AD614117F49; Fri, 25 May 2018 05:07:12 -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 OilKDP5VJwd1; Fri, 25 May 2018 05:07:12 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 9B10C117F2F; Fri, 25 May 2018 05:07:12 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 9A230784; Fri, 25 May 2018 05:07:12 -0400 (EDT) Date: Fri, 25 May 2018 05:07:12 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Doug Rupp Subject: [Ada] Make Max_Sensible_Delay uniform across all Posix targets Message-ID: <20180525090712.GA34674@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes For instance: 6 months where Duration is 64bits. Heretofore LynxOS was unique in having an approximately 12 days max delay. By experimentation the actual maximum was determined and all relevant delay and sleep procedures rewritten to incrementally wait if necessary. Tested on x86_64-pc-linux-gnu, committed on trunk 2018-05-25 Doug Rupp gcc/ada/ * libgnarl/s-osinte__aix.ads, libgnarl/s-osinte__android.ads, libgnarl/s-osinte__darwin.ads, libgnarl/s-osinte__freebsd.ads, libgnarl/s-osinte__hpux.ads, libgnarl/s-osinte__kfreebsd-gnu.ads, libgnarl/s-osinte__linux.ads, libgnarl/s-osinte__lynxos178e.ads, libgnarl/s-osinte__qnx.ads, libgnarl/s-osinte__rtems.ads (Relative_Timed_Wait): Remove. * libgnarl/s-tpopmo.adb (Timed_Sleep, Timed_Delay): Rewrite to allow for incremental looping. Remove references to Rel_Time and Relative_Timed_Wait. * libgnat/s-osprim__posix.adb, libgnat/s-osprim__posix2008.adb (Timed_Delay): Make separate. * libgnat/s-optide.adb: New separate procedure. * libgnat/s-osprim.ads (Max_System_Delay): New constant. * libgnat/s-osprim__lynxos.ads (Max_Sensible_Delay): Set to 6 months. (Max_System_Delay): New constant. --- gcc/ada/libgnarl/s-osinte__aix.ads +++ gcc/ada/libgnarl/s-osinte__aix.ads @@ -420,9 +420,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__android.ads +++ gcc/ada/libgnarl/s-osinte__android.ads @@ -414,9 +414,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__darwin.ads +++ gcc/ada/libgnarl/s-osinte__darwin.ads @@ -397,9 +397,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__freebsd.ads +++ gcc/ada/libgnarl/s-osinte__freebsd.ads @@ -431,9 +431,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__hpux.ads +++ gcc/ada/libgnarl/s-osinte__hpux.ads @@ -400,9 +400,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads +++ gcc/ada/libgnarl/s-osinte__kfreebsd-gnu.ads @@ -430,9 +430,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__linux.ads +++ gcc/ada/libgnarl/s-osinte__linux.ads @@ -448,9 +448,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__lynxos178e.ads +++ gcc/ada/libgnarl/s-osinte__lynxos178e.ads @@ -420,9 +420,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__qnx.ads +++ gcc/ada/libgnarl/s-osinte__qnx.ads @@ -417,9 +417,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-osinte__rtems.ads +++ gcc/ada/libgnarl/s-osinte__rtems.ads @@ -426,9 +426,6 @@ package System.OS_Interface is abstime : access timespec) return int; pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); - Relative_Timed_Wait : constant Boolean := False; - -- pthread_cond_timedwait requires an absolute delay time - -------------------------- -- POSIX.1c Section 13 -- -------------------------- --- gcc/ada/libgnarl/s-tpopmo.adb +++ gcc/ada/libgnarl/s-tpopmo.adb @@ -42,11 +42,10 @@ package body Monotonic is (Time : Duration; Mode : ST.Delay_Modes; Check_Time : out Duration; - Abs_Time : out Duration; - Rel_Time : out Duration); + Abs_Time : out Duration); -- Helper for Timed_Sleep and Timed_Delay: given a deadline specified by -- Time and Mode, compute the current clock reading (Check_Time), and the - -- target absolute and relative clock readings (Abs_Time, Rel_Time). The + -- target absolute and relative clock readings (Abs_Time). The -- epoch for Time depends on Mode; the epoch for Check_Time and Abs_Time -- is always that of CLOCK_RT_Ada. @@ -88,8 +87,7 @@ package body Monotonic is (Time : Duration; Mode : ST.Delay_Modes; Check_Time : out Duration; - Abs_Time : out Duration; - Rel_Time : out Duration) + Abs_Time : out Duration) is begin Check_Time := Monotonic_Clock; @@ -99,10 +97,6 @@ package body Monotonic is if Mode = Relative then Abs_Time := Duration'Min (Time, Max_Sensible_Delay) + Check_Time; - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time); - end if; - pragma Warnings (Off); -- Comparison "OSC.CLOCK_RT_Ada = OSC.CLOCK_REALTIME" is compile -- time known. @@ -115,10 +109,6 @@ package body Monotonic is pragma Warnings (On); Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, Time); - if Relative_Timed_Wait then - Rel_Time := Duration'Min (Max_Sensible_Delay, Time - Check_Time); - end if; - -- Absolute deadline specified using the calendar clock, in the -- case where it is not the same as the tasking clock: compensate for -- difference between clock epochs (Base_Time - Base_Cal_Time). @@ -133,10 +123,6 @@ package body Monotonic is Abs_Time := Duration'Min (Check_Time + Max_Sensible_Delay, RT_Time); - if Relative_Timed_Wait then - Rel_Time := - Duration'Min (Max_Sensible_Delay, RT_Time - Check_Time); - end if; end; end if; end Compute_Deadline; @@ -162,10 +148,11 @@ package body Monotonic is Base_Time : Duration; Check_Time : Duration; Abs_Time : Duration; - Rel_Time : Duration; + P_Abs_Time : Duration; Request : aliased timespec; Result : Interfaces.C.int; + Exit_Outer : Boolean := False; begin Timedout := True; @@ -175,38 +162,63 @@ package body Monotonic is (Time => Time, Mode => Mode, Check_Time => Check_Time, - Abs_Time => Abs_Time, - Rel_Time => Rel_Time); + Abs_Time => Abs_Time); Base_Time := Check_Time; + -- To keep a sensible Max_Sensible_Delay on a target whose system + -- maximum is less than sensible, we split the delay into manageable + -- chunks of time less than or equal to the Max_System_Delay. + if Abs_Time > Check_Time then - Request := - To_Timespec (if Relative_Timed_Wait then Rel_Time else Abs_Time); - loop - exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; + Outer : loop - Result := - pthread_cond_timedwait - (cond => Self_ID.Common.LL.CV'Access, - mutex => (if Single_Lock - then Single_RTS_Lock'Access - else Self_ID.Common.LL.L'Access), - abstime => Request'Access); + pragma Warnings (Off, "condition is always *"); + if Max_System_Delay < Max_Sensible_Delay and then + Abs_Time > Check_Time + Max_System_Delay + then + P_Abs_Time := Check_Time + Max_System_Delay; + else + P_Abs_Time := Abs_Time; + Exit_Outer := True; + end if; + pragma Warnings (On); - Check_Time := Monotonic_Clock; - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; + Request := To_Timespec (P_Abs_Time); - if Result in 0 | EINTR then + Inner : loop + exit Outer + when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; - -- Somebody may have called Wakeup for us + Result := + pthread_cond_timedwait + (cond => Self_ID.Common.LL.CV'Access, + mutex => (if Single_Lock + then Single_RTS_Lock'Access + else Self_ID.Common.LL.L'Access), + abstime => Request'Access); - Timedout := False; - exit; - end if; + case Result is + when 0 | EINTR => + -- Somebody may have called Wakeup for us + Timedout := False; + exit Outer; - pragma Assert (Result = ETIMEDOUT); - end loop; + when ETIMEDOUT => + exit Outer when Exit_Outer; + Check_Time := Monotonic_Clock; + exit Inner; + + when others => + pragma Assert (False); + + end case; + + exit Outer + when Abs_Time <= Check_Time or else Check_Time < Base_Time; + + end loop Inner; + end loop Outer; end if; end Timed_Sleep; @@ -225,11 +237,11 @@ package body Monotonic is Base_Time : Duration; Check_Time : Duration; Abs_Time : Duration; - Rel_Time : Duration; + P_Abs_Time : Duration; Request : aliased timespec; - Result : Interfaces.C.int; - pragma Warnings (Off, Result); + Result : Interfaces.C.int; + Exit_Outer : Boolean := False; begin if Single_Lock then @@ -242,31 +254,61 @@ package body Monotonic is (Time => Time, Mode => Mode, Check_Time => Check_Time, - Abs_Time => Abs_Time, - Rel_Time => Rel_Time); + Abs_Time => Abs_Time); Base_Time := Check_Time; + -- To keep a sensible Max_Sensible_Delay on a target whose system + -- maximum is less than sensible, we split the delay into manageable + -- chunks of time less than or equal to the Max_System_Delay. + if Abs_Time > Check_Time then - Request := - To_Timespec (if Relative_Timed_Wait then Rel_Time else Abs_Time); Self_ID.Common.State := Delay_Sleep; - loop - exit when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; + Outer : loop + + pragma Warnings (Off, "condition is always *"); + if Max_System_Delay < Max_Sensible_Delay and then + Abs_Time > Check_Time + Max_System_Delay + then + P_Abs_Time := Check_Time + Max_System_Delay; + else + P_Abs_Time := Abs_Time; + Exit_Outer := True; + end if; + pragma Warnings (On); + + Request := To_Timespec (P_Abs_Time); + + Inner : loop + exit Outer + when Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level; + + Result := + pthread_cond_timedwait + (cond => Self_ID.Common.LL.CV'Access, + mutex => (if Single_Lock + then Single_RTS_Lock'Access + else Self_ID.Common.LL.L'Access), + abstime => Request'Access); + + case Result is + when ETIMEDOUT => + exit Outer when Exit_Outer; + Check_Time := Monotonic_Clock; + exit Inner; + + when 0 | EINTR => null; + + when others => + pragma Assert (False); - Result := - pthread_cond_timedwait - (cond => Self_ID.Common.LL.CV'Access, - mutex => (if Single_Lock - then Single_RTS_Lock'Access - else Self_ID.Common.LL.L'Access), - abstime => Request'Access); + end case; - Check_Time := Monotonic_Clock; - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; + exit Outer + when Abs_Time <= Check_Time or else Check_Time < Base_Time; - pragma Assert (Result in 0 | ETIMEDOUT | EINTR); - end loop; + end loop Inner; + end loop Outer; Self_ID.Common.State := Runnable; end if; @@ -277,6 +319,7 @@ package body Monotonic is Unlock_RTS; end if; + pragma Unreferenced (Result); Result := sched_yield; end Timed_Delay; --- /dev/null new file mode 100644 +++ gcc/ada/libgnat/s-optide.adb @@ -0,0 +1,84 @@ +------------------------------------------------------------------------------ +-- -- +-- GNAT RUN-TIME COMPONENTS -- +-- -- +-- S Y S T E M . O S _ P R I M I T I V E S. T I M E D _ D E L A Y -- +-- -- +-- B o d y -- +-- -- +-- Copyright (C) 2012-2018, AdaCore -- +-- -- +-- 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- -- +-- ware Foundation; either version 3, or (at your option) any later ver- -- +-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- +-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- +-- or FITNESS FOR A PARTICULAR PURPOSE. -- +-- -- +-- As a special exception under Section 7 of GPL version 3, you are granted -- +-- additional permissions described in the GCC Runtime Library Exception, -- +-- version 3.1, as published by the Free Software Foundation. -- +-- -- +-- You should have received a copy of the GNU General Public License and -- +-- a copy of the GCC Runtime Library Exception along with this program; -- +-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- +-- . -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This is the Posix, Posix2008, and LynxOS version of this procedure. + +separate (System.OS_Primitives) +procedure Timed_Delay + (Time : Duration; + Mode : Integer) +is + Request : aliased timespec; + Remaind : aliased timespec; + Rel_Time : Duration; + Abs_Time : Duration; + Base_Time : constant Duration := Clock; + Check_Time : Duration := Base_Time; + Time_Chunk : Duration; + + Result : Integer; + pragma Unreferenced (Result); + +begin + if Mode = Relative then + Rel_Time := Time; + Abs_Time := Time + Check_Time; + else + Rel_Time := Time - Check_Time; + Abs_Time := Time; + end if; + + -- To keep a sensible Max_Sensible_Delay on a target whose system + -- maximum is less than sensible, we split the delay into manageable + -- chunks of time less than or equal to the Max_System_Delay. + + if Rel_Time > 0.0 then + Time_Chunk := Rel_Time; + loop + pragma Warnings (Off, "condition is always *"); + if Max_System_Delay < Max_Sensible_Delay and then + Time_Chunk > Max_System_Delay + then + Time_Chunk := Max_System_Delay; + end if; + pragma Warnings (On); + + Request := To_Timespec (Time_Chunk); + Result := nanosleep (Request'Access, Remaind'Access); + + Check_Time := Clock; + + exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; + + Time_Chunk := Abs_Time - Check_Time; + end loop; + end if; +end Timed_Delay; --- gcc/ada/libgnat/s-osprim.ads +++ gcc/ada/libgnat/s-osprim.ads @@ -52,6 +52,10 @@ package System.OS_Primitives is -- with 32-bit words, and possibly on some specific ports of GNAT), -- Duration'Last is used instead. + Max_System_Delay : constant Duration := Max_Sensible_Delay; + -- If the Max_System_Delay is larger it doesn't matter. Setting it equal + -- allows optimization of code in some targets delay functions. + procedure Initialize; -- Initialize global settings related to this package. This procedure -- should be called before any other subprograms in this package. Note --- gcc/ada/libgnat/s-osprim__lynxos.ads +++ gcc/ada/libgnat/s-osprim__lynxos.ads @@ -40,12 +40,24 @@ package System.OS_Primitives is pragma Preelaborate; - Max_Sensible_Delay : constant Duration := 16#10_0000.0#; - -- LynxOS does not support delays as long as half a year, so we set this to - -- a shorter, but still fairly long, duration. Experiments show that if - -- pthread_cond_timedwait is passed an abstime much greater than about - -- 2**21, it fails, returning EAGAIN. The cutoff is somewhere between - -- 16#20_8000.0# and 16#20_F000.0#. This behavior is not documented. + Max_Sensible_Delay : constant Duration := + Duration'Min (183 * 24 * 60 * 60.0, + Duration'Last); + -- Max of half a year delay, needed to prevent exceptions for large delay + -- values. It seems unlikely that any test will notice this restriction, + -- except in the case of applications setting the clock at run time (see + -- s-tastim.adb). Also note that a larger value might cause problems (e.g + -- overflow, or more likely OS limitation in the primitives used). In the + -- case where half a year is too long (which occurs in high integrity mode + -- with 32-bit words, and possibly on some specific ports of GNAT), + -- Duration'Last is used instead. + + Max_System_Delay : constant Duration := 2147483.0; + -- Note that Max_System_Delay is 2**31 / 1000 truncated. + -- LynxOS does not support delays as long as half a year, only the + -- number of seconds noted in Max_System_Delay, which is used to split + -- delays into chunks no larger than what the system can handle. This + -- maximum was found by experiment and is not documented. procedure Initialize; -- Initialize global settings related to this package. This procedure --- gcc/ada/libgnat/s-osprim__posix.adb +++ gcc/ada/libgnat/s-osprim__posix.adb @@ -127,38 +127,7 @@ package body System.OS_Primitives is procedure Timed_Delay (Time : Duration; Mode : Integer) - is - Request : aliased timespec; - Remaind : aliased timespec; - Rel_Time : Duration; - Abs_Time : Duration; - Base_Time : constant Duration := Clock; - Check_Time : Duration := Base_Time; - - Result : Integer; - pragma Unreferenced (Result); - - begin - if Mode = Relative then - Rel_Time := Time; - Abs_Time := Time + Check_Time; - else - Rel_Time := Time - Check_Time; - Abs_Time := Time; - end if; - - if Rel_Time > 0.0 then - loop - Request := To_Timespec (Rel_Time); - Result := nanosleep (Request'Access, Remaind'Access); - Check_Time := Clock; - - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - - Rel_Time := Abs_Time - Check_Time; - end loop; - end if; - end Timed_Delay; + is separate; ---------------- -- Initialize -- --- gcc/ada/libgnat/s-osprim__posix2008.adb +++ gcc/ada/libgnat/s-osprim__posix2008.adb @@ -127,38 +127,7 @@ package body System.OS_Primitives is procedure Timed_Delay (Time : Duration; Mode : Integer) - is - Request : aliased timespec; - Remaind : aliased timespec; - Rel_Time : Duration; - Abs_Time : Duration; - Base_Time : constant Duration := Clock; - Check_Time : Duration := Base_Time; - - Result : Integer; - pragma Unreferenced (Result); - - begin - if Mode = Relative then - Rel_Time := Time; - Abs_Time := Time + Check_Time; - else - Rel_Time := Time - Check_Time; - Abs_Time := Time; - end if; - - if Rel_Time > 0.0 then - loop - Request := To_Timespec (Rel_Time); - Result := nanosleep (Request'Access, Remaind'Access); - Check_Time := Clock; - - exit when Abs_Time <= Check_Time or else Check_Time < Base_Time; - - Rel_Time := Abs_Time - Check_Time; - end loop; - end if; - end Timed_Delay; + is separate; ---------------- -- Initialize --