diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 17:07:39 +0000 |
| commit | 37da2899f40661e3e9631e497da8dc59b971cbd0 (patch) | |
| tree | cbc6d4680e347d906f5fa7fca73214418741df72 /libmp/mtest.c | |
| parent | 54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff) | |
20060303a
Diffstat (limited to 'libmp/mtest.c')
| -rw-r--r-- | libmp/mtest.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libmp/mtest.c b/libmp/mtest.c new file mode 100644 index 00000000..f05674c3 --- /dev/null +++ b/libmp/mtest.c @@ -0,0 +1,70 @@ +#include <u.h> +#include <libc.h> +#include <mp.h> +#include "port/dat.h" + +int loops = 1; + +long randomreg; + +void +srand(long seed) +{ + randomreg = seed; +} + +long +lrand(void) +{ + randomreg = randomreg*104381 + 81761; + return randomreg; +} + +void +prng(uchar *p, int n) +{ + while(n-- > 0) + *p++ = lrand(); +} + + +void +testshift(char *str) +{ + mpint *b1, *b2; + int i; + + b1 = strtomp(str, nil, 16, nil); + malloccheck(); +fprint(2, "A"); + b2 = mpnew(0); +fprint(2, "B"); + malloccheck(); + mpleft(b1, 20, b2); +fprint(2, "C"); + malloccheck(); + mpfree(b1); +fprint(2, "D"); + malloccheck(); + mpfree(b2); +} + +void +main(int argc, char **argv) +{ + mpint *x, *y; + + ARGBEGIN{ + case 'n': + loops = atoi(ARGF()); + break; + }ARGEND; + + fmtinstall('B', mpfmt); + fmtinstall('Q', mpfmt); + srand(0); + mpsetminbits(2*Dbits); + testshift("1111111111111111"); + print("done\n"); + exits(0); +} |
