Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4233747imm; Mon, 8 Oct 2018 17:55:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV61OyGKI3mK/JRINv22VG5s008T3/R/YnU/MclDZ8OGGPB15/3VcVbNDkDRqzAh/1r23ihfk X-Received: by 2002:a63:904a:: with SMTP id a71-v6mr23970619pge.264.1539046552489; Mon, 08 Oct 2018 17:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539046552; cv=none; d=google.com; s=arc-20160816; b=zvOn17OrVAT8t2k6KACQmNZkGOlxXGNFjSNqafehECoealhnZwcUhFtGV8rBSNgPTq YaC5ilmQ2cGWHip49IGTC+b+fMKnxcYeciCDZ8Jj/2S2eTiEQrfhyuMsOYbXHBuxmV70 pF4+UnabKMuTHRpWyDdbaaIo3hF/cNeE8TcIKVbzgDBpc2eMnc0maCaK8PpBTQ5MGAgT YIy2AepBn05GnE0Qfg2SX/QO5e41vfo1GjOE2GZ6V3RizEb8/33PoK8cTEqR5rOTSGhp KawyuzroKGhzGAd+nFdQL5VERr+gIlT6tIVLOKwQ2nGSBhDi5NeR3fA0dfWHIuzjHsxl gbxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=OCKIbgXqLbCXcIgcfcFarCxW/f2Z6Cz8eJY1omDm1Xo=; b=ONiDtyBK57tj3SJVxC/pcYT3AeXliw/xmSm+wpZgvdqW6SgXdX39mgf8omDDPo10Rp eF2nrkA8R0w/XX2HaCLlXtDVgl3QgBu+F9c0Z48CQ/p2i7m0HiF2kZOQmpvBZALMcdfm QpUq0mzm4AFV20htrjW3r8/iiqqKLuXo3RrUwwfG+mvwaYnsnWjnw8Zax6lWk1+uCwF0 xmzPtHuXa5RH/d+Ww6P1JetaHP89JAl8yMWA8IFgF9cUlaKnplYLkbBkNxpkariycwj4 gd/d3DeJ5cihBhN2LBjSx4crL3oomdlUh+tpI9YVklKViSiZzQyknb//G/wOm/DMsOzH Ahbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K8WOz+WG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u1-v6si19802727pgq.1.2018.10.08.17.55.37; Mon, 08 Oct 2018 17:55:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K8WOz+WG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbeJIIJM (ORCPT + 99 others); Tue, 9 Oct 2018 04:09:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:41942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725794AbeJIIJM (ORCPT ); Tue, 9 Oct 2018 04:09:12 -0400 Received: from jouet.infradead.org (unknown [179.97.41.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 164D921476; Tue, 9 Oct 2018 00:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539046490; bh=bBPg5+B7Vfas0dN4aWxafvLyD4hqAb2KQYLBAKYvJIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K8WOz+WGW2s6u1eV1azXnDABEqt0zSzjtcgUAWnKL2UM8Eyhf9FsW0vWE6Q0aXghB X3k13Gccl37Ql9qeUVU/4tlxr5Nc6kyKdNNdf2tGpFrgfUk/Jn2B9W9RoF4nz1TFoS CwDSw9T2vYojbMGfhTyd3+/nwAm8iwDgwJjeVBvg= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Alexander Sverdlin , David Ahern , Jiri Olsa , Namhyung Kim , Wang Nan Subject: [PATCH 01/12] tools include: Adopt linux/bits.h Date: Mon, 8 Oct 2018 21:54:16 -0300 Message-Id: <20181009005427.6607-2-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181009005427.6607-1-acme@kernel.org> References: <20181009005427.6607-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo So that we reduce the difference of tools/include/linux/bitops.h to the original kernel file, include/linux/bitops.h, trying to remove the need to define BITS_PER_LONG, to avoid clashes with asm/bitsperlong.h. And the things removed from tools/include/linux/bitops.h are really in linux/bits.h, so that we can have a copy and then tools/perf/check_headers.sh will tell us when new stuff gets added to linux/bits.h so that we can check if it is useful and if any adjustment needs to be done to the tools/{include,arch}/ copies. Cc: Adrian Hunter Cc: Alexander Sverdlin Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-y1sqyydvfzo0bjjoj4zsl562@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/bitops.h | 7 ++----- tools/include/linux/bits.h | 26 ++++++++++++++++++++++++++ tools/perf/check-headers.sh | 1 + 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tools/include/linux/bits.h diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h index acc704bd3998..0b0ef3abc966 100644 --- a/tools/include/linux/bitops.h +++ b/tools/include/linux/bitops.h @@ -3,8 +3,6 @@ #define _TOOLS_LINUX_BITOPS_H_ #include -#include - #ifndef __WORDSIZE #define __WORDSIZE (__SIZEOF_LONG__ * 8) #endif @@ -12,10 +10,9 @@ #ifndef BITS_PER_LONG # define BITS_PER_LONG __WORDSIZE #endif +#include +#include -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) -#define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #define BITS_TO_U64(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u64)) #define BITS_TO_U32(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(u32)) diff --git a/tools/include/linux/bits.h b/tools/include/linux/bits.h new file mode 100644 index 000000000000..2b7b532c1d51 --- /dev/null +++ b/tools/include/linux/bits.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_BITS_H +#define __LINUX_BITS_H +#include + +#define BIT(nr) (1UL << (nr)) +#define BIT_ULL(nr) (1ULL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) +#define BITS_PER_BYTE 8 + +/* + * 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) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL(h, l) \ + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + +#endif /* __LINUX_BITS_H */ diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh index 466540ee8ea7..c72cc73a6b09 100755 --- a/tools/perf/check-headers.sh +++ b/tools/perf/check-headers.sh @@ -14,6 +14,7 @@ include/uapi/linux/sched.h include/uapi/linux/stat.h include/uapi/linux/vhost.h include/uapi/sound/asound.h +include/linux/bits.h include/linux/hash.h include/uapi/linux/hw_breakpoint.h arch/x86/include/asm/disabled-features.h -- 2.14.4