Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2629053lqz; Wed, 3 Apr 2024 04:08:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrGyjTXDtkA9z4ULo7RMVDfvfnAFGtz+jxiiKpngYY2eYB7NSoAU3LVhN779i7MFvNkAn6GB/icUprAkV4Hhf7m2qX0Vc/5Mm7kKzrBg== X-Google-Smtp-Source: AGHT+IF1w1KOlEXxWaJBXN6VIxQJP9UoCc1YMKiZmMjNhOGAIqDQzcogKJtGtiXXzO/wkY3dr0QA X-Received: by 2002:a05:6a20:8417:b0:1a5:6abb:7503 with SMTP id c23-20020a056a20841700b001a56abb7503mr14820837pzd.49.1712142527055; Wed, 03 Apr 2024 04:08:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712142527; cv=pass; d=google.com; s=arc-20160816; b=IhJl1tZg7cP7YDHctYzDlZa1P4ZoEvq4LyRx97nJzTzxl1rsTX5l0syhduDCGySk26 ziekQqSAqsFAy2w0zr43XkFZWuTic7tAGx5ToXfqsXG1e7hxII1fWEpnAKd8MPXsAfMC 2uW17JNPYiM+PqKZ3xRnnMe4g5r+TeDhhqRzM9i0Itoh8yY5m01RrPgr07Ki/Hm6sUaX mdTqabxbmURlapseEB3KRvMdoj4ny3+bP3lVgZBz7Y3Q8LQLkOELu8BWc9NQ9s7vCUDu a2sXCmu5g2nq/Z165FZQUujzvR7k+JOa8Bz75l5Ah5qyzkbXapE5LRj/zN/E158EsZF/ z2oA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:feedback-id:references :in-reply-to:message-id:subject:cc:from:to:date:dkim-signature; bh=gmr3sRWwVz1KFJTlsq4t7GqhuRPIjdz9F1vpTU2ecA4=; fh=1eN+strsLnX8cuvE+uTff7wY1KiEAf1jFO97IDCVf3U=; b=BM0lzon+FeVjApvzL4kmjF5b7dNPDQn457qA69F88xj7QE1zHEyB26erqYWWh5CTD8 jghru6z4nQef8+5reGdzL3U3ZZr4Xq++hv+eGGoUhtqIvKdpzOVBcFEvjty2d9NWrnvF nZuOZAAtqrkYGuGb/twSE5krXeV1WV9ehQNmzYk7AxzIwwWsIco6CThV7/NHAtJOZ5OG TTmuQjXx96M+t0tVCxBnFCYJzdW4IsC2LIbt/4pVsMSAScH4sBAGv/OlgIzgGV5QlumQ myMru2q+kvnoA3hgE1PtTzcbvVCZVIbO4o3Qt23j8Mv3DfK6hL4j0p3TcKv3nJcIjhM0 vG/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=KXtsN1gj; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-129588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129588-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k17-20020a170902c41100b001dd675cb6e3si13199024plk.214.2024.04.03.04.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 04:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@proton.me header.s=protonmail header.b=KXtsN1gj; arc=pass (i=1 spf=pass spfdomain=proton.me dkim=pass dkdomain=proton.me dmarc=pass fromdomain=proton.me); spf=pass (google.com: domain of linux-kernel+bounces-129588-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129588-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=proton.me Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AD8C1B252FF for ; Wed, 3 Apr 2024 10:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ABDA142E82; Wed, 3 Apr 2024 10:42:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="KXtsN1gj" Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57529433AD for ; Wed, 3 Apr 2024 10:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712140939; cv=none; b=sEI/TTBEPI9b5SLtcNUoUizKKIN5YTqvDMMJ3gGWXduJ2twL5I16ZhQ/BxEXlsVDa0GJv5KPfuwwCER+d+mA6PTGGVPWoIeTn/2tHy4b3N1QjiDXsTeeXIMK1vSZkZAXVOvFG6AFRffix3igUpMt8bwDyfG1xH2cDdKMkGjBS88= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712140939; c=relaxed/simple; bh=iC25lYOBAlQTYOx5EyMwl5mfX3TgCjRjQkwCKtwNzww=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MIkMKgA7jQe+e/yQHwdSZIvQu+2rgrgDymif4NSvHMcTyvLj7dbB6X3a4yi2ZczNGYmLwvO7Sy7E2ctrUPDZ/cL7UKgUPqjuBZUngiJ0bMuEJ3WbNm7cJhuRxn9SIxNwEYNiZopRBoCoWldGXLqNxlo4MCGRzTbC6WDLHPXRaF0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=KXtsN1gj; arc=none smtp.client-ip=185.70.43.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1712140935; x=1712400135; bh=gmr3sRWwVz1KFJTlsq4t7GqhuRPIjdz9F1vpTU2ecA4=; 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=KXtsN1gjpwhkuBWpW1Eyt2pTfbGx8FuLHYaNEHy1tMv7zk8N6JtGlhRxXqhNOfbIN 2V5NVUnqhw4omwtvF4kltzLHBGQKCK9awNyhrRnCMXEjqfneKhUXJl2BpA8vIBpxgs Mp7NqH9jB5t1P1gmF0KRjV38HZAp3AA82l3zBow5yYPisKh4ZHYsO0OORZeJE+GLgw MvHLFF9OmXkXE9IhyK0P2t4AfYxEhjVcjLoGKDxiktK9QsjTchp3wzBXzELfKmUoMp 8CQF1+gQFnfnlPhUPEQ+QFtZEbqFvSZAGleulorWLH1dSDIf1OGhJKQbJqG/ud2OYu rMOzaX0/FUVNg== Date: Wed, 03 Apr 2024 10:42:06 +0000 To: Alice Ryhl , Miguel Ojeda , Andrew Morton From: Benno Lossin Cc: Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Marco Elver , Kees Cook , Coly Li , Paolo Abeni , Pierre Gondois , Ingo Molnar , Jakub Kicinski , Wei Yang , Matthew Wilcox , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org Subject: Re: [PATCH 4/9] rust: list: add macro for implementing ListItem Message-ID: In-Reply-To: <20240402-linked-list-v1-4-b1c59ba7ae3b@google.com> References: <20240402-linked-list-v1-0-b1c59ba7ae3b@google.com> <20240402-linked-list-v1-4-b1c59ba7ae3b@google.com> Feedback-ID: 71780778:user:proton Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02.04.24 14:17, Alice Ryhl wrote: > +/// Declares that this type has a `ListLinks` field at a fixed offse= t. > +/// > +/// This trait is only used to help implement `ListItem` safely. If `Lis= tItem` is implemented > +/// manually, then this trait is not needed. > +/// > +/// # Safety > +/// > +/// All values of this type must have a `ListLinks` field at the giv= en offset. > +pub unsafe trait HasListLinks { > + /// The offset of the `ListLinks` field. > + const OFFSET: usize; > + > + /// Returns a pointer to the [`ListLinks`] field. > + /// > + /// # Safety > + /// > + /// The provided pointer must point at a valid struct of type `Self`= . > + /// > + /// [`ListLinks`]: ListLinks > + // We don't really need this method, but it's necessary for the impl= ementation of > + // `impl_has_work!` to be correct. > + #[inline] > + unsafe fn raw_get_list_links(ptr: *mut Self) -> *mut ListLinks { > + // SAFETY: The caller promises that the pointer is valid. The caller only provides a valid pointer, this also needs the requirement from the trait that `OFFSET` is correct. --=20 Cheers, Benno > + unsafe { (ptr as *mut u8).add(Self::OFFSET) as *mut ListLinks } > + } > +}