annotate gcc/ada/libgnat/a-caldel.adb @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A D A . C A L E N D A R . D E L A Y S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1991-2017, Florida State University --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
10 -- Copyright (C) 1995-2018, AdaCore --
111
kono
parents:
diff changeset
11 -- --
kono
parents:
diff changeset
12 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
13 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
14 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
17 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
18 -- --
kono
parents:
diff changeset
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
20 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
21 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
22 -- --
kono
parents:
diff changeset
23 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
24 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
26 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
27 -- --
kono
parents:
diff changeset
28 -- GNARL was developed by the GNARL team at Florida State University. --
kono
parents:
diff changeset
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
kono
parents:
diff changeset
30 -- --
kono
parents:
diff changeset
31 ------------------------------------------------------------------------------
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 with System.OS_Primitives;
kono
parents:
diff changeset
34 with System.Soft_Links;
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 package body Ada.Calendar.Delays is
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 package OSP renames System.OS_Primitives;
kono
parents:
diff changeset
39 package SSL renames System.Soft_Links;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 use type SSL.Timed_Delay_Call;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 -- Earlier, System.Time_Operations was used to implement the following
kono
parents:
diff changeset
44 -- operations. The idea was to avoid sucking in the tasking packages. This
kono
parents:
diff changeset
45 -- did not work. Logically, we can't have it both ways. There is no way to
kono
parents:
diff changeset
46 -- implement time delays that will have correct task semantics without
kono
parents:
diff changeset
47 -- reference to the tasking run-time system. To achieve this goal, we now
kono
parents:
diff changeset
48 -- use soft links.
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 -----------------------
kono
parents:
diff changeset
51 -- Local Subprograms --
kono
parents:
diff changeset
52 -----------------------
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Timed_Delay_NT (Time : Duration; Mode : Integer);
kono
parents:
diff changeset
55 -- Timed delay procedure used when no tasking is active
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 ---------------
kono
parents:
diff changeset
58 -- Delay_For --
kono
parents:
diff changeset
59 ---------------
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 procedure Delay_For (D : Duration) is
kono
parents:
diff changeset
62 begin
kono
parents:
diff changeset
63 SSL.Timed_Delay.all (Duration'Min (D, OSP.Max_Sensible_Delay),
kono
parents:
diff changeset
64 OSP.Relative);
kono
parents:
diff changeset
65 end Delay_For;
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -----------------
kono
parents:
diff changeset
68 -- Delay_Until --
kono
parents:
diff changeset
69 -----------------
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 procedure Delay_Until (T : Time) is
kono
parents:
diff changeset
72 D : constant Duration := To_Duration (T);
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 begin
kono
parents:
diff changeset
75 SSL.Timed_Delay.all (D, OSP.Absolute_Calendar);
kono
parents:
diff changeset
76 end Delay_Until;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 --------------------
kono
parents:
diff changeset
79 -- Timed_Delay_NT --
kono
parents:
diff changeset
80 --------------------
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 procedure Timed_Delay_NT (Time : Duration; Mode : Integer) is
kono
parents:
diff changeset
83 begin
kono
parents:
diff changeset
84 OSP.Timed_Delay (Time, Mode);
kono
parents:
diff changeset
85 end Timed_Delay_NT;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 -----------------
kono
parents:
diff changeset
88 -- To_Duration --
kono
parents:
diff changeset
89 -----------------
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 function To_Duration (T : Time) return Duration is
kono
parents:
diff changeset
92 begin
kono
parents:
diff changeset
93 -- Since time has multiple representations on different platforms, a
kono
parents:
diff changeset
94 -- target independent operation in Ada.Calendar is used to perform
kono
parents:
diff changeset
95 -- this conversion.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 return Delay_Operations.To_Duration (T);
kono
parents:
diff changeset
98 end To_Duration;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 begin
kono
parents:
diff changeset
101 -- Set up the Timed_Delay soft link to the non tasking version if it has
kono
parents:
diff changeset
102 -- not been already set. If tasking is present, Timed_Delay has already set
kono
parents:
diff changeset
103 -- this soft link, or this will be overridden during the elaboration of
kono
parents:
diff changeset
104 -- System.Tasking.Initialization
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 if SSL.Timed_Delay = null then
kono
parents:
diff changeset
107 SSL.Timed_Delay := Timed_Delay_NT'Access;
kono
parents:
diff changeset
108 end if;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 end Ada.Calendar.Delays;