1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- A D A . C A L E N D A R . D E L A Y S --
9 -- Copyright (C) 1991-1994, Florida State University --
10 -- Copyright (C) 1995-2010, AdaCore --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 3, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. --
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
20 -- additional permissions described in the GCC Runtime Library Exception, --
21 -- version 3.1, as published by the Free Software Foundation. --
23 -- You should have received a copy of the GNU General Public License and --
24 -- a copy of the GCC Runtime Library Exception along with this program; --
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
26 -- <http://www.gnu.org/licenses/>. --
28 -- GNARL was developed by the GNARL team at Florida State University. --
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 ------------------------------------------------------------------------------
33 with System
.OS_Primitives
;
34 with System
.Soft_Links
;
36 with System
.Parameters
;
38 package body Ada
.Calendar
.Delays
is
40 package OSP
renames System
.OS_Primitives
;
41 package SSL
renames System
.Soft_Links
;
43 use type SSL
.Timed_Delay_Call
;
47 -- Earlier, System.Time_Operations was used to implement the following
48 -- operations. The idea was to avoid sucking in the tasking packages. This
49 -- did not work. Logically, we can't have it both ways. There is no way to
50 -- implement time delays that will have correct task semantics without
51 -- reference to the tasking run-time system. To achieve this goal, we now
54 -----------------------
55 -- Local Subprograms --
56 -----------------------
58 procedure Timed_Delay_NT
(Time
: Duration; Mode
: Integer);
59 -- Timed delay procedure used when no tasking is active
65 procedure Delay_For
(D
: Duration) is
67 if System
.Parameters
.Runtime_Traces
then
68 Send_Trace_Info
(W_Delay
, D
);
71 SSL
.Timed_Delay
.all (Duration'Min (D
, OSP
.Max_Sensible_Delay
),
74 if System
.Parameters
.Runtime_Traces
then
75 Send_Trace_Info
(M_Delay
, D
);
83 procedure Delay_Until
(T
: Time
) is
84 D
: constant Duration := To_Duration
(T
);
87 if System
.Parameters
.Runtime_Traces
then
88 Send_Trace_Info
(WU_Delay
, D
);
91 SSL
.Timed_Delay
.all (D
, OSP
.Absolute_Calendar
);
93 if System
.Parameters
.Runtime_Traces
then
94 Send_Trace_Info
(M_Delay
, D
);
102 procedure Timed_Delay_NT
(Time
: Duration; Mode
: Integer) is
104 OSP
.Timed_Delay
(Time
, Mode
);
111 function To_Duration
(T
: Time
) return Duration is
113 -- Since time has multiple representations on different platforms, a
114 -- target independent operation in Ada.Calendar is used to perform
117 return Delay_Operations
.To_Duration
(T
);
121 -- Set up the Timed_Delay soft link to the non tasking version if it has
122 -- not been already set. If tasking is present, Timed_Delay has already set
123 -- this soft link, or this will be overridden during the elaboration of
124 -- System.Tasking.Initialization
126 if SSL
.Timed_Delay
= null then
127 SSL
.Timed_Delay
:= Timed_Delay_NT
'Access;
130 end Ada
.Calendar
.Delays
;