| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT 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 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1998-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNARL is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNARL was developed by the GNARL team at Florida State University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- This package provides low level primitives used to implement clock and |
| 33 |
-- delays in non tasking applications, for LynxOS. |
| 34 |
|
| 35 |
-- The choice of the real clock/delay implementation (depending on whether |
| 36 |
-- tasking is involved or not) is done via soft links (see s-soflin.ads) |
| 37 |
|
| 38 |
-- NEVER add any dependency to tasking packages here |
| 39 |
|
| 40 |
package System.OS_Primitives is |
| 41 |
pragma Preelaborate; |
| 42 |
|
| 43 |
Max_Sensible_Delay : constant Duration := |
| 44 |
Duration'Min (183 * 24 * 60 * 60.0, |
| 45 |
Duration'Last); |
| 46 |
-- Max of half a year delay, needed to prevent exceptions for large delay |
| 47 |
-- values. It seems unlikely that any test will notice this restriction, |
| 48 |
-- except in the case of applications setting the clock at run time (see |
| 49 |
-- s-tastim.adb). Also note that a larger value might cause problems (e.g |
| 50 |
-- overflow, or more likely OS limitation in the primitives used). In the |
| 51 |
-- case where half a year is too long (which occurs in high integrity mode |
| 52 |
-- with 32-bit words, and possibly on some specific ports of GNAT), |
| 53 |
-- Duration'Last is used instead. |
| 54 |
|
| 55 |
Max_System_Delay : constant Duration := 2147483.0; |
| 56 |
-- Note that Max_System_Delay is 2**31 / 1000 truncated. |
| 57 |
-- LynxOS does not support delays as long as half a year, only the |
| 58 |
-- number of seconds noted in Max_System_Delay, which is used to split |
| 59 |
-- delays into chunks no larger than what the system can handle. This |
| 60 |
-- maximum was found by experiment and is not documented. |
| 61 |
|
| 62 |
procedure Initialize; |
| 63 |
-- Initialize global settings related to this package. This procedure |
| 64 |
-- should be called before any other subprograms in this package. Note |
| 65 |
-- that this procedure can be called several times. |
| 66 |
|
| 67 |
function Clock return Duration; |
| 68 |
pragma Inline (Clock); |
| 69 |
-- Returns "absolute" time, represented as an offset relative to "the |
| 70 |
-- Epoch", which is Jan 1, 1970 00:00:00 UTC on UNIX systems. This |
| 71 |
-- implementation is affected by system's clock changes. |
| 72 |
|
| 73 |
Relative : constant := 0; |
| 74 |
Absolute_Calendar : constant := 1; |
| 75 |
Absolute_RT : constant := 2; |
| 76 |
-- Values for Mode call below. Note that the compiler (exp_ch9.adb) relies |
| 77 |
-- on these values. So any change here must be reflected in corresponding |
| 78 |
-- changes in the compiler. |
| 79 |
|
| 80 |
procedure Timed_Delay (Time : Duration; Mode : Integer); |
| 81 |
-- Implements the semantics of the delay statement when no tasking is used |
| 82 |
-- in the application. |
| 83 |
-- |
| 84 |
-- Mode is one of the three values above |
| 85 |
-- |
| 86 |
-- Time is a relative or absolute duration value, depending on Mode. |
| 87 |
-- |
| 88 |
-- Note that currently Ada.Real_Time always uses the tasking run time, |
| 89 |
-- so this procedure should never be called with Mode set to Absolute_RT. |
| 90 |
-- This may change in future or bare board implementations. |
| 91 |
|
| 92 |
end System.OS_Primitives; |