-
+ 190C221CD6DA728EEC4414F6ADB513310049DB129F571C47368F67BD399EEEEA5ED6E72DF6DC4427D418C1B6C50715946A94BBD622736AFDA4DC4117AD916DF3ffa/ffacalc/ffa_rng.adb(0 . 0)(1 . 58)
100 ------------------------------------------------------------------------------
101 ------------------------------------------------------------------------------
102 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
103 -- --
104 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
105 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
106 -- --
107 -- You do not have, nor can you ever acquire the right to use, copy or --
108 -- distribute this software ; Should you use this software for any purpose, --
109 -- or copy and distribute it to anyone or in any manner, you are breaking --
110 -- the laws of whatever soi-disant jurisdiction, and you promise to --
111 -- continue doing so for the indefinite future. In any case, please --
112 -- always : read and understand any software ; verify any PGP signatures --
113 -- that you use - for any purpose. --
114 -- --
115 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
116 ------------------------------------------------------------------------------
117 ------------------------------------------------------------------------------
118
119 with OS; use OS;
120
121 with FZ_Type; use FZ_Type;
122
123
124 package body FFA_RNG is
125
126 -- Prepare an RNG for use; at given path, or will use default
127 procedure Init_RNG(RNG : out RNG_Device;
128 RNG_Unix_Path : in String := Default_RNG_Path) is
129 begin
130 begin
131 -- Open the RNG at the offered path:
132 Word_IO.Open(File => RNG.F,
133 Mode => Word_IO.In_File,
134 Name => RNG_Unix_Path);
135 exception
136 when others =>
137 Eggog("Could not open RNG at : " & RNG_Unix_Path & "!");
138 end;
139 end Init_RNG;
140
141
142 -- Fill a FZ from RNG
143 procedure FZ_Random(RNG : in RNG_Device;
144 N : out FZ) is
145 begin
146 begin
147 -- Fill the destination FZ from this RNG:
148 for i in N'Range loop
149 Word_IO.Read(RNG.F, N(i));
150 end loop;
151 exception
152 when others =>
153 Eggog("Could not read from RNG!");
154 end;
155 end FZ_Random;
156
157 end FFA_RNG;