commit 498bb22174aa2c76493e8c67b92949271131ebfb
parent 0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4
Author: rsc <devnull@localhost>
Date: Sun, 21 Mar 2004 14:05:38 +0000
Add some missing files.
Diffstat:
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/src/lib9/lnrand.c b/src/lib9/lnrand.c
@@ -0,0 +1,18 @@
+#include <u.h>
+#include <libc.h>
+
+#define MASK 0x7fffffffL
+
+long
+lnrand(long n)
+{
+ long slop, v;
+
+ if(n < 0)
+ return n;
+ slop = MASK % n;
+ do
+ v = lrand();
+ while(v <= slop);
+ return v % n;
+}
diff --git a/src/lib9/lrand.c b/src/lib9/lrand.c
@@ -0,0 +1,8 @@
+#include <u.h>
+#include <libc.h>
+
+long
+lrand(void)
+{
+ return ((rand()<<16)^rand()) & 0x7FFFFFFF;
+}
diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c
@@ -0,0 +1,9 @@
+#include <u.h>
+#include <libc.h>
+
+int
+opentemp(char *template)
+{
+ return mkstemp(template);
+}
+