Message ID | 20240812182355.11641-22-dakr@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61725C52D7C for <linux-mm@archiver.kernel.org>; Mon, 12 Aug 2024 18:26:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F26186B0088; Mon, 12 Aug 2024 14:26:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED6B26B00A7; Mon, 12 Aug 2024 14:26:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D75DA6B00A8; Mon, 12 Aug 2024 14:26:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BA04A6B0088 for <linux-mm@kvack.org>; Mon, 12 Aug 2024 14:26:07 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7740C160359 for <linux-mm@kvack.org>; Mon, 12 Aug 2024 18:26:07 +0000 (UTC) X-FDA: 82444422774.11.6C7BF1B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 6FD891C0012 for <linux-mm@kvack.org>; Mon, 12 Aug 2024 18:26:05 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fE8d51Uy; spf=pass (imf18.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723487096; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dkPtj490zlFGnVlHtWZ3Siudb6D0KpgjZXn9rYj4+jw=; b=ZH6qa9iK+MnqF7qboUYCKb7D8me1S8oABTo1s0fMRTk/cXRhZwKy5McLc5hFgJ6dm2HEgC wMwr03ZARYnETDSPbHclVYs7MnPbMPDaXZZbSnitlis2k9hrh8uSaauFr3pB9HduEX2Ujq q+pq9GnQFAyKOQ5nn1dLzUkApIJY9Js= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723487096; a=rsa-sha256; cv=none; b=VAqjMzfvOxvdLXOzGYEL3SFl3GySph9i5rzV4dkmmtuMiXcsf+LBGpXY/2Jn/4BVNI2YEp KDxzGzrtCFxuE+m40FWQu39PvCRKkbGHDeNtzqSFWUnq7wtZ8OITLjdZmvCJF1URImsC0E 8qQBY79sgmeKEf2ADGxIYHiRpQx6r5g= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fE8d51Uy; spf=pass (imf18.hostedemail.com: domain of dakr@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=dakr@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9A585CE0FE7; Mon, 12 Aug 2024 18:26:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAB24C32782; Mon, 12 Aug 2024 18:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723487161; bh=tl80HVK20EtCGNYhPnG7N36D8g8ociS1KN//HywX5k4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fE8d51Uywi9gQkO5aVDXQS6bCB1Esv9I/pGSi59+t323AQL2pLKex1YwXjRRlx6d5 /eMp8maDX8Z24YUglnm+TSz8p7tRMIXY6wA+hBLiVjTzJB8Z8UI4V7rfMUIySu8X05 NbpWU0BEcdDgCiWUCEJnk3RlTEtUoBjFYUZ8WYduUgOgZvaMJuvH5NX8w8Gb1L7yJN UOC7iLtJy1PUyPNFyWha7v5bQqsNZqK1J4V/j69V+bjeeiTqX8Fh8BY5ogM0CUP9H0 XS038gpPB6uo1XOmJhNY4JDsPmsllDzyaQFHv2n1Vfa6YQEuYH9rcE9xx7NjVAw0lk iaDfSWN3spO5A== From: Danilo Krummrich <dakr@kernel.org> To: ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, akpm@linux-foundation.org Cc: daniel.almeida@collabora.com, faith.ekstrand@collabora.com, boris.brezillon@collabora.com, lina@asahilina.net, mcanal@igalia.com, zhiw@nvidia.com, cjia@nvidia.com, jhubbard@nvidia.com, airlied@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Danilo Krummrich <dakr@kernel.org> Subject: [PATCH v5 21/26] rust: alloc: implement `contains` for `Flags` Date: Mon, 12 Aug 2024 20:23:07 +0200 Message-ID: <20240812182355.11641-22-dakr@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240812182355.11641-1-dakr@kernel.org> References: <20240812182355.11641-1-dakr@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6FD891C0012 X-Stat-Signature: joh6kc7r5rshk1a4e45dhjbps6ggjoxx X-HE-Tag: 1723487165-5875 X-HE-Meta: U2FsdGVkX18B0EmSnh3cB4qALDuzd7RlSoyV/+i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8Qw/fQW03P/ENfWMbNbwssp/LvD7EBpIGIXVhreNXdW22RF/hxD+9BS3EcLGALk0E6d/7Cr5ERR4QYxxDEnzkNa+gUFhQxBPWzdSYiFhF7wsVX1J53gyiQZQDm2YOo3b60ws3sUncpeaK+S6A0uTFBFBpG7pdsE4JBxPz80klNvk5LevzzMsc62EvQrWR0lUq0am8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Generic `Allocator` support for Rust
|
expand
|
diff --git a/rust/kernel/alloc.rs b/rust/kernel/alloc.rs index 820ef6072e02..be2bd0f1e74a 100644 --- a/rust/kernel/alloc.rs +++ b/rust/kernel/alloc.rs @@ -34,7 +34,7 @@ /// They can be combined with the operators `|`, `&`, and `!`. /// /// Values can be used from the [`flags`] module. -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub struct Flags(u32); impl Flags { @@ -42,6 +42,11 @@ impl Flags { pub(crate) fn as_raw(self) -> u32 { self.0 } + + /// Check whether `flags` is contained in `self`. + pub fn contains(self, flags: Flags) -> bool { + (self & flags) == flags + } } impl core::ops::BitOr for Flags {