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 EAF74C02185 for ; Wed, 15 Jan 2025 11:35:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86D78280005; Wed, 15 Jan 2025 06:35:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 81D95280002; Wed, 15 Jan 2025 06:35:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E684280005; Wed, 15 Jan 2025 06:35:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 48944280002 for ; Wed, 15 Jan 2025 06:35:29 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 133431A09F4 for ; Wed, 15 Jan 2025 11:35:29 +0000 (UTC) X-FDA: 83009480778.17.00379A1 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by imf30.hostedemail.com (Postfix) with ESMTP id 1FC748000F for ; Wed, 15 Jan 2025 11:35:26 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=ventanamicro.com header.s=google header.b=DFYh3H0u; spf=pass (imf30.hostedemail.com: domain of ajones@ventanamicro.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=ajones@ventanamicro.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736940927; a=rsa-sha256; cv=none; b=Ai0Z8rnvF8gQijAbM3yCeiJhImCcF8l2XbZHLEBX4GpIgeCBBPCKIbWaLV5KjqJI4rxqeL bJAtdC7mDm1YctOinrxOTSpBLnSrizevY27/85jFzamJzEekp1cEvMWp1aTuAx3VWKO6Gt Me8nrD8OI0QZfl5EI0oPaGAMby+Mc+A= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=ventanamicro.com header.s=google header.b=DFYh3H0u; spf=pass (imf30.hostedemail.com: domain of ajones@ventanamicro.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=ajones@ventanamicro.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736940927; 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=lUHWtySzqJ9yO6ZWLDwixXceZtGyWajzSTrgRbyzKjU=; b=iOVX6xN4B2ar8OuXYb0eEJCnEK9IUlGulGfW8DnP70nTq79PcAELtdqwCLVmnk4P0Q9XUj QL0XxoOJTU/c3YHYDcFhYq47TbeZ0DFDyoGuWR6YXkojpPwCbcXTbj9n/Xm57/MP+54w3V Db5r+WAvn6XsTVfKb7WTLn6indeXv2Q= Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-aaf60d85238so1177125766b.0 for ; Wed, 15 Jan 2025 03:35:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1736940926; x=1737545726; 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=lUHWtySzqJ9yO6ZWLDwixXceZtGyWajzSTrgRbyzKjU=; b=DFYh3H0u6++VtIjKfOHiP8cj9ZrPfghqtCfAFaBAx0jwo34VXg2J19OhcUAK6k+oVM T4wtCAvpl2E6MTNWm1P7myC7kZcDzCsdnpjTo4L61fgIno3izsdlzkK31pkW4kaPr55o xorYZJHRr5PkK0rJjUKZncvgtCCbZGHHXuxpfyQlYw4gLU0FORiBT6YlYQ8iz0ZxLrgx owpGRQDr/WHRFNX7CUtczLHO6o1yA8eabpeLUaxhUT2+K1AG2fiD75y8Qus7ssWnm8/7 S+N7tOe76mJLvrwvLr9dOlF3WjdG4hgC472Gae05RnhySmZ9WDX4sdPoRrzDJNI08IuB dhVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736940926; x=1737545726; 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=lUHWtySzqJ9yO6ZWLDwixXceZtGyWajzSTrgRbyzKjU=; b=Br/owTpJXVt2NbqUw4B0OzJzScg+k18PzrDHmOWWSNe/IQwcJInw1/NvoqHz8VHdB7 Rs4pAB2MHusFkfHwjdqvj33y5aWeMevHbcEfrsve86w5GRZP7rdAPykGK//TAw/OTx+y 3+7k2YbkHg6oX9cGP+b9NmWxi2w2aScEh0/Hwnr405Zy3XJ8hlzfsq/lEKs7I6mKLG4F JWj2ALv4RNFUpUr0P46T0B3mU2oJV/KZGzNUVuMHC2AdxLcfQh/0AemfJ/Yd/Iqx0yb5 W9AgDypKCcAfbS3zKxJ3AAr2zcHES7N8fexfEIhY/0VPgn1Qljmi/LuWjMnQ7JihuADp SkTQ== X-Forwarded-Encrypted: i=1; AJvYcCVYMIr8aPOK3YjJ7ZEJmEMTO8oqAVxHYtk/M01BlejCdGf+J3TCEyUStBEDgQZiLcv1deW2oUqyWA==@kvack.org X-Gm-Message-State: AOJu0YzTg8rKYlSOOEqPLaVTi68OcuPU2Y1UIWxOpQuUpwSjcq/mK5pL WFhPMXBXURBKXtIqZ4xaPb8px5v4X18JsF/axtrAbjg2rY3a8Pwz6CmohWuNeBo= X-Gm-Gg: ASbGncsXmBeei6E/EvBvpTvYkVCqjfMuapjjh86WZ1YWytxyjDAW0GYe/T7KXNddriF DXJDNXrfUsxh8q8CnOBrAIgv02t4k9c5H8qwSNdekfnUEQ9JL2MKqEjylPpLL1WnMuI3o3ue1c1 EH503rbmw14rKI/L9Ut9/wmz25oqC6i9SJ+s7KFDrvoxyYANYB4A5PYK8HoFFCXkkhT+6HQo+jv 5DH6ZZolmX6dBx32hncVBYgJhPpDVe19srSscWo7TnN6m/RloPupyx0u/OUsbWu14VvdifCN+wn Or/dk/UHeJH2eVvbJSj6SS207Iv2siM36XNPCoxthQ== X-Google-Smtp-Source: AGHT+IEQLKTa0DBxC8EOVUTlbuIfogqAL7gY4MctOjS7wqT4IZEViihjVaBW+6yGKWlOG3PEpzozoQ== X-Received: by 2002:a17:907:9617:b0:ab2:d2e7:abc7 with SMTP id a640c23a62f3a-ab2d2e7b16bmr2022380966b.19.1736940925400; Wed, 15 Jan 2025 03:35:25 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c905ed87sm738090866b.28.2025.01.15.03.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2025 03:35:24 -0800 (PST) Date: Wed, 15 Jan 2025 12:35:24 +0100 From: Andrew Jones 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 , =?utf-8?B?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Ron Economos , Charlie Jenkins , 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: <20250115-710fcf2a3f874dfd032211c2@orel> 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-Rspamd-Queue-Id: 1FC748000F X-Stat-Signature: 4jo1ssbh1xyk15z7qmej8utdapaueug3 X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1736940926-367780 X-HE-Meta: U2FsdGVkX18+NV1wAz2glMNNgO1aamanOYPZ262M/3KU8P2L4x+GxD9j6C+RoqpciTQLO5bVeRwSbBy4K0zwwhd9QRYI6sbVO03QKqnOw9P3WdLdBeD0FUMzm68zNxQb6ES9FE5MqTeQUT10OqYYqKOFK6q4J1qHUHrIwVskTQHK6eK5BHsPBuuSAk/EUuZ957hKKxK51T+NCgQxLM/iJ+ZrpdiWOX33osSQc0Le7H4PcE1rhkPdsktBMN16f0Zla6BCIrD+Fb6UfBtXewtC36WocgItMsKZrfZLDGSR1ZoN8ylZ0sHp6yTbhom191yCA+SZbXcMMlWEt63HMD6urkg2Bw7K8N2p+v9DW8C+ulgV9Mec6zYoYLcKiWgAC8oNHodlaaX9S3PAs0h9WJlyXczF01LFu+bIAZcEjcoz92p3PkGpmznxV1dXWGb8rY5B/f7LOpfy6lZeS4DMQXuFiaqKEIipl2LHN7VZjfkXH4+YbQMJl7YoAm2/xjMLSsiL7QkQJcIRl/PiRFLJNW74s975eLiPL0us9QBxR71A/TWnvdfldTPWH7gXmnB+lU+bl7Zr5KMeWOLC05f5wOTFnkUGXyJUV0vi52YVyRzLzm6mCTZirIMTZTwrmI3cpokWB1IuzFrvmJC7+P+5fhXw1nTyc1PBGcoY0RNFYHFDnCuOQTrM4jSVIa6NxT02JOu8xb1zZ3EVqNMaMndtt2s/2ScRVSraqQjlEz2vOPWAkzWjOqAQX1rGTRadlPwJr3Qme9nv6jD7mlgbupGjWAA0bMLyt3l0jXzFAL6QEapCvjGglCn6ay1DmGt3GuhHVVbgMI8U2o4qE7ifRVjsZV50DtR+iTyjg7DE5ajYu7KZMZLWJ0fMVUvsq2Bm2R/TZm7KPe7te6lW/QU99cFVwHPm9N8txUImYEQkkEa4+1ru6Ogem33CV8xLq/4HWZUbeDgOPn+D/vv/qlnG392Zv8O DfC+xLzK 9smFxa2YLMNS7P9k0z3CWSD+q1cbxfR5y/LcnMWNImhu7u7TYL2CH1VyepMiiJFFX+k4qo2BTZ6jIJW/eR98DwB6eaPQ19sXV+ifYzqRhjKu2Ewa3IUaJhODrscIsDWaj75B2qeIZqc+PfkpEz/pYb4btq8Wp91Pl0PbEsZsbY90W2HzoZWsoKtbiTKDEMrz2HoCeHEto/W/FoCqdNKGMkJpXwFlbVOTdCx3JI5mGbFMzolAJ9VOyLxLEFg0BGBmBYll7APhd5VSf+I4m+es2QM6NccL8IM3gTe0DpBkchCk6JHfwDXL9BQl5G+dVht7GwTrVipQxgjQnAdeEjLuyH5fKAfb9aYxhLxDV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, 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 > --- > 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 > Reviewed-by: Andrew Jones