+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>
* back_end.adb: Remove Short_Enums handling (handled in
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
------------------------------------------------------------------------------
with Ada.Numerics.Long_Elementary_Functions;
-use Ada.Numerics.Long_Elementary_Functions;
+use Ada.Numerics.Long_Elementary_Functions;
with Ada.Unchecked_Conversion;
+
with System.Random_Numbers; use System.Random_Numbers;
package body GNAT.Random_Numbers is
return F (Gen.Rep, Min, Max);
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_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);
begin
return F (Gen.Rep);
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
Max : Result_Subtype := Result_Subtype'Last) return Result_Subtype;
-- Returns pseudo-random numbers uniformly distributed on Min .. Max
+ 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 <>;
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 Float;
; Options for the Ada front end.
-; Copyright (C) 2003, 2007, 2008, 2010, 2011, 2012
-; Free Software Foundation, Inc.
+; Copyright (C) 2003-2013 Free Software Foundation, Inc.
;
; This file is part of GCC.
;
; along with GCC; see the file COPYING3. If not see
; <http://www.gnu.org/licenses/>.
-
; See the GCC internals manual for a description of this file's format.
; Please try to keep this file in ASCII collating order.
Ada AdaWhy AdaSCIL Joined RejectNegative
Select the runtime
+fshort-enums
+Ada AdaWhy AdaSCIL
+Use the narrowest integer type possible for enumeration types
+
gant
Ada AdaWhy AdaSCIL Joined Undocumented
Catch typos
/* These are handled by the front-end. */
break;
+ case OPT_fshort_enums:
+ /* This is handled by the middle-end. */
+ break;
+
default:
gcc_unreachable ();
}
optimize_size = global_options.x_optimize_size;
flag_compare_debug = global_options.x_flag_compare_debug;
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;
+ /* 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;
}
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
package System.Random_Numbers is
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;
-- A non-limited version of a Generator's internal state
function Random (Gen : Generator) return 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_64;
Maximum_Alignment := Get_Maximum_Alignment;
Max_Unaligned_Field := Get_Max_Unaligned_Field;
Pointer_Size := Get_Pointer_Size;
+ Short_Enums := Get_Short_Enums;
Short_Size := Get_Short_Size;
Strict_Alignment := Get_Strict_Alignment;
System_Allocator_Alignment := Get_System_Allocator_Alignment;