From nobody Mon Aug 08 14:04:12 2022 X-Original-To: dev-commits-src-main@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 4M1dH02HKBz4Y4SY; Mon, 8 Aug 2022 14:04: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 4M1dH01V7wz3tcn; Mon, 8 Aug 2022 14:04:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659967452; 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=fsUPnMTVD5UDcF3mqpzGRCi0qJBnzhliuqbIAUrACsA=; b=QnW3tRiAKvPfP+7tCpYT982vygX5/7+GUYfQ9J1mqszsYkR2cGBdMDH13F2hmDSjNa3j++ UCun1QK5J4eHeiPAhMazwXLfhFh9s29u88DnFrZzUdi5tCWmr+xz4NSOCQlgm1ScynM2Ev brMoV/M0cftp/BZPJuRJOF9UbvowBQMzAHWbZHxrFviWOO3KP8iTLZ5b9Ok9V5GauWED1G q5GiVwFN8fIkii0QZq1Hmrv1IfoAnmY0olbYju8kK9/5Jh0bjIERDTUzhAodyQmuaKr1KV 9KV8RiAGeHHA0G2ltzqji7esEq2xYWXY8ARi9x0oUheNyDM4C3E0SyKopJT0Zw== 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 4M1dH00XYjztcJ; Mon, 8 Aug 2022 14:04:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 278E4CMJ088689; Mon, 8 Aug 2022 14:04:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 278E4CDG088688; Mon, 8 Aug 2022 14:04:12 GMT (envelope-from git) Date: Mon, 8 Aug 2022 14:04:12 GMT Message-Id: <202208081404.278E4CDG088688@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Emmanuel Vadot Subject: git: 885ab0dba28b - main - linuxkpi: math.h: Add mul_u64_u32_div and mul_u64_u32_shr List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 885ab0dba28b799c5c70923c2cb0ee162b5b75b1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659967452; 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=fsUPnMTVD5UDcF3mqpzGRCi0qJBnzhliuqbIAUrACsA=; b=J4koynnI0y3ta6OMUN/i+GYBhuaMVTJM/pY+tWTjCMFwstyvpcArdHgNCYTaWs0Mz9Ty0G 3H3uQEr6cAWsz+1SQerTeDj+lBVARgdnRMQki+DZGdofxJ2LZofpqwtPXINOQ1taElzRKO ehAVkXCT7yxMjMh69xOaoP7eWkKateK6e60UC6n5UarsJolkeVs0yP9T5rGyx3VZW9EgEK pehdWYnGwQxBCoDZNYBM8el5LRGcg0wc2Qu+h1ZIQIx/k+AfZ9qSRvhWoU+Glo1pqwiu3i R5n0ZXv25aKCHTJ3FWoEODcBc4ffK+VC6J5CZFlqxd/Hq8oL0cZaQ51Sz5HEuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659967452; a=rsa-sha256; cv=none; b=Wn9XE4LPuatSpfCMiuZPNhF9rLG78teEgO23KEWXdCbFQAEfjiesmUwvUd9v7otdhqeZL0 l1DCk3LTNoIzo1kkPi+SZhWKXWQ7vJH5SzEpYL16jr+F7x9FfMibjrBaCwjCI6uuIJz5bl zwyZLur59pLeFT8vZoldgwGNNsVWgoM3O0iahE6ciA4JOdj1MuZKPejBEcdwlBYx208KFi Riwt6PJ8y3x4pGyNDVa90wCIC2GWBm2L6ZvMw34BfRGo6tKOQ8RF90A67cwWm1pO2PyXrN 3ltd666Dw51i3y52BMqvjy7JeZHmeAiaiFCCx/rReMK1YRWZ4mzfLmo8kL0vaQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=885ab0dba28b799c5c70923c2cb0ee162b5b75b1 commit 885ab0dba28b799c5c70923c2cb0ee162b5b75b1 Author: Emmanuel Vadot AuthorDate: 2022-07-26 08:06:56 +0000 Commit: Emmanuel Vadot CommitDate: 2022-08-08 13:22:34 +0000 linuxkpi: math.h: Add mul_u64_u32_div and mul_u64_u32_shr Needed by drm-kmod. Reviewed by: hselasky Obtained from: OpenBSD Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D35937 --- sys/compat/linuxkpi/common/include/linux/math64.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/math64.h b/sys/compat/linuxkpi/common/include/linux/math64.h index da8b19d37efe..f708f1ae81fa 100644 --- a/sys/compat/linuxkpi/common/include/linux/math64.h +++ b/sys/compat/linuxkpi/common/include/linux/math64.h @@ -100,4 +100,23 @@ div64_u64_round_up(uint64_t dividend, uint64_t divisor) #define DIV64_U64_ROUND_UP(...) \ div64_u64_round_up(__VA_ARGS__) +static inline uint64_t +mul_u64_u32_div(uint64_t x, uint32_t y, uint32_t div) +{ + const uint64_t rem = x % div; + + return ((x / div) * y + (rem * y) / div); +} + +static inline uint64_t +mul_u64_u32_shr(uint64_t x, uint32_t y, unsigned int shift) +{ + uint32_t hi, lo; + hi = x >> 32; + lo = x & 0xffffffff; + + return (mul_u32_u32(lo, y) >> shift) + + (mul_u32_u32(hi, y) << (32 - shift)); +} + #endif /* _LINUXKPI_LINUX_MATH64_H */