mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-12-15 09:09:58 +08:00
b938e043ca
rand() in Perl can vary between platforms, so don't use it. Instead, remove a completely pointless level of indirection (it introduced a permutation which cancelled itself out) and provide a canned set of random numbers for the rest. This guarantees we will always use the same numbers.
43 lines
798 B
Perl
Executable File
43 lines
798 B
Perl
Executable File
#!/usr/bin/perl
|
|
#
|
|
# Generate a list of rotation vectors so we always use the same set.
|
|
# This needs to be run on a platform with /dev/urandom.
|
|
#
|
|
|
|
($n) = @ARGV;
|
|
|
|
sysopen(UR, '/dev/urandom', O_RDONLY) or die;
|
|
|
|
$maxlen = 78;
|
|
|
|
print "\@random_sv_vectors = (\n";
|
|
$outl = ' ';
|
|
|
|
for ($i = 0; $i < $n; $i++) {
|
|
|
|
do {
|
|
die if (sysread(UR, $x4, 4) != 4);
|
|
@n = unpack("C*", $x4);
|
|
|
|
$n[0] &= 31;
|
|
$n[1] &= 31;
|
|
$n[2] &= 31;
|
|
$n[3] &= 31;
|
|
} while ($n[0] == 0 || $n[1] == 0 || $n[2] == 0 || $n[3] == 0 ||
|
|
$n[0] == $n[3] || $n[1] == $n[2]);
|
|
|
|
$xl = sprintf(" [%d,%d,%d,%d]%s",
|
|
$n[0], $n[1], $n[2], $n[3],
|
|
($i == $n-1) ? '' : ',');
|
|
if (length($outl.$xl) > $maxlen) {
|
|
print $outl, "\n";
|
|
$outl = ' ';
|
|
}
|
|
$outl .= $xl;
|
|
}
|
|
close(UR);
|
|
|
|
print $outl, "\n";
|
|
print ");\n";
|
|
print "1;\n";
|