g-os_lib.ads (Current_Time): New function.

2007-04-06  Pascal Obry  <obry@adacore.com>
	    Thomas Quinot  <quinot@adacore.com>

	* g-os_lib.ads (Current_Time): New function. Returns the current
	system time as an OS_Time value.

	* s-osprim.ads (Clock): Add more precise definition of UNIX epoch.
	(Monotonic_Clock): Same.

From-SVN: r123547
This commit is contained in:
Pascal Obry 2007-04-06 11:16:52 +02:00 committed by Arnaud Charlet
parent 2c851ddd1c
commit 320ae22ae0
2 changed files with 39 additions and 34 deletions

View File

@ -114,6 +114,9 @@ package GNAT.OS_Lib is
subtype Second_Type is Integer range 0 .. 59;
-- Declarations similar to those in Calendar, breaking down the time
function Current_Time return OS_Time;
-- Return the system clock value as OS_Time
function GM_Year (Date : OS_Time) return Year_Type;
function GM_Month (Date : OS_Time) return Month_Type;
function GM_Day (Date : OS_Time) return Day_Type;
@ -131,15 +134,16 @@ package GNAT.OS_Lib is
-- to create accesses to any of these functions.
procedure GM_Split
(Date : OS_Time;
Year : out Year_Type;
Month : out Month_Type;
Day : out Day_Type;
Hour : out Hour_Type;
Minute : out Minute_Type;
Second : out Second_Type);
-- Analogous to the routine of similar name in Calendar, takes an OS_Time
-- and splits it into its component parts with obvious meanings.
(Date : OS_Time;
Year : out Year_Type;
Month : out Month_Type;
Day : out Day_Type;
Hour : out Hour_Type;
Minute : out Minute_Type;
Second : out Second_Type);
-- Analogous to the Split routine in Ada.Calendar, takes an OS_Time
-- and provides a representation of it as a set of component parts,
-- to be interpreted as a date point in UTC.
----------------
-- File Stuff --
@ -836,6 +840,7 @@ package GNAT.OS_Lib is
private
pragma Import (C, Path_Separator, "__gnat_path_separator");
pragma Import (C, Directory_Separator, "__gnat_dir_separator");
pragma Import (C, Current_Time, "__gnat_current_time");
type OS_Time is new Long_Integer;
-- Type used for timestamps in the compiler. This type is used to hold

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1998-2005 Free Software Foundation, Inc. --
-- Copyright (C) 1998-2006, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -45,49 +45,49 @@ package System.OS_Primitives is
Max_Sensible_Delay : constant Duration :=
Duration'Min (183 * 24 * 60 * 60.0,
Duration'Last);
-- Max of half a year delay, needed to prevent exceptions for large
-- delay values. It seems unlikely that any test will notice this
-- restriction, except in the case of applications setting the clock at
-- at run time (see s-tastim.adb). Also note that a larger value might
-- cause problems (e.g overflow, or more likely OS limitation in the
-- primitives used). In the case where half a year is too long (which
-- occurs in high integrity mode with 32-bit words, and possibly on
-- some specific ports of GNAT), Duration'Last is used instead.
-- Max of half a year delay, needed to prevent exceptions for large delay
-- values. It seems unlikely that any test will notice this restriction,
-- except in the case of applications setting the clock at at run time (see
-- s-tastim.adb). Also note that a larger value might cause problems (e.g
-- overflow, or more likely OS limitation in the primitives used). In the
-- case where half a year is too long (which occurs in high integrity mode
-- with 32-bit words, and possibly on some specific ports of GNAT),
-- Duration'Last is used instead.
procedure Initialize;
-- Initialize global settings related to this package.
-- This procedure should be called before any other subprograms in
-- this package. Note that this procedure can be called several times.
-- Initialize global settings related to this package. This procedure
-- should be called before any other subprograms in this package. Note
-- that this procedure can be called several times.
function Clock return Duration;
pragma Inline (Clock);
-- Returns "absolute" time, represented as an offset
-- relative to "the Epoch", which is Jan 1, 1970 on unixes.
-- This implementation is affected by system's clock changes.
-- Returns "absolute" time, represented as an offset relative to "the
-- Epoch", which is Jan 1, 1970 00:00:00 UTC on UNIX systems. This
-- implementation is affected by system's clock changes.
function Monotonic_Clock return Duration;
pragma Inline (Monotonic_Clock);
-- Returns "absolute" time, represented as an offset
-- relative to "the Epoch", which is Jan 1, 1970.
-- This clock implementation is immune to the system's clock changes.
-- Returns "absolute" time, represented as an offset relative to "the Unix
-- Epoch", which is Jan 1, 1970 00:00:00 UTC. This clock implementation is
-- immune to the system's clock changes.
Relative : constant := 0;
Absolute_Calendar : constant := 1;
Absolute_RT : constant := 2;
-- Values for Mode call below. Note that the compiler (exp_ch9.adb)
-- relies on these values. So any change here must be reflected in
-- corresponding changes in the compiler.
-- Values for Mode call below. Note that the compiler (exp_ch9.adb) relies
-- on these values. So any change here must be reflected in corresponding
-- changes in the compiler.
procedure Timed_Delay (Time : Duration; Mode : Integer);
-- Implements the semantics of the delay statement when no tasking is
-- used in the application.
-- Implements the semantics of the delay statement when no tasking is used
-- in the application.
--
-- Mode is one of the three values above
--
-- Time is a relative or absolute duration value, depending on Mode.
--
-- Note that currently Ada.Real_Time always uses the tasking run time, so
-- this procedure should never be called with Mode set to Absolute_RT.
-- Note that currently Ada.Real_Time always uses the tasking run time,
-- so this procedure should never be called with Mode set to Absolute_RT.
-- This may change in future or bare board implementations.
end System.OS_Primitives;