From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968809AbdDTLGS (ORCPT ); Thu, 20 Apr 2017 07:06:18 -0400 Received: from terminus.zytor.com ([65.50.211.136]:50115 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966235AbdDTLGO (ORCPT ); Thu, 20 Apr 2017 07:06:14 -0400 Date: Thu, 20 Apr 2017 04:03:57 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: wangnan0@huawei.com, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, tglx@linutronix.de, dsahern@gmail.com, adrian.hunter@intel.com, hpa@zytor.com Reply-To: hpa@zytor.com, adrian.hunter@intel.com, namhyung@kernel.org, jolsa@kernel.org, dsahern@gmail.com, tglx@linutronix.de, mingo@kernel.org, acme@redhat.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] tools include: Move ARRAY_SIZE() to linux/kernel.h Git-Commit-ID: 8607c1ee734d12f62c6a46abef13a510e25a1839 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8607c1ee734d12f62c6a46abef13a510e25a1839 Gitweb: http://git.kernel.org/tip/8607c1ee734d12f62c6a46abef13a510e25a1839 Author: Arnaldo Carvalho de Melo AuthorDate: Mon, 17 Apr 2017 11:29:26 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 19 Apr 2017 13:01:43 -0300 tools include: Move ARRAY_SIZE() to linux/kernel.h To match the kernel, then look for places redefining it to make it use this version, which checks that its parameter is an array at build time. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-txlcf1im83bcbj6kh0wxmyy8@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/kernel.h | 3 +++ tools/perf/util/util.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index adb4d01..73ccc48 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -4,6 +4,7 @@ #include #include #include +#include #ifndef UINT_MAX #define UINT_MAX (~0U) @@ -76,6 +77,8 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int scnprintf(char * buf, size_t size, const char * fmt, ...); +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + /* * This looks more complex than it should be. But we need to * get the type for the ~ right in round_down (it needs to be diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index df13658..3eccd6f 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -1,8 +1,6 @@ #ifndef GIT_COMPAT_UTIL_H #define GIT_COMPAT_UTIL_H -#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - #ifdef __GNUC__ #define TYPEOF(x) (__typeof__(x)) #else