git: d5025c491639 - stable/14 - LinuxKPI: add get_random_u8()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sat, 28 Sep 2024 10:38:19 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=d5025c4916393771c2759331c4308c7e4d11efc7

commit d5025c4916393771c2759331c4308c7e4d11efc7
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-08-27 21:20:09 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-09-28 10:35:13 +0000

    LinuxKPI: add get_random_u8()
    
    Add a get_random_u8() implementation following the u36 and u64 versions.
    We'll likely want to macro-ify them in the future and add all the types
    which makes sense just to be done.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D46464
    
    (cherry picked from commit f29e915bc0d216a87f222a208caeb2172c93e4ea)
---
 sys/compat/linuxkpi/common/include/linux/random.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/random.h b/sys/compat/linuxkpi/common/include/linux/random.h
index 808c5bc55974..893ee2b7b728 100644
--- a/sys/compat/linuxkpi/common/include/linux/random.h
+++ b/sys/compat/linuxkpi/common/include/linux/random.h
@@ -54,6 +54,15 @@ get_random_int(void)
 	return (val);
 }
 
+static inline uint8_t
+get_random_u8(void)
+{
+	uint8_t val;
+
+	get_random_bytes(&val, sizeof(val));
+	return (val);
+}
+
 #define	get_random_u32() get_random_int()
 
 /*