This file is indexed.

/usr/share/ada/adainclude/gmpada/gnu_multiple_precision-random_numbers.adb is in libgmpada4-dev 0.0.20131223-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
--    GMPAda, binding to the Ada Language for the GNU MultiPrecision library.
--    Copyright (C) 2007-2010 Nicolas Boulenguez <nicolas.boulenguez@free.fr>
--
--    This program is free software: you can redistribute it and/or modify
--    it under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    This program is distributed in the hope that it will be useful,
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--    GNU General Public License for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with this program.  If not, see <http://www.gnu.org/licenses/>.

with Ada.Calendar;
with Interfaces.C; use Interfaces.C;
with GMP.Binding; use GMP.Binding;

package body GNU_Multiple_Precision.Random_Numbers is

   procedure Random (Result : in out Big_Integer;
                     Gen    : in out Generator;
                     Modulo : in     Natural)
   is
   begin
      Mpz_Urandomb (Result.Value, Gen.Gen_State.Value, unsigned_long (Modulo));
   end Random;

   procedure Random (Result : in out Big_Integer;
                     Gen    : in out Generator;
                     Modulo : in     Big_Integer)
   is
   begin
      Mpz_Urandomm (Result.Value, Gen.Gen_State.Value, Modulo.Value);
   end Random;

   procedure Random_2exp (Result : in out Big_Integer;
                          Gen    : in out Generator;
                          Count  : in     Bit_Count)
   is
   begin
      Mpz_Urandomb (Result.Value, Gen.Gen_State.Value, Count);
   end Random_2exp;

   procedure Random_2exp (Result : in out Big_Float;
                          Gen    : in out Generator;
                          Count  : in     Bit_Count)
   is
   begin
      Mpf_Urandomb (Result.Value, Gen.Gen_State.Value, Count);
   end Random_2exp;

   procedure Reset (Gen       : in out Generator;
                    Initiator : in     Integer)
   is
   begin
      Gmp_Randseed_Ui (Gen.Gen_State.Value, unsigned_long (abs Initiator));
   end Reset;

   procedure Reset (Gen       : in out Generator;
                    Initiator : in     Big_Integer)
   is
   begin
      Gmp_Randseed (Gen.Gen_State.Value, Initiator.Value);
   end Reset;

   procedure Reset (Gen : in out Generator)
   is
      use Ada.Calendar;
      Now : constant Time := Clock;
   begin
      Gmp_Randseed_Ui (Gen.Gen_State.Value,
                       unsigned_long (Year    (Now)) * 12 * 31 +
                       unsigned_long (Month   (Now))      * 31 +
                       unsigned_long (Day     (Now))           +
                       unsigned_long (Seconds (Now) * 1000.0));
   end Reset;

   procedure Save (Gen      : in     Generator;
                   To_State :    out State)
   is
   begin
      Gmp_Randclear (To_State.Value);
      Gmp_Randinit_Set (To_State.Value, Gen.Gen_State.Value);
   end Save;

   procedure Reset (Gen        : in out Generator;
                    From_State : in     State)
   is
   begin
      Gmp_Randclear (Gen.Gen_State.Value);
      Gmp_Randinit_Set (Gen.Gen_State.Value, From_State.Value);
   end Reset;

   procedure Reset_Mersenne_Twister (Gen : in out Generator)
   is
   begin
      Gmp_Randclear (Gen.Gen_State.Value);
      Gmp_Randinit_Mt (Gen.Gen_State.Value);
   end Reset_Mersenne_Twister;

   procedure Reset_Linear_Congruential
     (Gen   : in out Generator;
      A     : in     Big_Integer;
      C     : in     Natural;
      M2exp : in     Bit_Count)
   is
   begin
      Gmp_Randclear (Gen.Gen_State.Value);
      Gmp_Randinit_Lc_2exp (Gen.Gen_State.Value, A.Value, unsigned_long (C),
                            M2exp);
   end Reset_Linear_Congruential;

   procedure Generate_Corner_Case_Random_Bytes
     (Rop   : in out Big_Integer;
      Gen   : in out Generator;
      Count : in     Bit_Count)
   is
   begin
      Mpz_Rrandomb (Rop.Value, Gen.Gen_State.Value, Count);
   end Generate_Corner_Case_Random_Bytes;

   procedure Reset_Linear_Congruential_2exp_Size
     (Gen            : in out Generator;
      Size           : in     Natural;
      Found_In_Table :    out Boolean)
   is
      Ret : int;
   begin
      Gmp_Randinit_Lc_2exp_Size (Ret, Gen.Gen_State.Value,
                                 unsigned_long (Size));
      Found_In_Table := Ret /= 0;
   end Reset_Linear_Congruential_2exp_Size;

   overriding procedure Initialize (Object : in out State)
   is
   begin
      Gmp_Randinit_Default (Object.Value);
   end Initialize;

   overriding procedure Adjust (Object : in out State)
   is
      Temp : constant Gmp_Randstate_T := Object.Value;
   begin
      Gmp_Randinit_Set (Object.Value, Temp);
   end Adjust;

   overriding procedure Finalize (Object : in out State)
   is
   begin
      Gmp_Randclear (Object.Value);
   end Finalize;

end GNU_Multiple_Precision.Random_Numbers;