From nobody Mon Apr 08 06:49:12 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VCfp06GLrz5GKpl; Mon, 8 Apr 2024 06:49:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VCfp052rXz4mHt; Mon, 8 Apr 2024 06:49:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712558952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0TGM3iZcsYK6Xa/Afcd4lBzfsnySolj94EOGhq5v3t8=; b=gPIHT3FWPLXvBfLokPe6FJPPhNbzYrSCUHrd3tnybFQ5g8iaJANmPdfZhOb9Fwc/8M8Y/h oGUvPX153uWZx8/k50LBhEr6YsiF4smpWAoWknaDh3rKq1M+hPDl4PGuXlUQfvzER88PDI VRFna/uy0n4cHKBZXhznTU1YIvMtj8lxDTduxV34qYimH/DwY1LdGCqnQ/5uo5tgbz67BI zDNPJJa5KWXDzZFJ/K127acfAyYNN/haahfQy5tgnRTStr/7VIk6f4u9/xgcvyanQL1jCz 5fnNzzJU69QjbbzhOZuSQIrrDea8OYV2EXxoJnKad7Rjraa0Cm5nRNQXWIP1eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712558952; a=rsa-sha256; cv=none; b=ATkGtmsrtpSqzKf+YYk+M/E2nOh51lgfyR9+ptlagjZwu8JvCwqzaS+Q5sPdGULEoYouJZ RguD91hmGRS9WclO+Qfg6pkO2iX9DgNKc7hDS4VEr7Ha1V+X2WBY9ofLM3bPRDmBH9ZSPs d707P3ZdgNnxHjL3CtqIFQy1eEJJ53jKeSoV5F/HnazmY79fUCojlqNlluNcywnwcrkYBk bJ0WUl8lOcrutTcoj06Bz1Nv7X0ki2Fdp/17JbSulFhyQEdUUjvahvHpbxRhAcTKBPEETI nHZFIoEKdgtUvqCXGSx5OWinkb9dMQoYuoHjrcr41UK2exi6CZTdJ4CGuwcPyg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712558952; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0TGM3iZcsYK6Xa/Afcd4lBzfsnySolj94EOGhq5v3t8=; b=J4cjrCoeM4Mx/16rNosCHs7w0jydyUonKN5e1wlvFa25QqmosciXL4edCp+8rb+k5R7DzE 2NBGTw0s0EcGWETNzqnKxVFFC5j5JFjEmIoCIuBSDHg2ue+CLvjT+8tYaZRRbxnW3+YMfV SU9HIq8CWl12q+aHlhU0kq2uODuLGsM9aRdrk+7Av1qg9hXpMuju1WTDPfXHtD+SriGvdo QT7ThyPIX9yGFGnek9wHoEh73saXRtH8dHYKKUpfELmmxpzfYLvGRlfrQe7fU+kGM4ni6j aIJjYqJVHWixS1Hcfs8QtjNWbA3PIMG5//yrJD6DKbMfFqyr3f838Zvg57zhhQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VCfp04fVmz11Mv; Mon, 8 Apr 2024 06:49:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4386nCnn032801; Mon, 8 Apr 2024 06:49:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4386nC1h032798; Mon, 8 Apr 2024 06:49:12 GMT (envelope-from git) Date: Mon, 8 Apr 2024 06:49:12 GMT Message-Id: <202404080649.4386nC1h032798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9289c1f6f151 - main - LinuxKPI: Add get_random_u32_below function List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9289c1f6f1514e714b17026c50ec09282f079cba Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9289c1f6f1514e714b17026c50ec09282f079cba commit 9289c1f6f1514e714b17026c50ec09282f079cba Author: Vladimir Kondratyev AuthorDate: 2024-04-08 06:47:42 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-04-08 06:47:42 +0000 LinuxKPI: Add get_random_u32_below function get_random_u32_below returns a random integer in the interval [0, ceil), with uniform distribution. Sponsored by: Serenity CyberSecurity, LLC Reviewed by: emaste MFC after: 1 week --- sys/compat/linuxkpi/common/include/linux/random.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/random.h b/sys/compat/linuxkpi/common/include/linux/random.h index e87d4412ea4e..808c5bc55974 100644 --- a/sys/compat/linuxkpi/common/include/linux/random.h +++ b/sys/compat/linuxkpi/common/include/linux/random.h @@ -96,6 +96,12 @@ get_random_u64(void) return (val); } +static inline uint32_t +get_random_u32_below(uint32_t max) +{ + return (arc4random_uniform(max)); +} + static __inline uint32_t prandom_u32(void) {