mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-11 01:30:55 +08:00
[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
This commit is contained in:
parent
f9e2a506da
commit
c51f5910f3
@ -1,3 +1,17 @@
|
||||
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
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- 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- --
|
||||
@ -30,8 +30,9 @@
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
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
|
||||
@ -87,6 +88,40 @@ 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 --
|
||||
------------
|
||||
@ -137,7 +172,7 @@ package body GNAT.Random_Numbers is
|
||||
-- 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);
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- 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- --
|
||||
@ -78,10 +78,28 @@ package GNAT.Random_Numbers is
|
||||
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;
|
||||
|
@ -1,6 +1,5 @@
|
||||
; 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.
|
||||
;
|
||||
@ -18,7 +17,6 @@
|
||||
; 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.
|
||||
@ -74,6 +72,10 @@ fRTS=
|
||||
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
|
||||
|
@ -151,6 +151,10 @@ gnat_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED, int value,
|
||||
/* These are handled by the front-end. */
|
||||
break;
|
||||
|
||||
case OPT_fshort_enums:
|
||||
/* This is handled by the middle-end. */
|
||||
break;
|
||||
|
||||
default:
|
||||
gcc_unreachable ();
|
||||
}
|
||||
@ -259,13 +263,14 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
-- --
|
||||
-- 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- --
|
||||
@ -56,12 +56,16 @@ with Interfaces;
|
||||
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;
|
||||
|
@ -573,6 +573,7 @@ begin
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user