From patchwork Wed Apr 13 15:55:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 65740 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp90995qge; Wed, 13 Apr 2016 08:57:16 -0700 (PDT) X-Received: by 10.140.44.8 with SMTP id f8mr12082105qga.42.1460563033579; Wed, 13 Apr 2016 08:57:13 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id p199si28945891qhb.90.2016.04.13.08.57.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Apr 2016 08:57:13 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqN8n-0002LG-UU; Wed, 13 Apr 2016 15:55:41 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqN8m-0002Km-9N for xen-devel@lists.xen.org; Wed, 13 Apr 2016 15:55:40 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id 14/8E-07120-BFB6E075; Wed, 13 Apr 2016 15:55:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTfd3Nl+ 4wcUbHBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bfyytsBTc5Kv5Pb2VpYFzG3sXIxSEksIlR 4knfPTYI5zSjRNu7a0AOJwebgKbEnc+fmEBsEQFpiWufLzOCFDEL3GWUeLiuhREkISzgIvHwQ SM7iM0ioCqxevpMIJuDgxco3n8yBSQsISAncfLYZFYQm1PAVWLPl8tgM4WASm7N/8o4gZF7AS PDKkb14tSistQiXUO9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYxA/zIAwQ7Gnc+ dDjFKcjApifJuC+YLF+JLyk+pzEgszogvKs1JLT7EKMPBoSTBKwIMFyHBotT01Iq0zBxgoMGk JTh4lER4FUHSvMUFibnFmekQqVOMilLivCezgBICIImM0jy4NlhwX2KUlRLmZQQ6RIinILUoN 7MEVf4VozgHo5Iwrz7IeJ7MvBK46a+AFjMBLS57xwuyuCQRISXVwJhb4XZQNChKRHBhefaSGA Z3Ub9tZyRjRWqkOHmNuwwUOZlnM4caMt0PVH59fXPy9p0vt7atMpp0bOL3ZaIyZ9j/tNuph0y 5u+HLfs1JTHUGz6eKBXb8+eT098juxn03vJkuPT8gnzA9cm3wrah1G6LkP58q3xO/VNmi4P/e D0lRr9Q/n71/eJISS3FGoqEWc1FxIgCy58KEaQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1460562938!9134155!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42084 invoked from network); 13 Apr 2016 15:55:39 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 13 Apr 2016 15:55:39 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9DCA03B2; Wed, 13 Apr 2016 08:54:24 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 16D9C3F25F; Wed, 13 Apr 2016 08:55:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Apr 2016 16:55:30 +0100 Message-Id: <1460562931-19858-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1460562931-19858-1-git-send-email-julien.grall@arm.com> References: <1460562931-19858-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, Keir Fraser , andre.przywara@arm.com, Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [for-4.7 1/2] xen/bitops: Introduce macros to generate mask X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The code has been imported from the header include/linux/bitops.h in Linux v4.6-rc3. Signed-off-by: Julien Grall --- Cc: Ian Jackson Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan --- xen/include/xen/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h index cb56f24..e1a4d93 100644 --- a/xen/include/xen/bitops.h +++ b/xen/include/xen/bitops.h @@ -3,6 +3,17 @@ #include /* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL(h, l) \ + (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + +/* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore * differs in spirit from the above ffz (man ffs).