summaryrefslogtreecommitdiff
path: root/sys/src/cmd/unix/drawterm/libmp/mprand.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/src/cmd/unix/drawterm/libmp/mprand.c')
-rw-r--r--sys/src/cmd/unix/drawterm/libmp/mprand.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/sys/src/cmd/unix/drawterm/libmp/mprand.c b/sys/src/cmd/unix/drawterm/libmp/mprand.c
deleted file mode 100644
index fd288f24e..000000000
--- a/sys/src/cmd/unix/drawterm/libmp/mprand.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "os.h"
-#include <mp.h>
-#include <libsec.h>
-#include "dat.h"
-
-mpint*
-mprand(int bits, void (*gen)(uchar*, int), mpint *b)
-{
- int n, m;
- mpdigit mask;
- uchar *p;
-
- n = DIGITS(bits);
- if(b == nil)
- b = mpnew(bits);
- else
- mpbits(b, bits);
-
- p = malloc(n*Dbytes);
- if(p == nil)
- return nil;
- (*gen)(p, n*Dbytes);
- betomp(p, n*Dbytes, b);
- free(p);
-
- // make sure we don't give too many bits
- m = bits%Dbits;
- n--;
- if(m > 0){
- mask = 1;
- mask <<= m;
- mask--;
- b->p[n] &= mask;
- }
-
- for(; n >= 0; n--)
- if(b->p[n] != 0)
- break;
- b->top = n+1;
- b->sign = 1;
- return b;
-}