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-2012, 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 -- This is the Alpha/VMS version
35 with System
.OS_Primitives
;
36 with System
.Soft_Links
;
38 package body Ada
.Calendar
.Delays
is
40 package OSP
renames System
.OS_Primitives
;
41 package TSL
renames System
.Soft_Links
;
43 use type TSL
.Timed_Delay_Call
;
45 -----------------------
46 -- Local Subprograms --
47 -----------------------
49 procedure Timed_Delay_NT
(Time
: Duration; Mode
: Integer);
50 -- Timed delay procedure used when no tasking is active
56 procedure Delay_For
(D
: Duration) is
59 (Duration'Min (D
, OSP
.Max_Sensible_Delay
), OSP
.Relative
);
66 procedure Delay_Until
(T
: Time
) is
68 TSL
.Timed_Delay
.all (To_Duration
(T
), OSP
.Absolute_Calendar
);
75 function To_Duration
(T
: Time
) return Duration is
76 Safe_Ada_High
: constant Time
:= Time_Of
(2250, 1, 1, 0.0);
77 -- A value distant enough to emulate "end of time" but which does not
80 Safe_T
: constant Time
:=
81 (if T
> Safe_Ada_High
then Safe_Ada_High
else T
);
84 return OSP
.To_Duration
(OSP
.OS_Time
(Safe_T
), OSP
.Absolute_Calendar
);
91 procedure Timed_Delay_NT
(Time
: Duration; Mode
: Integer) is
93 OSP
.Timed_Delay
(Time
, Mode
);
97 -- Set up the Timed_Delay soft link to the non tasking version if it has
98 -- not been already set. If tasking is present, Timed_Delay has already set
99 -- this soft link, or this will be overridden during the elaboration of
100 -- System.Tasking.Initialization
102 if TSL
.Timed_Delay
= null then
103 TSL
.Timed_Delay
:= Timed_Delay_NT
'Access;
105 end Ada
.Calendar
.Delays
;