From nobody Thu Oct 30 23:04:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1755988045; cv=none; d=zohomail.com; s=zohoarc; b=duB37mBlhUfZRR9H6RGVgky3s3RT0VOC1NecVcvehxZR/FVChApnT5kpr3zizjxSc5C8o14V9Z2vv4jgS+E/Nb1vh5s5fvNyeUmxspJ7lUjAoZm4ipbfNNhPynnkhUfBhIiaaiVrZCcO5sQDNcQ1ukBq+scvBKhAJJ+aVKvpPHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1755988045; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hxbSUIBsw0EVkmhIu0DrRsRTOlPMr0YznFiwwKR8I0U=; b=cV4hvABUK8kz58Q4PUWkacNV1Q9nvSOqsjo0CfxxvuHXNQSgehsCt/9xH5ES6MRmZuK1c112QCx2ysr5/y9R04w2cLbyP87dW37a1g5pEyG5LXihLR78SYyrgiTdd+0YqPkGXJQOsQRDZn54vaQkjfhBYl/2/5VrPA+col1KybI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1755988045451427.4637707504768; Sat, 23 Aug 2025 15:27:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1091560.1448080 (Exim 4.92) (envelope-from ) id 1upwhQ-0001QG-1k; Sat, 23 Aug 2025 22:27:00 +0000 Received: by outflank-mailman (output) from mailman id 1091560.1448080; Sat, 23 Aug 2025 22:27:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1upwhP-0001PK-Ri; Sat, 23 Aug 2025 22:26:59 +0000 Received: by outflank-mailman (input) for mailman id 1091560; Sat, 23 Aug 2025 22:26:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1upwhO-0001Mm-R9 for xen-devel@lists.xenproject.org; Sat, 23 Aug 2025 22:26:58 +0000 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [2a00:1450:4864:20::52d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 47d4fabd-8070-11f0-a32b-13f23c93f187; Sun, 24 Aug 2025 00:26:58 +0200 (CEST) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-6188b72d690so450913a12.2 for ; Sat, 23 Aug 2025 15:26:58 -0700 (PDT) Received: from lab.home (dynamic-2a00-1028-83a4-4bca-c0bb-96ff-feed-9d50.ipv6.o2.cz. [2a00:1028:83a4:4bca:c0bb:96ff:feed:9d50]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afe48fd37fbsm252045166b.47.2025.08.23.15.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Aug 2025 15:26:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 47d4fabd-8070-11f0-a32b-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755988017; x=1756592817; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hxbSUIBsw0EVkmhIu0DrRsRTOlPMr0YznFiwwKR8I0U=; b=Sr7Ud6jS6eRSf0GZDtOwnKjqsPOJCNk45Eub2ilnAjRR2u2p3mU2W1cMQSIoUXVHlO tX4RNhNZ6uMYdvEzDyjUfPO7P5oSmcfSin4WuvvINJSQda/EKKXJNo8cG2CG0X77T8BL nMj4yfJtAQkJxg+EFogCwMFmYK8oE2TjgVPoLJYtNdK5VtCXNxoDH9rcGpMPmL3aE4+A vl8p/r9A2bjTEveeiCNrk4OOqtiZ0ffp4P1kpaSjqxPSelNksR0POTYnmLU118Rj7oPU viXqlyihiQj7BLixjle35J+EdMjGoucyxwapWRu9euJksDV8cj/gwr5FVUpu7dkCTAEg MeCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755988017; x=1756592817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hxbSUIBsw0EVkmhIu0DrRsRTOlPMr0YznFiwwKR8I0U=; b=dqBM2JYk60PBOATgethxl1vTOLd+HiRThSH78o5dwXVyKRJDUCodWqUpfqS280zLKF xEoJP24+qFpxaIRLmX8TMijAYK0kIMAcvcgFrxKuAuwBFRgrB7WFgxx6B1fy+H7079rv 7dlvwWtTWPVb+NsDAEIQ1wcDtNDGOebzM/qKnGFGpfGNvM6puCqU5qku18UdZbNzo9oI 39zMevDOK+czNoFTrj+gBeG1SS9NbkgwRqGwaJ8xjjz/tnGVyhcq37RDhtXTI5nMo63+ 0wj/Nd7IwPodZwfWYH7csxZ1q5+g5hLhlxrzc0JDuUjr+HO3Q7nSxPIHO33T7O2LN4LX tzUA== X-Gm-Message-State: AOJu0Yyp123CJKcmiSOrxGgMVfkU50bNwrD82ToYRFh89dk2+WyOWHd8 vDEg2+kbeWYNFRyOaWYCRhnujd6AOLZ18D6NMmxCLsjcvXnEumSEySXRy+6LcQ== X-Gm-Gg: ASbGncsghcISAjGTmwj5lgne+JMLrHWsOZZaUvhvM7NqFaVNZx2ZCKqI7IDeDwhIiyh 6qRl1cRkQLzXKpUUnKNXd8NbOwZG1cFjLzHaYwSBIt7CvKEFT4Jz+A4A4p7cq6brPtVwwVgqBh3 Rngr4W/eNb3Pb37jQHo0XBqb5MqKpqO1xnjS87ECJf1otDAkRqsARIl/8nR8BY4iSQ21kLN/lsa 0TW/pSHZiGTPJD9AzuG5W9L9Bbnt9X2N18aGcsH+FNypo6CFJRSi0XN8zoZmR14gFBDdJTZKlob HZveEJOe2g06yg8QS8z848Pi7GZu/CVUMqGe3rNHnMeR+T72VmUhOcTdk0WYx8veVEE3XPT2uZ7 y0vUI4hnp4wqIQyIPqdkPa8ctcDGy1yX7BxInWRBNCdiLZYslKHhPYMRb5py+GDRf8R7amiSNZ6 +lCNdq70ARPWkJSxMG3vPfhA== X-Google-Smtp-Source: AGHT+IGiF52LgoFc0dxwElU/Bxjwb+i8FifOsoea3FMdnNUewjH/+n9bU2JS++tq+h0gcEicTZJ7Cg== X-Received: by 2002:a17:906:4794:b0:af8:fd22:6e28 with SMTP id a640c23a62f3a-afe2903168dmr384184466b.7.1755988016979; Sat, 23 Aug 2025 15:26:56 -0700 (PDT) From: "=?UTF-8?q?Petr=20Bene=C5=A1?=" X-Google-Original-From: =?UTF-8?q?Petr=20Bene=C5=A1?= To: xen-devel@lists.xenproject.org Cc: =?UTF-8?q?Petr=20Bene=C5=A1?= , Anthony PERARD Subject: [PATCH v5 1/4] tools: add sizeof_field and endof_field macros Date: Sat, 23 Aug 2025 22:26:49 +0000 Message-Id: <8dd6b217fbde427407113fedabb70f54d12aed61.1755987697.git.w1benny@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1755988048472124100 From: Petr Bene=C5=A1 * `sizeof_field` returns the size of a specific struct member * `endof_field` returns the offset to the end of the member within the stru= ct It will be useful in upcoming layout checks of SMBIOS structs. Signed-off-by: Petr Bene=C5=A1 Acked-by: Anthony PERARD --- tools/include/xen-tools/common-macros.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-to= ols/common-macros.h index 0088208c2e..9838a108aa 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -83,6 +83,11 @@ #define __packed __attribute__((__packed__)) #endif =20 +#define sizeof_field(type, member) sizeof(((type *)NULL)->member) + +#define endof_field(type, member) \ + (offsetof(type, member) + sizeof_field(type, member)) + #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member) *mptr__ =3D (ptr); \ (type *)((char *)mptr__ - offsetof(type, member)); \ --=20 2.34.1