Skip to content

Commit f000c87

Browse files
committed
compat: Backport prandom_u32_max().
Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Pravin B Shelar <pshelar@nicira.com>
1 parent 0d03e51 commit f000c87

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

acinclude.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
381381
[OVS_DEFINE([HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE])])
382382
383383
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
384+
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32_max])
384385
385386
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [get_link_net])
386387
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [name_assign_type])

datapath/linux/compat/include/linux/random.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,11 @@
77
#define prandom_u32() random32()
88
#endif
99

10+
#ifndef HAVE_PRANDOM_U32_MAX
11+
static inline u32 prandom_u32_max(u32 ep_ro)
12+
{
13+
return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
14+
}
15+
#endif
16+
1017
#endif

0 commit comments

Comments
 (0)