Message ID | 20230403154422.168633-6-y86-dev@protonmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2401448vqo; Mon, 3 Apr 2023 08:51:07 -0700 (PDT) X-Google-Smtp-Source: AKy350Y1lF6bqhOhluqtYPUJ/VaVZ2dSzvfPEY36GpmyigIHxpMJfsg69uzrP3wvkBygJqwxdUH4 X-Received: by 2002:aa7:d313:0:b0:4f9:e6f1:5c7c with SMTP id p19-20020aa7d313000000b004f9e6f15c7cmr36621962edq.32.1680537067501; Mon, 03 Apr 2023 08:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680537067; cv=none; d=google.com; s=arc-20160816; b=0xAAz52UvQQnLqC/wkZQxNa92BNZ9RouLBPP+Fhggsba2+/14QNnO51bWUg5cZ1qDL E47ZgB7pB+eLLWpHqWV04Z2aHHkmJ3FVwGnjR3TG37ibZgx3rzoMW/TMizuR97B+goHK QhmhPDSRmWqSixMwqKaOemZcuCHoQarR+O7mxJR1D/oO1G0Zs+FHJCULWp19AzlwUaoB SYrqq/S0DERPfobu6wkjjTZymrJ/oerAbOlGYkRTFwuOIHPLAEAZrMQfnkdTGqBeO9xH gNp5CWmKWHZ+OdcGq20+m7ygG5esqPXxMlH0hj71piJhjt8QPGdztvp/1lhFPG2WtmbQ 3kkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=7rH6H6G+ATzJ5NdhnHFFoHIa5Qvd43Dus1uGWQ71zqY=; b=fccV+PUJGLdlEqD0erRvoVHuPWt0DwB2x1IBOvGmezxFOIQWtzxamxX0f29Q0SEoq3 gAOXmqhnS+UWhgwnqGN/bkSzBSLW57B5+nQxl5nQtfTNqEIvKUwFKsVksTixicTp9Ufu BwWtgUUfAJxFz71faBjzRdupm+HOZaAkRcVuWp3m3tjCPWgbJiESNPqIMCXL1PZcPxBK W7E7W0mxiMRfXRN+ald6x+d0uyDTep9nP8v/BNvsfQWrI8m2/ey3WyNCdmwJccLUQrGb cag4mxHcWpSAhPnVXPymdAzskppUF2pj1sdE0g1AFengLPtCJzxMHkR3+cPqWpzZ1r2K nTpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=rOhPrLQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m17-20020a056402051100b004acef3d53b7si5978282edv.269.2023.04.03.08.50.43; Mon, 03 Apr 2023 08:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b=rOhPrLQY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233039AbjDCPqC (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Mon, 3 Apr 2023 11:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232789AbjDCPpr (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 3 Apr 2023 11:45:47 -0400 Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F6D435B3 for <linux-kernel@vger.kernel.org>; Mon, 3 Apr 2023 08:45:28 -0700 (PDT) Date: Mon, 03 Apr 2023 15:45:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1680536726; x=1680795926; bh=7rH6H6G+ATzJ5NdhnHFFoHIa5Qvd43Dus1uGWQ71zqY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=rOhPrLQYAcKOWJDIU61GZz6rq/yIy1wLIxWh57OGv3fmXFw7r5v7+S03zLG3pXTxm 8nanqh+YIm0CVcVeWxA1NvyBMnNg+1KR1C5MdWqvKMcHcctsH6sVnXR96dCM7Zihpm DLhpujgwjcrNizjgXs4mWNPd4cqXkbn/8X8rdPrrfci8ZBu6gJD4BxeE8v5n2tTuDh lLpGrC4ZyfcgVztNhTa4kLwP+vC+Yf3vrDPp8BaLSuwlcelXcoxshPx/qdhWhfgMWz mlLUw/OcRT+SwGY6gT2fmmvFLlN1hTRyTKlZKvskGX1ID2zx3wHxUBk6ekkTfjsTnx Veh8ArMiQoonA== To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Alice Ryhl <alice@ryhl.io> From: Benno Lossin <y86-dev@protonmail.com> Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Benno Lossin <y86-dev@protonmail.com>, Andreas Hindborg <a.hindborg@samsung.com>, Alice Ryhl <aliceryhl@google.com> Subject: [PATCH v5 05/15] rust: types: add `Opaque::raw_get` Message-ID: <20230403154422.168633-6-y86-dev@protonmail.com> In-Reply-To: <20230403154422.168633-1-y86-dev@protonmail.com> References: <20230403154422.168633-1-y86-dev@protonmail.com> Feedback-ID: 40624463:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762170835767365800?= X-GMAIL-MSGID: =?utf-8?q?1762170835767365800?= |
Series |
Rust pin-init API for pinned initialization of structs
|
|
Commit Message
y86-dev
April 3, 2023, 3:45 p.m. UTC
This function mirrors `UnsafeCell::raw_get`. It avoids creating a reference and allows solely using raw pointers. The `pin-init` API will be using this, since uninitialized memory requires raw pointers. Signed-off-by: Benno Lossin <y86-dev@protonmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> --- rust/kernel/types.rs | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.39.2
diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs index 9d0fdbc55843..ff2b2fac951d 100644 --- a/rust/kernel/types.rs +++ b/rust/kernel/types.rs @@ -238,6 +238,14 @@ impl<T> Opaque<T> { pub fn get(&self) -> *mut T { UnsafeCell::raw_get(self.0.as_ptr()) } + + /// Gets the value behind `this`. + /// + /// This function is useful to get access to the value without creating intermediate + /// references. + pub const fn raw_get(this: *const Self) -> *mut T { + UnsafeCell::raw_get(this.cast::<UnsafeCell<T>>()) + } } /// A sum type that always holds either a value of type `L` or `R`.