From patchwork Fri Nov 20 09:48:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11919857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BACAC5519F for ; Fri, 20 Nov 2020 09:49:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7F73204EF for ; Fri, 20 Nov 2020 09:49:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="EbmX6KfT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7F73204EF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.31840.62638 (Exim 4.92) (envelope-from ) id 1kg32X-0005PV-Tm; Fri, 20 Nov 2020 09:49:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 31840.62638; Fri, 20 Nov 2020 09:49:13 +0000 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" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32X-0005PI-OC; Fri, 20 Nov 2020 09:49:13 +0000 Received: by outflank-mailman (input) for mailman id 31840; Fri, 20 Nov 2020 09:49:12 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0005Mr-Dk for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:12 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32V-0002bN-Jp; Fri, 20 Nov 2020 09:49:11 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32V-0003d1-Bu; Fri, 20 Nov 2020 09:49:11 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32W-0005Mr-Dk for xen-devel@lists.xenproject.org; Fri, 20 Nov 2020 09:49:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=ur98iexNlxW3wPnCoGH5R8tJsU4anFW0cgN61u59s58=; b=EbmX6KfTkfVSVhcM7nRxkqW8q1 cP83sNOja9lntToF+lbfAB3WxN/n4OG8WM/rBZz55JBZvx3uqvq/S5dgGVU4ZtpzS/WERLLDgFUTM F8kf/CA4Gm7mPnxLhbcE8GQQkycbRgDjWAVmPv8yuB5bKBv3k5gDPF5UFcV6VBHOZ5tg=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kg32V-0002bN-Jp; Fri, 20 Nov 2020 09:49:11 +0000 Received: from host109-146-187-185.range109-146.btcentralplus.com ([109.146.187.185] helo=u2f063a87eabd5f.home) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kg32V-0003d1-Bu; Fri, 20 Nov 2020 09:49:11 +0000 From: Paul Durrant To: xen-devel@lists.xenproject.org Cc: Paul Durrant , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v2 07/12] xen/include: import sizeof_field() macro from Linux stddef.h Date: Fri, 20 Nov 2020 09:48:55 +0000 Message-Id: <20201120094900.1489-8-paul@xen.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120094900.1489-1-paul@xen.org> References: <20201120094900.1489-1-paul@xen.org> MIME-Version: 1.0 From: Paul Durrant Co-locate it with the definition of offsetof() (since this is also in stddef.h in the Linux kernel source). This macro will be needed in a subsequent patch. Signed-off-by: Paul Durrant Acked-by: Jan Beulich --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Stefano Stabellini Cc: Wei Liu --- xen/include/xen/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index c0e0ee9f27be..676c6ea1b0a0 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -76,6 +76,14 @@ #define offsetof(a,b) __builtin_offsetof(a,b) +/** + * sizeof_field(TYPE, MEMBER) + * + * @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)) + #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L #define alignof __alignof__ #endif