From nobody Thu Dec 02 09:00:28 2021 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 3D48E18CAB1C; Thu, 2 Dec 2021 09:00:29 +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 4J4VKS6dTfz4cK3; Thu, 2 Dec 2021 09:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 C3CED1A77A; Thu, 2 Dec 2021 09:00:28 +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 1B290SsG091637; Thu, 2 Dec 2021 09:00:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B290SgE091636; Thu, 2 Dec 2021 09:00:28 GMT (envelope-from git) Date: Thu, 2 Dec 2021 09:00:28 GMT Message-Id: <202112020900.1B290SgE091636@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wojciech Macek Subject: git: efa5d3831b0f - main - sys/libkern.h: Add type conversion helpers 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: wma X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: efa5d3831b0f0938115436be78f173366330a2ca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638435628; 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=4+OpxJF5Burq5Lzl86KlMN+rHDs2TQUvDjgsQ5nDo+k=; b=S1pcpZUZHZewv1HmxrwNRAwXLQCxsKPrtRqp4CEyptzHZYpN4WqTLikOrsA+GwzjFPadMR oxophEbWmrOO/Kz4G3ee2wgdQH7gwwzI83LBnIM7fULJzRW8uW0h7t4LLXC+Zw8oursSkB jvNJjyod1J/qgeMWOe2puRKkYUoNZ3KxXEnXOrqdnUWFlcMIvIMKP9CrwgZokK3TkxWIDf sCzi4SQWY/QQ+cqmFIPWCjHidCuHiuQYQsQinVm6XiiiwXTASAOKXkFslXGT3hbD53t3TV RoaLhKOiRQgAyaF+vLqfAwYp1o6WvQZ0J/1XEQ1qaUxPnqr+0aUYS3I2H0F+FA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638435628; a=rsa-sha256; cv=none; b=pkFzdEWcdUB1bteVo+Uixg0OUXStb1K/99mmNJOZOzhp6XaNkTj1lZnbJVMhFVvuKo/UdW o9VGxpxxJXQSNUhRWgJ2PmxgAsL463fl+HKGCRq38+pp3ZhhYx50W+hzXdN5Eud6rK8IpO JKBYHXzH2J/hFiHjtbBzvT0954YIOPY5bJyCgnjON8MhCvG5h7lhGVdEvFOqrP3BIxr850 1dbMXR+bzLWrwoDc9HK69xV75nIyvRj813dbt8yPsCWJg2bBlFUUq9ZyRUppNI6FKy9ddf w0QwOaK/OtxinDp1O7TKuRj0VeVNB6jF4pnLi512z5oXB6rVhlnMIqBZistVeg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by wma: URL: https://cgit.FreeBSD.org/src/commit/?id=efa5d3831b0f0938115436be78f173366330a2ca commit efa5d3831b0f0938115436be78f173366330a2ca Author: Hubert Mazur AuthorDate: 2021-11-26 09:20:04 +0000 Commit: Wojciech Macek CommitDate: 2021-12-02 08:18:48 +0000 sys/libkern.h: Add type conversion helpers Add helper functions for 32 and 64 bit unsigned to signed integers conversions. Reviewed by: Sponsored by: Alstom Obtained from: Semihalf Differential revision: https://reviews.freebsd.org/D33162 --- sys/sys/libkern.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 147eba9bd1bd..41844fa7490e 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -226,6 +226,22 @@ rindex(const char *p, int ch) return (strrchr(p, ch)); } +static __inline int64_t +signed_extend64(uint64_t bitmap, int lsb, int width) +{ + + return ((int64_t)(bitmap << (63 - lsb - (width - 1)))) >> + (63 - (width - 1)); +} + +static __inline int32_t +signed_extend32(uint32_t bitmap, int lsb, int width) +{ + + return ((int32_t)(bitmap << (31 - lsb - (width - 1)))) >> + (31 - (width - 1)); +} + /* fnmatch() return values. */ #define FNM_NOMATCH 1 /* Match failed. */