From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 83A17C02180 for ; Wed, 15 Jan 2025 21:34:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D04E280002; Wed, 15 Jan 2025 16:34:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 181766B0089; Wed, 15 Jan 2025 16:34:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02152280002; Wed, 15 Jan 2025 16:34:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D82F56B0088 for ; Wed, 15 Jan 2025 16:34:25 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5180B1A0332 for ; Wed, 15 Jan 2025 21:34:25 +0000 (UTC) X-FDA: 83010990090.21.40BA6E3 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf14.hostedemail.com (Postfix) with ESMTP id 5F12E100007 for ; Wed, 15 Jan 2025 21:34:23 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gT6ZGhR6; dmarc=none; spf=pass (imf14.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736976863; a=rsa-sha256; cv=none; b=oIIb63jyy+Rnh9qYKKMai2MRtPxYP/C8lSerDlJYF0aUGRZj3ErZeCrviBX+x9VEyuq7Ks 2RfKkQMHVuLQZOzmqavCojr35VwzPrjCWTXuy7zsoNNzF7Zb6yJOylEl/ofvadSDFi20St 2hVMrzf3awj3RQG89J+jFHeet+M2szU= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=gT6ZGhR6; dmarc=none; spf=pass (imf14.hostedemail.com: domain of charlie@rivosinc.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=charlie@rivosinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736976863; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XVmYZuo4JztFy4oHdJS4ilSyh+oEt0DgqkgC+LTjKe0=; b=AgN54yiDgEjwocw/+yTk0GTDJGWaHAOdIC2aUzBKe30mExjs22fWdHawcEa/yfZHcvn8Oj dmic+Cbzww1XShI5iy/xX/BIEpYG00uLKgdxSOyYHqrcX3WF96s6PHpinq67W/q1lsXWq+ I87RXkwvDh9noWkYi7CE/E7NDImZl9s= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2166651f752so3476135ad.3 for ; Wed, 15 Jan 2025 13:34:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1736976862; x=1737581662; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=XVmYZuo4JztFy4oHdJS4ilSyh+oEt0DgqkgC+LTjKe0=; b=gT6ZGhR6MAK0F5UDW5mYlucxs/X0cZScTGqGC2vzJCccanVRgbaildyYXy9JdjNmAz Ge9RIOOVHA0rW9NHxEm2Tk4dnk5XQ5uzDSWRKK5H2PmgyhDxKh75zGgcY6upcc/LpmUA d2SVfc8CF9opq+hO2gKh20LE84cbJR/9jmrZk7CGvgoi4NdaW3p16QTrfjSC60wQJA7V aFxzE0IjxfvpiC5CjTwf3JbXw2IkQVzTGGp6oxhvlrKJIagv8IDI8MyDa2nsuAD8fkCF QXZXusUk/CIFEYnmczVFGUPXOq7H76erLRcuQoAiJYxDy1O0h28DV9npuJJgtMErH9nL EthA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736976862; x=1737581662; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XVmYZuo4JztFy4oHdJS4ilSyh+oEt0DgqkgC+LTjKe0=; b=oH4s6Vh0Sd1goYax06GBL3HQmuYVKD/yShprVIWVcPjIjyeM8wUpJkLgiP69cPijgG maZk27TGvGBuUMMRmISddUDf44ILGDyS9CPs6LLuXetxMe+nswR/4TQGIDJoCCzH3tpN 1bDU/CtVYNxlrPw6dGBR7TneWdusN9D9tOZLnV3004paQyNae1iurNzqS92Oqtvx/9D1 AM2kswKb20BcG3+VNBZKLb1mGb7KBQqNFWBafgslZtq1LFgtTjRv9D1FXCTvRLm0qrWV QCZ8XrC0r/ZdGk+o02Fdqtx8eudHShjgBBgeZ7vKlwHLe3F3bl6E3IBosD52K3Nz/bnY Le0Q== X-Forwarded-Encrypted: i=1; AJvYcCUzOXzjcEwOTkSN1/M/ZzfKMvHwPVzViXXjGYODA4TyawNXn9FHGP7lnGqL+L/b9LzVMw8bHezYnA==@kvack.org X-Gm-Message-State: AOJu0YyAFyBmbYMSuSBRXVt5AH8eo2EEHlS46APV/UdFWJJsgAYjBjVJ +YKjyrOo5xiKCuUAtCYVoD8Lu/CD5RFplZTqKj8a+VjvxU8JrVrsdQJqz50v3JE= X-Gm-Gg: ASbGncsXzIzQhqMMYdU7MHrumYDh0a1Rvgos8XuPVEJR5+hOQeQJyHRJl0914knkpHK zqa48Oi+MgKf/Z6e8G7gewTVA3Kb+k2sae97DmIh66umLx5zgwZPF9CA3MBXQDqKoriu2ThA94o A4wYjH0OU5QNviyF/21JQ0ZWvkHeLLHtzOdvfxTbE6awqBYUYaNhJ7aZqKfhvx/zuAZRZNMawuc VEfFzZ5WIgNlI4KQjqNztcG6D1PCAmhXNHplCmi+HTO/bU= X-Google-Smtp-Source: AGHT+IEFFmZNaH6UqZPYmMZlBbhtp2FzCX0zJ/bThZgticWcSW23VRr/5H6Ff6GcPQSKFDKM32goTg== X-Received: by 2002:a17:903:2311:b0:216:4724:2757 with SMTP id d9443c01a7336-21a83f46a3fmr512059935ad.4.1736976862005; Wed, 15 Jan 2025 13:34:22 -0800 (PST) Received: from ghost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f25c927sm87197555ad.228.2025.01.15.13.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 13:34:21 -0800 (PST) Date: Wed, 15 Jan 2025 13:34:17 -0800 From: Charlie Jenkins To: Celeste Liu Cc: Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Eric Biederman , Kees Cook , Shuah Khan , Albert Ou , Alexandre Ghiti , "Dmitry V. Levin" , Andrea Bolognani , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Thomas Gleixner , Ron Economos , Andrew Jones , Quan Zhou , Felix Yan , Ruizhe Pan , Guo Ren , Yao Zi , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v6 2/3] tools: copy include/linux/stddef.h to tools/include Message-ID: References: <20250115-riscv-new-regset-v6-0-59bfddd33525@coelacanthus.name> <20250115-riscv-new-regset-v6-2-59bfddd33525@coelacanthus.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250115-riscv-new-regset-v6-2-59bfddd33525@coelacanthus.name> X-Rspam-User: X-Rspamd-Queue-Id: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dos502tASROgL3LToF6BPU0ANsgVD+1/l2OuGvPU+0gv8CQnpiK2nBTjQijVYVR8odYwGbFRGMjy+7AMbCi4saOdellF3Qm2rGStOwQIScLryMcPkh31snWgMsvEZ/lVhC7RwFusS9cQe0grTLnvvEqsW298fk8O4Wa67UkTtHYdoAsz2sAaiP4b1gKKiFsU7dr1pv9Tn4QpsLVrRvoRd/5vd9tMbsAV7zLQI8piR2XU9kBi+IqWG2/MLaHXmR+1FX847B2A1+wCsvUlmALdiGTCEGOFc2XZNOMCPetloOcTwN5F+OyPuS/TWvxM9VrEYIIH1xZLCIEByLUrseQxtznEonRTWpA33iParon1Nsbt61JuZQPbGLdJhPBUXl72h9pW7Kjmdb/TNDES00FNgHPHDu/QX3wcvcOXr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jan 15, 2025 at 07:13:28PM +0800, Celeste Liu wrote: > Some macro defined in stddef.h are useful and have been used in many > code in selftests. Copy them to tools/include so developers needn't > create their copy in every files. > > Remove some definitions like NULL and true/false to be suitable to > non-kernel environment. > > Signed-off-by: Celeste Liu Reviewed-by: Charlie Jenkins Tested-by: Charlie Jenkins > --- > tools/include/linux/stddef.h | 85 +++++++++++++++++++++++++++++++++++++++ > tools/include/uapi/linux/stddef.h | 6 +-- > 2 files changed, 87 insertions(+), 4 deletions(-) > > diff --git a/tools/include/linux/stddef.h b/tools/include/linux/stddef.h > new file mode 100644 > index 0000000000000000000000000000000000000000..55f3964d9a3d9f9f9345a75248eec027c56faef9 > --- /dev/null > +++ b/tools/include/linux/stddef.h > @@ -0,0 +1,85 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _LINUX_STDDEF_H > +#define _LINUX_STDDEF_H > + > +#include > + > +/** > + * sizeof_field() - Report the size of a struct field in bytes > + * > + * @TYPE: The structure containing the field of interest > + * @MEMBER: The field to return the size of > + */ > +#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) > + > +/** > + * offsetofend() - Report the offset of a struct field within the struct > + * > + * @TYPE: The type of the structure > + * @MEMBER: The member within the structure to get the end offset of > + */ > +#define offsetofend(TYPE, MEMBER) \ > + (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) > + > +/** > + * struct_group() - Wrap a set of declarations in a mirrored struct > + * > + * @NAME: The identifier name of the mirrored sub-struct > + * @MEMBERS: The member declarations for the mirrored structs > + * > + * Used to create an anonymous union of two structs with identical > + * layout and size: one anonymous and one named. The former can be > + * used normally without sub-struct naming, and the latter can be > + * used to reason about the start, end, and size of the group of > + * struct members. > + */ > +#define struct_group(NAME, MEMBERS...) \ > + __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS) > + > +/** > + * struct_group_attr() - Create a struct_group() with trailing attributes > + * > + * @NAME: The identifier name of the mirrored sub-struct > + * @ATTRS: Any struct attributes to apply > + * @MEMBERS: The member declarations for the mirrored structs > + * > + * Used to create an anonymous union of two structs with identical > + * layout and size: one anonymous and one named. The former can be > + * used normally without sub-struct naming, and the latter can be > + * used to reason about the start, end, and size of the group of > + * struct members. Includes structure attributes argument. > + */ > +#define struct_group_attr(NAME, ATTRS, MEMBERS...) \ > + __struct_group(/* no tag */, NAME, ATTRS, MEMBERS) > + > +/** > + * struct_group_tagged() - Create a struct_group with a reusable tag > + * > + * @TAG: The tag name for the named sub-struct > + * @NAME: The identifier name of the mirrored sub-struct > + * @MEMBERS: The member declarations for the mirrored structs > + * > + * Used to create an anonymous union of two structs with identical > + * layout and size: one anonymous and one named. The former can be > + * used normally without sub-struct naming, and the latter can be > + * used to reason about the start, end, and size of the group of > + * struct members. Includes struct tag argument for the named copy, > + * so the specified layout can be reused later. > + */ > +#define struct_group_tagged(TAG, NAME, MEMBERS...) \ > + __struct_group(TAG, NAME, /* no attrs */, MEMBERS) > + > +/** > + * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union > + * > + * @TYPE: The type of each flexible array element > + * @NAME: The name of the flexible array member > + * > + * In order to have a flexible array member in a union or alone in a > + * struct, it needs to be wrapped in an anonymous struct with at least 1 > + * named member, but that member can be empty. > + */ > +#define DECLARE_FLEX_ARRAY(TYPE, NAME) \ > + __DECLARE_FLEX_ARRAY(TYPE, NAME) > + > +#endif > diff --git a/tools/include/uapi/linux/stddef.h b/tools/include/uapi/linux/stddef.h > index bb6ea517efb51177a7983fadad9b590b12b786e5..f2548fd95f6e1d8cb218d52918bb81a3317d10b1 100644 > --- a/tools/include/uapi/linux/stddef.h > +++ b/tools/include/uapi/linux/stddef.h > @@ -1,8 +1,6 @@ > /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > -#ifndef _LINUX_STDDEF_H > -#define _LINUX_STDDEF_H > - > - > +#ifndef _UAPI_LINUX_STDDEF_H > +#define _UAPI_LINUX_STDDEF_H > > #ifndef __always_inline > #define __always_inline __inline__ > > -- > 2.48.0 >