s-rannum.adb, [...] (Get_Seed): Return Unsigned_64 rather than Duration.

2012-01-30  Thomas Quinot  <quinot@adacore.com>

	* s-rannum.adb, s-ransee.adb, s-ransee.ads (Get_Seed): Return
	Unsigned_64 rather than Duration.
	(System.Random_Numbers.Reset): Use full value of seed
	(do not truncate sub-second bits).

2012-01-30  Thomas Quinot  <quinot@adacore.com>

	* sem_cat.adb, sem_ch12.adb: Minor reformatting.

From-SVN: r183708
This commit is contained in:
Thomas Quinot 2012-01-30 11:39:58 +00:00 committed by Arnaud Charlet
parent 6d9e03cb09
commit 7873037fd8
6 changed files with 32 additions and 15 deletions

View File

@ -1,3 +1,14 @@
2012-01-30 Thomas Quinot <quinot@adacore.com>
* s-rannum.adb, s-ransee.adb, s-ransee.ads (Get_Seed): Return
Unsigned_64 rather than Duration.
(System.Random_Numbers.Reset): Use full value of seed
(do not truncate sub-second bits).
2012-01-30 Thomas Quinot <quinot@adacore.com>
* sem_cat.adb, sem_ch12.adb: Minor reformatting.
2012-01-30 Yannick Moy <moy@adacore.com>
* gnat_ugn.texi: Minor correction of GNAT UG, to take into

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2007-2011, Free Software Foundation, Inc. --
-- Copyright (C) 2007-2012, Free Software Foundation, Inc. --
-- --
-- GNAT 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- --
@ -480,12 +480,8 @@ package body System.Random_Numbers is
-----------
procedure Reset (Gen : Generator) is
X : constant Unsigned_32 :=
Unsigned_32'Mod (Unsigned_64 (Random_Seed.Get_Seed) * 64);
-- Why * 64 ???
begin
Init (Gen, X);
Init (Gen, Unsigned_32'Mod (Random_Seed.Get_Seed));
end Reset;
procedure Reset (Gen : Generator; Initiator : Integer_32) is

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2011, Free Software Foundation, Inc. --
-- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
-- --
-- GNAT 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- --
@ -32,16 +32,24 @@
-- Version used on all systems except Ravenscar where Calendar is unavailable
with Ada.Calendar; use Ada.Calendar;
with Ada.Unchecked_Conversion;
package body System.Random_Seed is
Y2K : constant Time :=
Time_Of (Year => 2000, Month => 1, Day => 1, Seconds => 0.0);
-- First day of Year 2000, to get a duration.
-- First day of Year 2000, to get a duration
function Get_Seed return Duration is
function To_U64 is
new Ada.Unchecked_Conversion (Duration, Interfaces.Unsigned_64);
--------------
-- Get_Seed --
--------------
function Get_Seed return Interfaces.Unsigned_64 is
begin
return Clock - Y2K;
return To_U64 (Clock - Y2K);
end Get_Seed;
end System.Random_Seed;

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
-- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
-- --
-- GNAT 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- --
@ -39,9 +39,11 @@
-- This is required because Ada.Calendar cannot be used on Ravenscar, but
-- Ada.Real_Time drags in the whole tasking runtime on regular platforms.
with Interfaces;
package System.Random_Seed is
function Get_Seed return Duration;
function Get_Seed return Interfaces.Unsigned_64;
-- Get a seed based on the clock
end System.Random_Seed;

View File

@ -491,8 +491,8 @@ package body Sem_Cat is
Nkind (Unit (Cunit (Current_Sem_Unit)));
begin
-- There are no constraints on body of remote_call_interface or
-- remote_types packages.
-- There are no constraints on the body of Remote_Call_Interface or
-- Remote_Types packages.
return (Unit_Entity /= Standard_Standard)
and then (Is_Preelaborated (Unit_Entity)

View File

@ -9410,7 +9410,7 @@ package body Sem_Ch12 is
Set_Corresponding_Generic_Association (Decl_Node, Act_Assoc);
-- The analysis of the actual may produce insert_action nodes, so
-- The analysis of the actual may produce Insert_Action nodes, so
-- the declaration must have a context in which to attach them.
Append (Decl_Node, List);