Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp2445723rdg; Mon, 14 Aug 2023 02:48:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdES/p4iWTTiwGsWNK20vI3PDJqXgQ6wOG0ZIH16l+jU89EV5507KSVQQtDrihjGyoeqvD X-Received: by 2002:a05:6a00:1708:b0:67b:8602:aa1b with SMTP id h8-20020a056a00170800b0067b8602aa1bmr10036238pfc.27.1692006520172; Mon, 14 Aug 2023 02:48:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692006520; cv=none; d=google.com; s=arc-20160816; b=rjj+nBaT+1VzSWsiDXvN/eqaJWPPFqD0MRiC+8dVYi1HNI4O/jyOHeS6sWLh5hB/1K i7c2oTiip9lAnskEqZq48wuZRU3Z3HLhU097QjvnsPqqcSS8+tV/aQCjkh7yrVkhP2k1 W2rYwwBBSBl+8zoKK2LEmXBMdnxiNnnL6dzvdmeBJsapIhH27rxkyiRanxl88IeUa67I +oGXN/MZ1O4grDxd5rf+lz5hsFQovquQeI7kU8NQCoqsQAfa3BlrXMY60v8DMDJQ2mo7 kVsghJrekhQDvenz5GyTroXer5yOPoV+8QTEBRGtN/x9H5Yx6RgslXuEZCdXYGHjBnw4 bAIQ== 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=cCm8wW9vNkKH2FZUy3jRZYJZ3dWJlVZH7ASGRvlZaKY=; fh=TE4onW3Du2FQ1EsedDK8TzgRHOYndfJXYpOtlseWrM0=; b=v3tLtUsxDNhDvsT5C8el3hOL3HbNXs/d3UXR4tVomf4FMn8a9U9xbxFTFXtDpYDY68 op59XzId7Jme1nmaUbw0ObUjg7PTk3vk0DHniIr+zHokMtVgTR8XWHsOoUxN3/xG++VD /l+64+cItkIlPzB3OMDXM+wZYN7clampKGkYBKRqeyW1WfPiIIKZNL5AYnJo2H5GDLgJ hJ10k8occEOSSTVszRL9GCvuKLtab9QltyitB+oZXalGA5AXRHw825M1o0LNcaGwmFEP Y4oJ5l1tqVrQvWLp5/1HyW3lyFNdaDG6Jgg96jvwhGebY8Gu+McEL/H2S8OlTkoNM2WG eiww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=f6gK19pW; 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=proton.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a63de0a000000b00563e652b06fsi8096072pgg.893.2023.08.14.02.48.28; Mon, 14 Aug 2023 02:48:40 -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=@proton.me header.s=protonmail header.b=f6gK19pW; 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=proton.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234428AbjHNIrM (ORCPT + 99 others); Mon, 14 Aug 2023 04:47:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234958AbjHNIqq (ORCPT ); Mon, 14 Aug 2023 04:46:46 -0400 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7299F12D; Mon, 14 Aug 2023 01:46:45 -0700 (PDT) Date: Mon, 14 Aug 2023 08:46:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1692002803; x=1692262003; bh=cCm8wW9vNkKH2FZUy3jRZYJZ3dWJlVZH7ASGRvlZaKY=; 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=f6gK19pWOkyU7bTj7Kg/FMG1ckvi7PYfOhAi1ncpXLPafgl5r3cYDtO/VzAzitHFA UCvdyD/gVxVDnRmgn7xGwopgP4ygYk7EBfd7NZTwxM+/AtaVkyobCrTsAvsw96nCTF kAob29TUS63xuJuUbLIVGGtzq0tSOcPMvklbF/9Z0GV+3HWNbs/aFPUvP8u8/OKSEJ 05yGRoWkw072+33b/wg1rt8IhtxIyeszCk5nDZtFjWAmNrtrxHROIQT0T2xq+u+0N8 uXi/Y5ldaxdaEYRZ0egRZBQLrLIIRZ05OvckVmROJn5TMwqHPgBDK0RFiu1Ey8/CrM qNK6obLjqQT8A== To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor From: Benno Lossin Cc: Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Martin Rodriguez Reboredo Subject: [PATCH v4 02/13] rust: init: make `#[pin_data]` compatible with conditional compilation of fields Message-ID: <20230814084602.25699-3-benno.lossin@proton.me> In-Reply-To: <20230814084602.25699-1-benno.lossin@proton.me> References: <20230814084602.25699-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org This patch allows one to write ``` #[pin_data] pub struct Foo { #[cfg(CONFIG_BAR)] a: Bar, #[cfg(not(CONFIG_BAR))] a: Baz, } ``` Before, this would result in a compile error, because `#[pin_data]` would generate two functions named `a` for both fields unconditionally. Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Gary Guo Reviewed-by: Alice Ryhl Signed-off-by: Benno Lossin --- v3 -> v4: - added Reviewed-by's from Gary, Alice and Martin. rust/kernel/init/macros.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rust/kernel/init/macros.rs b/rust/kernel/init/macros.rs index fbaebd34f218..9182fdf99e7e 100644 --- a/rust/kernel/init/macros.rs +++ b/rust/kernel/init/macros.rs @@ -962,6 +962,7 @@ impl<$($impl_generics)*> $pin_data<$($ty_generics)*> where $($whr)* { $( + $(#[$($p_attr)*])* $pvis unsafe fn $p_field( self, slot: *mut $p_type, @@ -971,6 +972,7 @@ impl<$($impl_generics)*> $pin_data<$($ty_generics)*> } )* $( + $(#[$($attr)*])* $fvis unsafe fn $field( self, slot: *mut $type, --=20 2.41.0