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-2018, 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
40package System.OS_Primitives is
41   pragma Preelaborate;
42
43   Max_Sensible_Delay : constant Duration := 16#10_0000.0#;
44   --  LynxOS does not support delays as long as half a year, so we set this to
45   --  a shorter, but still fairly long, duration. Experiments show that if
46   --  pthread_cond_timedwait is passed an abstime much greater than about
47   --  2**21, it fails, returning EAGAIN. The cutoff is somewhere between
48   --  16#20_8000.0# and 16#20_F000.0#. This behavior is not documented.
49
50   procedure Initialize;
51   --  Initialize global settings related to this package. This procedure
52   --  should be called before any other subprograms in this package. Note
53   --  that this procedure can be called several times.
54
55   function Clock return Duration;
56   pragma Inline (Clock);
57   --  Returns "absolute" time, represented as an offset relative to "the
58   --  Epoch", which is Jan 1, 1970 00:00:00 UTC on UNIX systems. This
59   --  implementation is affected by system's clock changes.
60
61   Relative          : constant := 0;
62   Absolute_Calendar : constant := 1;
63   Absolute_RT       : constant := 2;
64   --  Values for Mode call below. Note that the compiler (exp_ch9.adb) relies
65   --  on these values. So any change here must be reflected in corresponding
66   --  changes in the compiler.
67
68   procedure Timed_Delay (Time : Duration; Mode : Integer);
69   --  Implements the semantics of the delay statement when no tasking is used
70   --  in the application.
71   --
72   --    Mode is one of the three values above
73   --
74   --    Time is a relative or absolute duration value, depending on Mode.
75   --
76   --  Note that currently Ada.Real_Time always uses the tasking run time,
77   --  so this procedure should never be called with Mode set to Absolute_RT.
78   --  This may change in future or bare board implementations.
79
80end System.OS_Primitives;
81