1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . O S _ P R I M I T I V E S --
11 -- Copyright (C) 1998-2001 Free Software Foundation, Inc. --
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. --
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. --
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). --
35 ------------------------------------------------------------------------------
37 -- This is the OpenVMS/Alpha version of this file
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 :=
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
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
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
)
95 -- status = returned status
96 -- tim = current system time
101 Status
: out Cond_Value_Type
;
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
),
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",
134 function OS_Clock
return OS_Time
is
135 Status
: Cond_Value_Type
;
138 Sys_Gettim
(Status
, T
);
146 function Clock
return Duration is
148 return To_Duration
(OS_Clock
, Absolute_Calendar
);
151 ---------------------
152 -- Monotonic_Clock --
153 ---------------------
155 function Monotonic_Clock
return Duration renames Clock
;
161 procedure Timed_Delay
165 Sleep_Time
: OS_Time
;
166 Status
: Cond_Value_Type
;
169 Sleep_Time
:= To_OS_Time
(Time
, Mode
);
170 Sys_Schdwk
(Status
=> Status
, Daytim
=> Sleep_Time
);
178 function To_Duration
(T
: OS_Time
; Mode
: Integer) return Duration is
180 return Duration'Fixed_Value (T
- VMS_Epoch_Offset
) * 100;
187 function To_OS_Time
(D
: Duration; Mode
: Integer) return OS_Time
is
189 if Mode
= Relative
then
190 return -(Long_Integer'Integer_Value (D
) / 100);
192 return Long_Integer'Integer_Value (D
) / 100 + VMS_Epoch_Offset
;
196 end System
.OS_Primitives
;