1 #include <u.h> 2 #include <libc.h> 3 #include <mp.h> 4 #include "port/dat.h" 5 6 int loops = 1; 7 8 long randomreg; 9 10 void 11 srand(long seed) 12 { 13 randomreg = seed; 14 } 15 16 long 17 lrand(void) 18 { 19 randomreg = randomreg*104381 + 81761; 20 return randomreg; 21 } 22 23 void 24 prng(uchar *p, int n) 25 { 26 while(n-- > 0) 27 *p++ = lrand(); 28 } 29 30 31 void 32 testshift(char *str) 33 { 34 mpint *b1, *b2; 35 int i; 36 37 b1 = strtomp(str, nil, 16, nil); 38 malloccheck(); 39 fprint(2, "A"); 40 b2 = mpnew(0); 41 fprint(2, "B"); 42 malloccheck(); 43 mpleft(b1, 20, b2); 44 fprint(2, "C"); 45 malloccheck(); 46 mpfree(b1); 47 fprint(2, "D"); 48 malloccheck(); 49 mpfree(b2); 50 } 51 52 void 53 main(int argc, char **argv) 54 { 55 mpint *x, *y; 56 57 ARGBEGIN{ 58 case 'n': 59 loops = atoi(ARGF()); 60 break; 61 }ARGEND; 62 63 fmtinstall('B', mpfmt); 64 fmtinstall('Q', mpfmt); 65 srand(0); 66 mpsetminbits(2*Dbits); 67 testshift("1111111111111111"); 68 print("done\n"); 69 exits(0); 70 } 71