aboutsummaryrefslogtreecommitdiff
path: root/src/lib9
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-21 14:05:38 +0000
committerrsc <devnull@localhost>2004-03-21 14:05:38 +0000
commit498bb22174aa2c76493e8c67b92949271131ebfb (patch)
tree0baf3bd3415fbc50f9bc879ab621613fe238ead0 /src/lib9
parent0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4 (diff)
downloadplan9port-498bb22174aa2c76493e8c67b92949271131ebfb.tar.gz
plan9port-498bb22174aa2c76493e8c67b92949271131ebfb.tar.bz2
plan9port-498bb22174aa2c76493e8c67b92949271131ebfb.zip
Add some missing files.
Diffstat (limited to 'src/lib9')
-rw-r--r--src/lib9/lnrand.c18
-rw-r--r--src/lib9/lrand.c8
-rw-r--r--src/lib9/opentemp.c9
3 files changed, 35 insertions, 0 deletions
diff --git a/src/lib9/lnrand.c b/src/lib9/lnrand.c
new file mode 100644
index 00000000..5b648d08
--- /dev/null
+++ 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
new file mode 100644
index 00000000..47c331d9
--- /dev/null
+++ 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
new file mode 100644
index 00000000..ff2b3f81
--- /dev/null
+++ b/src/lib9/opentemp.c
@@ -0,0 +1,9 @@
+#include <u.h>
+#include <libc.h>
+
+int
+opentemp(char *template)
+{
+ return mkstemp(template);
+}
+