1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . O S _ I N T E R F A C E --
10 -- Copyright (C) 1997-2002 Free Software Foundation --
12 -- GNARL 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 2, or (at your option) any later ver- --
15 -- sion. GNARL 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. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 ------------------------------------------------------------------------------
35 -- This is the VxWorks version.
37 -- This package encapsulates all direct interfaces to OS services
38 -- that are needed by children of System.
41 -- Turn off polling, we do not want ATC polling to take place during
42 -- tasking operations. It causes infinite loops and other problems.
44 package body System
.OS_Interface
is
46 use type Interfaces
.C
.int
;
48 Low_Priority
: constant := 255;
49 -- VxWorks native (default) lowest scheduling priority.
56 (set
: access sigset_t
;
57 sig
: access Signal
) return int
62 (set
: access sigset_t
; sigvalue
: System
.Address
) return int
;
63 pragma Import
(C
, sigwaitinfo
, "sigwaitinfo");
66 Result
:= sigwaitinfo
(set
, System
.Null_Address
);
69 sig
.all := Signal
(Result
);
81 function To_Duration
(TS
: timespec
) return Duration is
83 return Duration (TS
.ts_sec
) + Duration (TS
.ts_nsec
) / 10#
1#E9
;
90 function To_Timespec
(D
: Duration) return timespec
is
94 S
:= time_t
(Long_Long_Integer (D
));
95 F
:= D
- Duration (S
);
97 -- If F has negative value due to a round-up, adjust for positive F
104 return timespec
' (ts_sec => S,
105 ts_nsec => long (Long_Long_Integer (F * 10#1#E9)));
108 -------------------------
109 -- To_VxWorks_Priority --
110 -------------------------
112 function To_VxWorks_Priority (Priority : in int) return int is
114 return Low_Priority - Priority;
115 end To_VxWorks_Priority;
121 -- ??? - For now, we'll always get the system clock rate
122 -- since it is allowed to be changed during run-time in
123 -- VxWorks. A better method would be to provide an operation
124 -- to set it that so we can always know its value.
126 -- Another thing we should probably allow for is a resultant
127 -- tick count greater than int'Last. This should probably
128 -- be a procedure with two output parameters, one in the
129 -- range 0 .. int'Last, and another representing the overflow
132 function To_Clock_Ticks (D : Duration) return int is
133 Ticks : Long_Long_Integer;
134 Rate_Duration : Duration;
135 Ticks_Duration : Duration;
142 -- Ensure that the duration can be converted to ticks
143 -- at the current clock tick rate without overflowing.
145 Rate_Duration := Duration (sysClkRateGet);
147 if D > (Duration'Last / Rate_Duration) then
148 Ticks := Long_Long_Integer (int'Last);
150 Ticks_Duration := D * Rate_Duration;
151 Ticks := Long_Long_Integer (Ticks_Duration);
153 if Ticks_Duration > Duration (Ticks) then
157 if Ticks > Long_Long_Integer (int'Last) then
158 Ticks := Long_Long_Integer (int'Last);
165 end System.OS_Interface;