summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-01-22 16:34:08 +0100
committerTheodore Ts'o <tytso@mit.edu>2017-01-27 14:25:06 -0500
commitc440408cf6901eeb2c09563397e24a9097907078 (patch)
tree0b6333b3529b2d1608649fdbb2fa9217cdb020d7 /include
parentf5b98461cb8167ba362ad9f74c41d126b7becea7 (diff)
downloadlinux-stable-c440408cf6901eeb2c09563397e24a9097907078.tar.gz
linux-stable-c440408cf6901eeb2c09563397e24a9097907078.tar.bz2
linux-stable-c440408cf6901eeb2c09563397e24a9097907078.zip
random: convert get_random_int/long into get_random_u32/u64
Many times, when a user wants a random number, he wants a random number of a guaranteed size. So, thinking of get_random_int and get_random_long in terms of get_random_u32 and get_random_u64 makes it much easier to achieve this. It also makes the code simpler. On 32-bit platforms, get_random_int and get_random_long are both aliased to get_random_u32. On 64-bit platforms, int->u32 and long->u64. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'include')
-rw-r--r--include/linux/random.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/random.h b/include/linux/random.h
index 16ab429735a7..ed5c3838780d 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -42,8 +42,21 @@ extern void get_random_bytes_arch(void *buf, int nbytes);
extern const struct file_operations random_fops, urandom_fops;
#endif
-unsigned int get_random_int(void);
-unsigned long get_random_long(void);
+u32 get_random_u32(void);
+u64 get_random_u64(void);
+static inline unsigned int get_random_int(void)
+{
+ return get_random_u32();
+}
+static inline unsigned long get_random_long(void)
+{
+#if BITS_PER_LONG == 64
+ return get_random_u64();
+#else
+ return get_random_u32();
+#endif
+}
+
unsigned long randomize_page(unsigned long start, unsigned long range);
u32 prandom_u32(void);