Commit c51f5910 by Arnaud Charlet

[multiple changes]

2014-01-24  Eric Botcazou  <ebotcazou@adacore.com>

	* set_targ.adb: Set Short_Enums.
	* gcc-interface/lang.opt (fshort-enums): New option.
	* gcc-interface/misc.c (gnat_handle_option): Handle it.
	(gnat_post_options): Do not modify the global settings.

2014-01-24  Robert Dewar  <dewar@adacore.com>

	* g-rannum.ads, g-rannum.adb (Random_Ordinary_Fixed): New generic
	function.
	(Random_Decimal_Fixed): New generic function.
	* s-rannum.ads: Minor comment clarifications.

From-SVN: r207049
parent f9e2a506
2014-01-24 Eric Botcazou <ebotcazou@adacore.com>
* set_targ.adb: Set Short_Enums.
* gcc-interface/lang.opt (fshort-enums): New option.
* gcc-interface/misc.c (gnat_handle_option): Handle it.
(gnat_post_options): Do not modify the global settings.
2014-01-24 Robert Dewar <dewar@adacore.com>
* g-rannum.ads, g-rannum.adb (Random_Ordinary_Fixed): New generic
function.
(Random_Decimal_Fixed): New generic function.
* s-rannum.ads: Minor comment clarifications.
2014-01-24 Robert Dewar <dewar@adacore.com> 2014-01-24 Robert Dewar <dewar@adacore.com>
* back_end.adb: Remove Short_Enums handling (handled in * back_end.adb: Remove Short_Enums handling (handled in
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- -- Copyright (C) 2007-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Ada.Numerics.Long_Elementary_Functions; with Ada.Numerics.Long_Elementary_Functions;
use Ada.Numerics.Long_Elementary_Functions; use Ada.Numerics.Long_Elementary_Functions;
with Ada.Unchecked_Conversion; with Ada.Unchecked_Conversion;
with System.Random_Numbers; use System.Random_Numbers; with System.Random_Numbers; use System.Random_Numbers;
package body GNAT.Random_Numbers is package body GNAT.Random_Numbers is
...@@ -87,6 +88,40 @@ package body GNAT.Random_Numbers is ...@@ -87,6 +88,40 @@ package body GNAT.Random_Numbers is
return F (Gen.Rep, Min, Max); return F (Gen.Rep, Min, Max);
end Random_Discrete; end Random_Discrete;
--------------------------
-- Random_Decimal_Fixed --
--------------------------
function Random_Decimal_Fixed
(Gen : Generator;
Min : Result_Subtype := Default_Min;
Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype
is
subtype IntV is Integer_64 range
Integer_64'Integer_Value (Min) ..
Integer_64'Integer_Value (Max);
function R is new Random_Discrete (Integer_64, IntV'First);
begin
return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last));
end Random_Decimal_Fixed;
---------------------------
-- Random_Ordinary_Fixed --
---------------------------
function Random_Ordinary_Fixed
(Gen : Generator;
Min : Result_Subtype := Default_Min;
Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype
is
subtype IntV is Integer_64 range
Integer_64'Integer_Value (Min) ..
Integer_64'Integer_Value (Max);
function R is new Random_Discrete (Integer_64, IntV'First);
begin
return Result_Subtype'Fixed_Value (R (Gen, IntV'First, IntV'Last));
end Random_Ordinary_Fixed;
------------ ------------
-- Random -- -- Random --
------------ ------------
...@@ -137,7 +172,7 @@ package body GNAT.Random_Numbers is ...@@ -137,7 +172,7 @@ package body GNAT.Random_Numbers is
-- Random_Float -- -- Random_Float --
------------------ ------------------
function Random_Float (Gen : Generator) return Result_Subtype is function Random_Float (Gen : Generator) return Result_Subtype is
function F is new System.Random_Numbers.Random_Float (Result_Subtype); function F is new System.Random_Numbers.Random_Float (Result_Subtype);
begin begin
return F (Gen.Rep); return F (Gen.Rep);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2007-2009 Free Software Foundation, Inc. -- -- Copyright (C) 2007-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -79,9 +79,27 @@ package GNAT.Random_Numbers is ...@@ -79,9 +79,27 @@ package GNAT.Random_Numbers is
-- Returns pseudo-random numbers uniformly distributed on Min .. Max -- Returns pseudo-random numbers uniformly distributed on Min .. Max
generic generic
type Result_Subtype is delta <>;
Default_Min : Result_Subtype := 0.0;
function Random_Ordinary_Fixed
(Gen : Generator;
Min : Result_Subtype := Default_Min;
Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype;
-- Returns pseudo-random numbers uniformly distributed on Min .. Max
generic
type Result_Subtype is delta <> digits <>;
Default_Min : Result_Subtype := 0.0;
function Random_Decimal_Fixed
(Gen : Generator;
Min : Result_Subtype := Default_Min;
Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype;
-- Returns pseudo-random numbers uniformly distributed on Min .. Max
generic
type Result_Subtype is digits <>; type Result_Subtype is digits <>;
function Random_Float (Gen : Generator) return Result_Subtype; function Random_Float (Gen : Generator) return Result_Subtype;
-- Returns pseudo-random numbers uniformly distributed on [0 .. 1) -- Returns pseudo-random numbers uniformly distributed on [0.0 .. 1.0)
function Random_Gaussian (Gen : Generator) return Long_Float; function Random_Gaussian (Gen : Generator) return Long_Float;
function Random_Gaussian (Gen : Generator) return Float; function Random_Gaussian (Gen : Generator) return Float;
......
; Options for the Ada front end. ; Options for the Ada front end.
; Copyright (C) 2003, 2007, 2008, 2010, 2011, 2012 ; Copyright (C) 2003-2013 Free Software Foundation, Inc.
; Free Software Foundation, Inc.
; ;
; This file is part of GCC. ; This file is part of GCC.
; ;
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
; along with GCC; see the file COPYING3. If not see ; along with GCC; see the file COPYING3. If not see
; <http://www.gnu.org/licenses/>. ; <http://www.gnu.org/licenses/>.
; See the GCC internals manual for a description of this file's format. ; See the GCC internals manual for a description of this file's format.
; Please try to keep this file in ASCII collating order. ; Please try to keep this file in ASCII collating order.
...@@ -74,6 +72,10 @@ fRTS= ...@@ -74,6 +72,10 @@ fRTS=
Ada AdaWhy AdaSCIL Joined RejectNegative Ada AdaWhy AdaSCIL Joined RejectNegative
Select the runtime Select the runtime
fshort-enums
Ada AdaWhy AdaSCIL
Use the narrowest integer type possible for enumeration types
gant gant
Ada AdaWhy AdaSCIL Joined Undocumented Ada AdaWhy AdaSCIL Joined Undocumented
Catch typos Catch typos
......
...@@ -151,6 +151,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value, ...@@ -151,6 +151,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
/* These are handled by the front-end. */ /* These are handled by the front-end. */
break; break;
case OPT_fshort_enums:
/* This is handled by the middle-end. */
break;
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
...@@ -259,13 +263,14 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED) ...@@ -259,13 +263,14 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
optimize_size = global_options.x_optimize_size; optimize_size = global_options.x_optimize_size;
flag_compare_debug = global_options.x_flag_compare_debug; flag_compare_debug = global_options.x_flag_compare_debug;
flag_stack_check = global_options.x_flag_stack_check; flag_stack_check = global_options.x_flag_stack_check;
/* Unfortunately the post_options hook is called before setting the
short_enums flag. Set it now. */
if (global_options.x_flag_short_enums == 2)
global_options.x_flag_short_enums = targetm.default_short_enums ();
flag_short_enums = global_options.x_flag_short_enums; flag_short_enums = global_options.x_flag_short_enums;
/* Unfortunately the post_options hook is called before the value of
flag_short_enums is autodetected, if need be. Mimic the process
for our private flag_short_enums. */
if (flag_short_enums == 2)
flag_short_enums = targetm.default_short_enums ();
return false; return false;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2007-2010, Free Software Foundation, Inc. -- -- Copyright (C) 2007-2013, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -56,12 +56,16 @@ with Interfaces; ...@@ -56,12 +56,16 @@ with Interfaces;
package System.Random_Numbers is package System.Random_Numbers is
type Generator is limited private; type Generator is limited private;
-- Generator encodes the current state of a random number stream, it is
-- provided as input to produce the next random number, and updated so
-- that it is ready to produce the next one.
type State is private; type State is private;
-- A non-limited version of a Generator's internal state -- A non-limited version of a Generator's internal state
function Random (Gen : Generator) return Float; function Random (Gen : Generator) return Float;
function Random (Gen : Generator) return Long_Float; function Random (Gen : Generator) return Long_Float;
-- Return pseudo-random numbers uniformly distributed on [0 .. 1) -- Return pseudo-random numbers uniformly distributed on [0.0 .. 1.0)
function Random (Gen : Generator) return Interfaces.Unsigned_32; function Random (Gen : Generator) return Interfaces.Unsigned_32;
function Random (Gen : Generator) return Interfaces.Unsigned_64; function Random (Gen : Generator) return Interfaces.Unsigned_64;
......
...@@ -573,6 +573,7 @@ begin ...@@ -573,6 +573,7 @@ begin
Maximum_Alignment := Get_Maximum_Alignment; Maximum_Alignment := Get_Maximum_Alignment;
Max_Unaligned_Field := Get_Max_Unaligned_Field; Max_Unaligned_Field := Get_Max_Unaligned_Field;
Pointer_Size := Get_Pointer_Size; Pointer_Size := Get_Pointer_Size;
Short_Enums := Get_Short_Enums;
Short_Size := Get_Short_Size; Short_Size := Get_Short_Size;
Strict_Alignment := Get_Strict_Alignment; Strict_Alignment := Get_Strict_Alignment;
System_Allocator_Alignment := Get_System_Allocator_Alignment; System_Allocator_Alignment := Get_System_Allocator_Alignment;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment