compat: Backport prandom_u32_max().
[cascardo/ovs.git] / datapath / linux / compat / include / linux / random.h
1 #ifndef __LINUX_RANDOM_WRAPPER_H
2 #define __LINUX_RANDOM_WRAPPER_H 1
3
4 #include_next <linux/random.h>
5
6 #ifndef HAVE_PRANDOM_U32
7 #define prandom_u32()           random32()
8 #endif
9
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
17 #endif