From: Eric Botcazou Date: Mon, 12 Oct 2020 19:12:56 +0000 (+0200) Subject: [Ada] Add support for 128-bit integer types to GNAT.Random_Numbers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d88dbdc5e33765ae481b57e5ed027fe1fb2e409;p=gcc.git [Ada] Add support for 128-bit integer types to GNAT.Random_Numbers gcc/ada/ * libgnat/g-rannum.ads (Random): New functions returning 128-bit. * libgnat/g-rannum.adb (Random): Implement them and alphabetize. (To_Signed): New unchecked conversion function for 128-bit. --- diff --git a/gcc/ada/libgnat/g-rannum.adb b/gcc/ada/libgnat/g-rannum.adb index b7ef7d19d07..3895cdd0548 100644 --- a/gcc/ada/libgnat/g-rannum.adb +++ b/gcc/ada/libgnat/g-rannum.adb @@ -58,6 +58,8 @@ is new Ada.Unchecked_Conversion (Unsigned_32, Integer_32); function To_Signed is new Ada.Unchecked_Conversion (Unsigned_64, Integer_64); + function To_Signed is + new Ada.Unchecked_Conversion (Unsigned_128, Integer_128); ------------------ -- Insert_Image -- @@ -147,9 +149,9 @@ is return Random (Gen.Rep); end Random; - function Random (Gen : Generator) return Integer_64 is + function Random (Gen : Generator) return Interfaces.Unsigned_128 is begin - return To_Signed (Unsigned_64'(Random (Gen))); + return Random (Gen.Rep); end Random; function Random (Gen : Generator) return Integer_32 is @@ -157,6 +159,16 @@ is return To_Signed (Unsigned_32'(Random (Gen))); end Random; + function Random (Gen : Generator) return Integer_64 is + begin + return To_Signed (Unsigned_64'(Random (Gen))); + end Random; + + function Random (Gen : Generator) return Integer_128 is + begin + return To_Signed (Unsigned_128'(Random (Gen))); + end Random; + function Random (Gen : Generator) return Long_Integer is function Random_Long_Integer is new Random_Discrete (Long_Integer); begin diff --git a/gcc/ada/libgnat/g-rannum.ads b/gcc/ada/libgnat/g-rannum.ads index 5b633ff913b..f795ae09aec 100644 --- a/gcc/ada/libgnat/g-rannum.ads +++ b/gcc/ada/libgnat/g-rannum.ads @@ -69,6 +69,8 @@ is function Random (Gen : Generator) return Interfaces.Unsigned_32; function Random (Gen : Generator) return Interfaces.Integer_64; function Random (Gen : Generator) return Interfaces.Unsigned_64; + function Random (Gen : Generator) return Interfaces.Integer_128; + function Random (Gen : Generator) return Interfaces.Unsigned_128; function Random (Gen : Generator) return Integer; function Random (Gen : Generator) return Long_Integer; -- Return pseudo-random numbers uniformly distributed on T'First .. T'Last