summaryrefslogtreecommitdiff
path: root/libmp/mtest.c
blob: f05674c365f7f782d28ac4caecb12d10b471bd80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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);
}