git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1e0f761
)
New function random_range().
author
Ben Pfaff
<blp@nicira.com>
Wed, 9 Jul 2008 01:40:41 +0000
(18:40 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Fri, 18 Jul 2008 20:42:37 +0000
(13:42 -0700)
include/random.h
patch
|
blob
|
history
lib/random.c
patch
|
blob
|
history
diff --git
a/include/random.h
b/include/random.h
index
92e2cb3
..
d9f5f9d
100644
(file)
--- a/
include/random.h
+++ b/
include/random.h
@@
-39,5
+39,6
@@
void random_bytes(void *, size_t);
uint32_t random_uint32(void);
+int random_range(int max);
#endif /* random.h */
diff --git
a/lib/random.c
b/lib/random.c
index
55507e0
..
d5d8b95
100644
(file)
--- a/
lib/random.c
+++ b/
lib/random.c
@@
-70,3
+70,9
@@
random_uint32(void)
random_bytes(&x, sizeof x);
return x;
}
+
+int
+random_range(int max)
+{
+ return random_uint32() % max;
+}