projects
/
openvswitch
/ 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 92e2cb3bbee0f5e6cc7801163d03d72dcdd63ae1..d9f5f9d08aee6d45125a635335063bfe3430d31f 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 55507e027ed30aa58cff2723cfc51afaff5c2028..d5d8b957fb39876e4ce9115726440cd3c07a12cd 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;
+}