* c-decl.c (duplicate_decls): Conditionalize DECL_SAVED_TREE copy.
[official-gcc.git] / gcc / ada / 5vosprim.adb
blobcde0e3b49d03e23db930c03eb1345130471f5b65
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . O S _ P R I M I T I V E S --
6 -- --
7 -- B o d y --
8 -- --
9 -- $Revision: 1.2 $
10 -- --
11 -- Copyright (C) 1998-2001 Free Software Foundation, Inc. --
12 -- --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
30 -- --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
34 -- --
35 ------------------------------------------------------------------------------
37 -- This is the OpenVMS/Alpha version of this file
39 with System.Aux_DEC;
41 package body System.OS_Primitives is
43 --------------------------------------
44 -- Local functions and declarations --
45 --------------------------------------
47 function Get_GMToff return Integer;
48 pragma Import (C, Get_GMToff, "get_gmtoff");
49 -- Get the offset from GMT for this timezone
51 VMS_Epoch_Offset : constant Long_Integer :=
52 10_000_000 *
53 (3_506_716_800 + Long_Integer (Get_GMToff));
54 -- The offset between the Unix Epoch and the VMS Epoch
56 subtype Cond_Value_Type is System.Aux_DEC.Unsigned_Longword;
57 -- Condition Value return type
59 ----------------
60 -- Sys_Schdwk --
61 ----------------
63 -- Schedule Wakeup
65 -- status = returned status
66 -- pidadr = address of process id to be woken up
67 -- prcnam = name of process to be woken up
68 -- daytim = time to wake up
69 -- reptim = repitition interval of wakeup calls
72 procedure Sys_Schdwk
74 Status : out Cond_Value_Type;
75 Pidadr : in Address := Null_Address;
76 Prcnam : in String := String'Null_Parameter;
77 Daytim : in Long_Integer;
78 Reptim : in Long_Integer := Long_Integer'Null_Parameter
81 pragma Interface (External, Sys_Schdwk);
82 -- VMS system call to schedule a wakeup event
83 pragma Import_Valued_Procedure
84 (Sys_Schdwk, "SYS$SCHDWK",
85 (Cond_Value_Type, Address, String, Long_Integer, Long_Integer),
86 (Value, Value, Descriptor (S), Reference, Reference)
89 ----------------
90 -- Sys_Gettim --
91 ----------------
93 -- Get System Time
95 -- status = returned status
96 -- tim = current system time
99 procedure Sys_Gettim
101 Status : out Cond_Value_Type;
102 Tim : out OS_Time
104 -- VMS system call to get the current system time
105 pragma Interface (External, Sys_Gettim);
106 pragma Import_Valued_Procedure
107 (Sys_Gettim, "SYS$GETTIM",
108 (Cond_Value_Type, OS_Time),
109 (Value, Reference)
112 ---------------
113 -- Sys_Hiber --
114 ---------------
116 -- Hibernate (until woken up)
118 -- status = returned status
121 procedure Sys_Hiber (Status : out Cond_Value_Type);
122 -- VMS system call to hibernate the current process
123 pragma Interface (External, Sys_Hiber);
124 pragma Import_Valued_Procedure
125 (Sys_Hiber, "SYS$HIBER",
126 (Cond_Value_Type),
127 (Value)
130 -----------
131 -- Clock --
132 -----------
134 function OS_Clock return OS_Time is
135 Status : Cond_Value_Type;
136 T : OS_Time;
137 begin
138 Sys_Gettim (Status, T);
139 return (T);
140 end OS_Clock;
142 -----------
143 -- Clock --
144 -----------
146 function Clock return Duration is
147 begin
148 return To_Duration (OS_Clock, Absolute_Calendar);
149 end Clock;
151 ---------------------
152 -- Monotonic_Clock --
153 ---------------------
155 function Monotonic_Clock return Duration renames Clock;
157 -----------------
158 -- Timed_Delay --
159 -----------------
161 procedure Timed_Delay
162 (Time : Duration;
163 Mode : Integer)
165 Sleep_Time : OS_Time;
166 Status : Cond_Value_Type;
168 begin
169 Sleep_Time := To_OS_Time (Time, Mode);
170 Sys_Schdwk (Status => Status, Daytim => Sleep_Time);
171 Sys_Hiber (Status);
172 end Timed_Delay;
174 -----------------
175 -- To_Duration --
176 -----------------
178 function To_Duration (T : OS_Time; Mode : Integer) return Duration is
179 begin
180 return Duration'Fixed_Value (T - VMS_Epoch_Offset) * 100;
181 end To_Duration;
183 ----------------
184 -- To_OS_Time --
185 ----------------
187 function To_OS_Time (D : Duration; Mode : Integer) return OS_Time is
188 begin
189 if Mode = Relative then
190 return -(Long_Integer'Integer_Value (D) / 100);
191 else
192 return Long_Integer'Integer_Value (D) / 100 + VMS_Epoch_Offset;
193 end if;
194 end To_OS_Time;
196 end System.OS_Primitives;