NASM 2.04rc5
[nasm.git] / perllib / gensv.pl
blobb80ccbe6c1945f5935ad9b946e64976bbd0027c5
1 #!/usr/bin/perl
3 # Generate a list of rotation vectors so we always use the same set.
4 # This needs to be run on a platform with /dev/urandom.
7 ($n) = @ARGV;
9 sysopen(UR, '/dev/urandom', O_RDONLY) or die;
11 $maxlen = 78;
13 print "\@random_sv_vectors = (\n";
14 $outl = ' ';
16 for ($i = 0; $i < $n; $i++) {
18 die if (sysread(UR, $x8, 8) != 8);
19 @n = unpack("V*", $x8);
21 $xl = sprintf(" [0x%08x, 0x%08x]%s",
22 $n[0], $n[1],
23 ($i == $n-1) ? '' : ',');
24 if (length($outl.$xl) > $maxlen) {
25 print $outl, "\n";
26 $outl = ' ';
28 $outl .= $xl;
30 close(UR);
32 print $outl, "\n";
33 print ");\n";
34 print "1;\n";