Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Sep 2024 13:28:00 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f29e915bc0d2 - main - LinuxKPI: add get_random_u8()
Message-ID:  <202409011328.481DS0Ji030702@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

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

commit f29e915bc0d216a87f222a208caeb2172c93e4ea
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-08-27 21:20:09 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-08-31 21:32:11 +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
    MFC after:      3 days
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D46464
---
 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()
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202409011328.481DS0Ji030702>