[ovs-dev] [PATCH 05/23] compat: Backport prandom_u32_max().
Joe Stringer
joestringer at nicira.com
Sat Nov 7 19:59:43 UTC 2015
Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
acinclude.m4 | 1 +
datapath/linux/compat/include/linux/random.h | 7 +++++++
2 files changed, 8 insertions(+)
diff --git a/acinclude.m4 b/acinclude.m4
index 9465adb1daab..cb3326227f82 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -375,6 +375,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
[OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])])
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
+ OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32_max])
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [get_link_net])
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [name_assign_type])
diff --git a/datapath/linux/compat/include/linux/random.h b/datapath/linux/compat/include/linux/random.h
index f2a6d6aa1468..5c088a2d860b 100644
--- a/datapath/linux/compat/include/linux/random.h
+++ b/datapath/linux/compat/include/linux/random.h
@@ -7,4 +7,11 @@
#define prandom_u32() random32()
#endif
+#ifndef HAVE_PRANDOM_U32_MAX
+static inline u32 prandom_u32_max(u32 ep_ro)
+{
+ return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
+}
+#endif
+
#endif
--
2.1.4
More information about the dev
mailing list