From: Ben Pfaff Date: Wed, 9 Jul 2008 01:40:41 +0000 (-0700) Subject: New function random_range(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61e2e1505107617687d30e92eb871776217f3775;p=openvswitch New function random_range(). --- diff --git a/include/random.h b/include/random.h index 92e2cb3b..d9f5f9d0 100644 --- 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 55507e02..d5d8b957 100644 --- 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; +}