tAdd some missing files. - plan9port - [fork] Plan 9 from user space
HTML git clone git://src.adamsgaard.dk/plan9port
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 498bb22174aa2c76493e8c67b92949271131ebfb
DIR parent 0fc65b37a1e7585ca2347bf61dcb8bc3a6b146a4
HTML Author: rsc <devnull@localhost>
Date: Sun, 21 Mar 2004 14:05:38 +0000
Add some missing files.
Diffstat:
A src/lib9/lnrand.c | 18 ++++++++++++++++++
A src/lib9/lrand.c | 8 ++++++++
A src/lib9/opentemp.c | 9 +++++++++
3 files changed, 35 insertions(+), 0 deletions(-)
---
DIR diff --git a/src/lib9/lnrand.c b/src/lib9/lnrand.c
t@@ -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;
+}
DIR diff --git a/src/lib9/lrand.c b/src/lib9/lrand.c
t@@ -0,0 +1,8 @@
+#include <u.h>
+#include <libc.h>
+
+long
+lrand(void)
+{
+ return ((rand()<<16)^rand()) & 0x7FFFFFFF;
+}
DIR diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c
t@@ -0,0 +1,9 @@
+#include <u.h>
+#include <libc.h>
+
+int
+opentemp(char *template)
+{
+ return mkstemp(template);
+}
+