Author: markj Date: Wed Oct 4 17:29:08 2017 New Revision: 324285 URL: https://svnweb.freebsd.org/changeset/base/324285
Log: Add get_random_{int,long} to the LinuxKPI. Fix some whitespace bugs while here. Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D12588 Modified: head/sys/compat/linuxkpi/common/include/linux/random.h Modified: head/sys/compat/linuxkpi/common/include/linux/random.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/random.h Wed Oct 4 16:35:58 2017 (r324284) +++ head/sys/compat/linuxkpi/common/include/linux/random.h Wed Oct 4 17:29:08 2017 (r324285) @@ -28,7 +28,8 @@ * * $FreeBSD$ */ -#ifndef _LINUX_RANDOM_H_ + +#ifndef _LINUX_RANDOM_H_ #define _LINUX_RANDOM_H_ #include <sys/random.h> @@ -37,8 +38,27 @@ static inline void get_random_bytes(void *buf, int nbytes) { + if (read_random(buf, nbytes) == 0) arc4rand(buf, nbytes, 0); } -#endif /* _LINUX_RANDOM_H_ */ +static inline u_int +get_random_int(void) +{ + u_int val; + + get_random_bytes(&val, sizeof(val)); + return (val); +} + +static inline u_long +get_random_long(void) +{ + u_long val; + + get_random_bytes(&val, sizeof(val)); + return (val); +} + +#endif /* _LINUX_RANDOM_H_ */ _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"